X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FRtsStartup.c;h=013fe66d9a25ea57b7724d38afb45bff50142eb2;hb=e778a17045aac8aded0e0438f5e0178643ff678d;hp=caca89f3322a99fd298af659229334fa5c78e266;hpb=b9d8ddb91c9360e3165244520f31dcd28c396825;p=ghc-hetmet.git diff --git a/ghc/rts/RtsStartup.c b/ghc/rts/RtsStartup.c index caca89f..013fe66 100644 --- a/ghc/rts/RtsStartup.c +++ b/ghc/rts/RtsStartup.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: RtsStartup.c,v 1.38 2000/04/03 15:54:50 simonmar Exp $ + * $Id: RtsStartup.c,v 1.48 2001/02/09 13:09:16 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * @@ -23,6 +23,15 @@ #include "StgStartup.h" #include "Prelude.h" /* fixupRTStoPreludeRefs */ +#ifdef GHCI +#include "HsFFI.h" +#include "Linker.h" +#endif + +#if defined(RTS_GTK_FRONTPANEL) +#include "FrontPanel.h" +#endif + #if defined(PROFILING) || defined(DEBUG) # include "Profiling.h" # include "ProfHeap.h" @@ -50,10 +59,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 +93,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 /* @@ -123,6 +152,11 @@ startupHaskell(int argc, char *argv[], void *init_root) /* initialize the storage manager */ initStorage(); + /* initialise the object linker, if necessary */ +#ifdef GHCI + initLinker(); +#endif + /* initialise the stable pointer table */ initStablePtrTable(); @@ -131,9 +165,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 +190,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 +226,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 +233,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 +311,12 @@ shutdownHaskell(void) */ exitStorage(); +#ifdef RTS_GTK_FRONTPANEL + if (RtsFlags.GcFlags.frontpanel) { + stopFrontPanel(); + } +#endif + #if defined(PROFILING) || defined(DEBUG) endProfiling(); #endif