diff options
author | Eric Anholt <eric@anholt.net> | 2013-12-17 10:38:29 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2013-12-17 12:11:05 -0800 |
commit | 5112b477c25f8efc65b3892573bc9499de910dbe (patch) | |
tree | 54f274cfc4e12c5057e6a5517ee2b7075806bf54 /src | |
parent | 417927e2ebea79f52f65e63e2524c01a351960ee (diff) |
win32: Move dynamic symbol loading to do_dlsym().
This should help get us better error handling when we accidentally
call the wrong loader path.
Diffstat (limited to 'src')
-rw-r--r-- | src/dispatch_common.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/dispatch_common.c b/src/dispatch_common.c index b804eb7..209d450 100644 --- a/src/dispatch_common.c +++ b/src/dispatch_common.c @@ -156,7 +156,6 @@ static struct api api = { #endif }; -#ifndef _WIN32 static bool library_initialized; static void @@ -180,6 +179,9 @@ get_dlopen_handle(void **handle, const char *lib_name, bool exit_on_fail) abort(); } +#ifdef _WIN32 + *handle = LoadLibraryA(lib_name); +#else pthread_mutex_lock(&api.mutex); if (!*handle) { *handle = dlopen(lib_name, RTLD_LAZY | RTLD_LOCAL); @@ -189,6 +191,7 @@ get_dlopen_handle(void **handle, const char *lib_name, bool exit_on_fail) } } pthread_mutex_unlock(&api.mutex); +#endif } static void * @@ -199,20 +202,18 @@ do_dlsym(void **handle, const char *lib_name, const char *name, get_dlopen_handle(handle, lib_name, exit_on_fail); +#ifdef _WIN32 + result = GetProcAddress(*handle, name); +#else result = dlsym(*handle, name); - if (!result) - errx(1, "%s() not found in %s", name, lib_name); +#endif + if (!result) { + fprintf(stderr,"%s() not found in %s", name, lib_name); + exit(1); + } return result; } -#else -static void * -do_dlsym(void **handle, const char *lib_name, const char *name, - bool exit_on_fail) -{ - return NULL; -} -#endif PUBLIC bool epoxy_is_desktop_gl(void) @@ -361,7 +362,7 @@ void * epoxy_gl_dlsym(const char *name) { #ifdef _WIN32 - return GetProcAddress(LoadLibraryA("OPENGL32"), name); + return do_dlsym(&api.gl_handle, "OPENGL32", name, true); #elif defined(__APPLE__) return do_dlsym(&api.gl_handle, "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", |