/* -----------------------------------------------------------------------------
- * $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
*
*
* ---------------------------------------------------------------------------*/
+#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");
case Interrupted:
/* carry on */
}
- shutdownHaskell();
- stg_exit(EXIT_SUCCESS);
+ shutdownHaskellAndExit(EXIT_SUCCESS);
}
-#endif /* BATCH_MODE */
+# endif /* BATCH_MODE */