/* ----------------------------------------------------------------------------
- * $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
*
/* ----------------------------------------------------------------------------
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
*
# include <windows.h>
#endif
+EXTFUN(__init_Main);
/* Hack: we assume that we're building a batch-mode system unless
* INTERPRETER is set
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
*
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)
/* run the per-module initialisation code */
#if !defined(INTERPRETER)
- initModules();
+ initModules(init_root);
#endif
#if defined(PROFILING) || defined(DEBUG)
/* 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
*
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_
}