[m-rev.] for review: initialisation code

Zoltan Somogyi zs at cs.mu.OZ.AU
Tue Aug 21 16:24:00 AEST 2001


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.

> @@ -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);

This is fine.

> 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).

Zoltan.
--------------------------------------------------------------------------
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