Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11dyn.c @ 1235:f60f6f4ffc6f
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.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Fri, 06 Jan 2006 20:56:13 +0000 |
parents | d05306f0dc21 |
children | ed252764287a |
comparison
equal
deleted
inserted
replaced
1234:73676c1f56ee | 1235:f60f6f4ffc6f |
---|---|
18 | 18 |
19 Sam Lantinga | 19 Sam Lantinga |
20 slouken@libsdl.org | 20 slouken@libsdl.org |
21 */ | 21 */ |
22 | 22 |
23 /*#define DEBUG_DYNAMIC_X11 1*/ | 23 #if 0 |
24 #define DEBUG_DYNAMIC_X11 1 | |
25 #endif | |
24 | 26 |
25 #define __SDL_NO_REDEFINE_X11_HEADER_SYMS 1 | 27 #define __SDL_NO_REDEFINE_X11_HEADER_SYMS 1 |
26 #include "SDL_x11dyn.h" | 28 #include "SDL_x11dyn.h" |
27 | 29 |
28 #ifdef DEBUG_DYNAMIC_X11 | 30 #ifdef DEBUG_DYNAMIC_X11 |
36 static const char *x11_library = X11_DYNAMIC; | 38 static const char *x11_library = X11_DYNAMIC; |
37 static void *x11_handle = NULL; | 39 static void *x11_handle = NULL; |
38 static const char *x11ext_library = X11EXT_DYNAMIC; | 40 static const char *x11ext_library = X11EXT_DYNAMIC; |
39 static void *x11ext_handle = NULL; | 41 static void *x11ext_handle = NULL; |
40 | 42 |
41 static void *X11_GetSym(const char *fnname, int *rc) | 43 static void *X11_GetSym(int required, const char *fnname, int *rc) |
42 { | 44 { |
43 void *fn = NULL; | 45 void *fn = NULL; |
44 if (*rc) { /* haven't already failed on a previous lookup? */ | 46 if (*rc) { /* haven't already failed on a previous lookup? */ |
45 fn = SDL_LoadFunction(x11_handle, fnname); | 47 fn = SDL_LoadFunction(x11_handle, fnname); |
46 #if DEBUG_DYNAMIC_X11 | 48 #if DEBUG_DYNAMIC_X11 |
55 printf("X11: Found '%s' in libXext (%p)\n", fnname, fn); | 57 printf("X11: Found '%s' in libXext (%p)\n", fnname, fn); |
56 else | 58 else |
57 printf("X11: Symbol '%s' NOT FOUND!\n", fnname); | 59 printf("X11: Symbol '%s' NOT FOUND!\n", fnname); |
58 #endif | 60 #endif |
59 } | 61 } |
60 *rc = (fn != NULL); | 62 *rc = ((fn != NULL) || (!required)); |
61 } | 63 } |
62 | 64 |
63 return fn; | 65 return fn; |
64 } | 66 } |
65 #endif /* defined X11_DYNAMIC */ | 67 #endif /* defined X11_DYNAMIC */ |
66 | 68 |
67 /* Define all the function pointers... */ | 69 /* Define all the function pointers... */ |
68 #define SDL_X11_SYM(ret,fn,params) ret (*p##fn) params = NULL; | 70 #define SDL_X11_SYM(req,ret,fn,params) ret (*p##fn) params = NULL; |
69 #include "SDL_x11sym.h" | 71 #include "SDL_x11sym.h" |
70 #undef SDL_X11_SYM | 72 #undef SDL_X11_SYM |
71 | 73 |
72 static int x11_load_refcount = 0; | 74 static int x11_load_refcount = 0; |
73 | 75 |
75 { | 77 { |
76 /* Don't actually unload if more than one module is using the libs... */ | 78 /* Don't actually unload if more than one module is using the libs... */ |
77 if (x11_load_refcount > 0) { | 79 if (x11_load_refcount > 0) { |
78 if (--x11_load_refcount == 0) { | 80 if (--x11_load_refcount == 0) { |
79 /* set all the function pointers to NULL. */ | 81 /* set all the function pointers to NULL. */ |
80 #define SDL_X11_SYM(ret,fn,params) p##fn = NULL; | 82 #define SDL_X11_SYM(req,ret,fn,params) p##fn = NULL; |
81 #include "SDL_x11sym.h" | 83 #include "SDL_x11sym.h" |
82 #undef SDL_X11_SYM | 84 #undef SDL_X11_SYM |
83 | 85 |
84 #ifdef X11_DYNAMIC | 86 #ifdef X11_DYNAMIC |
85 if (x11_handle != NULL) { | 87 if (x11_handle != NULL) { |
104 if (x11_load_refcount++ == 0) { | 106 if (x11_load_refcount++ == 0) { |
105 #ifdef X11_DYNAMIC | 107 #ifdef X11_DYNAMIC |
106 x11_handle = SDL_LoadObject(x11_library); | 108 x11_handle = SDL_LoadObject(x11_library); |
107 x11ext_handle = SDL_LoadObject(x11ext_library); | 109 x11ext_handle = SDL_LoadObject(x11ext_library); |
108 rc = ((x11_handle != NULL) && (x11ext_handle != NULL)); | 110 rc = ((x11_handle != NULL) && (x11ext_handle != NULL)); |
109 #define SDL_X11_SYM(r,fn,arg) p##fn = X11_GetSym(#fn, &rc); | 111 #define SDL_X11_SYM(req,r,fn,arg) p##fn = X11_GetSym(req,#fn, &rc); |
110 #include "SDL_x11sym.h" | 112 #include "SDL_x11sym.h" |
111 #undef SDL_X11_SYM | 113 #undef SDL_X11_SYM |
112 | 114 |
113 if (!rc) | 115 if (!rc) |
114 SDL_X11_UnloadSymbols(); /* in case one of these loaded... */ | 116 SDL_X11_UnloadSymbols(); /* in case one of these loaded... */ |
115 | 117 |
116 #else | 118 #else |
117 #define SDL_X11_SYM(r,fn,arg) p##fn = fn; | 119 #define SDL_X11_SYM(req,r,fn,arg) p##fn = fn; |
118 #include "SDL_x11sym.h" | 120 #include "SDL_x11sym.h" |
119 #undef SDL_X11_SYM | 121 #undef SDL_X11_SYM |
120 #endif | 122 #endif |
121 } | 123 } |
122 | 124 |