1 /* -----------------------------------------------------------------------------
2 * $Id: Main.c,v 1.3 1999/01/21 10:31:47 simonm Exp $
4 * (c) The GHC Team 1998-1999
6 * Main function for a standalone Haskell program.
8 * ---------------------------------------------------------------------------*/
13 #include "Schedule.h" /* for MainTSO */
17 #include "RtsFlags.h" /* for debugging flags */
18 #include "Printer.h" /* for printing */
22 #include "Assembler.h"
31 /* Hack: we assume that we're building a batch-mode system unless
34 #ifndef INTERPRETER /* Hack */
35 int main(int argc, char *argv[])
37 SchedulerStatus status;
38 startupHaskell(argc,argv);
41 MainTSO = createIOThread(stg_max(BLOCK_SIZE_W,
42 RtsFlags.GcFlags.initialStkSize),
43 (StgClosure *)&mainIO_closure);
44 status = schedule(MainTSO,NULL);
46 if (IAmMainThread == rtsTrue) {
47 /*Just to show we're alive */
48 fprintf(stderr, "Main Thread Started ...\n");
50 MainTSO = createIOThread(stg_max(BLOCK_SIZE_W,
51 RtsFlags.GcFlags.initialStkSize),
52 (StgClosure *)&mainIO_closure);
53 status = schedule(MainTSO,NULL);
55 WaitForPEOp(PP_FINISH,SysManTask);
61 barf("Scheduler stopped, all threads blocked");
64 barf("No threads to run! Deadlock?");
66 belch("%s: warning: main thread killed", prog_argv[0]);
72 stg_exit(EXIT_SUCCESS);
74 #endif /* BATCH_MODE */