Commit 8f549cb8 authored by Ryan C. Gordon's avatar Ryan C. Gordon

Make some dynamic X11 symbols option. _XData32 and _XRead32 are only available

 on 64-bit systems, and are chosen with macros in the X11 headers. So on
 32-bit systems, it should fail to find these symbols and keep going anyhow.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401238
parent 68e2ab65
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
slouken@libsdl.org slouken@libsdl.org
*/ */
/*#define DEBUG_DYNAMIC_X11 1*/ #if 0
#define DEBUG_DYNAMIC_X11 1
#endif
#define __SDL_NO_REDEFINE_X11_HEADER_SYMS 1 #define __SDL_NO_REDEFINE_X11_HEADER_SYMS 1
#include "SDL_x11dyn.h" #include "SDL_x11dyn.h"
...@@ -38,7 +40,7 @@ static void *x11_handle = NULL; ...@@ -38,7 +40,7 @@ static void *x11_handle = NULL;
static const char *x11ext_library = X11EXT_DYNAMIC; static const char *x11ext_library = X11EXT_DYNAMIC;
static void *x11ext_handle = NULL; static void *x11ext_handle = NULL;
static void *X11_GetSym(const char *fnname, int *rc) static void *X11_GetSym(int required, const char *fnname, int *rc)
{ {
void *fn = NULL; void *fn = NULL;
if (*rc) { /* haven't already failed on a previous lookup? */ if (*rc) { /* haven't already failed on a previous lookup? */
...@@ -57,7 +59,7 @@ static void *X11_GetSym(const char *fnname, int *rc) ...@@ -57,7 +59,7 @@ static void *X11_GetSym(const char *fnname, int *rc)
printf("X11: Symbol '%s' NOT FOUND!\n", fnname); printf("X11: Symbol '%s' NOT FOUND!\n", fnname);
#endif #endif
} }
*rc = (fn != NULL); *rc = ((fn != NULL) || (!required));
} }
return fn; return fn;
...@@ -65,7 +67,7 @@ static void *X11_GetSym(const char *fnname, int *rc) ...@@ -65,7 +67,7 @@ static void *X11_GetSym(const char *fnname, int *rc)
#endif /* defined X11_DYNAMIC */ #endif /* defined X11_DYNAMIC */
/* Define all the function pointers... */ /* Define all the function pointers... */
#define SDL_X11_SYM(ret,fn,params) ret (*p##fn) params = NULL; #define SDL_X11_SYM(req,ret,fn,params) ret (*p##fn) params = NULL;
#include "SDL_x11sym.h" #include "SDL_x11sym.h"
#undef SDL_X11_SYM #undef SDL_X11_SYM
...@@ -77,7 +79,7 @@ void SDL_X11_UnloadSymbols(void) ...@@ -77,7 +79,7 @@ void SDL_X11_UnloadSymbols(void)
if (x11_load_refcount > 0) { if (x11_load_refcount > 0) {
if (--x11_load_refcount == 0) { if (--x11_load_refcount == 0) {
/* set all the function pointers to NULL. */ /* set all the function pointers to NULL. */
#define SDL_X11_SYM(ret,fn,params) p##fn = NULL; #define SDL_X11_SYM(req,ret,fn,params) p##fn = NULL;
#include "SDL_x11sym.h" #include "SDL_x11sym.h"
#undef SDL_X11_SYM #undef SDL_X11_SYM
...@@ -106,7 +108,7 @@ int SDL_X11_LoadSymbols(void) ...@@ -106,7 +108,7 @@ int SDL_X11_LoadSymbols(void)
x11_handle = SDL_LoadObject(x11_library); x11_handle = SDL_LoadObject(x11_library);
x11ext_handle = SDL_LoadObject(x11ext_library); x11ext_handle = SDL_LoadObject(x11ext_library);
rc = ((x11_handle != NULL) && (x11ext_handle != NULL)); rc = ((x11_handle != NULL) && (x11ext_handle != NULL));
#define SDL_X11_SYM(r,fn,arg) p##fn = X11_GetSym(#fn, &rc); #define SDL_X11_SYM(req,r,fn,arg) p##fn = X11_GetSym(req,#fn, &rc);
#include "SDL_x11sym.h" #include "SDL_x11sym.h"
#undef SDL_X11_SYM #undef SDL_X11_SYM
...@@ -114,7 +116,7 @@ int SDL_X11_LoadSymbols(void) ...@@ -114,7 +116,7 @@ int SDL_X11_LoadSymbols(void)
SDL_X11_UnloadSymbols(); /* in case one of these loaded... */ SDL_X11_UnloadSymbols(); /* in case one of these loaded... */
#else #else
#define SDL_X11_SYM(r,fn,arg) p##fn = fn; #define SDL_X11_SYM(req,r,fn,arg) p##fn = fn;
#include "SDL_x11sym.h" #include "SDL_x11sym.h"
#undef SDL_X11_SYM #undef SDL_X11_SYM
#endif #endif
......
...@@ -58,7 +58,7 @@ typedef Bool (*SDL_X11_XESetWireToEventRetType)(Display*,XEvent*,xEvent*); ...@@ -58,7 +58,7 @@ typedef Bool (*SDL_X11_XESetWireToEventRetType)(Display*,XEvent*,xEvent*);
typedef int (*SDL_X11_XSynchronizeRetType)(Display*); typedef int (*SDL_X11_XSynchronizeRetType)(Display*);
typedef Status (*SDL_X11_XESetEventToWireRetType)(Display*,XEvent*,xEvent*); typedef Status (*SDL_X11_XESetEventToWireRetType)(Display*,XEvent*,xEvent*);
#define SDL_X11_SYM(ret,fn,params) extern ret (*p##fn) params; #define SDL_X11_SYM(req,ret,fn,params) extern ret (*p##fn) params;
#include "SDL_x11sym.h" #include "SDL_x11sym.h"
#undef SDL_X11_SYM #undef SDL_X11_SYM
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment