Update library pragma C code

Thomas Charles CONWAY conway at cs.mu.OZ.AU
Fri Jul 31 12:18:14 AEST 1998


Hi

For whoever to review.
-- 
Thomas Conway <conway at cs.mu.oz.au>
Nail here [] for new monitor.  )O+


library/*.m:
	Convert
		:- pagma(c_code, ...
	to 
		:- pagma c_code(...
	
	and introduce will_not_call_mercury in places where it is implicit
	(this is in preparation for changing the default to may_call_mercury).

cvs diff: Diffing .
Index: array.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/array.m,v
retrieving revision 1.45
diff -u -r1.45 array.m
--- array.m	1998/04/08 11:33:15	1.45
+++ array.m	1998/07/31 01:49:42
@@ -258,7 +258,7 @@
 
 %-----------------------------------------------------------------------------%
 
-:- pragma(c_code, "
+:- pragma c_code("
 
 Define_extern_entry(mercury____Unify___array__array_1_0);
 Define_extern_entry(mercury____Index___array__array_1_0);
@@ -382,7 +382,7 @@
 MR_ArrayType *ML_make_array(Integer size, Word item);
 ").
 
-:- pragma(c_code, "
+:- pragma c_code("
 MR_ArrayType *
 ML_make_array(Integer size, Word item)
 {
@@ -398,33 +398,31 @@
 }
 ").
 
-:- pragma(c_code,
-	array__init(Size::in, Item::in, Array::array_uo),
-"
+:- pragma c_code(array__init(Size::in, Item::in, Array::array_uo),
+		will_not_call_mercury, "
 	Array = (Word) ML_make_array(Size, Item);
 ").
 
-:- pragma(c_code,
-	array__make_empty_array(Array::array_uo),
-"
+:- pragma c_code(array__make_empty_array(Array::array_uo),
+		will_not_call_mercury, "
 	Array = (Word) ML_make_array(0, 0);
 ").
 
 %-----------------------------------------------------------------------------%
 
-:- pragma(c_code, array__min(Array::array_ui, Min::out), "
+:- pragma c_code(array__min(Array::array_ui, Min::out), will_not_call_mercury, "
 	/* Array not used */
 	Min = 0;
 ").
