X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FRtsStartup.c;h=10cd451be8dbd6ef55daaf7c2f51f76aa96be4d2;hb=4417e97d436e2796bed886cb1a830acb88d3da28;hp=d605328484047f76cb00d08c94d4b27f7727be66;hpb=4bd153f2dd93745183584054e17c6ff169691a49;p=ghc-hetmet.git diff --git a/ghc/rts/RtsStartup.c b/ghc/rts/RtsStartup.c index d605328..10cd451 100644 --- a/ghc/rts/RtsStartup.c +++ b/ghc/rts/RtsStartup.c @@ -11,9 +11,11 @@ #include "RtsAPI.h" #include "RtsUtils.h" #include "RtsFlags.h" +#include "OSThreads.h" #include "Storage.h" /* initStorage, exitStorage */ #include "Schedule.h" /* initScheduler */ #include "Stats.h" /* initStats */ +#include "STM.h" /* initSTM */ #include "Signals.h" #include "Timer.h" /* startTimer, stopTimer */ #include "Weak.h" @@ -48,16 +50,12 @@ # include "LLC.h" #endif -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) #include "win32/AsyncIO.h" #endif #include -#ifdef HAVE_LOCALE_H -#include -#endif - #ifdef HAVE_TERMIOS_H #include #endif @@ -90,6 +88,7 @@ __hscore_set_saved_termios(int fd, void* ts) /* ----------------------------------------------------------------------------- Initialise floating point unit on x86 (currently disabled. why?) + (see comment in ghc/compiler/nativeGen/MachInstrs.lhs). -------------------------------------------------------------------------- */ #define X86_INIT_FPU 0 @@ -158,8 +157,7 @@ hs_init(int *argc, char **argv[]) /* Parse the flags, separating the RTS flags from the programs args */ if (argc != NULL && argv != NULL) { setupRtsFlags(argc, *argv, &rts_argc, rts_argv); - prog_argc = *argc; - prog_argv = *argv; + setProgArgv(*argc,*argv); } #if defined(PAR) @@ -193,8 +191,10 @@ hs_init(int *argc, char **argv[]) /* initialise the stable pointer table */ initStablePtrTable(); +#if defined(DEBUG) /* initialise thread label table (tso->char*) */ initThreadLabelTable(); +#endif #if defined(PROFILING) || defined(DEBUG) initProfiling1(); @@ -213,7 +213,7 @@ hs_init(int *argc, char **argv[]) initDefaultHandlers(); #endif -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) startupAsyncIO(); #endif @@ -223,10 +223,6 @@ hs_init(int *argc, char **argv[]) } #endif -#ifdef HAVE_LOCALE_H - setlocale(LC_CTYPE,""); -#endif - #if X86_INIT_FPU x86_init_fpu(); #endif @@ -240,36 +236,12 @@ void startupHaskell(int argc, char *argv[], void (*init_root)(void)) { hs_init(&argc, &argv); - hs_add_root(init_root); + if(init_root) + hs_add_root(init_root); } /* ----------------------------------------------------------------------------- - Getting/Setting the program's arguments. - - These are used by System.Environment. - -------------------------------------------------------------------------- */ - -void -getProgArgv(int *argc, char **argv[]) -{ - if (argc) { *argc = prog_argc; } - if (argv) { *argv = prog_argv; } -} - -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; -} - -/* ----------------------------------------------------------------------------- Per-module initialisation This process traverses all the compiled modules in the program @@ -317,7 +289,7 @@ hs_add_root(void (*init_root)(void)) /* The initialisation stack grows downward, with sp pointing to the last occupied word */ init_sp = INIT_STACK_BLOCKS*BLOCK_SIZE_W; - bd = allocGroup(INIT_STACK_BLOCKS); + bd = allocGroup_lock(INIT_STACK_BLOCKS); init_stack = (F_ *)bd->start; init_stack[--init_sp] = (F_)stg_init_finish; if (init_root != NULL) { @@ -327,7 +299,7 @@ hs_add_root(void (*init_root)(void)) cap.r.rSp = (P_)(init_stack + init_sp); StgRun((StgFunPtr)stg_init, &cap.r); - freeGroup(bd); + freeGroup_lock(bd); #if defined(PROFILING) || defined(DEBUG) // This must be done after module initialisation. @@ -355,11 +327,6 @@ hs_exit(void) /* start timing the shutdown */ stat_startExit(); -#if !defined(GRAN) - /* Finalize any remaining weak pointers */ - finalizeWeakPointersNow(); -#endif - /* stop all running tasks */ exitScheduler(); @@ -439,7 +406,7 @@ hs_exit(void) if (RtsFlags.TickyFlags.showTickyStats) PrintTickyInfo(); #endif -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) shutdownAsyncIO(); #endif }