[project @ 2000-01-12 15:15:17 by simonmar]
[ghc-hetmet.git] / ghc / rts / Main.c
index 9f2c9c1..a15a037 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Main.c,v 1.5 1999/02/26 16:46:50 simonm Exp $
+ * $Id: Main.c,v 1.12 1999/11/02 15:05:58 simonmar Exp $
  *
  * (c) The GHC Team 1998-1999
  *
@@ -7,14 +7,15 @@
  *
  * ---------------------------------------------------------------------------*/
 
+#define COMPILING_RTS_MAIN
+
 #include "Rts.h"
 #include "RtsAPI.h"
+#include "SchedAPI.h"
 #include "RtsFlags.h"
-#include "Schedule.h"  /* for MainTSO */
 #include "RtsUtils.h"
 
 #ifdef DEBUG
-#include "RtsFlags.h"  /* for debugging flags */
 #include "Printer.h"   /* for printing        */
 #endif
 
 #include "LLC.h"
 #endif
 
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+
+
 /* Hack: we assume that we're building a batch-mode system unless 
  * INTERPRETER is set
  */
-#ifndef INTERPRETER /* Hack */
+# ifndef INTERPRETER /* Hack */
 int main(int argc, char *argv[])
 {
     SchedulerStatus status;
     startupHaskell(argc,argv);
 
-#ifndef PAR
-    MainTSO = createIOThread(stg_max(BLOCK_SIZE_W,
-                                    RtsFlags.GcFlags.initialStkSize),
-                            (StgClosure *)&mainIO_closure);
-    status = schedule(MainTSO,NULL);
-#else
+#  ifndef PAR
+    /* ToDo: want to start with a larger stack size */
+    status = rts_evalIO((StgClosure *)&mainIO_closure, NULL);
+#  else
     if (IAmMainThread == rtsTrue) {
     /*Just to show we're alive */
       fprintf(stderr, "Main Thread Started ...\n");
      
-      MainTSO = createIOThread(stg_max(BLOCK_SIZE_W,
-                                      RtsFlags.GcFlags.initialStkSize),
-                              (StgClosure *)&mainIO_closure);
-      status = schedule(MainTSO,NULL);
+      status = rts_evalIO((StgClosure *)&mainIO_closure, NULL);
     } else {
       WaitForPEOp(PP_FINISH,SysManTask);
       exit(EXIT_SUCCESS);
     }
-#endif /* PAR */
+#  endif /* PAR */
     switch (status) {
     case AllBlocked:
       barf("Scheduler stopped, all threads blocked");
@@ -68,7 +69,6 @@ int main(int argc, char *argv[])
     case Interrupted:
       /* carry on */
     }
-    shutdownHaskell();
-    stg_exit(EXIT_SUCCESS);
+    shutdownHaskellAndExit(EXIT_SUCCESS);
 }
-#endif /* BATCH_MODE */
+# endif /* BATCH_MODE */