summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gmail.com>2017-09-11 16:30:38 +0100
committerGitHub <noreply@github.com>2017-09-11 16:30:38 +0100
commite9e0098e5c75d39d49960696f017f83a54db8e65 (patch)
tree03a03ce11c408ecfc850d862d010affddac65e56 /src
parent073418813631ffd9d8406f0c0ab0422e1b349d2c (diff)
parent7ff061a944119ccb1c79b9755dd6b775c9984a1c (diff)
downloadlibepoxy-e9e0098e5c75d39d49960696f017f83a54db8e65.tar.gz
Merge pull request #131 from nwnk/nonfatal-resolve-handler
RFC: Add epoxy_set_resolver_failure_handler()
Diffstat (limited to 'src')
-rw-r--r--src/dispatch_common.c18
-rw-r--r--src/dispatch_common.h2
-rw-r--r--src/gen_dispatch.py4
3 files changed, 24 insertions, 0 deletions
diff --git a/src/dispatch_common.c b/src/dispatch_common.c
index 7ec91b6..434a2a2 100644
--- a/src/dispatch_common.c
+++ b/src/dispatch_common.c
@@ -845,3 +845,21 @@ WRAPPER(epoxy_glEnd)(void)
PFNGLBEGINPROC epoxy_glBegin = epoxy_glBegin_wrapped;
PFNGLENDPROC epoxy_glEnd = epoxy_glEnd_wrapped;
+
+epoxy_resolver_failure_handler_t epoxy_resolver_failure_handler;
+
+epoxy_resolver_failure_handler_t
+epoxy_set_resolver_failure_handler(epoxy_resolver_failure_handler_t handler)
+{
+#ifdef _WIN32
+ return InterlockedExchangePointer(&epoxy_resolver_failure_handler,
+ handler);
+#else
+ epoxy_resolver_failure_handler_t old;
+ pthread_mutex_lock(&api.mutex);
+ old = epoxy_resolver_failure_handler;
+ epoxy_resolver_failure_handler = handler;
+ pthread_mutex_unlock(&api.mutex);
+ return old;
+#endif
+}
diff --git a/src/dispatch_common.h b/src/dispatch_common.h
index e16771f..895d5ac 100644
--- a/src/dispatch_common.h
+++ b/src/dispatch_common.h
@@ -172,6 +172,8 @@ bool epoxy_extension_in_string(const char *extension_list, const char *ext);
extern void UNWRAPPED_PROTO(glBegin_unwrapped)(GLenum primtype);
extern void UNWRAPPED_PROTO(glEnd_unwrapped)(void);
+extern epoxy_resolver_failure_handler_t epoxy_resolver_failure_handler;
+
#if USING_DISPATCH_TABLE
void gl_init_dispatch_table(void);
void gl_switch_to_dispatch_table(void);
diff --git a/src/gen_dispatch.py b/src/gen_dispatch.py
index c22fd82..28dad2b 100644
--- a/src/gen_dispatch.py
+++ b/src/gen_dispatch.py
@@ -718,6 +718,10 @@ class Generator(object):
self.outln(' }')
self.outln('')
+ self.outln(' if (epoxy_resolver_failure_handler)')
+ self.outln(' return epoxy_resolver_failure_handler(name);')
+ self.outln('')
+
# If the function isn't provided by any known extension, print
# something useful for the poor application developer before
# aborting. (In non-epoxy GL usage, the app developer would