summaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/libsdl/libsdl-1.2.14/add.XGetRequest.symbol.patch
blob: 33ba8ecde980e6b5daa82136de0f6d988c5ce9be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
From e49fe9e2d75764d2d7ef79ab4252a1f6b99adcd3 Mon Sep 17 00:00:00 2001
From: Martin Jansa <martin.jansa@gmail.com>
Date: Thu, 23 Feb 2012 18:38:19 +0100
Subject: [PATCH] _XGetRequest API was backported to libx11-1.4.4 in:
 http://git.openembedded.org/openembedded-core/commit/?id=e08604800fe1cb8f240f53c147ceb4ee08a29b91

This breaks e.g. libsdl-image build with:
| /OE/shr-core/tmp-eglibc/sysroots/qemux86-64/usr/lib/libSDL.so: undefined reference to `_XGetRequest'

For details see: https://bugzilla.redhat.com/show_bug.cgi?id=782251

Upstream-Status: Accepted
---
 src/video/x11/SDL_x11dyn.c |   24 ++++++++++++++++++++++++
 src/video/x11/SDL_x11sym.h |    6 ++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/src/video/x11/SDL_x11dyn.c b/src/video/x11/SDL_x11dyn.c
index 4e549b3..a7e800e 100644
--- a/src/video/x11/SDL_x11dyn.c
+++ b/src/video/x11/SDL_x11dyn.c
@@ -109,6 +109,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)
@@ -168,6 +183,15 @@ int SDL_X11_LoadSymbols(void)
 		X11_GetSym("XGetICValues",&SDL_X11_HAVE_UTF8,(void **)&pXGetICValues);
 		#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 3dfa146..f1e7841 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__)
-- 
1.7.2.5