diff options
author | Ian Lynagh <igloo@earth.li> | 2007-08-24 22:23:17 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2007-08-24 22:23:17 +0000 |
commit | 49b8105e8d56c90099234e31c32ba3f1643276fe (patch) | |
tree | 01d11dff9c5afd8daf3bfd9a021b9c8848f28223 /rts/Main.c | |
parent | 32f2ee11b7288a53b89ea81ebdf4f8a74b707fed (diff) | |
download | haskell-49b8105e8d56c90099234e31c32ba3f1643276fe.tar.gz |
Jump through some hoops to make the Windows SEH exception stuff happy
Diffstat (limited to 'rts/Main.c')
-rw-r--r-- | rts/Main.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/rts/Main.c b/rts/Main.c index 5f16fa344a..434f79156b 100644 --- a/rts/Main.c +++ b/rts/Main.c @@ -16,7 +16,9 @@ #include "RtsUtils.h" #include "Prelude.h" #include "Task.h" -#include "seh_excn.h" +#if defined(mingw32_HOST_OS) +#include "win32/seh_excn.h" +#endif #include <stdlib.h> #ifdef DEBUG @@ -39,18 +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! */ - BEGIN_CATCH - 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; @@ -135,8 +139,21 @@ int main(int argc, char *argv[]) barf("main thread completed with invalid status"); } shutdownHaskellAndExit(exit_status); +} +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 - return 0; /* not reached unless a Windows exception happens, - also keeps gcc -Wall happy */ +#endif + return 0; /* not reached, but keeps gcc -Wall happy */ } # endif /* BATCH_MODE */ |