Skip to content
Snippets Groups Projects
Commit c108d3f6 authored by Simon Marlow's avatar Simon Marlow
Browse files

[project @ 2000-03-30 12:03:30 by simonmar]

HEADS UP!!!

change the type of startupHaskell():

   void startupHaskell  ( int argc, char *argv[], void *init_root );

the extra parameter is a pointer to the initialisation function for
the root module in the program.  eg., Main.c now passes __init_Main for
this parameter.  It can be left as NULL if there is no root module.

This interface may need to be revised, since in some circumstances
there may be more than one "root module".

Sigbjorn: H/Direct will need some changes to stay in sync here.
parent 83ea6d69
No related merge requests found
/* ----------------------------------------------------------------------------
* $Id: RtsAPI.h,v 1.9 2000/01/13 12:40:15 simonmar Exp $
* $Id: RtsAPI.h,v 1.10 2000/03/30 12:03:31 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
......@@ -26,7 +26,7 @@ typedef StgClosure *HaskellObj;
/* ----------------------------------------------------------------------------
Starting up and shutting down the Haskell RTS.
------------------------------------------------------------------------- */
extern void startupHaskell ( int argc, char *argv[] );
extern void startupHaskell ( int argc, char *argv[], void *init_root );
extern void shutdownHaskell ( void );
extern void shutdownHaskellAndExit ( int exitCode );
......
/* -----------------------------------------------------------------------------
* $Id: Main.c,v 1.18 2000/03/14 09:55:05 simonmar Exp $
* $Id: Main.c,v 1.19 2000/03/30 12:03:30 simonmar Exp $
*
* (c) The GHC Team 1998-2000
*
......@@ -38,6 +38,7 @@
# include <windows.h>
#endif
EXTFUN(__init_Main);
/* Hack: we assume that we're building a batch-mode system unless
* INTERPRETER is set
......@@ -49,7 +50,7 @@ int main(int argc, char *argv[])
SchedulerStatus status;
/* all GranSim/GUM init is done in startupHaskell; sets IAmMainThread! */
startupHaskell(argc,argv);
startupHaskell(argc,argv,__init_Main);
/* kick off the computation by creating the main thread with a pointer
to mainIO_closure representing the computation of the overall program;
......
/* -----------------------------------------------------------------------------
* $Id: RtsStartup.c,v 1.35 2000/03/21 14:33:18 simonmar Exp $
* $Id: RtsStartup.c,v 1.36 2000/03/30 12:03:30 simonmar Exp $
*
* (c) The GHC Team, 1998-2000
*
......@@ -49,10 +49,11 @@ static int rts_has_started_up = 0;
static ullong startTime = 0;
#endif
static void initModules ( void );
EXTFUN(__init_Prelude);
static void initModules ( void * );
void
startupHaskell(int argc, char *argv[])
startupHaskell(int argc, char *argv[], void *init_root)
{
/* To avoid repeated initialisations of the RTS */
if (rts_has_started_up)
......@@ -131,7 +132,7 @@ startupHaskell(int argc, char *argv[])
/* run the per-module initialisation code */
#if !defined(INTERPRETER)
initModules();
initModules(init_root);
#endif
#if defined(PROFILING) || defined(DEBUG)
......@@ -200,16 +201,21 @@ startupHaskell(int argc, char *argv[])
/* The init functions use an explicit stack...
*/
#define INIT_STACK_SIZE (BLOCK_SIZE * 4)
F_ *init_stack;
F_ *init_stack = NULL;
nat init_sp = 0;
static void
initModules ( void )
initModules ( void *init_root )
{
/* this storage will be reclaimed by the garbage collector,
* as a large block.
*/
init_sp = 0;
init_stack = (F_ *)allocate(INIT_STACK_SIZE / sizeof(W_));
init_stack[init_sp++] = (F_)stg_init_ret;
init_stack[init_sp++] = (F_)__init_Prelude;
if (init_root != NULL) {
init_stack[init_sp++] = (F_)init_root;
}
MainRegTable.rSp = (P_)(init_stack + init_sp);
StgRun((StgFunPtr)stg_init, NULL/* no reg table */);
}
......
/* -----------------------------------------------------------------------------
* $Id: StgStartup.hc,v 1.9 2000/03/21 14:33:18 simonmar Exp $
* $Id: StgStartup.hc,v 1.10 2000/03/30 12:03:30 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
......@@ -146,15 +146,15 @@ STGFUN(stg_init_ret)
FE_
}
/* On entry to stg_init:
* init_stack[0] = &stg_init_ret;
* init_stack[1] = __init_Something;
*/
STGFUN(stg_init)
{
EF_(__init_PrelMain);
EF_(__init_Prelude);
FB_
Sp = (P_)init_stack;
PUSH_INIT_STACK(stg_init_ret);
PUSH_INIT_STACK(__init_Prelude);
JMP_(__init_PrelMain);
Sp = MainRegTable.rSp;
JMP_(POP_INIT_STACK());
FE_
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment