Mercurial > sdl-ios-xcode
comparison src/SDL_assert.c @ 3662:6a0b3048f271
Handle assertion failures when SDL_Init() isn't called.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 13 Jan 2010 09:44:17 +0000 |
parents | 22b6a0c7ea6e |
children | 8bdc37b1a52a |
comparison
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 |