X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FRtsStartup.c;h=840ebf24b49e9deb01aeac4ef5c27331114b7b8c;hb=a7dff32d3a8c10c9bd2081f441285ed31a01d2c1;hp=37bc4c0a9a53d55fe0c913a5efaa6e71b9931913;hpb=dd4c28a9c706cce09ecc2c6f532969efa925532f;p=ghc-hetmet.git diff --git a/ghc/rts/RtsStartup.c b/ghc/rts/RtsStartup.c index 37bc4c0..840ebf2 100644 --- a/ghc/rts/RtsStartup.c +++ b/ghc/rts/RtsStartup.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: RtsStartup.c,v 1.37 2000/03/31 03:09:36 hwloidl Exp $ + * $Id: RtsStartup.c,v 1.49 2001/02/11 17:51:08 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * @@ -22,9 +22,15 @@ #include "StgRun.h" #include "StgStartup.h" #include "Prelude.h" /* fixupRTStoPreludeRefs */ +#include "HsFFI.h" +#include "Linker.h" + +#if defined(RTS_GTK_FRONTPANEL) +#include "FrontPanel.h" +#endif #if defined(PROFILING) || defined(DEBUG) -# include "ProfRts.h" +# include "Profiling.h" # include "ProfHeap.h" #endif @@ -50,10 +56,30 @@ static ullong startTime = 0; #endif EXTFUN(__init_Prelude); -static void initModules ( void * ); +static void initModules ( void (*)(void) ); + +void +setProgArgv(int argc, char *argv[]) +{ + /* Usually this is done by startupHaskell, so we don't need to call this. + However, sometimes Hugs wants to change the arguments which Haskell + getArgs >>= ... will be fed. So you can do that by calling here + _after_ calling startupHaskell. + */ + prog_argc = argc; + prog_argv = argv; +} + +void +getProgArgv(int *argc, char **argv[]) +{ + *argc = prog_argc; + *argv = prog_argv; +} + void -startupHaskell(int argc, char *argv[], void *init_root) +startupHaskell(int argc, char *argv[], void (*init_root)(void)) { /* To avoid repeated initialisations of the RTS */ if (rts_has_started_up) @@ -64,7 +90,7 @@ startupHaskell(int argc, char *argv[], void *init_root) /* The very first thing we do is grab the start time...just in case we're * collecting timing statistics. */ - start_time(); + stat_startInit(); #ifdef PAR /* @@ -131,9 +157,7 @@ startupHaskell(int argc, char *argv[], void *init_root) #endif /* run the per-module initialisation code */ -#if !defined(INTERPRETER) initModules(init_root); -#endif #if defined(PROFILING) || defined(DEBUG) initProfiling2(); @@ -158,16 +182,14 @@ startupHaskell(int argc, char *argv[], void *init_root) init_default_handlers(); #endif -#if !defined(INTERPRETER) - /* Initialise pointers from the RTS to the prelude. - Only for compiled code -- the interpreter - will call this itself later, so don't do so now. - */ - fixupRTStoPreludeRefs(NULL); +#ifdef RTS_GTK_FRONTPANEL + if (RtsFlags.GcFlags.frontpanel) { + initFrontPanel(); + } #endif /* Record initialization times */ - end_init(); + stat_endInit(); } /* ----------------------------------------------------------------------------- @@ -196,8 +218,6 @@ startupHaskell(int argc, char *argv[], void *init_root) StgRun to call this stuff. -------------------------------------------------------------------------- */ -#ifndef INTERPRETER - /* The init functions use an explicit stack... */ #define INIT_STACK_SIZE (BLOCK_SIZE * 4) @@ -205,21 +225,25 @@ F_ *init_stack = NULL; nat init_sp = 0; static void -initModules ( void *init_root ) +initModules ( void (*init_root)(void) ) { - 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 */); -} +#ifdef SMP + Capability cap; +#else +#define cap MainRegTable +#endif -#endif /* !INTERPRETER */ + 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; + } + + cap.rSp = (P_)(init_stack + init_sp); + StgRun((StgFunPtr)stg_init, &cap); +} /* ----------------------------------------------------------------------------- * Shutting down the RTS - two ways of doing this, one which @@ -279,6 +303,12 @@ shutdownHaskell(void) */ exitStorage(); +#ifdef RTS_GTK_FRONTPANEL + if (RtsFlags.GcFlags.frontpanel) { + stopFrontPanel(); + } +#endif + #if defined(PROFILING) || defined(DEBUG) endProfiling(); #endif