[m-rev.] for review: initialisation code

David Jeffery dgj at cs.mu.OZ.AU
Tue Aug 21 15:49:13 AEST 2001


For Zoltan to review.

(I'm not sure that the fix I've made is the right one.)

===================================================================

Estimated hours taken: 4

util/mkinit.c:
	Ensure that initialisation code is included if the user explictly
	asks for it.

tests/hard_coded/Mmakefile:
tests/hard_coded/needs_init.m:
	A test case to ensure that initialisation code can be explicitly
	run.

===================================================================
cvs server: Diffing tests
cvs server: Diffing tests/benchmarks
cvs server: Diffing tests/debugger
cvs server: Diffing tests/debugger/declarative
cvs server: Diffing tests/dppd
cvs server: Diffing tests/general
cvs server: Diffing tests/general/accumulator
cvs server: Diffing tests/general/structure_reuse
cvs server: Diffing tests/hard_coded
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.121
diff -u -t -r1.121 Mmakefile
--- tests/hard_coded/Mmakefile	2001/06/22 03:14:32	1.121
+++ tests/hard_coded/Mmakefile	2001/08/21 05:12:00
@@ -78,6 +78,7 @@
         multimode \
         myset_test \
         name_mangling \
+        needs_init \
         no_fully_strict \
         no_inline \
         nondet_ctrl_vn \
@@ -248,6 +249,11 @@
 
 C2INITFLAGS-split-c-files       =       --trace
 MLFLAGS-split-c-files           =       --trace
+
+C2INITFLAGS-needs_init          =       --include-initialization-code --extra-inits
+C2INITARGS-needs_init           =       needs_init.init
+
+needs_init: needs_init.init
 
 # no_fully_strict is expected to fail (it calls error/1).
 # We also need to pipe the output through sed to avoid hard-coding
cvs server: tests/hard_coded/needs_init.m is a new entry, no comparison available
cvs server: Diffing tests/hard_coded/exceptions
cvs server: Diffing tests/hard_coded/purity
cvs server: Diffing tests/hard_coded/sub-modules
cvs server: Diffing tests/hard_coded/typeclasses
cvs server: Diffing tests/intermod
cvs server: Diffing tests/invalid
cvs server: Diffing tests/invalid/purity
cvs server: Diffing tests/misc_tests
cvs server: Diffing tests/recompilation
cvs server: Diffing tests/submodules
cvs server: Diffing tests/tabling
cvs server: Diffing tests/term
cvs server: Diffing tests/tools
cvs server: Diffing tests/typeclasses
cvs server: Diffing tests/valid
cvs server: Diffing tests/warnings
cvs server: Diffing util
Index: util/mkinit.c
===================================================================
RCS file: /home/mercury1/repository/mercury/util/mkinit.c,v
retrieving revision 1.77
diff -u -t -r1.77 mkinit.c
--- util/mkinit.c	2001/05/31 06:00:27	1.77
+++ util/mkinit.c	2001/08/21 05:12:00
@@ -418,7 +418,6 @@
 main(int argc, char **argv)
 {
         int     num_bunches;
-        const char      *need_main_ifdef;
 
         MR_progname = argv[0];
 
@@ -430,10 +429,8 @@
         output_headers();
 
         if (need_initialization_code) {
-                need_main_ifdef = NULL;
-        } else {
-                need_main_ifdef = if_need_to_init;
-        }
+                printf("#define MR_MAY_NEED_INITIALIZATION\n\n");
+        } 
 
         num_bunches = output_sub_init_functions(PURPOSE_INIT);
         output_main_init_function(PURPOSE_INIT, num_bunches);

New File: tests/hard_coded/needs_init.m
===================================================================
:- module needs_init.

:- interface.

:- import_module io.

:- pred main(io__state::di, io__state::uo) is det.

:- implementation.

:- pred init_modules(io__state::di, io__state::uo) is det.
:- pragma import(init_modules(di, uo), "do_init_modules").

main --> 
	init_modules,
	write_string("world!\n").

:- pred hello(io__state::di, io__state::uo) is det.
:- pragma export(hello(di, uo), "run_at_init_time_init").
hello --> write_string("hello, ").

:- pragma c_header_code("
void run_at_init_time_init_type_tables(void);
").

:- pragma c_code("

/*
INIT run_at_init_time
ENDINIT
*/

void run_at_init_time_init_type_tables() {}
").




-- 
David Jeffery (dgj at cs.mu.oz.au) | If you want to build a ship, don't drum up 
PhD student,                    | people together to collect wood or assign 
Dept. of Comp. Sci. & Soft. Eng.| them tasks and work, but rather teach them 
The University of Melbourne     | to long for the endless immensity of the sea.
Australia                       | -- Antoine de Saint Exupery
--------------------------------------------------------------------------
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