33 #ifndef SDL_ASSERT_LEVEL
34 #ifdef SDL_DEFAULT_ASSERT_LEVEL
35 #define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL
36 #elif defined(_DEBUG) || defined(DEBUG) || \
37 (defined(__GNUC__) && !defined(__OPTIMIZE__))
38 #define SDL_ASSERT_LEVEL 2
40 #define SDL_ASSERT_LEVEL 1
52 extern void __cdecl __debugbreak(
void);
53 #define SDL_TriggerBreakpoint() __debugbreak()
54 #elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
55 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
56 #elif defined(HAVE_SIGNAL_H)
58 #define SDL_TriggerBreakpoint() raise(SIGTRAP)
61 #define SDL_TriggerBreakpoint()
64 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
65 # define SDL_FUNCTION __func__
66 #elif ((__GNUC__ >= 2) || defined(_MSC_VER))
67 # define SDL_FUNCTION __FUNCTION__
69 # define SDL_FUNCTION "???"
71 #define SDL_FILE __FILE__
72 #define SDL_LINE __LINE__
90 #define SDL_NULL_WHILE_LOOP_CONDITION (-1 == __LINE__)
92 #define SDL_NULL_WHILE_LOOP_CONDITION (0)
95 #define SDL_disabled_assert(condition) \
96 do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION)
114 const char *
function;
118 #if (SDL_ASSERT_LEVEL > 0)
132 #define SDL_enabled_assert(condition) \
134 while ( !(condition) ) { \
135 static struct SDL_assert_data assert_data = { \
136 0, 0, #condition, 0, 0, 0, 0 \
138 const SDL_assert_state state = SDL_ReportAssertion(&assert_data, \
142 if (state == SDL_ASSERTION_RETRY) { \
144 } else if (state == SDL_ASSERTION_BREAK) { \
145 SDL_TriggerBreakpoint(); \
149 } while (SDL_NULL_WHILE_LOOP_CONDITION)
154 #if SDL_ASSERT_LEVEL == 0
155 # define SDL_assert(condition) SDL_disabled_assert(condition)
156 # define SDL_assert_release(condition) SDL_disabled_assert(condition)
157 # define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
158 #elif SDL_ASSERT_LEVEL == 1
159 # define SDL_assert(condition) SDL_disabled_assert(condition)
160 # define SDL_assert_release(condition) SDL_enabled_assert(condition)
161 # define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
162 #elif SDL_ASSERT_LEVEL == 2
163 # define SDL_assert(condition) SDL_enabled_assert(condition)
164 # define SDL_assert_release(condition) SDL_enabled_assert(condition)
165 # define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
166 #elif SDL_ASSERT_LEVEL == 3
167 # define SDL_assert(condition) SDL_enabled_assert(condition)
168 # define SDL_assert_release(condition) SDL_enabled_assert(condition)
169 # define SDL_assert_paranoid(condition) SDL_enabled_assert(condition)
171 # error Unknown assertion level.
175 #define SDL_assert_always(condition) SDL_enabled_assert(condition)
struct SDL_assert_data SDL_assert_data
unsigned int trigger_count
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
DECLSPEC void SDLCALL SDL_SetAssertionHandler(SDL_AssertionHandler handler, void *userdata)
Set an application-defined assertion handler.
SDL_assert_state(SDLCALL * SDL_AssertionHandler)(const SDL_assert_data *data, void *userdata)
struct SDL_assert_data * next
DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *, const char *, const char *, int)
DECLSPEC const SDL_assert_data *SDLCALL SDL_GetAssertionReport(void)
Get a list of all assertion failures.
DECLSPEC void SDLCALL SDL_ResetAssertionReport(void)
Reset the list of all assertion failures.