Cleaned up symbol loading macro salsa a bit more.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 13 Feb 2019 17:48:31 -0500
changeset 55852e5d3808f2
parent 54 3511abf3a80d
child 56 a8a08936f60f
Cleaned up symbol loading macro salsa a bit more.
src/SDL12_compat.c
src/SDL20_syms.h
     1.1 --- a/src/SDL12_compat.c	Wed Feb 13 08:33:29 2019 -0500
     1.2 +++ b/src/SDL12_compat.c	Wed Feb 13 17:48:31 2019 -0500
     1.3 @@ -114,14 +114,8 @@
     1.4  #define SDL20_SYM(rc,fn,params,args,ret) \
     1.5      typedef rc (SDLCALL *SDL20_##fn##_t) params; \
     1.6      static SDL20_##fn##_t SDL20_##fn = NULL;
     1.7 -#define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) \
     1.8 -    SDL20_SYM(rc,fn,params,args,ret)
     1.9  #include "SDL20_syms.h"
    1.10  
    1.11 -/* this doesn't get handled in SDL20_syms.h because it uses varargs. */
    1.12 -typedef int (SDLCALL *SDL20_SetError_t)(const char *fmt, ...);
    1.13 -static SDL20_SetError_t SDL20_SetError = NULL;
    1.14 -
    1.15  /* Things that _should_ be binary compatible pass right through... */
    1.16  #define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) \
    1.17      DECLSPEC rc SDLCALL SDL_##fn params { ret SDL20_##fn args; }
    1.18 @@ -491,8 +485,9 @@
    1.19      if (*okay)  /* only bother trying if we haven't previously failed. */
    1.20      {
    1.21          retval = LookupSDL20Sym(fn);
    1.22 -        if (retval == NULL)
    1.23 -            *okay = 0;
    1.24 +if (!retval) { fprintf(stderr, "WARNING: LOAD FAILED: %s\n", fn); }
    1.25 +//        if (retval == NULL)
    1.26 +//            *okay = 0;
    1.27      }
    1.28      return retval;
    1.29  }
    1.30 @@ -501,9 +496,7 @@
    1.31  UnloadSDL20(void)
    1.32  {
    1.33      #define SDL20_SYM(rc,fn,params,args,ret) SDL20_##fn = NULL;
    1.34 -    #define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) SDL20_SYM(rc,fn,params,args,ret)
    1.35      #include "SDL20_syms.h"
    1.36 -    SDL20_SetError = NULL;
    1.37      CloseSDL20Library();
    1.38  }
    1.39  
    1.40 @@ -515,9 +508,7 @@
    1.41      {
    1.42          okay = LoadSDL20Library();
    1.43          #define SDL20_SYM(rc,fn,params,args,ret) SDL20_##fn = (SDL20_##fn##_t) LoadSDL20Symbol("SDL_" #fn, &okay);
    1.44 -        #define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) SDL20_SYM(rc,fn,params,args,ret)
    1.45          #include "SDL20_syms.h"
    1.46 -        SDL20_SetError = (SDL20_SetError_t) LoadSDL20Symbol("SDL_SetError", &okay);
    1.47          if (!okay)
    1.48              UnloadSDL20();
    1.49      }
     2.1 --- a/src/SDL20_syms.h	Wed Feb 13 08:33:29 2019 -0500
     2.2 +++ b/src/SDL20_syms.h	Wed Feb 13 17:48:31 2019 -0500
     2.3 @@ -26,13 +26,19 @@
     2.4  #endif
     2.5  
     2.6  #ifndef SDL20_SYM_PASSTHROUGH
     2.7 -#define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret)
     2.8 +#define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) SDL20_SYM(rc,fn,params,args,ret)
     2.9 +#endif
    2.10 +
    2.11 +#ifndef SDL20_SYM_VARARGS
    2.12 +#define SDL20_SYM_VARARGS(rc,fn,params) SDL20_SYM(rc,fn,params,unused,unused)
    2.13  #endif
    2.14  
    2.15  SDL20_SYM(int,Init,(Uint32 a),(a),return)
    2.16  SDL20_SYM(int,InitSubSystem,(Uint32 a),(a),return)
    2.17  SDL20_SYM(Uint32,WasInit,(Uint32 a),(a),return)
    2.18  SDL20_SYM(char*,GetError,(void),(),return)
    2.19 +SDL20_SYM_VARARGS(int,SetError,(const char *fmt, ...))
    2.20 +
    2.21  SDL20_SYM_PASSTHROUGH(int,Error,(SDL_errorcode a),(a),return)
    2.22  SDL20_SYM_PASSTHROUGH(void,ClearError,(void),(),)
    2.23  SDL20_SYM(void,Quit,(void),(),)
    2.24 @@ -222,8 +228,8 @@
    2.25  SDL20_SYM_PASSTHROUGH(int,strncmp,(const char *a, const char *b, size_t c),(a,b,c),return)
    2.26  SDL20_SYM_PASSTHROUGH(int,strcasecmp,(const char *a, const char *b),(a,b),return)
    2.27  SDL20_SYM_PASSTHROUGH(int,strncasecmp,(const char *a, const char *b, size_t c),(a,b,c),return)
    2.28 -//SDL20_SYM_PASSTHROUGH(int,sscanf,(const char *text, const char *fmt, ...);
    2.29 -//SDL20_SYM_PASSTHROUGH(int,snprintf,(char *text, size_t maxlen, const char *fmt, ...);
    2.30 +SDL20_SYM_VARARGS(int,sscanf,(const char *text, const char *fmt, ...))
    2.31 +SDL20_SYM_VARARGS(int,snprintf,(char *text, size_t maxlen, const char *fmt, ...))
    2.32  SDL20_SYM_PASSTHROUGH(int,vsnprintf,(char *a, size_t b, const char *c, va_list d),(a,b,c,d),return)
    2.33  SDL20_SYM_PASSTHROUGH(SDL_iconv_t,iconv_open,(const char *a, const char *b),(a,b),return)
    2.34  SDL20_SYM_PASSTHROUGH(int,iconv_close,(SDL_iconv_t a),(a),return)
    2.35 @@ -234,6 +240,7 @@
    2.36  
    2.37  #undef SDL20_SYM
    2.38  #undef SDL20_SYM_PASSTHROUGH
    2.39 +#undef SDL20_SYM_VARARGS
    2.40  
    2.41  /* vi: set ts=4 sw=4 expandtab: */
    2.42