1 /* -----------------------------------------------------------------------------
2 * $Id: Main.c,v 1.6 1999/03/03 19:20:42 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"
32 /* Hack: we assume that we're building a batch-mode system unless
35 #ifndef INTERPRETER /* Hack */
36 int main(int argc, char *argv[])
38 SchedulerStatus status;
39 startupHaskell(argc,argv);
42 MainTSO = createIOThread(stg_max(BLOCK_SIZE_W,
43 RtsFlags.GcFlags.initialStkSize),
44 (StgClosure *)&mainIO_closure);
45 status = schedule(MainTSO,NULL);
47 if (IAmMainThread == rtsTrue) {
48 /*Just to show we're alive */
49 fprintf(stderr, "Main Thread Started ...\n");
51 MainTSO = createIOThread(stg_max(BLOCK_SIZE_W,
52 RtsFlags.GcFlags.initialStkSize),
53 (StgClosure *)&mainIO_closure);
54 status = schedule(MainTSO,NULL);
56 WaitForPEOp(PP_FINISH,SysManTask);
62 barf("Scheduler stopped, all threads blocked");
65 barf("No threads to run! Deadlock?");
67 belch("%s: warning: main thread killed", prog_argv[0]);
73 stg_exit(EXIT_SUCCESS);
75 #endif /* BATCH_MODE */