-:- pragma(c_code, array__min(Array::in, Min::out), "
+:- pragma c_code(array__min(Array::in, Min::out), will_not_call_mercury, "
 	/* Array not used */
 	Min = 0;
 ").
 
-:- pragma(c_code, array__max(Array::array_ui, Max::out), "
+:- pragma c_code(array__max(Array::array_ui, Max::out), will_not_call_mercury, "
 	Max = ((MR_ArrayType *)Array)->size - 1;
 ").
-:- pragma(c_code, array__max(Array::in, Max::out), "
+:- pragma c_code(array__max(Array::in, Max::out), will_not_call_mercury, "
 	Max = ((MR_ArrayType *)Array)->size - 1;
 ").
 
@@ -434,10 +432,11 @@
 
 %-----------------------------------------------------------------------------%
 
-:- pragma(c_code, array__size(Array::array_ui, Max::out), "
+:- pragma c_code(array__size(Array::array_ui, Max::out),
+		will_not_call_mercury, "
 	Max = ((MR_ArrayType *)Array)->size;
 ").
-:- pragma(c_code, array__size(Array::in, Max::out), "
+:- pragma c_code(array__size(Array::in, Max::out), will_not_call_mercury, "
 	Max = ((MR_ArrayType *)Array)->size;
 ").
 
@@ -465,8 +464,8 @@
 
 %-----------------------------------------------------------------------------%
 
-:- pragma(c_code, array__lookup(Array::array_ui, Index::in,
-		Item::out), "{
+:- pragma c_code(array__lookup(Array::array_ui, Index::in, Item::out),
+		will_not_call_mercury, "{
 	MR_ArrayType *array = (MR_ArrayType *)Array;
 #ifndef ML_OMIT_ARRAY_BOUNDS_CHECKS
 	if ((Unsigned) Index >= (Unsigned) array->size) {
@@ -475,7 +474,8 @@
 #endif
 	Item = array->elements[Index];
 }").
-:- pragma(c_code, array__lookup(Array::in, Index::in, Item::out), "{
+:- pragma c_code(array__lookup(Array::in, Index::in, Item::out),
+		will_not_call_mercury, "{
 	MR_ArrayType *array = (MR_ArrayType *)Array;
 #ifndef ML_OMIT_ARRAY_BOUNDS_CHECKS
 	if ((Unsigned) Index >= (Unsigned) array->size) {
@@ -487,8 +487,8 @@
 
 %-----------------------------------------------------------------------------%
 
-:- pragma(c_code, array__set(Array0::array_di, Index::in,
-		Item::in, Array::array_uo), "{
+:- pragma c_code(array__set(Array0::array_di, Index::in,
+		Item::in, Array::array_uo), will_not_call_mercury, "{
 	MR_ArrayType *array = (MR_ArrayType *)Array0;
 #ifndef ML_OMIT_ARRAY_BOUNDS_CHECKS
 	if ((Unsigned) Index >= (Unsigned) array->size) {
@@ -501,12 +501,12 @@
 
 %-----------------------------------------------------------------------------%
 
-:- pragma(c_header_code, "
+:- pragma c_header_code("
 MR_ArrayType * ML_resize_array(MR_ArrayType *old_array,
 					Integer array_size, Word item);
 ").
 
-:- pragma(c_code, "
+:- pragma c_code("
 MR_ArrayType *
 ML_resize_array(MR_ArrayType *old_array, Integer array_size,
 				Word item)
@@ -540,22 +540,20 @@
 }
 ").
 
-:- pragma(c_code,
-	array__resize(Array0::array_di, Size::in, Item::in,
-		Array::array_uo),
-"
+:- pragma c_code(array__resize(Array0::array_di, Size::in, Item::in,
+		Array::array_uo), will_not_call_mercury, "
 	Array = (Word) ML_resize_array(
 				(MR_ArrayType *) Array0, Size, Item);
 ").
 
 %-----------------------------------------------------------------------------%
 
-:- pragma(c_header_code, "
+:- pragma c_header_code("
 MR_ArrayType * ML_shrink_array(MR_ArrayType *old_array,
 					Integer array_size);
 ").
 
-:- pragma(c_code, "
+:- pragma c_code("
 MR_ArrayType *
 ML_shrink_array(MR_ArrayType *old_array, Integer array_size)
 {
@@ -585,21 +583,19 @@
 }
 ").
 
-:- pragma(c_code,
-	array__shrink(Array0::array_di, Size::in,
-		Array::array_uo),
-"
+:- pragma c_code(array__shrink(Array0::array_di, Size::in, Array::array_uo),
+		will_not_call_mercury, "
 	Array = (Word) ML_shrink_array(
 				(MR_ArrayType *) Array0, Size);
 ").
 
 %-----------------------------------------------------------------------------%
 
-:- pragma(c_header_code, "
+:- pragma c_header_code("
 MR_ArrayType *ML_copy_array(MR_ArrayType *old_array);
 ").
 
-:- pragma(c_code, "
+:- pragma c_code("
 MR_ArrayType *
 ML_copy_array(MR_ArrayType *old_array)
 {
@@ -622,18 +618,14 @@
 }
 ").
 
-:- pragma(c_code,
-	array__copy(Array0::array_ui, Array::array_uo),
-"
-	Array =
-		(Word) ML_copy_array((MR_ArrayType *) Array0);
+:- pragma c_code(array__copy(Array0::array_ui, Array::array_uo),
+		will_not_call_mercury, "
+	Array = (Word) ML_copy_array((MR_ArrayType *) Array0);
 ").
 
-:- pragma(c_code,
-	array__copy(Array0::in, Array::array_uo),
-"
-	Array =
-		(Word) ML_copy_array((MR_ArrayType *) Array0);
+:- pragma c_code(array__copy(Array0::in, Array::array_uo),
+		will_not_call_mercury, "
+	Array = (Word) ML_copy_array((MR_ArrayType *) Array0);
 ").
 
 %-----------------------------------------------------------------------------%
Index: io.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/io.m,v
retrieving revision 1.159
diff -u -r1.159 io.m
--- io.m	1998/07/22 07:41:32	1.159
+++ io.m	1998/07/31 01:59:42
@@ -2139,7 +2139,8 @@
 :- pred io__get_stream_names(io__stream_names, io__state, io__state).
 :- mode io__get_stream_names(out, di, uo) is det.
 
-:- pragma c_code(io__get_stream_names(StreamNames::out, IO0::di, IO::uo), "
+:- pragma c_code(io__get_stream_names(StreamNames::out, IO0::di, IO::uo), 
+		will_not_call_mercury, "
 	StreamNames = ML_io_stream_names;
 	update_io(IO0, IO);
 ").
@@ -2147,7 +2148,8 @@
 :- pred io__set_stream_names(io__stream_names, io__state, io__state).
 :- mode io__set_stream_names(in, di, uo) is det.
 
-:- pragma c_code(io__set_stream_names(StreamNames::in, IO0::di, IO::uo), "
+:- pragma c_code(io__set_stream_names(StreamNames::in, IO0::di, IO::uo), 
+		will_not_call_mercury, "
 	ML_io_stream_names = StreamNames;
 	update_io(IO0, IO);
 ").
@@ -2176,12 +2178,14 @@
 	% XXX design flaw with regard to unique modes
 	% and io__get_globals/3: the `Globals::uo' mode here is a lie.
 
-:- pragma c_code(io__get_globals(Globals::uo, IOState0::di, IOState::uo), "
+:- pragma c_code(io__get_globals(Globals::uo, IOState0::di, IOState::uo), 
+		will_not_call_mercury, "
 	Globals = ML_io_user_globals;
 	update_io(IOState0, IOState);
 ").
 
-:- pragma c_code(io__set_globals(Globals::di, IOState0::di, IOState::uo), "
+:- pragma c_code(io__set_globals(Globals::di, IOState0::di, IOState::uo), 
+		will_not_call_mercury, "
 	ML_io_user_globals = Globals;
 	update_io(IOState0, IOState);
 ").
@@ -2268,7 +2272,7 @@
 :- mode io__gc_init(in, in, di, uo) is det.
 
 :- pragma c_code(io__gc_init(StreamNamesType::in, UserGlobalsType::in,
-		IO0::di, IO::uo), "
+		IO0::di, IO::uo), will_not_call_mercury, "
 	/* for Windows DLLs, we need to call GC_INIT() from each DLL */
 #ifdef CONSERVATIVE_GC
 	GC_INIT();
@@ -2491,13 +2495,13 @@
 /* input predicates */
 
 :- pragma(c_code, io__read_char_code(File::in, CharCode::out, IO0::di, IO::uo),
-"
+		will_not_call_mercury, "
 	CharCode = mercury_getc((MercuryFile *) File);
 	update_io(IO0, IO);
 ").
 
 :- pragma(c_code, io__putback_char(File::in, Character::in, IO0::di, IO::uo),
-"{
+		will_not_call_mercury, "{
 	MercuryFile* mf = (MercuryFile *)File;
 	if (Character == '\\n') {
 		mf->line_number--;
@@ -2510,7 +2514,7 @@
 }").
 
 :- pragma(c_code, io__putback_byte(File::in, Character::in, IO0::di, IO::uo),
-"{
+		will_not_call_mercury, "{
 	MercuryFile* mf = (MercuryFile *)File;
 	/* XXX should work even if ungetc() fails */
 	if (ungetc(Character, mf->file) == EOF) {
@@ -2521,12 +2525,14 @@
 
 /* output predicates - with output to mercury_current_text_output */
 
-:- pragma(c_code, io__write_string(Message::in, IO0::di, IO::uo), "
+:- pragma(c_code, io__write_string(Message::in, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	mercury_print_string(mercury_current_text_output, Message);
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__write_char(Character::in, IO0::di, IO::uo), "
+:- pragma(c_code, io__write_char(Character::in, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	if (putc(Character, mercury_current_text_output->file) < 0) {
 		mercury_output_error(mercury_current_text_output);
 	}
@@ -2536,21 +2542,24 @@
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__write_int(Val::in, IO0::di, IO::uo), "
+:- pragma(c_code, io__write_int(Val::in, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	if (fprintf(mercury_current_text_output->file, ""%ld"", (long) Val) < 0) {
 		mercury_output_error(mercury_current_text_output);
 	}
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__write_float(Val::in, IO0::di, IO::uo), "
+:- pragma(c_code, io__write_float(Val::in, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	if (fprintf(mercury_current_text_output->file, ""%#.15g"", Val) < 0) {
 		mercury_output_error(mercury_current_text_output);
 	}
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__write_byte(Byte::in, IO0::di, IO::uo), "
+:- pragma(c_code, io__write_byte(Byte::in, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	/* call putc with a strictly non-negative byte-sized integer */
 	if (putc((int) ((unsigned char) Byte),
 			mercury_current_binary_output->file) < 0) {
@@ -2559,19 +2568,22 @@
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__write_bytes(Message::in, IO0::di, IO::uo), "{
+:- pragma(c_code, io__write_bytes(Message::in, IO0::di, IO::uo),
+		will_not_call_mercury, "{
 	mercury_print_binary_string(mercury_current_binary_output, Message);
 	update_io(IO0, IO);
 }").
 
-:- pragma(c_code, io__flush_output(IO0::di, IO::uo), "
+:- pragma(c_code, io__flush_output(IO0::di, IO::uo),
+		will_not_call_mercury, "
 	if (fflush(mercury_current_text_output->file) < 0) {
 		mercury_output_error(mercury_current_text_output);
 	}
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__flush_binary_output(IO0::di, IO::uo), "
+:- pragma(c_code, io__flush_binary_output(IO0::di, IO::uo),
+		will_not_call_mercury, "
 	if (fflush(mercury_current_binary_output->file) < 0) {
 		mercury_output_error(mercury_current_binary_output);
 	}
@@ -2594,7 +2606,7 @@
 :- mode io__seek_binary_2(in, in, in, di, uo) is det.
 
 :- pragma c_code(io__seek_binary_2(Stream::in, Flag::in, Off::in,
-	IO0::di, IO::uo),
+	IO0::di, IO::uo), will_not_call_mercury,
 "{
 	static const int seek_flags[] = { SEEK_SET, SEEK_CUR, SEEK_END };
 	MercuryFile *stream = (MercuryFile *) Stream;
@@ -2603,7 +2615,7 @@
 }").
 
 :- pragma c_code(io__binary_stream_offset(Stream::in, Offset::out,
-		IO0::di, IO::uo),
+		IO0::di, IO::uo), will_not_call_mercury,
 "{
 	MercuryFile *stream = (MercuryFile *) Stream;
 	Offset = ftell(stream->file);
@@ -2614,6 +2626,7 @@
 /* output predicates - with output to the specified stream */
 
 :- pragma(c_code, io__write_string(Stream::in, Message::in, IO0::di, IO::uo),
+		will_not_call_mercury, 
 "{
 	MercuryFile *stream = (MercuryFile *) Stream;
 	mercury_print_string(stream, Message);
@@ -2621,6 +2634,7 @@
 }").
 
 :- pragma(c_code, io__write_char(Stream::in, Character::in, IO0::di, IO::uo),
+		will_not_call_mercury, 
 "{
 	MercuryFile *stream = (MercuryFile *) Stream;
 	if (putc(Character, stream->file) < 0) {
@@ -2632,7 +2646,8 @@
 	update_io(IO0, IO);
 }").
 
-:- pragma(c_code, io__write_int(Stream::in, Val::in, IO0::di, IO::uo), "{
+:- pragma(c_code, io__write_int(Stream::in, Val::in, IO0::di, IO::uo),
+		will_not_call_mercury, "{
 	MercuryFile *stream = (MercuryFile *) Stream;
 	if (fprintf(stream->file, ""%ld"", (long) Val) < 0) {
 		mercury_output_error(stream);
@@ -2640,7 +2655,8 @@
 	update_io(IO0, IO);
 }").
 
-:- pragma(c_code, io__write_float(Stream::in, Val::in, IO0::di, IO::uo), "{
+:- pragma(c_code, io__write_float(Stream::in, Val::in, IO0::di, IO::uo),
+		will_not_call_mercury, "{
 	MercuryFile *stream = (MercuryFile *) Stream;
 	if (fprintf(stream->file, ""%#.15g"", Val) < 0) {
 		mercury_output_error(stream);
@@ -2648,7 +2664,8 @@
 	update_io(IO0, IO);
 }").
 
-:- pragma(c_code, io__write_byte(Stream::in, Byte::in, IO0::di, IO::uo), "{
+:- pragma(c_code, io__write_byte(Stream::in, Byte::in, IO0::di, IO::uo),
+		will_not_call_mercury, "{
 	MercuryFile *stream = (MercuryFile *) Stream;
 	/* call putc with a strictly non-negative byte-sized integer */
 	if (putc((int) ((unsigned char) Byte), stream->file) < 0) {
@@ -2657,13 +2674,15 @@
 	update_io(IO0, IO);
 }").
 
-:- pragma(c_code, io__write_bytes(Stream::in, Message::in, IO0::di, IO::uo), "{
+:- pragma(c_code, io__write_bytes(Stream::in, Message::in, IO0::di, IO::uo),
+		will_not_call_mercury, "{
 	MercuryFile *stream = (MercuryFile *) Stream;
 	mercury_print_binary_string(stream, Message);
 	update_io(IO0, IO);
 }").
 
-:- pragma(c_code, io__flush_output(Stream::in, IO0::di, IO::uo), "{
+:- pragma(c_code, io__flush_output(Stream::in, IO0::di, IO::uo),
+		will_not_call_mercury, "{
 	MercuryFile *stream = (MercuryFile *) Stream;
 	if (fflush(stream->file) < 0) {
 		mercury_output_error(stream);
@@ -2671,7 +2690,8 @@
 	update_io(IO0, IO);
 }").
 
-:- pragma(c_code, io__flush_binary_output(Stream::in, IO0::di, IO::uo), "{
+:- pragma(c_code, io__flush_binary_output(Stream::in, IO0::di, IO::uo),
+		will_not_call_mercury, "{
 	MercuryFile *stream = (MercuryFile *) Stream;
 	if (fflush(stream->file) < 0) {
 		mercury_output_error(stream);
@@ -2681,98 +2701,111 @@
 
 /* stream predicates */
 
-:- pragma(c_code, io__stdin_stream(Stream::out, IO0::di, IO::uo), "
+:- pragma(c_code, io__stdin_stream(Stream::out, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	Stream = (Word) &mercury_stdin;
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__stdout_stream(Stream::out, IO0::di, IO::uo), "
+:- pragma(c_code, io__stdout_stream(Stream::out, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	Stream = (Word) &mercury_stdout;
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__stderr_stream(Stream::out, IO0::di, IO::uo), "
+:- pragma(c_code, io__stderr_stream(Stream::out, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	Stream = (Word) &mercury_stderr;
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__stdin_binary_stream(Stream::out, IO0::di, IO::uo), "
+:- pragma(c_code, io__stdin_binary_stream(Stream::out, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	Stream = (Word) &mercury_stdin;
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__stdout_binary_stream(Stream::out, IO0::di, IO::uo), "
+:- pragma(c_code, io__stdout_binary_stream(Stream::out, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	Stream = (Word) &mercury_stdout;
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__input_stream(Stream::out, IO0::di, IO::uo), "
+:- pragma(c_code, io__input_stream(Stream::out, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	Stream = (Word) mercury_current_text_input;
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__output_stream(Stream::out, IO0::di, IO::uo), "
+:- pragma(c_code, io__output_stream(Stream::out, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	Stream = (Word) mercury_current_text_output;
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__binary_input_stream(Stream::out, IO0::di, IO::uo), "
+:- pragma(c_code, io__binary_input_stream(Stream::out, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	Stream = (Word) mercury_current_binary_input;
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__binary_output_stream(Stream::out, IO0::di, IO::uo), "
+:- pragma(c_code, io__binary_output_stream(Stream::out, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	Stream = (Word) mercury_current_binary_output;
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__get_line_number(LineNum::out, IO0::di, IO::uo), "
+:- pragma(c_code, io__get_line_number(LineNum::out, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	LineNum = mercury_current_text_input->line_number;
 	update_io(IO0, IO);
 ").
 	
 :- pragma(c_code,
 	io__get_line_number(Stream::in, LineNum::out, IO0::di, IO::uo),
-"{
+		will_not_call_mercury, "{
 	MercuryFile *stream = (MercuryFile *) Stream;
 	LineNum = stream->line_number;
 	update_io(IO0, IO);
 }").
 	
-:- pragma(c_code, io__set_line_number(LineNum::in, IO0::di, IO::uo), "
+:- pragma(c_code, io__set_line_number(LineNum::in, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	mercury_current_text_input->line_number = LineNum;
 	update_io(IO0, IO);
 ").
 	
 :- pragma(c_code,
 	io__set_line_number(Stream::in, LineNum::in, IO0::di, IO::uo),
-"{
+		will_not_call_mercury, "{
 	MercuryFile *stream = (MercuryFile *) Stream;
 	stream->line_number = LineNum;
 	update_io(IO0, IO);
 }").
 	
-:- pragma(c_code, io__get_output_line_number(LineNum::out, IO0::di, IO::uo), "
+:- pragma(c_code, io__get_output_line_number(LineNum::out, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	LineNum = mercury_current_text_output->line_number;
 	update_io(IO0, IO);
 ").
 	
 :- pragma(c_code,
 	io__get_output_line_number(Stream::in, LineNum::out, IO0::di, IO::uo),
-"{
+		will_not_call_mercury, "{
 	MercuryFile *stream = (MercuryFile *) Stream;
 	LineNum = stream->line_number;
 	update_io(IO0, IO);
 }").
 
-:- pragma(c_code, io__set_output_line_number(LineNum::in, IO0::di, IO::uo), "
+:- pragma(c_code, io__set_output_line_number(LineNum::in, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	mercury_current_text_output->line_number = LineNum;
 	update_io(IO0, IO);
 ").
 	
 :- pragma(c_code,
 	io__set_output_line_number(Stream::in, LineNum::in, IO0::di, IO::uo),
-"{
+		will_not_call_mercury, "{
 	MercuryFile *stream = (MercuryFile *) Stream;
 	stream->line_number = LineNum;
 	update_io(IO0, IO);
@@ -2783,7 +2816,7 @@
 %	Returns the previous stream.
 :- pragma(c_code,
 	io__set_input_stream(NewStream::in, OutStream::out, IO0::di, IO::uo),
-"
+		will_not_call_mercury, "
 	OutStream = (Word) mercury_current_text_input;
 	mercury_current_text_input = (MercuryFile*) NewStream;
 	update_io(IO0, IO);
@@ -2791,7 +2824,7 @@
 
 :- pragma(c_code,
 	io__set_output_stream(NewStream::in, OutStream::out, IO0::di, IO::uo),
-"
+		will_not_call_mercury, "
 	OutStream = (Word) mercury_current_text_output;
 	mercury_current_text_output = (MercuryFile*) NewStream;
 	update_io(IO0, IO);
@@ -2799,8 +2832,7 @@
 
 :- pragma(c_code,
 	io__set_binary_input_stream(NewStream::in, OutStream::out,
-					IO0::di, IO::uo),
-"
+			IO0::di, IO::uo), will_not_call_mercury, "
 	OutStream = (Word) mercury_current_binary_input;
 	mercury_current_binary_input = (MercuryFile*) NewStream;
 	update_io(IO0, IO);
@@ -2808,8 +2840,7 @@
 
 :- pragma(c_code,
 	io__set_binary_output_stream(NewStream::in, OutStream::out,
-					IO0::di, IO::uo),
-"
+			IO0::di, IO::uo), will_not_call_mercury, "
 	OutStream = (Word) mercury_current_binary_output;
 	mercury_current_binary_output = (MercuryFile*) NewStream;
 	update_io(IO0, IO);
@@ -2822,29 +2853,33 @@
 %	ResultCode is 0 for success, -1 for failure.
 :- pragma(c_code,
 	io__do_open(FileName::in, Mode::in, ResultCode::out,
-			Stream::out, IO0::di, IO::uo),
+			Stream::out, IO0::di, IO::uo), will_not_call_mercury,
 "
 	Stream = (Word) mercury_open(FileName, Mode);
 	ResultCode = (Stream ? 0 : -1);
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__close_input(Stream::in, IO0::di, IO::uo), "
+:- pragma(c_code, io__close_input(Stream::in, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	mercury_close((MercuryFile*)Stream);
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__close_output(Stream::in, IO0::di, IO::uo), "
+:- pragma(c_code, io__close_output(Stream::in, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	mercury_close((MercuryFile*)Stream);
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__close_binary_input(Stream::in, IO0::di, IO::uo), "
+:- pragma(c_code, io__close_binary_input(Stream::in, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	mercury_close((MercuryFile*)Stream);
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__close_binary_output(Stream::in, IO0::di, IO::uo), "
+:- pragma(c_code, io__close_binary_output(Stream::in, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	mercury_close((MercuryFile*)Stream);
 	update_io(IO0, IO);
 ").
@@ -2853,7 +2888,7 @@
 
 :- pragma(c_code,
 	io__progname(DefaultProgname::in, PrognameOut::out, IO0::di, IO::uo),
-"
+		will_not_call_mercury, "
 	if (progname) {
 		/* The silly casting below is needed to avoid
 		   a gcc warning about casting away const.
@@ -2869,7 +2904,8 @@
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__command_line_arguments(Args::out, IO0::di, IO::uo), "
+:- pragma(c_code, io__command_line_arguments(Args::out, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	/* convert mercury_argv from a vector to a list */
 	{ int i = mercury_argc;
 	  Args = list_empty();
@@ -2880,18 +2916,20 @@
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__get_exit_status(ExitStatus::out, IO0::di, IO::uo), "
+:- pragma(c_code, io__get_exit_status(ExitStatus::out, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	ExitStatus = mercury_exit_status;
 	update_io(IO0, IO);
 ").
 
-:- pragma(c_code, io__set_exit_status(ExitStatus::in, IO0::di, IO::uo), "
+:- pragma(c_code, io__set_exit_status(ExitStatus::in, IO0::di, IO::uo),
+		will_not_call_mercury, "
 	mercury_exit_status = ExitStatus;
 	update_io(IO0, IO);
 ").
 
 :- pragma(c_code, io__preallocate_heap_space(HeapSpace::in, IO0::di, IO::uo),
-"
+		will_not_call_mercury, "
 	/* HeapSpace not used */
 	/* don't do anything - preallocate_heap_space was just a
 	   hack for NU-Prolog */
@@ -2900,7 +2938,7 @@
 
 :- pragma(c_code,
 	io__call_system_code(Command::in, Status::out, IO0::di, IO::uo),
-"
+		will_not_call_mercury, "
 	Status = system(Command);
 	if ( Status == -1 || Status == 127 ) {
 		/* 
@@ -2936,12 +2974,12 @@
 
 /* io__getenv and io__putenv, from io.m */
 
-:- pragma(c_code, io__getenv(Var::in, Value::out), "{
+:- pragma(c_code, io__getenv(Var::in, Value::out), will_not_call_mercury, "{
 	Value = getenv(Var);
 	SUCCESS_INDICATOR = (Value != 0);
 }").
 
-:- pragma(c_code, io__putenv(VarAndValue::in), "
+:- pragma(c_code, io__putenv(VarAndValue::in), will_not_call_mercury, "
 	SUCCESS_INDICATOR = (putenv(VarAndValue) == 0);
 ").
 
Index: string.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/string.m,v
retrieving revision 1.104
diff -u -r1.104 string.m
--- string.m	1998/05/21 16:52:16	1.104
+++ string.m	1998/07/31 02:04:41
@@ -586,7 +586,8 @@
 % but the optimized implementation in C below is there for efficiency since
 % it improves the overall speed of parsing by about 7%.
 %
-:- pragma(c_code, string__from_rev_char_list(Chars::in, Str::out), "
+:- pragma(c_code, string__from_rev_char_list(Chars::in, Str::out),
+		will_not_call_mercury, "
 {
 	Word list_ptr;
 	Word size, len;
@@ -1549,7 +1550,8 @@
 
 %-----------------------------------------------------------------------------%
 
-:- pragma(c_code, string__float_to_string(FloatVal::in, FloatString::out), "{
+:- pragma(c_code, string__float_to_string(FloatVal::in, FloatString::out),
+		will_not_call_mercury, "{
 	char buf[500];
 	Word tmp;
 	sprintf(buf, ""%#.15g"", FloatVal);
@@ -1563,7 +1565,8 @@
 
 :- pred string__float_to_f_string(float::in, string::out) is det.
 
-:- pragma(c_code, string__float_to_f_string(FloatVal::in, FloatString::out), "{
+:- pragma(c_code, string__float_to_f_string(FloatVal::in, FloatString::out),
+		will_not_call_mercury, "{
 	char buf[500];
 	Word tmp;
 	sprintf(buf, ""%.15f"", FloatVal);
@@ -1572,7 +1575,8 @@
 	strcpy(FloatString, buf);
 }").
 
-:- pragma(c_code, string__to_float(FloatString::in, FloatVal::out), "{
+:- pragma(c_code, string__to_float(FloatString::in, FloatVal::out),
+		will_not_call_mercury, "{
 	/* use a temporary, since we can't don't know whether FloatVal
 	   is a double or float */
 	double tmp;
@@ -1589,7 +1593,8 @@
 :- mode string__to_int_list(out, in) is det.
 */
 
-:- pragma(c_code, string__to_int_list(Str::in, IntList::out), "{
+:- pragma(c_code, string__to_int_list(Str::in, IntList::out),
+		will_not_call_mercury, "{
 	const char *p = Str + strlen(Str);
 	IntList = list_empty();
 	while (p > Str) {
@@ -1598,7 +1603,8 @@
 	}
 }").
 
-:- pragma(c_code, string__to_int_list(Str::out, IntList::in), "{
+:- pragma(c_code, string__to_int_list(Str::out, IntList::in),
+		will_not_call_mercury, "{
 		/* mode (out, in) is det */
 	Word int_list_ptr;
 	size_t size;
@@ -1640,7 +1646,8 @@
 :- pred string__contains_char(string, char).
 :- mode string__contains_char(in, in) is semidet.
 */
-:- pragma(c_code, string__contains_char(Str::in, Ch::in), "
+:- pragma(c_code, string__contains_char(Str::in, Ch::in),
+		will_not_call_mercury, "
 	SUCCESS_INDICATOR = (strchr(Str, Ch) != NULL);
 ").
 
@@ -1650,7 +1657,8 @@
 :- pred string__index(string, int, char).
 :- mode string__index(in, in, out) is semidet.
 */
-:- pragma(c_code, string__index(Str::in, Index::in, Ch::out), "
+:- pragma(c_code, string__index(Str::in, Index::in, Ch::out),
+		will_not_call_mercury, "
 	if ((Word) Index >= strlen(Str)) {
 		SUCCESS_INDICATOR = FALSE;
 	} else {
@@ -1661,7 +1669,8 @@
 
 /*-----------------------------------------------------------------------*/
 
-:- pragma(c_code, string__unsafe_index(Str::in, Index::in, Ch::out), "
+:- pragma(c_code, string__unsafe_index(Str::in, Index::in, Ch::out),
+		will_not_call_mercury, "
 	Ch = Str[Index];
 ").
 
@@ -1671,7 +1680,8 @@
 :- pred string__length(string, int).
 :- mode string__length(in, out) is det.
 */
-:- pragma(c_code, string__length(Str::in, Length::uo), "
+:- pragma(c_code, string__length(Str::in, Length::uo),
+		will_not_call_mercury, "
 	Length = strlen(Str);
 ").
 
@@ -1688,7 +1698,8 @@
 /*
 :- mode string__append(in, in, in) is semidet.
 */
-:- pragma(c_code, string__append(S1::in, S2::in, S3::in), "{
+:- pragma(c_code, string__append(S1::in, S2::in, S3::in),
+		will_not_call_mercury, "{
 	size_t len_1 = strlen(S1);
 	SUCCESS_INDICATOR = (
 		strncmp(S1, S3, len_1) == 0 &&
@@ -1699,7 +1710,8 @@
 /*
 :- mode string__append(in, out, in) is semidet.
 */
-:- pragma(c_code, string__append(S1::in, S2::out, S3::in), "{
+:- pragma(c_code, string__append(S1::in, S2::out, S3::in),
+		will_not_call_mercury, "{
 	Word tmp;
 	size_t len_1, len_2, len_3;
 
@@ -1723,7 +1735,8 @@
 /*
 :- mode string__append(in, in, out) is det.
 */
-:- pragma(c_code, string__append(S1::in, S2::in, S3::out), "{
+:- pragma(c_code, string__append(S1::in, S2::in, S3::out),
+		will_not_call_mercury, "{
 	size_t len_1, len_2;
 	Word tmp;
 	len_1 = strlen(S1);
@@ -1804,7 +1817,8 @@
 ").
 
 % :- mode string__append(out, out, in) is multidet.
-:- pragma(c_code, string__append(S1::out, S2::out, S3::in), "
+:- pragma(c_code, string__append(S1::out, S2::out, S3::in),
+		will_not_call_mercury, "
 	/*
 	** The pragma_c_code will generate a mkframe();
 	** we need to pop off that frame before jumping to the hand-coded
@@ -1891,7 +1905,8 @@
 %	treated as if it were the nearest end-point of that range.)
 */
 
-:- pragma(c_code, string__split(Str::in, Count::in, Left::out, Right::out), "{
+:- pragma(c_code, string__split(Str::in, Count::in, Left::out, Right::out),
+		will_not_call_mercury, "{
 	Integer len;
 	Word tmp;
 	if (Count <= 0) {
@@ -1932,7 +1947,8 @@
 /*
 :- mode string__first_char(in, in, in) is semidet.	% implied
 */
-:- pragma(c_code, string__first_char(Str::in, First::in, Rest::in), "
+:- pragma(c_code, string__first_char(Str::in, First::in, Rest::in),
+		will_not_call_mercury, "
 	SUCCESS_INDICATOR = (
 		Str[0] == First &&
 		First != '\\0' &&
@@ -1943,7 +1959,8 @@
 /*
 :- mode string__first_char(in, out, in) is semidet.	% implied
 */
-:- pragma(c_code, string__first_char(Str::in, First::out, Rest::in), "
+:- pragma(c_code, string__first_char(Str::in, First::out, Rest::in),
+		will_not_call_mercury, "
 	First = Str[0];
 	SUCCESS_INDICATOR = (First != '\\0' && strcmp(Str + 1, Rest) == 0);
 ").
@@ -1951,7 +1968,8 @@
 /*
 :- mode string__first_char(in, in, out) is semidet.	% implied
 */
-:- pragma(c_code, string__first_char(Str::in, First::in, Rest::out), "{
+:- pragma(c_code, string__first_char(Str::in, First::in, Rest::out),
+		will_not_call_mercury, "{
 	Word tmp;
 	if (Str[0] != First || First == '\\0') {
 		SUCCESS_INDICATOR = FALSE;
@@ -1972,7 +1990,8 @@
 /*
 :- mode string__first_char(in, out, out) is semidet.
 */
-:- pragma(c_code, string__first_char(Str::in, First::out, Rest::out), "{
+:- pragma(c_code, string__first_char(Str::in, First::out, Rest::out),
+		will_not_call_mercury, "{
 	Word tmp;
 	First = Str[0];
 	if (First == '\\0') {
@@ -1994,7 +2013,8 @@
 /*
 :- mode string__first_char(out, in, in) is det.
 */
-:- pragma(c_code, string__first_char(Str::out, First::in, Rest::in), "{
+:- pragma(c_code, string__first_char(Str::out, First::in, Rest::in),
+		will_not_call_mercury, "{
 	size_t len = strlen(Rest) + 1;
 	Word tmp;
 	incr_hp_atomic(tmp, (len + sizeof(Word)) / sizeof(Word));



More information about the developers mailing list