summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan C. Gordon <icculus@icculus.org>2012-01-18 03:03:23 -0500
committerRyan C. Gordon <icculus@icculus.org>2012-01-18 03:03:23 -0500
commit2352a63e087b8ed9fb4f58b8ecf3e2fb86000fd7 (patch)
treea693e9e93a0d22913d26e5cd126b1e1f76432643
parent135fb02e928be8539f0f6b9c360d4f647b7f4202 (diff)
downloadsdl-2352a63e087b8ed9fb4f58b8ecf3e2fb86000fd7.tar.gz
Add dynamic symbol for _XGetRequest, which libX11 1.4.99.1 added.
Fixes Bugzilla #1376.
-rw-r--r--src/video/x11/SDL_x11dyn.c24
-rw-r--r--src/video/x11/SDL_x11sym.h6
2 files changed, 30 insertions, 0 deletions
diff --git a/src/video/x11/SDL_x11dyn.c b/src/video/x11/SDL_x11dyn.c
index 1c890bdac..7058addfa 100644
--- a/src/video/x11/SDL_x11dyn.c
+++ b/src/video/x11/SDL_x11dyn.c
@@ -112,6 +112,21 @@ char *(*pXGetICValues)(XIC, ...) = NULL;
#undef SDL_X11_SYM
+static void *SDL_XGetRequest_workaround(Display* dpy, CARD8 type, size_t len)
+{
+ xReq *req;
+ WORD64ALIGN
+ if (dpy->bufptr + len > dpy->bufmax)
+ _XFlush(dpy);
+ dpy->last_req = dpy->bufptr;
+ req = (xReq*)dpy->bufptr;
+ req->reqType = type;
+ req->length = len / 4;
+ dpy->bufptr += len;
+ dpy->request++;
+ return req;
+}
+
static int x11_load_refcount = 0;
void SDL_X11_UnloadSymbols(void)
@@ -174,6 +189,15 @@ int SDL_X11_LoadSymbols(void)
&SDL_X11_HAVE_UTF8);
#endif
+ /*
+ * In case we're built with newer Xlib headers, we need to make sure
+ * that _XGetRequest() is available, even on older systems.
+ * Otherwise, various Xlib macros we use will call a NULL pointer.
+ */
+ if (!SDL_X11_HAVE_XGETREQUEST) {
+ p_XGetRequest = SDL_XGetRequest_workaround;
+ }
+
if (SDL_X11_HAVE_BASEXLIB) { /* all required symbols loaded. */
SDL_ClearError();
} else {
diff --git a/src/video/x11/SDL_x11sym.h b/src/video/x11/SDL_x11sym.h
index fa9cccb2d..4875b989c 100644
--- a/src/video/x11/SDL_x11sym.h
+++ b/src/video/x11/SDL_x11sym.h
@@ -170,6 +170,12 @@ SDL_X11_SYM(void,_XRead32,(Display *dpy,register long *data,long len),(dpy,data,
#endif
/*
+ * libX11 1.4.99.1 added _XGetRequest, and macros use it behind the scenes.
+ */
+SDL_X11_MODULE(XGETREQUEST)
+SDL_X11_SYM(void *,_XGetRequest,(Display* a,CARD8 b,size_t c),(a,b,c),return)
+
+/*
* These only show up on some variants of Unix.
*/
#if defined(__osf__)