Estimated hours taken: 1
Fix a bug which caused link errors in some grades for some test cases
where the module name wasn't the same as the file name, and which
probably would have caused runtime errors in some grades for test
cases using nested modules.
compiler/modules.m:
Call $(C2INIT) with $(foo.cs) instead of $(foo.ms).
This is necessary now that a single .m file can get compiled
to multiple .c files, if it contains nested modules,
or to a .c file whose name reflects the module name rather
than the source file name.
util/mkinit.c:
scripts/c2init.in:
For efficiency, change c2init and mkinit so that when c2init's
arguments are `.c' files, it computes the init function based
on the filename (like it used to do with `.m' files), rather
than by reading the file contents and searching for "** INIT"
comments. Add a new option `-x' (`--extra-inits') which keeps
the old behaviour.
compiler/modules.m:
scripts/Mmake.rules:
Instead of deleting the `_init.c' file every time we recreate
the `.dep' file, just tell make that the `_init.c' file depends on
the `.dep' file, so that make will remake it if the `.dep' file
changes. (I don't know why I didn't do it that way in the
first place.)
Estimated hours taken: 0.25
scripts/c2init.in:
Use only libmercury.init and runtime.init in $MERCURY_MOD_LIB_DIR,
rather than using `$MERCURY_MOD_LIB_DIR/*'. This avoids problems
if other .init files (e.g. cfloat_lib.init) are installed in
the same directory.
Estimated hours taken: 8
Split up the startup interface so that there are seperate
initialization and termination functions, rather than just a single
mercury_runtime_main() function which does everything.
Also change things so that the io__state data is stored in global
variables.
runtime/init.h:
util/mkinit.c:
runtime/wrapper.h:
runtime/wrapper.mod:
Move declarations for stuff defined in wrapper.mod from init.h
to wrapper.h. Clean up the remainder of init.h so that it
is clear which parts are interface and which are just there
for use by *_init.c.
Change the automatically-generated *_init.c files
so that they call mercury_runtime_init(),
mercury_runtime_main(), and mercury_runtime_terminate(),
rather than just mercury_runtime_main().
Define these new two functions in wrapper.mod.
Delete the library_entry_point; change do_interpreter
to call program_entry_point directly, rather than via
library_entry_point.
runtime/engine.h:
runtime/engine.mod:
Add new function terminate_engine().
Delete the function start_mercury_engine();
move the code that used to be there to the end
of init_engine().
runtime/context.h:
runtime/context.mod:
Add new function shutdown_processes().
(The current implementation is just a stub.)
Add a call to debug_memory() in init_process_context().
runtime/memory.h:
runtime/memory.c:
Export the debug_memory() function, for use by context.c.
library/io.m:
library/io.nu.nl:
Change things so that the io__state data is stored in C global
variables (or, for Prolog, using assert/retract), rather than
passing around a data structure. (Actually we still pass the
data structure around, but it is just a dummy Word that never
gets used.)
Delete the old hand-coded io__run predicate, which was
the library entry point; instead export C functions
ML_io_init_state() and ML_io_finalize_state(). Move the
code for handling profiling from io__run to do_interpreter
in runtime/wrapper.mod.
scripts/c2init.in:
Change the default entry point from io__run_0_0 to main_2_0
scripts/c2init.in:
scripts/mmake.in:
scripts/msc.in:
Small changes to the help messages to make them come out
better when converted to man pages.
scripts/mgnuc.in:
Add a `--help' option.
Estimated hours taken: 0.5
More stuff to support non-Mercury main() programs.
util/c2init.c:
Implement a new `-l' / `--libary' option.
If this option is enabled, we pass `-l' to mkinit,
which has the end result that we don't emit a main(),
but instead we emit a mercury_main(argc, argv, stack_bottom)
function that can be called from C.
Estimated hours taken: 0.5
scripts/{c2init,mnc,mnl,msc,msl}.in:
Fix a portability problem: ULTRIX's /bin/sh does not understand
`shift 2', so I've replaced all occurrences of this with
`shift; shift'. (Thanks to Jeff Schultz for the bug report.)
scripts/*.in:
Replace all uses of
... "$@" ...
with
case $# in
0) ... ...
*) ... "$@" ...
esac
since on ULTRIX and OSF, "$@" does the wrong thing if $# is 0.
rather than invoking `mkinit' directly. The reason is that `mkinit' only
does part of `mod2init's old job; `c2init' collects the filenames of the
standard library modules (possibly overridden by environment variables)
and passes these, together with the modules named on the command line,
to `mkinit'.