Should fix type-punning compiler warnings.
This commit is contained in:
parent
82ebf2d4ff
commit
9a4128b20d
1 changed files with 22 additions and 16 deletions
|
@ -77,35 +77,38 @@ static x11dynlib x11libs[] = {
|
||||||
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE}
|
{NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void *
|
||||||
X11_GetSym(const char *fnname, int *rc, void **fn)
|
X11_GetSym(const char *fnname, int *pHasModule)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
void *fn = NULL;
|
||||||
for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
|
for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
|
||||||
if (x11libs[i].lib != NULL) {
|
if (x11libs[i].lib != NULL) {
|
||||||
*fn = SDL_LoadFunction(x11libs[i].lib, fnname);
|
fn = SDL_LoadFunction(x11libs[i].lib, fnname);
|
||||||
if (*fn != NULL)
|
if (fn != NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_DYNAMIC_X11
|
#if DEBUG_DYNAMIC_X11
|
||||||
if (*fn != NULL)
|
if (fn != NULL)
|
||||||
printf("X11: Found '%s' in %s (%p)\n", fnname, x11libs[i].libname,
|
printf("X11: Found '%s' in %s (%p)\n", fnname, x11libs[i].libname, fn);
|
||||||
*fn);
|
|
||||||
else
|
else
|
||||||
printf("X11: Symbol '%s' NOT FOUND!\n", fnname);
|
printf("X11: Symbol '%s' NOT FOUND!\n", fnname);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (*fn == NULL)
|
if (fn == NULL)
|
||||||
*rc = 0; /* kill this module. */
|
*pHasModule = 0; /* kill this module. */
|
||||||
|
|
||||||
|
return fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Define all the function pointers and wrappers... */
|
/* Define all the function pointers and wrappers... */
|
||||||
#define SDL_X11_MODULE(modname)
|
#define SDL_X11_MODULE(modname)
|
||||||
#define SDL_X11_SYM(rc,fn,params,args,ret) \
|
#define SDL_X11_SYM(rc,fn,params,args,ret) \
|
||||||
static rc (*p##fn) params = NULL; \
|
typedef rc (*SDL_DYNX11FN_##fn) params; \
|
||||||
|
static SDL_DYNX11FN_##fn p##fn = NULL; \
|
||||||
rc fn params { ret p##fn args ; }
|
rc fn params { ret p##fn args ; }
|
||||||
#include "SDL_x11sym.h"
|
#include "SDL_x11sym.h"
|
||||||
#undef SDL_X11_MODULE
|
#undef SDL_X11_MODULE
|
||||||
|
@ -114,8 +117,10 @@ X11_GetSym(const char *fnname, int *rc, void **fn)
|
||||||
|
|
||||||
/* Annoying varargs entry point... */
|
/* Annoying varargs entry point... */
|
||||||
#ifdef X_HAVE_UTF8_STRING
|
#ifdef X_HAVE_UTF8_STRING
|
||||||
XIC(*pXCreateIC) (XIM,...) = NULL;
|
typedef XIC(*SDL_DYNX11FN_XCreateIC) (XIM,...);
|
||||||
char *(*pXGetICValues) (XIC, ...) = NULL;
|
SDL_DYNX11FN_XCreateIC pXCreateIC = NULL;
|
||||||
|
typedef char *(*SDL_DYNX11FN_XGetICValues) (XIC, ...);
|
||||||
|
SDL_DYNX11FN_XGetICValues pXGetICValues = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */
|
/* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */
|
||||||
|
@ -184,15 +189,16 @@ SDL_X11_LoadSymbols(void)
|
||||||
#undef SDL_X11_SYM
|
#undef SDL_X11_SYM
|
||||||
|
|
||||||
#define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname;
|
#define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname;
|
||||||
#define SDL_X11_SYM(a,fn,x,y,z) X11_GetSym(#fn,thismod,(void**)&p##fn);
|
#define SDL_X11_SYM(a,fn,x,y,z) p##fn = (SDL_DYNX11FN_##fn) X11_GetSym(#fn,thismod);
|
||||||
#include "SDL_x11sym.h"
|
#include "SDL_x11sym.h"
|
||||||
#undef SDL_X11_MODULE
|
#undef SDL_X11_MODULE
|
||||||
#undef SDL_X11_SYM
|
#undef SDL_X11_SYM
|
||||||
|
|
||||||
#ifdef X_HAVE_UTF8_STRING
|
#ifdef X_HAVE_UTF8_STRING
|
||||||
X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8, (void **) &pXCreateIC);
|
pXCreateIC = (SDL_DYNX11FN_XCreateIC)
|
||||||
X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8,
|
X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8);
|
||||||
(void **) &pXGetICValues);
|
pXGetICValues = (SDL_DYNX11FN_XGetICValues)
|
||||||
|
X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (SDL_X11_HAVE_BASEXLIB) {
|
if (SDL_X11_HAVE_BASEXLIB) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue