summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2009-07-30 15:00:54 +0100
committerJon TURNEY <jon.turney@dronecode.org.uk>2009-10-04 17:14:30 +0100
commit2dea994cf1d75e6199654e1fef782ffaa7aea357 (patch)
tree11c5280733e22363b84e2b924c721cc2ddde5773
parent7573e991c84709ce997878e4ab90fdadc4d767f3 (diff)
Avoid using a complex macro for wglGetProcAddress() lookup/cachingcygwin-aiglx-for-1.6
-rwxr-xr-xhw/xwin/glwrap.c50
1 files changed, 38 insertions, 12 deletions
diff --git a/hw/xwin/glwrap.c b/hw/xwin/glwrap.c
index 8e101de75..8d5ed408a 100755
--- a/hw/xwin/glwrap.c
+++ b/hw/xwin/glwrap.c
@@ -67,24 +67,50 @@ glWinCallDelta(void)
}
}
-#define RESOLVE_RET(procname, symbol, retval) \
- static Bool init = TRUE; \
- static __stdcall procname proc = NULL; \
- if (init) { \
- proc = (procname)wglGetProcAddress(symbol); \
- init = FALSE; \
- if (proc == NULL) { \
- ErrorF("glwrap: Can't resolve \"%s\"\n", symbol); \
- } else \
- ErrorF("glwrap: Resolved \"%s\"\n", symbol); \
- } \
+static PROC
+glWinResolveHelper(PROC *cache, char *symbol)
+{
+ PROC proc = NULL;
+
+ /* If not yet cached, call wglGetProcAddress */
+ if ((*cache) == NULL)
+ {
+ proc = wglGetProcAddress(symbol);
+ if (proc == NULL)
+ {
+ ErrorF("glwrap: Can't resolve \"%s\"\n", symbol);
+ (*cache) = (PROC)-1;
+ }
+ else
+ {
+ ErrorF("glwrap: Resolved \"%s\"\n", symbol);
+ (*cache) = proc;
+ }
+ }
+ /* Cached wglGetProcAddress failure */
+ else if ((*cache) == (PROC)-1)
+ {
+ proc = 0;
+ }
+ /* Cached wglGetProcAddress result */
+ else
+ {
+ proc = (*cache);
+ }
+
+ return proc;
+}
+
+#define RESOLVE_RET(proctype, symbol, retval) \
+ static PROC cache = NULL; \
+ __stdcall proctype proc = (proctype)glWinResolveHelper(&cache, symbol); \
if (proc == NULL) { \
__glXErrorCallBack(0); \
return retval; \
} \
glWinIndirectProcCalls++;
-#define RESOLVE(procname, symbol) RESOLVE_RET(procname, symbol,)
+#define RESOLVE(proctype, symbol) RESOLVE_RET(proctype, symbol,)
/*
* GL dispatch table debugging