src/SDL_assert.c
changeset 3662 6a0b3048f271
parent 3661 22b6a0c7ea6e
child 3664 8bdc37b1a52a
equal deleted inserted replaced
3661:22b6a0c7ea6e 3662:6a0b3048f271
   349 SDL_assert_state
   349 SDL_assert_state
   350 SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
   350 SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
   351                     int line)
   351                     int line)
   352 {
   352 {
   353     static int assertion_running = 0;
   353     static int assertion_running = 0;
       
   354     static SDL_SpinLock spinlock = 0;
   354     SDL_assert_state state = SDL_ASSERTION_IGNORE;
   355     SDL_assert_state state = SDL_ASSERTION_IGNORE;
       
   356 
       
   357     SDL_AtomicLock(&spinlock);
       
   358     if (assertion_mutex == NULL) { /* never called SDL_Init()? */
       
   359         assertion_mutex = SDL_CreateMutex();
       
   360         if (assertion_mutex == NULL) {
       
   361             SDL_AtomicUnlock(&spinlock);
       
   362             return SDL_ASSERTION_IGNORE;   /* oh well, I guess. */
       
   363         }
       
   364     }
       
   365     SDL_AtomicUnlock(&spinlock);
   355 
   366 
   356     if (SDL_LockMutex(assertion_mutex) < 0) {
   367     if (SDL_LockMutex(assertion_mutex) < 0) {
   357         return SDL_ASSERTION_IGNORE;   /* oh well, I guess. */
   368         return SDL_ASSERTION_IGNORE;   /* oh well, I guess. */
   358     }
   369     }
   359 
   370