summaryrefslogtreecommitdiff
path: root/jim-win32compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'jim-win32compat.c')
-rw-r--r--jim-win32compat.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/jim-win32compat.c b/jim-win32compat.c
index 76e7a96..bbda937 100644
--- a/jim-win32compat.c
+++ b/jim-win32compat.c
@@ -1,5 +1,34 @@
#include <jim.h>
+#ifdef HAVE_DLOPEN_COMPAT
+void *dlopen(const char *path, int mode)
+{
+ JIM_NOTUSED(mode);
+
+ return (void *)LoadLibraryA(path);
+}
+
+int dlclose(void *handle)
+{
+ FreeLibrary((HANDLE)handle);
+ return 0;
+}
+
+void *dlsym(void *handle, const char *symbol)
+{
+ return GetProcAddress((HMODULE)handle, symbol);
+}
+
+const char *dlerror(void)
+{
+ static char msg[121];
+ FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
+ LANG_NEUTRAL, msg, sizeof(msg) - 1, NULL);
+ return msg;
+}
+#endif
+
+#if !defined(__MINGW32__) && !defined(__CYGWIN__)
/* POSIX gettimeofday() compatibility for WIN32 */
int gettimeofday(struct timeval *tv, void *unused)
{
@@ -88,29 +117,4 @@ struct dirent *readdir(DIR * dir)
}
return result;
}
-
-void *dlopen(const char *path, int mode)
-{
- JIM_NOTUSED(mode);
-
- return (void *)LoadLibraryA(path);
-}
-
-int dlclose(void *handle)
-{
- FreeLibrary((HANDLE)handle);
- return 0;
-}
-
-void *dlsym(void *handle, const char *symbol)
-{
- return GetProcAddress((HMODULE)handle, symbol);
-}
-
-const char *dlerror(void)
-{
- static char msg[121];
- FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
- LANG_NEUTRAL, msg, sizeof(msg) - 1, NULL);
- return msg;
-}
+#endif