[project @ 1999-09-16 08:29:01 by sof]
authorsof <unknown>
Thu, 16 Sep 1999 08:29:01 +0000 (08:29 +0000)
committersof <unknown>
Thu, 16 Sep 1999 08:29:01 +0000 (08:29 +0000)
Move DllMain() into separate file + it doesn't call startupHaskell()
any longer upon loading of the DLL. That is the task of clients of
the RTS.

ghc/rts/Main.c
ghc/rts/RtsDllMain.c [new file with mode: 0644]

index 6ed8ac2..01c05e6 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Main.c,v 1.10 1999/07/14 13:38:27 simonmar Exp $
+ * $Id: Main.c,v 1.11 1999/09/16 08:29:01 sof Exp $
  *
  * (c) The GHC Team 1998-1999
  *
@@ -35,8 +35,6 @@
 #endif
 
 
-#ifndef ENABLE_WIN32_DLL_SUPPORT
-
 /* Hack: we assume that we're building a batch-mode system unless 
  * INTERPRETER is set
  */
@@ -80,31 +78,3 @@ int main(int argc, char *argv[])
     shutdownHaskellAndExit(EXIT_SUCCESS);
 }
 # endif /* BATCH_MODE */
-
-#else   /* !ENABLE_WIN32_DLL_SUPPORT */
-
-static char* args[] = { "ghcRts" };
-
-BOOL
-WINAPI
-DllMain ( HINSTANCE hInstance
-        , DWORD reason
-       , LPVOID reserved
-       )
-{
-  /*
-    ToDo: let the user configure RTS options to use
-          via the registry.
-   */
-  switch (reason) {
-  case DLL_PROCESS_ATTACH:
-    startupHaskell(1,args);
-    /* ToDo: gracefully handle startupHaskell() failures.. */
-    return TRUE;
-  case DLL_PROCESS_DETACH:
-    shutdownHaskell();
-  }
-  return TRUE;
-}
-
-#endif /* !ENABLE_WIN32_DLL_SUPPORT */
diff --git a/ghc/rts/RtsDllMain.c b/ghc/rts/RtsDllMain.c
new file mode 100644 (file)
index 0000000..4c03082
--- /dev/null
@@ -0,0 +1,39 @@
+/* -----------------------------------------------------------------------------
+ * $Id: RtsDllMain.c,v 1.1 1999/09/16 08:29:01 sof Exp $
+ *
+ * (c) The GHC Team 1999-1900
+ *
+ * Entry point for RTS-in-a-DLL
+ *
+ * ---------------------------------------------------------------------------*/
+
+#include "Rts.h"
+#include "RtsAPI.h"
+
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+
+/* I'd be mildly surprised if this wasn't defined, but still. */
+#ifdef ENABLE_WIN32_DLL_SUPPORT
+
+BOOL
+WINAPI
+DllMain ( HINSTANCE hInstance
+        , DWORD reason
+       , LPVOID reserved
+       )
+{
+  /*
+   * Note: the DllMain() doesn't call startupHaskell() for you,
+   *       that is the task of users of the RTS. The reason is
+   *       that *you* want to be able to control the arguments
+   *       you pass to the RTS.
+   */
+  switch (reason) {
+  case DLL_PROCESS_DETACH: shutdownHaskell();
+  }
+  return TRUE;
+}
+
+#endif /* ENABLE_WIN32_DLL_SUPPORT */