[m-rev.] diff: c_code to foreign_proc
Zoltan Somogyi
zs at cs.mu.OZ.AU
Thu May 29 22:03:36 AEST 2003
This diff has no changes in program logic.
Zoltan.
library/exception.m:
library/float.m:
library/io.m:
library/library.m:
library/private_builtin.m:
library/store.m:
library/string.m:
library/time.m:
Convert c_codes to foreign_procs, and clean up their formatting.
cvs diff: Diffing .
Index: exception.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/exception.m,v
retrieving revision 1.76
diff -u -r1.76 exception.m
--- exception.m 20 May 2003 03:18:09 -0000 1.76
+++ exception.m 20 May 2003 09:21:14 -0000
@@ -649,7 +649,8 @@
#endif /* ML_HLC_EXCEPTION_GUARD */
").
-:- pragma c_code("
+:- pragma foreign_code("C",
+"
#ifdef MR_HIGHLEVEL_CODE
/*
@@ -1237,7 +1238,8 @@
% The --no-high-level-code implementation
%
-:- pragma c_header_code("
+:- pragma foreign_decl("C",
+"
#ifndef MR_HIGHLEVEL_CODE
#include <assert.h>
#include <stdio.h>
@@ -1252,8 +1254,8 @@
#endif
").
-:- pragma c_code("
-
+:- pragma foreign_code("C",
+"
/* forward decls, to suppress gcc -Wmissing-decl warnings */
void mercury_sys_init_exceptions_init(void);
void mercury_sys_init_exceptions_init_type_tables(void);
Index: float.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/float.m,v
retrieving revision 1.54
diff -u -r1.54 float.m
--- float.m 19 May 2003 09:22:40 -0000 1.54
+++ float.m 20 May 2003 09:21:14 -0000
@@ -483,7 +483,8 @@
% is a reasonable default these days, and doing that might improve
% the compiler's optimization.
-:- pragma c_header_code("
+:- pragma foreign_decl("C",
+"
#define ML_FLOAT_RADIX FLT_RADIX /* There is no DBL_RADIX. */
Index: io.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.297
diff -u -r1.297 io.m
--- io.m 26 May 2003 09:00:29 -0000 1.297
+++ io.m 26 May 2003 09:19:09 -0000
@@ -1656,11 +1656,10 @@
io__state, io__state).
:- mode io__read_line_as_string_2(in, in, out, out, di, uo) is det.
-:- pragma foreign_proc("C", io__read_line_as_string_2(File::in,
- _Bool::in, Res :: out,
- RetString::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure,
- tabled_for_io, thread_safe],
+:- pragma foreign_proc("C",
+ io__read_line_as_string_2(File::in, _Bool::in, Res :: out,
+ RetString::out, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
#define ML_IO_READ_LINE_GROW(n) ((n) * 3 / 2)
#define ML_IO_BYTES_TO_WORDS(n) (((n) + sizeof(MR_Word) - 1) / sizeof(MR_Word))
@@ -1892,9 +1891,9 @@
:- mode io__clear_err(in, di, uo) is det.
% same as ANSI C's clearerr().
-:- pragma foreign_proc("C", io__clear_err(Stream::in, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure,
- tabled_for_io, thread_safe],
+:- pragma foreign_proc("C",
+ io__clear_err(Stream::in, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
MercuryFile *f = (MercuryFile *) Stream;
@@ -1906,8 +1905,9 @@
MR_update_io(IO0, IO);
}").
-:- pragma foreign_proc("MC++", io__clear_err(_Stream::in, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, thread_safe],
+:- pragma foreign_proc("MC++",
+ io__clear_err(_Stream::in, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, thread_safe],
"{
// XXX no error flag to reset as in MC++ an error throws directly an
// exception (we should create an error indicator in MF_Mercury_file
@@ -1931,10 +1931,9 @@
:- mode io__ferror(in, out, out, di, uo) is det.
% similar to ANSI C's ferror().
-:- pragma foreign_proc("C", ferror(Stream::in, RetVal::out, RetStr::out,
- IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure,
- tabled_for_io, thread_safe],
+:- pragma foreign_proc("C",
+ ferror(Stream::in, RetVal::out, RetStr::out, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
MercuryFile *f = (MercuryFile *) Stream;
@@ -1949,9 +1948,9 @@
MR_update_io(IO0, IO);
}").
-:- pragma foreign_proc("MC++", ferror(_Stream::in, RetVal::out, _RetStr::out,
- IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, thread_safe],
+:- pragma foreign_proc("MC++",
+ ferror(_Stream::in, RetVal::out, _RetStr::out, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, thread_safe],
"{
// XXX see clearerr
RetVal = 0;
@@ -1967,7 +1966,7 @@
:- pragma foreign_proc("C",
make_err_msg(Msg0::in, Msg::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"{
ML_maybe_make_err_msg(MR_TRUE, Msg0, MR_PROC_LABEL, Msg);
MR_update_io(IO0, IO);
@@ -1975,7 +1974,7 @@
:- pragma foreign_proc("MC++",
make_err_msg(Msg0::in, Msg::out, _IO0::di, _IO::uo),
- [will_not_call_mercury, promise_pure],
+ [will_not_call_mercury, promise_pure],
"{
Msg = System::String::Concat(Msg0, MR_io_exception->Message);
}").
@@ -1998,10 +1997,9 @@
#endif
").
-:- pragma foreign_proc("C", io__stream_file_size(Stream::in, Size::out,
- IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+:- pragma foreign_proc("C",
+ io__stream_file_size(Stream::in, Size::out, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
MercuryFile *f = (MercuryFile *) Stream;
#if defined(MR_HAVE_FSTAT) && \
@@ -2025,9 +2023,9 @@
MR_update_io(IO0, IO);
}").
-:- pragma foreign_proc("MC++", io__stream_file_size(Stream::in, Size::out,
- IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, thread_safe],
+:- pragma foreign_proc("MC++",
+ io__stream_file_size(Stream::in, Size::out, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, thread_safe],
"{
MR_MercuryFile mf = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(Stream));
@@ -2051,8 +2049,9 @@
io__state, io__state).
:- mode io__file_modification_time_2(in, out, out, out, di, uo) is det.
-:- pragma foreign_proc("C", io__file_modification_time_2(FileName::in,
- Status::out, Msg::out, Time::out, IO0::di, IO::uo),
+:- pragma foreign_proc("C",
+ io__file_modification_time_2(FileName::in, Status::out, Msg::out,
+ Time::out, IO0::di, IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
#ifdef MR_HAVE_STAT
@@ -2196,8 +2195,7 @@
:- pragma foreign_proc("C",
io__read_into_buffer(Stream::in, Buffer0::buffer_di, Pos0::in,
Size::in, Buffer::buffer_uo, Pos::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
MercuryFile *f = (MercuryFile *) Stream;
int items_read;
@@ -3168,32 +3166,32 @@
:- mode io__set_stream_names(in, di, uo) is det.
:- pragma foreign_proc("C",
- io__get_stream_names(StreamNames::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ io__get_stream_names(StreamNames::out, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
StreamNames = ML_io_stream_names;
MR_update_io(IO0, IO);
").
:- pragma foreign_proc("C",
- io__set_stream_names(StreamNames::in, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ io__set_stream_names(StreamNames::in, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
ML_io_stream_names = StreamNames;
MR_update_io(IO0, IO);
").
:- pragma foreign_proc("MC++",
- io__get_stream_names(StreamNames::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ io__get_stream_names(StreamNames::out, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
StreamNames = ML_io_stream_names;
MR_update_io(IO0, IO);
").
:- pragma foreign_proc("MC++",
- io__set_stream_names(StreamNames::in, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ io__set_stream_names(StreamNames::in, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
ML_io_stream_names = StreamNames;
MR_update_io(IO0, IO);
@@ -3224,16 +3222,16 @@
% and io__get_globals/3: the `Globals::uo' mode here is a lie.
:- pragma foreign_proc("C",
- io__get_globals(Globals::uo, IOState0::di, IOState::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ io__get_globals(Globals::uo, IOState0::di, IOState::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
Globals = ML_io_user_globals;
MR_update_io(IOState0, IOState);
").
:- pragma foreign_proc("C",
- io__set_globals(Globals::di, IOState0::di, IOState::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ io__set_globals(Globals::di, IOState0::di, IOState::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
/* XXX need to globalize the memory */
ML_io_user_globals = Globals;
@@ -3241,16 +3239,16 @@
").
:- pragma foreign_proc("MC++",
- io__get_globals(Globals::uo, IOState0::di, IOState::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ io__get_globals(Globals::uo, IOState0::di, IOState::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
Globals = ML_io_user_globals;
MR_update_io(IOState0, IOState);
").
:- pragma foreign_proc("MC++",
- io__set_globals(Globals::di, IOState0::di, IOState::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ io__set_globals(Globals::di, IOState0::di, IOState::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
ML_io_user_globals = Globals;
MR_update_io(IOState0, IOState);
@@ -3272,7 +3270,8 @@
:- pragma foreign_proc("C",
io__get_stream_id(Stream::in, Id::out),
- [will_not_call_mercury, promise_pure], "
+ [will_not_call_mercury, promise_pure],
+"
#ifndef MR_NATIVE_GC
/*
@@ -3291,7 +3290,8 @@
:- pragma foreign_proc("MC++",
io__get_stream_id(Stream::in, Id::out),
- [will_not_call_mercury, promise_pure], "
+ [will_not_call_mercury, promise_pure],
+"
MR_MercuryFile mf = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(Stream));
Id = mf->id;
@@ -3393,9 +3393,8 @@
:- mode io__gc_init(in, in, di, uo) is det.
:- pragma foreign_proc("C",
- io__gc_init(StreamNamesType::in, UserGlobalsType::in,
- IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ io__gc_init(StreamNamesType::in, UserGlobalsType::in, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
/* for Windows DLLs, we need to call GC_INIT() from each DLL */
#ifdef MR_CONSERVATIVE_GC
@@ -3407,8 +3406,10 @@
").
:- pragma foreign_proc("MC++",
- io__gc_init(_StreamNamesType::in, _UserGlobalsType::in,
- IO0::di, IO::uo), [will_not_call_mercury, promise_pure], "
+ io__gc_init(_StreamNamesType::in, _UserGlobalsType::in,
+ IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure],
+"
MR_update_io(IO0, IO);
").
@@ -4301,7 +4302,7 @@
:- pragma foreign_proc("C",
io__read_char_code(File::in, CharCode::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
CharCode = mercury_getc((MercuryFile *) File);
MR_update_io(IO0, IO);
@@ -4309,7 +4310,7 @@
:- pragma foreign_proc("C",
io__read_byte_val(File::in, ByteVal::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
ByteVal = mercury_getc((MercuryFile *) File);
MR_update_io(IO0, IO);
@@ -4317,7 +4318,7 @@
:- pragma foreign_proc("C",
io__putback_char(File::in, Character::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io],
+ [may_call_mercury, promise_pure, tabled_for_io],
"{
MercuryFile* mf = (MercuryFile *) File;
if (Character == '\\n') {
@@ -4332,7 +4333,7 @@
:- pragma foreign_proc("C",
io__putback_byte(File::in, Character::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io],
+ [may_call_mercury, promise_pure, tabled_for_io],
"{
MercuryFile* mf = (MercuryFile *) File;
/* XXX should work even if ungetc() fails */
@@ -4344,7 +4345,8 @@
:- pragma foreign_proc("MC++",
io__read_char_code(File::in, CharCode::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure], "
+ [will_not_call_mercury, promise_pure],
+"
MR_MercuryFile mf = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(File));
CharCode = mercury_getc(mf);
@@ -4353,7 +4355,8 @@
:- pragma foreign_proc("MC++",
io__read_byte_val(File::in, ByteVal::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure], "
+ [will_not_call_mercury, promise_pure],
+"
MR_MercuryFile mf = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(File));
if (mf->putback != -1) {
@@ -4367,7 +4370,8 @@
:- pragma foreign_proc("MC++",
io__putback_char(File::in, Character::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure], "{
+ [may_call_mercury, promise_pure],
+"{
MR_MercuryFile mf = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(File));
mercury_ungetc(mf, Character);
@@ -4376,7 +4380,8 @@
:- pragma foreign_proc("MC++",
io__putback_byte(File::in, Byte::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure], "{
+ [may_call_mercury, promise_pure],
+"{
MR_MercuryFile mf = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(File));
if (mf->putback != -1) {
@@ -4391,7 +4396,7 @@
:- pragma foreign_proc("C",
io__write_string(Message::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
mercury_print_string(mercury_current_text_output, Message);
MR_update_io(IO0, IO);
@@ -4399,7 +4404,7 @@
:- pragma foreign_proc("C",
io__write_char(Character::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
if (MR_PUTCH(*mercury_current_text_output, Character) < 0) {
mercury_output_error(mercury_current_text_output);
@@ -4412,7 +4417,7 @@
:- pragma foreign_proc("C",
io__write_int(Val::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
if (ML_fprintf(mercury_current_text_output, ""%ld"", (long) Val) < 0) {
mercury_output_error(mercury_current_text_output);
@@ -4422,7 +4427,7 @@
:- pragma foreign_proc("C",
io__write_float(Val::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
char buf[MR_SPRINTF_FLOAT_BUF_SIZE];
MR_sprintf_float(buf, Val);
@@ -4434,7 +4439,7 @@
:- pragma foreign_proc("C",
io__write_byte(Byte::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
/* call putc with a strictly non-negative byte-sized integer */
if (MR_PUTCH(*mercury_current_binary_output,
@@ -4447,7 +4452,7 @@
:- pragma foreign_proc("C",
io__write_bytes(Message::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
mercury_print_binary_string(mercury_current_binary_output, Message);
MR_update_io(IO0, IO);
@@ -4455,7 +4460,7 @@
:- pragma foreign_proc("C",
io__flush_output(IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
if (MR_FLUSH(*mercury_current_text_output) < 0) {
mercury_output_error(mercury_current_text_output);
@@ -4465,7 +4470,7 @@
:- pragma foreign_proc("C",
io__flush_binary_output(IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
if (MR_FLUSH(*mercury_current_binary_output) < 0) {
mercury_output_error(mercury_current_binary_output);
@@ -4475,7 +4480,7 @@
:- pragma foreign_proc("MC++",
io__write_string(Message::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
+ [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
mercury_print_string(mercury_current_text_output, Message);
MR_update_io(IO0, IO);
@@ -4483,7 +4488,7 @@
:- pragma foreign_proc("MC++",
io__write_char(Character::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
+ [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
/* See mercury_output_string() for comments */
if (mercury_current_text_output->writer == NULL) {
@@ -4512,7 +4517,7 @@
:- pragma foreign_proc("MC++",
io__write_int(Val::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
+ [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
mercury_print_string(mercury_current_text_output, Val.ToString());
MR_update_io(IO0, IO);
@@ -4520,7 +4525,7 @@
:- pragma foreign_proc("MC++",
io__write_byte(Byte::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
+ [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
mercury_current_binary_output->stream->WriteByte(Byte);
MR_update_io(IO0, IO);
@@ -4528,7 +4533,7 @@
:- pragma foreign_proc("MC++",
io__write_bytes(Message::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
+ [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
"{
mercury_print_binary_string(mercury_current_binary_output, Message);
MR_update_io(IO0, IO);
@@ -4536,7 +4541,7 @@
:- pragma foreign_proc("MC++",
io__flush_output(IO0::di, IO::uo),
- [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
+ [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
mercury_current_text_output->stream->Flush();
MR_update_io(IO0, IO);
@@ -4544,7 +4549,7 @@
:- pragma foreign_proc("MC++",
io__flush_binary_output(IO0::di, IO::uo),
- [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
+ [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
mercury_current_binary_output->stream->Flush();
MR_update_io(IO0, IO);
@@ -4569,10 +4574,8 @@
:- mode io__seek_binary_2(in, in, in, di, uo) is det.
:- pragma foreign_proc("C",
- io__seek_binary_2(Stream::in, Flag::in, Off::in,
- IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ io__seek_binary_2(Stream::in, Flag::in, Off::in, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
static const int seek_flags[] = { SEEK_SET, SEEK_CUR, SEEK_END };
MercuryFile *stream = (MercuryFile *) Stream;
@@ -4588,10 +4591,8 @@
}").
:- pragma foreign_proc("C",
- io__binary_stream_offset(Stream::in, Offset::out,
- IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ io__binary_stream_offset(Stream::in, Offset::out, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
MercuryFile *stream = (MercuryFile *) Stream;
/* XXX should check for failure */
@@ -4609,7 +4610,7 @@
:- pragma foreign_proc("C",
io__write_string(Stream::in, Message::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
MercuryFile *stream = (MercuryFile *) Stream;
mercury_print_string(stream, Message);
@@ -4618,7 +4619,7 @@
:- pragma foreign_proc("C",
io__write_char(Stream::in, Character::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
MercuryFile *stream = (MercuryFile *) Stream;
if (MR_PUTCH(*stream, Character) < 0) {
@@ -4632,7 +4633,7 @@
:- pragma foreign_proc("C",
io__write_int(Stream::in, Val::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
MercuryFile *stream = (MercuryFile *) Stream;
if (ML_fprintf(stream, ""%ld"", (long) Val) < 0) {
@@ -4643,7 +4644,7 @@
:- pragma foreign_proc("C",
io__write_float(Stream::in, Val::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
MercuryFile *stream = (MercuryFile *) Stream;
char buf[MR_SPRINTF_FLOAT_BUF_SIZE];
@@ -4656,7 +4657,7 @@
:- pragma foreign_proc("C",
io__write_byte(Stream::in, Byte::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
MercuryFile *stream = (MercuryFile *) Stream;
/* call putc with a strictly non-negative byte-sized integer */
@@ -4668,7 +4669,7 @@
:- pragma foreign_proc("C",
io__write_bytes(Stream::in, Message::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
MercuryFile *stream = (MercuryFile *) Stream;
mercury_print_binary_string(stream, Message);
@@ -4677,7 +4678,7 @@
:- pragma foreign_proc("C",
io__flush_output(Stream::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
MercuryFile *stream = (MercuryFile *) Stream;
if (MR_FLUSH(*stream) < 0) {
@@ -4688,7 +4689,7 @@
:- pragma foreign_proc("C",
io__flush_binary_output(Stream::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
MercuryFile *stream = (MercuryFile *) Stream;
if (MR_FLUSH(*stream) < 0) {
@@ -4699,7 +4700,7 @@
:- pragma foreign_proc("MC++",
io__write_string(Stream::in, Message::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
+ [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
"{
MR_MercuryFile stream = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(Stream));
@@ -4709,7 +4710,7 @@
:- pragma foreign_proc("MC++",
io__write_char(Stream::in, Character::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
+ [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
"{
MR_MercuryFile stream = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(Stream));
@@ -4738,7 +4739,7 @@
:- pragma foreign_proc("MC++",
io__write_int(Stream::in, Val::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
+ [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
"{
MR_MercuryFile stream = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(Stream));
@@ -4748,7 +4749,7 @@
:- pragma foreign_proc("MC++",
io__write_byte(Stream::in, Byte::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
+ [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
"{
MR_MercuryFile stream = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(Stream));
@@ -4758,7 +4759,7 @@
:- pragma foreign_proc("MC++",
io__write_bytes(Stream::in, Message::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
+ [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
"{
MR_MercuryFile stream = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(Stream));
@@ -4768,7 +4769,7 @@
:- pragma foreign_proc("MC++",
io__flush_output(Stream::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
+ [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
"{
MR_MercuryFile stream = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(Stream));
@@ -4778,7 +4779,7 @@
:- pragma foreign_proc("MC++",
io__flush_binary_output(Stream::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
+ [may_call_mercury, promise_pure, thread_safe, tabled_for_io],
"{
MR_MercuryFile stream = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(Stream));
@@ -4797,8 +4798,7 @@
:- pragma foreign_proc("C",
io__stdin_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
Stream = (MR_Word) &mercury_stdin;
MR_update_io(IO0, IO);
@@ -4806,8 +4806,7 @@
:- pragma foreign_proc("C",
io__stdout_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
Stream = (MR_Word) &mercury_stdout;
MR_update_io(IO0, IO);
@@ -4815,8 +4814,7 @@
:- pragma foreign_proc("C",
io__stderr_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
Stream = (MR_Word) &mercury_stderr;
MR_update_io(IO0, IO);
@@ -4824,8 +4822,7 @@
:- pragma foreign_proc("C",
io__stdin_binary_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
Stream = (MR_Word) &mercury_stdin_binary;
MR_update_io(IO0, IO);
@@ -4833,8 +4830,7 @@
:- pragma foreign_proc("C",
io__stdout_binary_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
Stream = (MR_Word) &mercury_stdout_binary;
MR_update_io(IO0, IO);
@@ -4842,7 +4838,7 @@
:- pragma foreign_proc("C",
io__input_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
Stream = (MR_Word) mercury_current_text_input;
MR_update_io(IO0, IO);
@@ -4850,7 +4846,7 @@
:- pragma foreign_proc("C",
io__output_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
Stream = (MR_Word) mercury_current_text_output;
MR_update_io(IO0, IO);
@@ -4858,7 +4854,7 @@
:- pragma foreign_proc("C",
io__binary_input_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
Stream = (MR_Word) mercury_current_binary_input;
MR_update_io(IO0, IO);
@@ -4866,7 +4862,7 @@
:- pragma foreign_proc("C",
io__binary_output_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
Stream = (MR_Word) mercury_current_binary_output;
MR_update_io(IO0, IO);
@@ -4874,7 +4870,7 @@
:- pragma foreign_proc("C",
io__get_line_number(LineNum::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
LineNum = MR_line_number(*mercury_current_text_input);
MR_update_io(IO0, IO);
@@ -4882,7 +4878,7 @@
:- pragma foreign_proc("C",
io__get_line_number(Stream::in, LineNum::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"{
MercuryFile *stream = (MercuryFile *) Stream;
LineNum = MR_line_number(*stream);
@@ -4891,7 +4887,7 @@
:- pragma foreign_proc("C",
io__set_line_number(LineNum::in, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
MR_line_number(*mercury_current_text_input) = LineNum;
MR_update_io(IO0, IO);
@@ -4899,7 +4895,7 @@
:- pragma foreign_proc("C",
io__set_line_number(Stream::in, LineNum::in, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"{
MercuryFile *stream = (MercuryFile *) Stream;
MR_line_number(*stream) = LineNum;
@@ -4908,7 +4904,7 @@
:- pragma foreign_proc("C",
io__get_output_line_number(LineNum::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
LineNum = MR_line_number(*mercury_current_text_output);
MR_update_io(IO0, IO);
@@ -4916,7 +4912,7 @@
:- pragma foreign_proc("C",
io__get_output_line_number(Stream::in, LineNum::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"{
MercuryFile *stream = (MercuryFile *) Stream;
LineNum = MR_line_number(*stream);
@@ -4925,16 +4921,15 @@
:- pragma foreign_proc("C",
io__set_output_line_number(LineNum::in, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
MR_line_number(*mercury_current_text_output) = LineNum;
MR_update_io(IO0, IO);
").
:- pragma foreign_proc("C",
- io__set_output_line_number(Stream::in, LineNum::in,
- IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ io__set_output_line_number(Stream::in, LineNum::in, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"{
MercuryFile *stream = (MercuryFile *) Stream;
MR_line_number(*stream) = LineNum;
@@ -4950,9 +4945,8 @@
% Changes the current input stream to the stream specified.
% Returns the previous stream.
:- pragma foreign_proc("C",
- io__set_input_stream(NewStream::in, OutStream::out,
- IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ io__set_input_stream(NewStream::in, OutStream::out, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
OutStream = (MR_Word) mercury_current_text_input;
mercury_current_text_input = (MercuryFile *) NewStream;
@@ -4960,9 +4954,8 @@
").
:- pragma foreign_proc("C",
- io__set_output_stream(NewStream::in, OutStream::out,
- IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ io__set_output_stream(NewStream::in, OutStream::out, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
OutStream = (MR_Word) mercury_current_text_output;
mercury_current_text_output = (MercuryFile *) NewStream;
@@ -4972,7 +4965,7 @@
:- pragma foreign_proc("C",
io__set_binary_input_stream(NewStream::in, OutStream::out,
IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
OutStream = (MR_Word) mercury_current_binary_input;
mercury_current_binary_input = (MercuryFile *) NewStream;
@@ -4982,7 +4975,7 @@
:- pragma foreign_proc("C",
io__set_binary_output_stream(NewStream::in, OutStream::out,
IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
OutStream = (MR_Word) mercury_current_binary_output;
mercury_current_binary_output = (MercuryFile *) NewStream;
@@ -4991,8 +4984,7 @@
:- pragma foreign_proc("MC++",
io__stdin_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, thread_safe,
- tabled_for_io],
+ [will_not_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
MR_c_pointer_to_word(Stream, mercury_stdin);
MR_update_io(IO0, IO);
@@ -5000,8 +4992,7 @@
:- pragma foreign_proc("MC++",
io__stdout_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, thread_safe,
- tabled_for_io],
+ [will_not_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
MR_c_pointer_to_word(Stream, mercury_stdout);
MR_update_io(IO0, IO);
@@ -5009,8 +5000,7 @@
:- pragma foreign_proc("MC++",
io__stderr_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, thread_safe,
- tabled_for_io],
+ [will_not_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
MR_c_pointer_to_word(Stream, mercury_stderr);
MR_update_io(IO0, IO);
@@ -5018,8 +5008,7 @@
:- pragma foreign_proc("MC++",
io__stdin_binary_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, thread_safe,
- tabled_for_io],
+ [will_not_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
MR_c_pointer_to_word(Stream, mercury_stdin_binary);
MR_update_io(IO0, IO);
@@ -5027,8 +5016,7 @@
:- pragma foreign_proc("MC++",
io__stdout_binary_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, thread_safe,
- tabled_for_io],
+ [will_not_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
MR_c_pointer_to_word(Stream, mercury_stdout_binary);
MR_update_io(IO0, IO);
@@ -5036,7 +5024,7 @@
:- pragma foreign_proc("MC++",
io__input_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
MR_c_pointer_to_word(Stream, mercury_current_text_input);
MR_update_io(IO0, IO);
@@ -5044,7 +5032,7 @@
:- pragma foreign_proc("MC++",
io__output_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
MR_c_pointer_to_word(Stream, mercury_current_text_output);
MR_update_io(IO0, IO);
@@ -5052,7 +5040,7 @@
:- pragma foreign_proc("MC++",
io__binary_input_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
MR_c_pointer_to_word(Stream, mercury_current_binary_input);
MR_update_io(IO0, IO);
@@ -5060,7 +5048,7 @@
:- pragma foreign_proc("MC++",
io__binary_output_stream(Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
MR_c_pointer_to_word(Stream, mercury_current_binary_output);
MR_update_io(IO0, IO);
@@ -5068,7 +5056,7 @@
:- pragma foreign_proc("MC++",
io__get_line_number(LineNum::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
LineNum = mercury_current_text_input->line_number;
MR_update_io(IO0, IO);
@@ -5076,7 +5064,7 @@
:- pragma foreign_proc("MC++",
io__get_line_number(Stream::in, LineNum::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"{
MR_MercuryFile stream = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(Stream));
@@ -5086,7 +5074,7 @@
:- pragma foreign_proc("MC++",
io__set_line_number(LineNum::in, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
mercury_current_text_input->line_number = LineNum;
MR_update_io(IO0, IO);
@@ -5094,7 +5082,7 @@
:- pragma foreign_proc("MC++",
io__set_line_number(Stream::in, LineNum::in, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"{
MR_MercuryFile stream = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(Stream));
@@ -5104,14 +5092,16 @@
:- pragma foreign_proc("MC++",
io__get_output_line_number(LineNum::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io], "
+ [will_not_call_mercury, promise_pure, tabled_for_io],
+"
LineNum = mercury_current_text_output->line_number;
MR_update_io(IO0, IO);
").
:- pragma foreign_proc("MC++",
io__get_output_line_number(Stream::in, LineNum::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io], "{
+ [will_not_call_mercury, promise_pure, tabled_for_io],
+"{
MR_MercuryFile stream = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(Stream));
LineNum = stream->line_number;
@@ -5120,14 +5110,16 @@
:- pragma foreign_proc("MC++",
io__set_output_line_number(LineNum::in, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io], "
+ [will_not_call_mercury, promise_pure, tabled_for_io],
+"
mercury_current_text_output->line_number = LineNum;
MR_update_io(IO0, IO);
").
:- pragma foreign_proc("MC++",
io__set_output_line_number(Stream::in, LineNum::in, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io], "{
+ [will_not_call_mercury, promise_pure, tabled_for_io],
+"{
MR_MercuryFile stream = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(Stream));
stream->line_number = LineNum;
@@ -5139,7 +5131,8 @@
% Returns the previous stream.
:- pragma foreign_proc("MC++",
io__set_input_stream(NewStream::in, OutStream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io], "
+ [will_not_call_mercury, promise_pure, tabled_for_io],
+"
MR_c_pointer_to_word(OutStream, mercury_current_text_input);
mercury_current_text_input =
ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(NewStream));
@@ -5148,7 +5141,8 @@
:- pragma foreign_proc("MC++",
io__set_output_stream(NewStream::in, OutStream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io], "
+ [will_not_call_mercury, promise_pure, tabled_for_io],
+"
MR_c_pointer_to_word(OutStream, mercury_current_text_output);
mercury_current_text_output =
ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(NewStream));
@@ -5158,7 +5152,8 @@
:- pragma foreign_proc("MC++",
io__set_binary_input_stream(NewStream::in, OutStream::out,
IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io], "
+ [will_not_call_mercury, promise_pure, tabled_for_io],
+"
MR_c_pointer_to_word(OutStream, mercury_current_binary_input);
mercury_current_binary_input =
ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(NewStream));
@@ -5168,7 +5163,8 @@
:- pragma foreign_proc("MC++",
io__set_binary_output_stream(NewStream::in, OutStream::out,
IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io], "
+ [will_not_call_mercury, promise_pure, tabled_for_io],
+"
MR_c_pointer_to_word(OutStream, mercury_current_binary_output);
mercury_current_binary_output =
ML_DownCast(MR_MercuryFile, MR_word_to_c_pointer(NewStream));
@@ -5183,8 +5179,7 @@
:- pragma foreign_proc("C",
io__do_open_text(FileName::in, Mode::in, ResultCode::out,
Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
Stream = (MR_Word) mercury_open(FileName, Mode);
ResultCode = (Stream ? 0 : -1);
@@ -5194,8 +5189,7 @@
:- pragma foreign_proc("C",
io__do_open_binary(FileName::in, Mode::in, ResultCode::out,
Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
Stream = (MR_Word) mercury_open(FileName, Mode);
ResultCode = (Stream ? 0 : -1);
@@ -5205,8 +5199,7 @@
:- pragma foreign_proc("MC++",
io__do_open_text(FileName::in, Mode::in, ResultCode::out,
Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
MR_MercuryFile mf = mercury_open(FileName, Mode,
ML_default_text_encoding);
@@ -5218,8 +5211,7 @@
:- pragma foreign_proc("MC++",
io__do_open_binary(FileName::in, Mode::in, ResultCode::out,
Stream::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
MR_MercuryFile mf = mercury_open(FileName, Mode, ML_raw_binary);
MR_c_pointer_to_word(Stream, mf);
@@ -5245,14 +5237,18 @@
:- pred io__close_stream(stream::in, io__state::di, io__state::uo) is det.
-:- pragma foreign_proc("C", io__close_stream(Stream::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe], "
+:- pragma foreign_proc("C",
+ io__close_stream(Stream::in, IO0::di, IO::uo),
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+"
mercury_close((MercuryFile *) Stream);
MR_update_io(IO0, IO);
").
-:- pragma foreign_proc("MC++", io__close_stream(Stream::in, IO0::di, IO::uo),
- [may_call_mercury, promise_pure, tabled_for_io, thread_safe], "
+:- pragma foreign_proc("MC++",
+ io__close_stream(Stream::in, IO0::di, IO::uo),
+ [may_call_mercury, promise_pure, tabled_for_io, thread_safe],
+"
MR_MercuryFile mf = ML_DownCast(MR_MercuryFile,
MR_word_to_c_pointer(Stream));
mercury_close(mf);
@@ -5263,8 +5259,7 @@
:- pragma foreign_proc("C",
io__progname(DefaultProgname::in, PrognameOut::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
if (MR_progname) {
/*
@@ -5286,8 +5281,7 @@
:- pragma foreign_proc("C",
io__command_line_arguments(Args::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
/* convert mercury_argv from a vector to a list */
{ int i = mercury_argc;
@@ -5302,7 +5296,7 @@
:- pragma foreign_proc("C",
io__get_exit_status(ExitStatus::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
ExitStatus = mercury_exit_status;
MR_update_io(IO0, IO);
@@ -5310,7 +5304,7 @@
:- pragma foreign_proc("C",
io__set_exit_status(ExitStatus::in, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
mercury_exit_status = ExitStatus;
MR_update_io(IO0, IO);
@@ -5319,7 +5313,7 @@
:- pragma foreign_proc("C",
io__call_system_code(Command::in, Status::out, Msg::out,
IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
Status = system(Command);
if ( Status == -1 ) {
@@ -5397,8 +5391,8 @@
:- pragma foreign_proc("MC++",
io__command_line_arguments(Args::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe], "
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
+"
MR_String arg_vector __gc[] = System::Environment::GetCommandLineArgs();
int i = arg_vector->Length;
MR_list_nil(Args);
@@ -5411,7 +5405,7 @@
:- pragma foreign_proc("MC++",
io__get_exit_status(ExitStatus::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
ExitStatus = System::Environment::ExitCode;
MR_update_io(IO0, IO);
@@ -5419,7 +5413,7 @@
:- pragma foreign_proc("MC++",
io__set_exit_status(ExitStatus::in, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
System::Environment::ExitCode = ExitStatus;
MR_update_io(IO0, IO);
@@ -5428,7 +5422,7 @@
:- pragma foreign_proc("C#",
io__call_system_code(Command::in, Status::out, Msg::out,
_IO0::di, _IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io],
+ [will_not_call_mercury, promise_pure, tabled_for_io],
"
try {
// XXX This could be better... need to handle embedded spaces
@@ -5477,15 +5471,17 @@
:- pragma promise_semipure(io__getenv/2).
-:- pragma foreign_proc("C", io__getenv(Var::in, Value::out),
- [will_not_call_mercury, tabled_for_io],
+:- pragma foreign_proc("C",
+ io__getenv(Var::in, Value::out),
+ [will_not_call_mercury, tabled_for_io],
"{
Value = getenv(Var);
SUCCESS_INDICATOR = (Value != 0);
}").
-:- pragma foreign_proc("C#", io__getenv(Var::in, Value::out),
- [will_not_call_mercury, tabled_for_io],
+:- pragma foreign_proc("C#",
+ io__getenv(Var::in, Value::out),
+ [will_not_call_mercury, tabled_for_io],
"{
Value = System.Environment.GetEnvironmentVariable(Var);
SUCCESS_INDICATOR = (Value != null);
@@ -5504,14 +5500,16 @@
% Not supported for .NET.
% This should only be called from io__setenv.
-:- pragma foreign_proc("C", io__putenv(VarAndValue::in),
- [will_not_call_mercury, tabled_for_io],
+:- pragma foreign_proc("C",
+ io__putenv(VarAndValue::in),
+ [will_not_call_mercury, tabled_for_io],
"
SUCCESS_INDICATOR = (putenv(VarAndValue) == 0);
").
-:- pragma foreign_proc("MC++", io__putenv(VarAndValue::in),
- [will_not_call_mercury, tabled_for_io],
+:- pragma foreign_proc("MC++",
+ io__putenv(VarAndValue::in),
+ [will_not_call_mercury, tabled_for_io],
"
/*
** Unfortunately there is no API in the .NET standard library
@@ -5599,8 +5597,7 @@
:- pragma foreign_proc("C",
io__do_make_temp(Dir::in, Prefix::in, FileName::out,
Error::out, ErrorMessage::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure,
- tabled_for_io, thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
/*
** Constructs a temporary name by concatenating Dir, `/',
@@ -5658,8 +5655,7 @@
:- pragma foreign_proc("MC++",
io__do_make_temp(Dir::in, Prefix::in, FileName::out,
Error::out, ErrorMessage::out, _IO0::di, _IO::uo),
- [will_not_call_mercury, promise_pure,
- tabled_for_io, thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
/* XXX For some reason this code below doesn't work.
* We get the following error message:
@@ -5770,8 +5766,7 @@
:- pragma foreign_proc("C",
io__remove_file_2(FileName::in, RetVal::out, RetStr::out,
IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
RetVal = remove(FileName);
ML_maybe_make_err_msg(RetVal != 0, ""remove failed: "",
@@ -5782,8 +5777,7 @@
:- pragma foreign_proc("C#",
io__remove_file_2(FileName::in, RetVal::out, RetStr::out,
_IO0::di, _IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
try {
if (System.IO.File.Exists(FileName)) {
@@ -5813,10 +5807,9 @@
:- mode io__rename_file_2(in, in, out, out, di, uo) is det.
:- pragma foreign_proc("C",
- io__rename_file_2(OldFileName::in, NewFileName::in,
- RetVal::out, RetStr::out, IO0::di, IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ io__rename_file_2(OldFileName::in, NewFileName::in, RetVal::out,
+ RetStr::out, IO0::di, IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
RetVal = rename(OldFileName, NewFileName);
ML_maybe_make_err_msg(RetVal != 0, ""rename failed: "",
@@ -5825,10 +5818,9 @@
}").
:- pragma foreign_proc("C#",
- io__rename_file_2(OldFileName::in, NewFileName::in,
- RetVal::out, RetStr::out, _IO0::di, _IO::uo),
- [will_not_call_mercury, promise_pure, tabled_for_io,
- thread_safe],
+ io__rename_file_2(OldFileName::in, NewFileName::in, RetVal::out,
+ RetStr::out, _IO0::di, _IO::uo),
+ [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
try {
if (System.IO.File.Exists(OldFileName)) {
Index: library.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/library.m,v
retrieving revision 1.68
diff -u -r1.68 library.m
--- library.m 3 Mar 2003 03:29:37 -0000 1.68
+++ library.m 19 May 2003 09:00:07 -0000
@@ -46,7 +46,7 @@
:- import_module private_builtin, table_builtin, profiling_builtin.
:- import_module rtti_implementation.
-% library__version must be implemented using pragma c_code,
+% library__version must be implemented using pragma foreign_proc,
% so we can get at the MR_VERSION and MR_FULLARCH configuration
% parameters. We can't just generate library.m from library.m.in
% at configuration time, because that would cause bootstrapping problems --
Index: private_builtin.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/private_builtin.m,v
retrieving revision 1.119
diff -u -r1.119 private_builtin.m
--- private_builtin.m 14 May 2003 14:38:46 -0000 1.119
+++ private_builtin.m 19 May 2003 09:01:11 -0000
@@ -343,13 +343,6 @@
% The definitions for type_ctor_info/1 and type_info/1.
- % XXX probably redundant
-% :- pragma c_header_code("
-% #ifdef MR_DEEP_PROFILING
-% #include ""mercury_deep_profiling.h""
-% #endif
-% ").
-
:- pragma foreign_code("MC++", "
static MR_TypeInfo MR_typeclass_info_type_info(
Index: store.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/store.m,v
retrieving revision 1.38
diff -u -r1.38 store.m
--- store.m 14 May 2003 14:38:48 -0000 1.38
+++ store.m 19 May 2003 09:03:23 -0000
@@ -287,23 +287,26 @@
I wonder whether it is worth it? Hmm, probably not.
*/
-:- pragma foreign_proc("C", new_mutvar(Val::in, Mutvar::out, S0::di, S::uo),
- [will_not_call_mercury, promise_pure],
+:- pragma foreign_proc("C",
+ new_mutvar(Val::in, Mutvar::out, S0::di, S::uo),
+ [will_not_call_mercury, promise_pure],
"
MR_incr_hp_msg(Mutvar, 1, MR_PROC_LABEL, ""store:mutvar/2"");
* (MR_Word *) Mutvar = Val;
S = S0;
").
-:- pragma foreign_proc("C", get_mutvar(Mutvar::in, Val::out, S0::di, S::uo),
- [will_not_call_mercury, promise_pure],
+:- pragma foreign_proc("C",
+ get_mutvar(Mutvar::in, Val::out, S0::di, S::uo),
+ [will_not_call_mercury, promise_pure],
"
Val = * (MR_Word *) Mutvar;
S = S0;
").
-:- pragma foreign_proc("C", set_mutvar(Mutvar::in, Val::in, S0::di, S::uo),
- [will_not_call_mercury, promise_pure],
+:- pragma foreign_proc("C",
+ set_mutvar(Mutvar::in, Val::in, S0::di, S::uo),
+ [will_not_call_mercury, promise_pure],
"
* (MR_Word *) Mutvar = Val;
S = S0;
@@ -318,8 +321,8 @@
:- mode store__unsafe_new_uninitialized_mutvar(out, di, uo) is det.
:- pragma foreign_proc("C",
- unsafe_new_uninitialized_mutvar(Mutvar::out, S0::di, S::uo),
- [will_not_call_mercury, promise_pure],
+ unsafe_new_uninitialized_mutvar(Mutvar::out, S0::di, S::uo),
+ [will_not_call_mercury, promise_pure],
"
MR_incr_hp_msg(Mutvar, 1, MR_PROC_LABEL, ""store:mutvar/2"");
S = S0;
@@ -332,8 +335,9 @@
%-----------------------------------------------------------------------------%
-:- pragma foreign_proc("C", new_ref(Val::di, Ref::out, S0::di, S::uo),
- [will_not_call_mercury, promise_pure],
+:- pragma foreign_proc("C",
+ new_ref(Val::di, Ref::out, S0::di, S::uo),
+ [will_not_call_mercury, promise_pure],
"
MR_incr_hp_msg(Ref, 1, MR_PROC_LABEL, ""store:ref/2"");
* (MR_Word *) Ref = Val;
@@ -350,8 +354,10 @@
% value.
:- pred store__unsafe_ref_value(generic_ref(T, S), T, S, S) <= store(S).
:- mode store__unsafe_ref_value(in, uo, di, uo) is det.
-:- pragma foreign_proc("C", unsafe_ref_value(Ref::in, Val::uo, S0::di, S::uo),
- [will_not_call_mercury, promise_pure],
+
+:- pragma foreign_proc("C",
+ unsafe_ref_value(Ref::in, Val::uo, S0::di, S::uo),
+ [will_not_call_mercury, promise_pure],
"
Val = * (MR_Word *) Ref;
S = S0;
@@ -361,17 +367,17 @@
unsafe_ref_value(Ref, Val),
{ functor(Val, Functor, Arity) }.
-:- pragma c_header_code("
+:- pragma foreign_decl("C",
+"
#include ""mercury_type_info.h""
#include ""mercury_heap.h""
#include ""mercury_misc.h"" /* for MR_fatal_error() */
#include ""mercury_deconstruct.h"" /* for MR_arg() */
-
").
:- pragma foreign_proc("C",
arg_ref(Ref::in, ArgNum::in, ArgRef::out, S0::di, S::uo),
- [will_not_call_mercury, promise_pure],
+ [will_not_call_mercury, promise_pure],
"{
MR_TypeInfo type_info;
MR_TypeInfo arg_type_info;
@@ -404,7 +410,7 @@
:- pragma foreign_proc("C",
new_arg_ref(Val::di, ArgNum::in, ArgRef::out, S0::di, S::uo),
- [will_not_call_mercury, promise_pure],
+ [will_not_call_mercury, promise_pure],
"{
MR_TypeInfo type_info;
MR_TypeInfo arg_type_info;
@@ -450,7 +456,7 @@
:- pragma foreign_proc("C",
set_ref(Ref::in, ValRef::in, S0::di, S::uo),
- [will_not_call_mercury, promise_pure],
+ [will_not_call_mercury, promise_pure],
"
* (MR_Word *) Ref = * (MR_Word *) ValRef;
S = S0;
@@ -458,7 +464,7 @@
:- pragma foreign_proc("C",
set_ref_value(Ref::in, Val::di, S0::di, S::uo),
- [will_not_call_mercury, promise_pure],
+ [will_not_call_mercury, promise_pure],
"
* (MR_Word *) Ref = Val;
S = S0;
@@ -466,7 +472,7 @@
:- pragma foreign_proc("C",
extract_ref_value(_S::di, Ref::in, Val::out),
- [will_not_call_mercury, promise_pure],
+ [will_not_call_mercury, promise_pure],
"
Val = * (MR_Word *) Ref;
").
@@ -475,7 +481,7 @@
:- pragma foreign_proc("C",
unsafe_arg_ref(Ref::in, Arg::in, ArgRef::out, S0::di, S::uo),
- [will_not_call_mercury, promise_pure],
+ [will_not_call_mercury, promise_pure],
"{
/* unsafe - does not check type & arity, won't handle no_tag types */
MR_Word *Ptr = (MR_Word *) MR_strip_tag((MR_Word) Ref);
@@ -483,13 +489,12 @@
S = S0;
}").
-:- pragma foreign_proc("C", unsafe_new_arg_ref(Val::di, Arg::in, ArgRef::out,
- S0::di, S::uo),
- [will_not_call_mercury, promise_pure],
+:- pragma foreign_proc("C",
+ unsafe_new_arg_ref(Val::di, Arg::in, ArgRef::out, S0::di, S::uo),
+ [will_not_call_mercury, promise_pure],
"{
/* unsafe - does not check type & arity, won't handle no_tag types */
MR_Word *Ptr = (MR_Word *) MR_strip_tag((MR_Word) Val);
ArgRef = (MR_Word) &Ptr[Arg];
S = S0;
}").
-
Index: string.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.201
diff -u -r1.201 string.m
--- string.m 26 May 2003 09:00:31 -0000 1.201
+++ string.m 26 May 2003 09:19:09 -0000
@@ -2783,7 +2783,8 @@
% The remaining routines are implemented using the C interface.
-:- pragma c_header_code("
+:- pragma foreign_decl("C",
+"
#include <ctype.h>
#include <string.h>
#include <stdio.h>
@@ -3053,7 +3054,8 @@
/*-----------------------------------------------------------------------*/
-:- pragma c_header_code("
+:- pragma foreign_decl("C",
+"
#ifdef MR_USE_GCC_GLOBAL_REGISTERS
/*
** GNU C version egcs-1.1.2 crashes with `fixed or forbidden
@@ -3067,7 +3069,8 @@
#endif
").
-:- pragma c_code("
+:- pragma foreign_code("C",
+"
#ifdef MR_USE_GCC_GLOBAL_REGISTERS
/*
** GNU C version egcs-1.1.2 crashes with `fixed or forbidden
Index: time.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/time.m,v
retrieving revision 1.33
diff -u -r1.33 time.m
--- time.m 22 Feb 2003 11:17:36 -0000 1.33
+++ time.m 19 May 2003 09:03:44 -0000
@@ -182,7 +182,8 @@
% is not very portable.
:- type time_t == int.
-:- pragma c_header_code("
+:- pragma foreign_decl("C",
+"
#include <time.h>
#ifdef MR_HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -287,8 +288,9 @@
:- func time__c_clk_tck = int.
-:- pragma foreign_proc("C", time__c_clk_tck = (Ret::out),
- [will_not_call_mercury, promise_pure],
+:- pragma foreign_proc("C",
+ time__c_clk_tck = (Ret::out),
+ [will_not_call_mercury, promise_pure],
"{
#if defined(MR_HAVE_SYSCONF) && defined(_SC_CLK_TCK)
Ret = (MR_Integer) sysconf(_SC_CLK_TCK);
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list