Ticket #3605: HsDllMain.c

File HsDllMain.c, 651 bytes (added by NeilMitchell, 4 years ago)
Line 
1#include <stdio.h>
2#include <windows.h>
3#include <Rts.h>
4
5static void
6HsDllMain(char *name, void (entry)(void))
7{
8  int argc = 1;
9  char* argv[2];
10  argv[0] = name;
11  argv[1] = NULL;
12  char** args = argv;
13 
14  printf("pre hs_init\n");
15  startupHaskell(argc,args,entry);
16 
17  /*
18  hs_init(&argc, &args);
19  printf("pre hs_add_root\n");
20  hs_add_root(entry);
21  */
22  printf("pre hs_done\n");
23}
24
25extern void __stginit_HsDemo(void);
26
27BOOL STDCALL DllMain(
28    HANDLE hModule,
29    DWORD reason,
30    void* reserved)
31{
32  if (reason == DLL_PROCESS_ATTACH) {
33    HsDllMain("DsoHsDemo", __stginit_HsDemo);
34  }
35  return TRUE;
36}