[m-rev.] for review: initialisation code

David Jeffery dgj at cs.mu.OZ.AU
Tue Aug 21 16:43:07 AEST 2001


On 21-Aug-2001, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> On 21-Aug-2001, David Jeffery <dgj at cs.mu.OZ.AU> wrote:
> > (I'm not sure that the fix I've made is the right one.)
> 
> I think it is, but your test case is wrong.
> 
> > +C2INITARGS-needs_init           =       needs_init.init
> > +
> > +needs_init: needs_init.init
> 
> The needs_init.init file will cause needs_init_init.c to call only functions
> it was going to call anyway, so I don't think it has any effect.

Fixed.

> > 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() {}
> > ").
> 
> Each module needs four functions. You have given two, run_at_init_time_init
> and run_at_init_time_init_type_tables, but you also need two others,
> run_at_init_time_init_debugger and run_at_init_time_write_out_proc_statics,
> if you want the test case to pass in .debug and .profdeep grades. Check to
> see what calls the _init.c file makes to those functions, and base your
> other functions' signature on that (their bodies can be empty, of course).

Fixed too.

Revised diff follows:

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 06:39:40
@@ -78,6 +78,7 @@
         multimode \
         myset_test \
         name_mangling \
+        needs_init \
         no_fully_strict \
         no_inline \
         nondet_ctrl_vn \
@@ -248,6 +249,8 @@
 
 C2INITFLAGS-split-c-files       =       --trace
 MLFLAGS-split-c-files           =       --trace
+
+C2INITFLAGS-needs_init          =       --include-initialization-code --extra-inits
 
 # 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.exp is a new entry, no comparison available
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 06:39:40
@@ -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.exp
===================================================================
hello, world!

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);
void run_at_init_time_write_out_proc_statics(FILE *);
void run_at_init_time_init_debugger(void);
").

:- pragma c_code("

/*
INIT run_at_init_time
ENDINIT
*/

void run_at_init_time_init_type_tables() {}
void run_at_init_time_write_out_proc_statics(FILE *f) {}
void run_at_init_time_init_debugger() {}
").



dgj
-- 
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