From 8016c1d53332b9ad2af8e49482f7848648995a89 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Wed, 20 Oct 2010 10:55:07 +1000 Subject: Allow extensions to be built/installed as modules This includes C extensions and Tcl extensions Also adds windows support (mingw32 and cygwin) Now the sqlite*, readline and win32 extensions are supported Signed-off-by: Steve Bennett --- jim-win32compat.c | 56 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'jim-win32compat.c') 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 +#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 -- cgit v1.2.3