[m-dev.] Update library pragma C code
Thomas Charles CONWAY
conway at cs.mu.OZ.AU
Mon Aug 3 10:18:01 AEST 1998
Here's the final diff. I've committed this.
--
Thomas Conway <conway at cs.mu.oz.au>
Nail here [] for new monitor. )O+
library/*.m:
Convert
:- pragma(c_code, ...
to
:- pragma 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/08/03 00:11:41
@@ -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);
@@ -378,11 +378,11 @@
%-----------------------------------------------------------------------------%
-:- pragma(c_header_code, "
+:- pragma c_header_code("
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/08/03 00:12:40
@@ -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();
@@ -2326,7 +2330,7 @@
** They are also implemented for NU-Prolog in `io.nu.nl'.
*/
-:- pragma(c_header_code, "
+:- pragma c_header_code("
#include ""mercury_init.h""
#include ""mercury_wrapper.h""
@@ -2363,7 +2367,7 @@
void mercury_close(MercuryFile* mf);
").
-:- pragma(c_code, "
+:- pragma c_code("
MercuryFile mercury_stdin = { NULL, 1 };
MercuryFile mercury_stdout = { NULL, 1 };
@@ -2383,7 +2387,7 @@
").
-:- pragma(c_code, "
+:- pragma c_code("
MercuryFile*
mercury_open(const char *filename, const char *type)
@@ -2401,7 +2405,7 @@
").
-:- pragma(c_code, "
+:- pragma c_code("
void
mercury_fatal_io_error(void)
@@ -2411,7 +2415,7 @@
").
-:- pragma(c_code, "
+:- pragma c_code("
int
mercury_output_error(MercuryFile* mf)
@@ -2424,7 +2428,7 @@
").
-:- pragma(c_code, "
+:- pragma c_code("
void
mercury_print_string(MercuryFile* mf, const char *s)
@@ -2441,7 +2445,7 @@
").
-:- pragma(c_code, "
+:- pragma c_code("
void
mercury_print_binary_string(MercuryFile* mf, const char *s)
@@ -2453,7 +2457,7 @@
").
-:- pragma(c_code, "
+:- pragma c_code("
int
mercury_getc(MercuryFile* mf)
@@ -2467,7 +2471,7 @@
").
-:- pragma(c_code, "
+:- pragma c_code("
void
mercury_close(MercuryFile* mf)
@@ -2490,14 +2494,14 @@
/* input predicates */
-:- pragma(c_code, io__read_char_code(File::in, CharCode::out, IO0::di, IO::uo),
-"
+:- 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),
-"{
+:- 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--;
@@ -2509,8 +2513,8 @@
update_io(IO0, IO);
}").
-:- pragma(c_code, io__putback_byte(File::in, Character::in, IO0::di, IO::uo),
-"{
+:- 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);
@@ -2613,14 +2625,16 @@
/* output predicates - with output to the specified stream */
-:- pragma(c_code, io__write_string(Stream::in, Message::in, IO0::di, IO::uo),
+:- 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);
update_io(IO0, IO);
}").
-:- pragma(c_code, io__write_char(Stream::in, Character::in, IO0::di, IO::uo),
+:- 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,
+:- 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,
+:- 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,
+:- 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,
+:- 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);
@@ -2781,35 +2814,33 @@
% io__set_input_stream(NewStream, OldStream, IO0, IO1)
% Changes the current input stream to the stream specified.
% Returns the previous stream.
-:- pragma(c_code,
+:- 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);
").
-:- pragma(c_code,
+:- 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);
").
-:- pragma(c_code,
+:- 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);
").
-:- pragma(c_code,
+:- 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);
@@ -2820,40 +2851,44 @@
% io__do_open(File, Mode, ResultCode, Stream, IO0, IO1).
% Attempts to open a file in the specified mode.
% ResultCode is 0 for success, -1 for failure.
-:- pragma(c_code,
+:- 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);
").
/* miscellaneous predicates */
-:- pragma(c_code,
+:- 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,27 +2916,29 @@
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),
-"
+:- 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 */
update_io(IO0, IO);
").
-:- pragma(c_code,
+:- 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: math.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/math.m,v
retrieving revision 1.12
diff -u -r1.12 math.m
--- math.m 1998/05/31 22:19:09 1.12
+++ math.m 1998/08/03 00:13:14
@@ -170,7 +170,7 @@
% These operations are all implemented using the C interface.
-:- pragma(c_header_code, "
+:- pragma c_header_code("
#include <math.h>
@@ -186,7 +186,7 @@
"). % end pragma c_header_code
-:- pragma(c_code, "
+:- pragma c_code("
#include <stdio.h>
@@ -639,29 +639,29 @@
% Mathematical constants from math.m
%
% Pythagoras' number
-:- pragma(c_code, math__pi(Pi::out), "Pi = MERCURY_FLOAT__PI;").
+:- pragma c_code(math__pi(Pi::out), "Pi = MERCURY_FLOAT__PI;").
% Base of natural logarithms
-:- pragma(c_code, math__e(E::out), "E = MERCURY_FLOAT__E;").
+:- pragma c_code(math__e(E::out), "E = MERCURY_FLOAT__E;").
%
% math__ceiling(X, Ceil) is true if Ceil is the smallest integer
% not less than X.
%
-:- pragma(c_code, math__ceiling(Num::in, Ceil::out), "Ceil = ceil(Num);").
+:- pragma c_code(math__ceiling(Num::in, Ceil::out), "Ceil = ceil(Num);").
%
% math__floor(X, Floor) is true if Floor is the largest integer
% not greater than X.
%
-:- pragma(c_code, math__floor(Num::in, Floor::out), "Floor = floor(Num);").
+:- pragma c_code(math__floor(Num::in, Floor::out), "Floor = floor(Num);").
%
% math__round(X, Round) is true if Round is the integer
% closest to X. If X has a fractional component of 0.5,
% it is rounded up.
%
-:- pragma(c_code, math__round(Num::in, Rounded::out), "
+:- pragma c_code(math__round(Num::in, Rounded::out), "
Rounded = floor(Num+0.5);
").
@@ -669,7 +669,7 @@
% math__truncate(X, Trunc) is true if Trunc is the integer
% closest to X such that |Trunc| =< |X|.
%
-:- pragma(c_code, math__truncate(X::in, Trunc::out), "
+:- pragma c_code(math__truncate(X::in, Trunc::out), "
if (X < 0.0) {
Trunc = ceil(X);
} else {
@@ -684,7 +684,7 @@
% Domain restrictions:
% X >= 0
%
-:- pragma(c_code, math__sqrt(X::in, SquareRoot::out), "
+:- pragma c_code(math__sqrt(X::in, SquareRoot::out), "
if (X < 0.0) {
mercury_domain_error(""math__sqrt"");
}
@@ -699,7 +699,7 @@
% X >= 0
% X = 0 implies Y > 0
%
-:- pragma(c_code, math__pow(X::in, Y::in, Res::out), "
+:- pragma c_code(math__pow(X::in, Y::in, Res::out), "
if (X < 0.0) {
mercury_domain_error(""math__pow"");
}
@@ -717,7 +717,7 @@
% math__exp(X, Exp) is true if Exp is X raised to the
% power of e.
%
-:- pragma(c_code, math__exp(X::in, Exp::out), "Exp = exp(X);").
+:- pragma c_code(math__exp(X::in, Exp::out), "Exp = exp(X);").
%
% math__ln(X, Log) is true if Log is the natural logarithm
@@ -726,7 +726,7 @@
% Domain restrictions:
% X > 0
%
-:- pragma(c_code, math__ln(X::in, Log::out), "
+:- pragma c_code(math__ln(X::in, Log::out), "
if (X <= 0.0) {
mercury_domain_error(""math__ln"");
}
@@ -740,7 +740,7 @@
% Domain restrictions:
% X > 0
%
-:- pragma(c_code, math__log10(X::in, Log10::out), "
+:- pragma c_code(math__log10(X::in, Log10::out), "
if (X <= 0.0)
mercury_domain_error(""math__log10"");
Log10 = log10(X);
@@ -753,7 +753,7 @@
% Domain restrictions:
% X > 0
%
-:- pragma(c_code, math__log2(X::in, Log2::out), "
+:- pragma c_code(math__log2(X::in, Log2::out), "
if (X <= 0.0) {
mercury_domain_error(""math__log2"");
}
@@ -769,7 +769,7 @@
% B > 0
% B \= 1
%
-:- pragma(c_code, math__log(B::in, X::in, Log::out), "
+:- pragma c_code(math__log(B::in, X::in, Log::out), "
if (X <= 0.0 || B <= 0.0) {
mercury_domain_error(""math__log"");
}
@@ -782,17 +782,17 @@
%
% math__sin(X, Sin) is true if Sin is the sine of X.
%
-:- pragma(c_code, math__sin(X::in, Sin::out), "Sin = sin(X);").
+:- pragma c_code(math__sin(X::in, Sin::out), "Sin = sin(X);").
%
% math__cos(X, Sin) is true if Cos is the cosine of X.
%
-:- pragma(c_code, math__cos(X::in, Cos::out), "Cos = cos(X);").
+:- pragma c_code(math__cos(X::in, Cos::out), "Cos = cos(X);").
%
% math__tan(X, Tan) is true if Tan is the tangent of X.
%
-:- pragma(c_code, math__tan(X::in, Tan::out), "Tan = tan(X);").
+:- pragma c_code(math__tan(X::in, Tan::out), "Tan = tan(X);").
%
% math__asin(X, ASin) is true if ASin is the inverse
@@ -801,7 +801,7 @@
% Domain restrictions:
% X must be in the range [-1,1]
%
-:- pragma(c_code, math__asin(X::in, ASin::out), "
+:- pragma c_code(math__asin(X::in, ASin::out), "
if (X < -1.0 || X > 1.0) {
mercury_domain_error(""math__asin"");
}
@@ -815,7 +815,7 @@
% Domain restrictions:
% X must be in the range [-1,1]
%
-:- pragma(c_code, math__acos(X::in, ACos::out), "
+:- pragma c_code(math__acos(X::in, ACos::out), "
if (X < -1.0 || X > 1.0) {
mercury_domain_error(""math__acos"");
}
@@ -826,13 +826,13 @@
% math__atan(X, ATan) is true if ATan is the inverse
% tangent of X, where ATan is in the range [-pi/2,pi/2].
%
-:- pragma(c_code, math__atan(X::in, ATan::out), "ATan = atan(X);").
+:- pragma c_code(math__atan(X::in, ATan::out), "ATan = atan(X);").
%
% math__atan2(Y, X, ATan) is true if ATan is the inverse
% tangent of Y/X, where ATan is in the range [-pi,pi].
%
-:- pragma(c_code, math__atan2(Y::in, X::in, ATan2::out), "
+:- pragma c_code(math__atan2(Y::in, X::in, ATan2::out), "
ATan2 = atan2(Y, X);
").
@@ -840,19 +840,19 @@
% math__sinh(X, Sinh) is true if Sinh is the hyperbolic
% sine of X.
%
-:- pragma(c_code, math__sinh(X::in, Sinh::out), "Sinh = sinh(X);").
+:- pragma c_code(math__sinh(X::in, Sinh::out), "Sinh = sinh(X);").
%
% math__cosh(X, Cosh) is true if Cosh is the hyperbolic
% cosine of X.
%
-:- pragma(c_code, math__cosh(X::in, Cosh::out), "Cosh = cosh(X);").
+:- pragma c_code(math__cosh(X::in, Cosh::out), "Cosh = cosh(X);").
%
% math__tanh(X, Tanh) is true if Tanh is the hyperbolic
% tangent of X.
%
-:- pragma(c_code, math__tanh(X::in, Tanh::out), "Tanh = tanh(X);").
+:- pragma c_code(math__tanh(X::in, Tanh::out), "Tanh = tanh(X);").
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
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/08/03 00:13:23
@@ -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;
@@ -1542,14 +1543,15 @@
% The remaining routines are implemented using the C interface.
-:- pragma(c_header_code, "
+:- pragma c_header_code("
#include <string.h>
#include <stdio.h>
").
%-----------------------------------------------------------------------------%
-:- 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);
@@ -1734,7 +1747,7 @@
strcpy(S3 + len_1, S2);
}").
-:- pragma(c_code, "
+:- pragma c_code("
#ifdef COMPACT_ARGS
#define string__append_ooi_input_reg r1
@@ -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