From 30b8a4cd2d115eab93ca39709c956f48aa8dadbe Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 3 Feb 2017 16:13:45 +0000 Subject: Add conservative functions for checking platform symbols MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When checking whether GLX or EGL are available on the system, we don't want to use the internal API that forces an exit() on missing libraries and symbols — as that would defeat the point. Instead, we should have safe functions to call internally that simply return a NULL pointer, so we can bail out ourselves in a controlled fashion. --- src/dispatch_common.c | 16 ++++++++++++++-- src/dispatch_common.h | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/dispatch_common.c b/src/dispatch_common.c index 17d0c5e..b521b1b 100644 --- a/src/dispatch_common.c +++ b/src/dispatch_common.c @@ -568,16 +568,28 @@ epoxy_conservative_has_gl_extension(const char *ext) return epoxy_internal_has_gl_extension(ext, true); } +void * +epoxy_conservative_egl_dlsym(const char *name, bool exit_if_fails) +{ + return do_dlsym(&api.egl_handle, EGL_LIB, name, exit_if_fails); +} + void * epoxy_egl_dlsym(const char *name) { - return do_dlsym(&api.egl_handle, EGL_LIB, name, true); + return epoxy_conservative_egl_dlsym(name, true); +} + +void * +epoxy_conservative_glx_dlsym(const char *name, bool exit_if_fails) +{ + return do_dlsym(&api.glx_handle, GLX_LIB, name, exit_if_fails); } void * epoxy_glx_dlsym(const char *name) { - return do_dlsym(&api.glx_handle, GLX_LIB, name, true); + return epoxy_conservative_glx_dlsym(name, true); } void * diff --git a/src/dispatch_common.h b/src/dispatch_common.h index 2cc566a..9d38a78 100644 --- a/src/dispatch_common.h +++ b/src/dispatch_common.h @@ -162,6 +162,8 @@ bool epoxy_conservative_has_glx_extension(const char *name); int epoxy_conservative_egl_version(void); bool epoxy_conservative_has_egl_extension(const char *name); bool epoxy_conservative_has_wgl_extension(const char *name); +void *epoxy_conservative_egl_dlsym(const char *name, bool exit_if_fails); +void *epoxy_conservative_glx_dlsym(const char *name, bool exit_if_fails); bool epoxy_extension_in_string(const char *extension_list, const char *ext); -- cgit v1.2.1