src/SDL_assert.c
changeset 11015 b00c4088f687
parent 10737 3406a0f8b041
child 11017 411bf9f7f908
     1.1 --- a/src/SDL_assert.c	Fri May 19 12:40:55 2017 -0400
     1.2 +++ b/src/SDL_assert.c	Fri May 19 12:54:17 2017 -0400
     1.3 @@ -53,7 +53,10 @@
     1.4   */
     1.5  static SDL_assert_data *triggered_assertions = NULL;
     1.6  
     1.7 +#ifndef SDL_THREADS_DISABLED
     1.8  static SDL_mutex *assertion_mutex = NULL;
     1.9 +#endif
    1.10 +
    1.11  static SDL_AssertionHandler assertion_handler = SDL_PromptAssertion;
    1.12  static void *assertion_userdata = NULL;
    1.13  
    1.14 @@ -265,10 +268,11 @@
    1.15  SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
    1.16                      int line)
    1.17  {
    1.18 +    SDL_assert_state state = SDL_ASSERTION_IGNORE;
    1.19      static int assertion_running = 0;
    1.20 +
    1.21 +#ifndef SDL_THREADS_DISABLED
    1.22      static SDL_SpinLock spinlock = 0;
    1.23 -    SDL_assert_state state = SDL_ASSERTION_IGNORE;
    1.24 -
    1.25      SDL_AtomicLock(&spinlock);
    1.26      if (assertion_mutex == NULL) { /* never called SDL_Init()? */
    1.27          assertion_mutex = SDL_CreateMutex();
    1.28 @@ -282,6 +286,7 @@
    1.29      if (SDL_LockMutex(assertion_mutex) < 0) {
    1.30          return SDL_ASSERTION_IGNORE;   /* oh well, I guess. */
    1.31      }
    1.32 +#endif
    1.33  
    1.34      /* doing this because Visual C is upset over assigning in the macro. */
    1.35      if (data->trigger_count == 0) {
    1.36 @@ -325,7 +330,10 @@
    1.37      }
    1.38  
    1.39      assertion_running--;
    1.40 +
    1.41 +#ifndef SDL_THREADS_DISABLED
    1.42      SDL_UnlockMutex(assertion_mutex);
    1.43 +#endif
    1.44  
    1.45      return state;
    1.46  }
    1.47 @@ -334,10 +342,12 @@
    1.48  void SDL_AssertionsQuit(void)
    1.49  {
    1.50      SDL_GenerateAssertionReport();
    1.51 +#ifndef SDL_THREADS_DISABLED
    1.52      if (assertion_mutex != NULL) {
    1.53          SDL_DestroyMutex(assertion_mutex);
    1.54          assertion_mutex = NULL;
    1.55      }
    1.56 +#endif
    1.57  }
    1.58  
    1.59  void SDL_SetAssertionHandler(SDL_AssertionHandler handler, void *userdata)