From 86585e3bb0781ad1ef925e6fd81888190c12b1a5 Mon Sep 17 00:00:00 2001 From: Kyle Brenneman Date: Mon, 28 Mar 2016 17:26:32 -0600 Subject: GLX: A few more ABI fixes. Fix the return type in the __GLX_MAIN_PROTO macro. In GLX_dummy.c, check the major and minor version numbers like a real vendor library might. In addition, GLX_dummy.c now keeps a pointer to the __GLXapiExports struct instead of a copy of it. --- include/glvnd/libglxabi.h | 10 +++++----- tests/GLX_dummy/GLX_dummy.c | 39 +++++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/include/glvnd/libglxabi.h b/include/glvnd/libglxabi.h index 13189b9..b664e76 100644 --- a/include/glvnd/libglxabi.h +++ b/include/glvnd/libglxabi.h @@ -387,11 +387,11 @@ typedef struct __GLXapiImportsRec { /*****************************************************************************/ #define __GLX_MAIN_PROTO_NAME "__glx_Main" -#define __GLX_MAIN_PROTO(version, exports, vendor, imports) \ - __GLXapiImports *__glx_Main(uint32_t version, \ - const __GLXapiExports *exports, \ - __GLXvendorInfo *vendor, \ - __GLXapiImports *imports) +#define __GLX_MAIN_PROTO(version, exports, vendor, imports) \ + Bool __glx_Main(uint32_t version, \ + const __GLXapiExports *exports, \ + __GLXvendorInfo *vendor, \ + __GLXapiImports *imports) typedef Bool (*__PFNGLXMAINPROC) (uint32_t version, const __GLXapiExports *exports, __GLXvendorInfo *vendor, __GLXapiImports *imports); diff --git a/tests/GLX_dummy/GLX_dummy.c b/tests/GLX_dummy/GLX_dummy.c index cb493eb..29465c9 100644 --- a/tests/GLX_dummy/GLX_dummy.c +++ b/tests/GLX_dummy/GLX_dummy.c @@ -42,7 +42,7 @@ #include "compiler.h" -static __GLXapiExports apiExports; +static const __GLXapiExports *apiExports = NULL; /* * Dummy context structure. @@ -329,7 +329,7 @@ static void dummySelectEvent (Display *dpy, */ static void dummy_glBegin (void) { - GLXContext ctx = apiExports.getCurrentContext(); + GLXContext ctx = apiExports->getCurrentContext(); assert(ctx); ctx->beginHit++; @@ -337,7 +337,7 @@ static void dummy_glBegin (void) static void dummy_glVertex3fv(GLfloat *v) { - GLXContext ctx = apiExports.getCurrentContext(); + GLXContext ctx = apiExports->getCurrentContext(); assert(ctx); ctx->vertex3fvHit++; @@ -345,7 +345,7 @@ static void dummy_glVertex3fv(GLfloat *v) static void dummy_glEnd (void) { - GLXContext ctx = apiExports.getCurrentContext(); + GLXContext ctx = apiExports->getCurrentContext(); assert(ctx); ctx->endHit++; @@ -355,7 +355,7 @@ static void dummy_glMakeCurrentTestResults(GLint req, GLboolean *saw, void **ret) { - GLXContext ctx = apiExports.getCurrentContext(); + GLXContext ctx = apiExports->getCurrentContext(); assert(ctx); *saw = GL_TRUE; @@ -405,13 +405,13 @@ static void dispatch_glXExampleExtensionFunction(Display *dpy, ExampleExtensionFunctionPtr func; const int index = dummyExampleExtensionFunctionIndex; - dynDispatch = apiExports.getDynDispatch(dpy, screen); + dynDispatch = apiExports->getDynDispatch(dpy, screen); if (!dynDispatch) { return; } func = (ExampleExtensionFunctionPtr) - apiExports.fetchDispatchEntry(dynDispatch, index); + apiExports->fetchDispatchEntry(dynDispatch, index); if (func) { func(dpy, screen, retval); } @@ -671,20 +671,23 @@ PUBLIC Bool __glx_Main(uint32_t version, __GLXvendorInfo *vendor, __GLXapiImports *imports) { - if (version <= GLX_VENDOR_ABI_VERSION) { - memcpy(&apiExports, exports, sizeof(*exports)); + if (GLX_VENDOR_ABI_GET_MAJOR_VERSION(version) + == GLX_VENDOR_ABI_GET_MAJOR_VERSION(GLX_VENDOR_ABI_VERSION)) { + if (GLX_VENDOR_ABI_GET_MINOR_VERSION(version) + >= GLX_VENDOR_ABI_GET_MINOR_VERSION(GLX_VENDOR_ABI_VERSION)) { + apiExports = exports; - imports->isScreenSupported = dummyCheckSupportsScreen; - imports->getProcAddress = dummyGetProcAddress; - imports->getDispatchAddress = dummyGetDispatchAddress; - imports->setDispatchIndex = dummySetDispatchIndex; + imports->isScreenSupported = dummyCheckSupportsScreen; + imports->getProcAddress = dummyGetProcAddress; + imports->getDispatchAddress = dummyGetDispatchAddress; + imports->setDispatchIndex = dummySetDispatchIndex; #if defined(PATCH_ENTRYPOINTS) - imports->isPatchSupported = dummyCheckPatchSupported; - imports->initiatePatch = dummyInitiatePatch; + imports->isPatchSupported = dummyCheckPatchSupported; + imports->initiatePatch = dummyInitiatePatch; #endif - return True; - } else { - return False; + return True; + } } + return False; } -- cgit v1.2.3