1 /* -----------------------------------------------------------------------------
2 * $Id: Main.c,v 1.8 1999/05/10 10:06:24 sof Exp $
4 * (c) The GHC Team 1998-1999
6 * Main function for a standalone Haskell program.
8 * ---------------------------------------------------------------------------*/
10 #define COMPILING_RTS_MAIN
15 #include "Schedule.h" /* for MainTSO */
19 #include "Printer.h" /* for printing */
23 #include "Assembler.h"
37 #ifndef ENABLE_WIN32_DLL_SUPPORT
39 /* Hack: we assume that we're building a batch-mode system unless
42 # ifndef INTERPRETER /* Hack */
43 int main(int argc, char *argv[])
45 SchedulerStatus status;
46 startupHaskell(argc,argv);
49 MainTSO = createIOThread(stg_max(BLOCK_SIZE_W,
50 RtsFlags.GcFlags.initialStkSize),
51 (StgClosure *)&mainIO_closure);
52 status = schedule(MainTSO,NULL);
54 if (IAmMainThread == rtsTrue) {
55 /*Just to show we're alive */
56 fprintf(stderr, "Main Thread Started ...\n");
58 MainTSO = createIOThread(stg_max(BLOCK_SIZE_W,
59 RtsFlags.GcFlags.initialStkSize),
60 (StgClosure *)&mainIO_closure);
61 status = schedule(MainTSO,NULL);
63 WaitForPEOp(PP_FINISH,SysManTask);
69 barf("Scheduler stopped, all threads blocked");
72 barf("No threads to run! Deadlock?");
74 belch("%s: warning: main thread killed", prog_argv[0]);
80 stg_exit(EXIT_SUCCESS);
82 # endif /* BATCH_MODE */
84 #else /* !ENABLE_WIN32_DLL_SUPPORT */
86 static char* args[] = { "ghcRts" };
90 DllMain ( HINSTANCE hInstance
96 ToDo: let the user configure RTS options to use
100 case DLL_PROCESS_ATTACH:
101 startupHaskell(1,args);
102 /* ToDo: gracefully handle startupHaskell() failures.. */
104 case DLL_PROCESS_DETACH:
110 #endif /* !ENABLE_WIN32_DLL_SUPPORT */