示例#1
0
BOOL STDCALL DllMain(HANDLE hModule, DWORD reason, void* reserved) 
{
  static char* args[] = {"libpandoc", NULL};
  if (reason == DLL_PROCESS_ATTACH) {
    startupHaskell(1, args, __stginit_LibPandoc);
  }
  return TRUE;
}
示例#2
0
文件: RtsMain.c 项目: raeez/ghc
/* Hack: we assume that we're building a batch-mode system unless
 * INTERPRETER is set
 */
#ifndef INTERPRETER /* Hack */
static void real_main(void)
{
    int exit_status;
    SchedulerStatus status;
    /* all GranSim/GUM init is done in startupHaskell; sets IAmMainThread! */

    startupHaskell(progargc,progargv,NULL);

    /* kick off the computation by creating the main thread with a pointer
       to mainIO_closure representing the computation of the overall program;
       then enter the scheduler with this thread and off we go;

       the same for GranSim (we have only one instance of this code)

       in a parallel setup, where we have many instances of this code
       running on different PEs, we should do this only for the main PE
       (IAmMainThread is set in startupHaskell)
    */

    /* ToDo: want to start with a larger stack size */
    {
        Capability *cap = rts_lock();
        cap = rts_evalLazyIO(cap,progmain_closure, NULL);
        status = rts_getSchedStatus(cap);
        taskTimeStamp(myTask());
        rts_unlock(cap);
    }

    /* check the status of the entire Haskell computation */
    switch (status) {
    case Killed:
        errorBelch("main thread exited (uncaught exception)");
        exit_status = EXIT_KILLED;
        break;
    case Interrupted:
        errorBelch("interrupted");
        exit_status = EXIT_INTERRUPTED;
        break;
    case HeapExhausted:
        exit_status = EXIT_HEAPOVERFLOW;
        break;
    case Success:
        exit_status = EXIT_SUCCESS;
        break;
    default:
        barf("main thread completed with invalid status");
    }
    shutdownHaskellAndExit(exit_status);
}
示例#3
0
BOOL
STDCALL
DllMain
   ( HANDLE hModule
   , DWORD reason
   , void* reserved
   )
{
  if (reason == DLL_PROCESS_ATTACH) {
      /* By now, the RTS DLL should have been hoisted in, but we need to start
         it up.
	 
	 Note: for ghc-4.08 and later, you need to give the main / 'root module'
	 of the Haskell module you want to start running. So, if this is something 
	 other than 'ComDllMain', you'll need to tweak the invocation below.
      */
#if __GLASGOW_HASKELL__ >= 408
      startupHaskell( sizeof(args) / sizeof(char*)
		    , args
		    , &__stginit_ComDllMain
		    );
#else
      startupHaskell(sizeof(args) / sizeof(char*), args);
#endif
      comDll = newComDll(hModule);
      return TRUE;
  } else {
    if (comDll && reason == DLL_PROCESS_DETACH) {
        (comDll)->dllUnload();
	shutdownHaskell();
	/* Not properly letting go of memory here is rude, but we're shutting down.. */
	comDll=NULL;
    }
    return TRUE;
  }
}