[MLton-commit] r7011

Wesley Terpstra wesley at mlton.org
Thu Jan 15 05:55:01 PST 2009


These dl* functions are currently broken due to a MLton_ prefix.
Furthermore, we concluded on the mailing list that dl* functions are better 
supported by bundling an additional (external) library under windows.


----------------------------------------------------------------------

U   mlton/trunk/runtime/platform/mingw.c
U   mlton/trunk/runtime/platform/mingw.h

----------------------------------------------------------------------

Modified: mlton/trunk/runtime/platform/mingw.c
===================================================================
--- mlton/trunk/runtime/platform/mingw.c	2009-01-11 14:36:47 UTC (rev 7010)
+++ mlton/trunk/runtime/platform/mingw.c	2009-01-15 13:55:00 UTC (rev 7011)
@@ -1170,94 +1170,6 @@
 }
 
 /* ------------------------------------------------- */
-/*                      libdl                        */
-/* ------------------------------------------------- */
-
-static DWORD dlerror_last = ERROR_SUCCESS;
-/* This is for emulating the ugly stateful behavior of dlerror. */
-
-static HMODULE dl_main_module = NULL;
-/* Handle to the main module returned by GetModuleHandle(NULL).  It is
- * assumed that the main module isn't freed during the lifetime of the
- * process.
- */
-
-void *dlopen(const char *filename, __attribute__ ((unused)) int flag_IGNORED) {
-        if (!filename) {
-                if (!dl_main_module)
-                        dl_main_module = GetModuleHandle(NULL);
-
-                if (!dl_main_module)
-                        dlerror_last = GetLastError();
-
-                return dl_main_module;
-        }
-
-        {
-                HMODULE result = LoadLibrary(filename);
-
-                if (!result)
-                        dlerror_last = GetLastError();
-
-                return result;
-        }
-}
-
-const char *dlerror(void) {
-        if (ERROR_SUCCESS == dlerror_last) {
-                return NULL;
-        } else {
-                static char buffer[256];
-
-                if (!FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS |
-                                   FORMAT_MESSAGE_FROM_SYSTEM,
-                                   NULL, dlerror_last, 0,
-                                   buffer, sizeof(buffer),
-                                   NULL))
-                        snprintf(buffer, sizeof(buffer),
-                                 "Failed to format error message");
-
-                dlerror_last = ERROR_SUCCESS;
-
-                return buffer;
-        }
-}
-
-void *dlsym(void *void_hmodule, const char *symbol) {
-        HMODULE hmodule = void_hmodule;
-
-        if (!hmodule) {
-                dlerror_last = ERROR_INVALID_HANDLE;
-                return NULL;
-        }
-
-        {
-                void* result = (void*)GetProcAddress(hmodule, symbol);
-
-                if (!result)
-                        dlerror_last = GetLastError();
-
-                return result;
-        }
-}
-
-int dlclose(void *void_hmodule) {
-        HMODULE hmodule = void_hmodule;
-
-        if (!hmodule || hmodule == dl_main_module)
-                return 0;
-
-        {
-                int result = !FreeLibrary(hmodule);
-
-                if (result)
-                        dlerror_last = GetLastError();
-
-                return result;
-        }
-}
-
-/* ------------------------------------------------- */
 /*                        MinGW                      */
 /* ------------------------------------------------- */
 

Modified: mlton/trunk/runtime/platform/mingw.h
===================================================================
--- mlton/trunk/runtime/platform/mingw.h	2009-01-11 14:36:47 UTC (rev 7010)
+++ mlton/trunk/runtime/platform/mingw.h	2009-01-15 13:55:00 UTC (rev 7011)
@@ -1554,22 +1554,3 @@
 #define openlog MLton_openlog
 #define closelog MLton_closelog
 #define syslog MLton_syslog
-
-/* ------------------------------------------------- */
-/*                      libdl                        */
-/* ------------------------------------------------- */
-
-MLTON_WRAPPER void *MLton_dlopen(const char *filename, int flag_IGNORED);
-MLTON_WRAPPER const char *MLton_dlerror(void);
-MLTON_WRAPPER void *MLton_dlsym(void *void_hmodule, const char *symbol);
-MLTON_WRAPPER int MLton_dlclose(void *void_hmodule);
-
-#undef dlopen
-#undef dlerror
-#undef dlsym
-#undef dlclose
-
-#define dlopen MLton_dlopen
-#define dlerror MLton_dlerror
-#define dlsym MLton_dlsym
-#define dlclose MLton_dlclose




More information about the MLton-commit mailing list