1 /* -----------------------------------------------------------------------------
2 * $Id: Main.c,v 1.9 1999/07/06 15:05:49 sof Exp $
4 * (c) The GHC Team 1998-1999
6 * Main function for a standalone Haskell program.
8 * ---------------------------------------------------------------------------*/
10 #define COMPILING_RTS_MAIN
16 #include "Schedule.h" /* for MainTSO */
20 #include "Printer.h" /* for printing */
24 #include "Assembler.h"
38 #ifndef ENABLE_WIN32_DLL_SUPPORT
40 /* Hack: we assume that we're building a batch-mode system unless
43 # ifndef INTERPRETER /* Hack */
44 int main(int argc, char *argv[])
46 SchedulerStatus status;
47 startupHaskell(argc,argv);
50 MainTSO = createIOThread(stg_max(BLOCK_SIZE_W,
51 RtsFlags.GcFlags.initialStkSize),
52 (StgClosure *)&mainIO_closure);
53 status = schedule(MainTSO,NULL);
55 if (IAmMainThread == rtsTrue) {
56 /*Just to show we're alive */
57 fprintf(stderr, "Main Thread Started ...\n");
59 MainTSO = createIOThread(stg_max(BLOCK_SIZE_W,
60 RtsFlags.GcFlags.initialStkSize),
61 (StgClosure *)&mainIO_closure);
62 status = schedule(MainTSO,NULL);
64 WaitForPEOp(PP_FINISH,SysManTask);
70 barf("Scheduler stopped, all threads blocked");
73 barf("No threads to run! Deadlock?");
75 belch("%s: warning: main thread killed", prog_argv[0]);
81 stg_exit(EXIT_SUCCESS);
83 # endif /* BATCH_MODE */
85 #else /* !ENABLE_WIN32_DLL_SUPPORT */
87 static char* args[] = { "ghcRts" };
91 DllMain ( HINSTANCE hInstance
97 ToDo: let the user configure RTS options to use
101 case DLL_PROCESS_ATTACH:
102 startupHaskell(1,args);
103 /* ToDo: gracefully handle startupHaskell() failures.. */
105 case DLL_PROCESS_DETACH:
111 #endif /* !ENABLE_WIN32_DLL_SUPPORT */