X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FMain.c;h=434f79156b668079f7e07abe30e68f115816fa21;hb=05b677fad57427a5639b36a1822c9ebd52cb3339;hp=6aef280e256b1476e30422678ad70e7e5618d302;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/rts/Main.c b/rts/Main.c index 6aef280..434f791 100644 --- a/rts/Main.c +++ b/rts/Main.c @@ -12,11 +12,13 @@ #include "Rts.h" #include "RtsAPI.h" #include "SchedAPI.h" -#include "Schedule.h" #include "RtsFlags.h" #include "RtsUtils.h" #include "Prelude.h" #include "Task.h" +#if defined(mingw32_HOST_OS) +#include "win32/seh_excn.h" +#endif #include #ifdef DEBUG @@ -39,17 +41,20 @@ extern void __stginit_ZCMain(void); +static int progargc; +static char **progargv; + /* Hack: we assume that we're building a batch-mode system unless * INTERPRETER is set */ #ifndef INTERPRETER /* Hack */ -int main(int argc, char *argv[]) +static void real_main(void) { int exit_status; SchedulerStatus status; /* all GranSim/GUM init is done in startupHaskell; sets IAmMainThread! */ - startupHaskell(argc,argv,__stginit_ZCMain); + startupHaskell(progargc,progargv,__stginit_ZCMain); /* kick off the computation by creating the main thread with a pointer to mainIO_closure representing the computation of the overall program; @@ -102,9 +107,10 @@ int main(int argc, char *argv[]) /* ToDo: want to start with a larger stack size */ { - void *cap = rts_lock(); + Capability *cap = rts_lock(); cap = rts_evalLazyIO(cap,(HaskellObj)(void *)mainIO_closure, NULL); status = rts_getSchedStatus(cap); + taskTimeStamp(myTask()); rts_unlock(cap); } @@ -133,6 +139,21 @@ int main(int argc, char *argv[]) barf("main thread completed with invalid status"); } shutdownHaskellAndExit(exit_status); - return 0; /* never reached, keep gcc -Wall happy */ +} +int main(int argc, char *argv[]) +{ + /* We do this dance with argc and argv as otherwise the SEH exception + stuff (the BEGIN/END CATCH below) on Windows gets confused */ + progargc = argc; + progargv = argv; + +#if defined(mingw32_HOST_OS) + BEGIN_CATCH +#endif + real_main(); +#if defined(mingw32_HOST_OS) + END_CATCH +#endif + return 0; /* not reached, but keeps gcc -Wall happy */ } # endif /* BATCH_MODE */