Files
mercury/scripts/c2init.in
Fergus Henderson d1cc2ddee4 Split up the startup interface so that there are seperate
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
1997-09-05 22:38:58 +00:00

79 lines
2.2 KiB
Bash
Executable File

#! /bin/sh
# @configure_input@
#---------------------------------------------------------------------------#
# Copyright (C) 1995-1997 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public License - see the file COPYING in the Mercury distribution.
#---------------------------------------------------------------------------#
# C2INIT - Convert *.c to *_init.c
#
# This script outputs an appropriate init.c, given the .c files.
# Type `c2init --help' for usage message.
#
# IMPORTANT: the manpage is produced automatically from this help
# message, so if you change the help message, don't forget to check
# that the manpage still looks OK.
Help="\
Name: c2init - Create Mercury initialization file.
Usage: c2init [options] modules ...
Options:
-l, --library
Don't generate a \`main()' function.
Instead, generate a function
mercury_main(int argc, char **argv);
(declared in \"init.h\") that can be called from C code.
(A more fine-grained interface is also available;
see \"init.h\" for details.)
-c <n>, --max-calls <n>
Break up the initialization into groups of at most <n> function
calls. (Default value of <n> is 40.)
-w <label>, --entry-point <label>
Set entry point to <label>.
(Default value is \`mercury__main_2_0'.)
Environment variables:
MERCURY_MOD_LIB_DIR, MERCURY_MOD_LIB_MODS, MERCURY_MKINIT.
"
MERCURY_MOD_LIB_DIR=${MERCURY_MOD_LIB_DIR=@LIBDIR@/modules}
MERCURY_MOD_LIB_MODS=${MERCURY_MOD_LIB_MODS=$MERCURY_MOD_LIB_DIR/*}
MKINIT=${MERCURY_MKINIT=mkinit}
# maximum number of calls to put in a single function
maxcalls=40
defentry=mercury__main_2_0
library_opt=""
while true; do
case "$1" in
-c|--max-calls)
maxcalls="$2"; shift; shift;;
-w|--entry-point)
defentry="$2"; shift; shift;;
-l|--library)
library_opt="-l"; shift;;
-l-|--no-library)
library_opt=""; shift;;
-h|--help|"-?")
echo "$Help"
exit 0;;
--)
shift; break;;
-*)
echo "`basename $0`: invalid option \`$1'" 1>&2;
echo "Try \`$0 --help' for help." 1>&2;
exit 1;;
*)
break;;
esac
done
case $# in
0) exec $MKINIT -w"$defentry" -c"$maxcalls" $library_opt \
$MERCURY_MOD_LIB_MODS
;;
*) exec $MKINIT -w"$defentry" -c"$maxcalls" $library_opt \
"$@" $MERCURY_MOD_LIB_MODS
;;
esac