summaryrefslogtreecommitdiff
path: root/rts/RtsDllMain.c
diff options
context:
space:
mode:
Diffstat (limited to 'rts/RtsDllMain.c')
-rw-r--r--rts/RtsDllMain.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/rts/RtsDllMain.c b/rts/RtsDllMain.c
new file mode 100644
index 0000000000..af3c5090de
--- /dev/null
+++ b/rts/RtsDllMain.c
@@ -0,0 +1,39 @@
+/* -----------------------------------------------------------------------------
+ *
+ * (c) The GHC Team 1999-2000
+ *
+ * Entry point for RTS-in-a-DLL
+ *
+ * ---------------------------------------------------------------------------*/
+
+#include "PosixSource.h"
+#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 */