src/SDL12_compat.c
changeset 107 675826327470
parent 106 8948c4b1ef8d
child 108 d3b0971aa72c
     1.1 --- a/src/SDL12_compat.c	Wed Mar 06 16:53:24 2019 -0500
     1.2 +++ b/src/SDL12_compat.c	Fri Mar 08 21:27:57 2019 -0500
     1.3 @@ -820,6 +820,22 @@
     1.4      return okay;
     1.5  }
     1.6  
     1.7 +static void dllinit(void) __attribute__((constructor));
     1.8 +static void dllinit(void)
     1.9 +{
    1.10 +    if (!LoadSDL20()) {
    1.11 +        fprintf(stderr, "ERROR: sdl12-compat failed to load SDL 2.0! Aborting!\n");
    1.12 +        fflush(stderr);
    1.13 +        abort();
    1.14 +    }
    1.15 +}
    1.16 +
    1.17 +static void dllquit(void) __attribute__((destructor));
    1.18 +static void dllquit(void)
    1.19 +{
    1.20 +    UnloadSDL20();
    1.21 +}
    1.22 +
    1.23  DECLSPEC const SDL_version * SDLCALL
    1.24  SDL_Linked_Version(void)
    1.25  {
    1.26 @@ -1099,6 +1115,8 @@
    1.27  }
    1.28  
    1.29  
    1.30 +
    1.31 +
    1.32  DECLSPEC int SDLCALL
    1.33  SDL_InitSubSystem(Uint32 sdl12flags)
    1.34  {
    1.35 @@ -1113,9 +1131,6 @@
    1.36      Uint32 sdl20flags = 0;
    1.37      int rc;
    1.38  
    1.39 -    if (!LoadSDL20())
    1.40 -        return -1;
    1.41 -
    1.42  #ifdef __MACOSX__
    1.43      extern void sdl12_compat_macos_init(void);
    1.44      sdl12_compat_macos_init();
    1.45 @@ -1248,7 +1263,6 @@
    1.46  
    1.47      if ((SDL20_WasInit(0) == 0) && (!CDRomInit)) {
    1.48          SDL20_Quit();
    1.49 -        UnloadSDL20();
    1.50      }
    1.51  }
    1.52  
    1.53 @@ -1266,10 +1280,6 @@
    1.54      size_t len = 0;
    1.55      va_list ap;
    1.56  
    1.57 -    if (!LoadSDL20()) {  /* SDL_SetError gets called before init sometimes. */
    1.58 -        return;
    1.59 -    }
    1.60 -
    1.61      va_start(ap, fmt);
    1.62      len = SDL20_vsnprintf(&ch, 1, fmt, ap);
    1.63      va_end(ap);