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()
56 #define SDL_TriggerBreakpoint() assert(0)
57#elif SDL_HAS_BUILTIN(__builtin_debugtrap)
58 #define SDL_TriggerBreakpoint() __builtin_debugtrap()
59#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))
60 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
61#elif ( defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) )
62 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" )
63#elif defined(__APPLE__) && defined(__arm__)
64 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" )
65#elif defined(__386__) && defined(__WATCOMC__)
66 #define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
67#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__)
69 #define SDL_TriggerBreakpoint() raise(SIGTRAP)
72 #define SDL_TriggerBreakpoint()
75#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
76# define SDL_FUNCTION __func__
77#elif ((defined(__GNUC__) && (__GNUC__ >= 2)) || defined(_MSC_VER) || defined (__WATCOMC__))
78# define SDL_FUNCTION __FUNCTION__
80# define SDL_FUNCTION "???"
82#define SDL_FILE __FILE__
83#define SDL_LINE __LINE__
103#define SDL_NULL_WHILE_LOOP_CONDITION (0,0)
105#define SDL_NULL_WHILE_LOOP_CONDITION (0)
108#define SDL_disabled_assert(condition) \
109 do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION)
131#if (SDL_ASSERT_LEVEL > 0)
146 const char *file,
int line)
147#if defined(__clang__)
148#if __has_feature(attribute_analyzer_noreturn)
149 __attribute__((analyzer_noreturn))
165#define SDL_enabled_assert(condition) \
167 while ( !(condition) ) { \
168 static struct SDL_AssertData sdl_assert_data = { \
169 0, 0, #condition, 0, 0, 0, 0 \
171 const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
172 if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
174 } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \
175 SDL_TriggerBreakpoint(); \
179 } while (SDL_NULL_WHILE_LOOP_CONDITION)
184#if SDL_ASSERT_LEVEL == 0
185# define SDL_assert(condition) SDL_disabled_assert(condition)
186# define SDL_assert_release(condition) SDL_disabled_assert(condition)
187# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
188#elif SDL_ASSERT_LEVEL == 1
189# define SDL_assert(condition) SDL_disabled_assert(condition)
190# define SDL_assert_release(condition) SDL_enabled_assert(condition)
191# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
192#elif SDL_ASSERT_LEVEL == 2
193# define SDL_assert(condition) SDL_enabled_assert(condition)
194# define SDL_assert_release(condition) SDL_enabled_assert(condition)
195# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
196#elif SDL_ASSERT_LEVEL == 3
197# define SDL_assert(condition) SDL_enabled_assert(condition)
198# define SDL_assert_release(condition) SDL_enabled_assert(condition)
199# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition)
201# error Unknown assertion level.
205#define SDL_assert_always(condition) SDL_enabled_assert(condition)
@ SDL_ASSERTION_ALWAYS_IGNORE
SDL_AssertState SDL_ReportAssertion(SDL_AssertData *data, const char *func, const char *file, int line)
SDL_AssertState(* SDL_AssertionHandler)(const SDL_AssertData *data, void *userdata)
const SDL_AssertData * SDL_GetAssertionReport(void)
void SDL_ResetAssertionReport(void)
void SDL_SetAssertionHandler(SDL_AssertionHandler handler, void *userdata)
SDL_AssertionHandler SDL_GetDefaultAssertionHandler(void)
SDL_AssertionHandler SDL_GetAssertionHandler(void **puserdata)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
const struct SDL_AssertData * next
unsigned int trigger_count