Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add dynamic symbol for _XGetRequest, which libX11 1.4.99.1 added.
Fixes Bugzilla #1376.
  • Loading branch information
icculus committed Jan 18, 2012
1 parent a2fd04d commit b7c2f37
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/video/x11/SDL_x11dyn.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions src/video/x11/SDL_x11sym.h
Expand Up @@ -169,6 +169,12 @@ SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,da
SDL_X11_SYM(void,_XRead32,(Display *dpy,register long *data,long len),(dpy,data,len),)
#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.
*/
Expand Down

0 comments on commit b7c2f37

Please sign in to comment.