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 _SDL_HAS_BUILTIN(__builtin_debugtrap)
55 #define SDL_TriggerBreakpoint() __builtin_debugtrap()
56#elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) )
57 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
58#elif (defined(__GNUC__) || defined(__clang__)) && defined(__riscv)
59 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "ebreak\n\t" )
60#elif ( defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) )
61 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" )
62#elif defined(__APPLE__) && defined(__arm__)
63 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" )
64#elif defined(_WIN32) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__arm64__) || defined(__aarch64__)) )
65 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #0xF000\n\t" )
66#elif defined(__386__) && defined(__WATCOMC__)
67 #define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
68#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__)
70 #define SDL_TriggerBreakpoint() raise(SIGTRAP)
73 #define SDL_TriggerBreakpoint()
76#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
77# define SDL_FUNCTION __func__
78#elif ((defined(__GNUC__) && (__GNUC__ >= 2)) || defined(_MSC_VER) || defined (__WATCOMC__))
79# define SDL_FUNCTION __FUNCTION__
81# define SDL_FUNCTION "???"
83#define SDL_FILE __FILE__
84#define SDL_LINE __LINE__
104#define SDL_NULL_WHILE_LOOP_CONDITION (0,0)
106#define SDL_NULL_WHILE_LOOP_CONDITION (0)
109#define SDL_disabled_assert(condition) \
110 do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION)
136#if defined(__clang__)
137#if __has_feature(attribute_analyzer_noreturn)
141 __attribute__((analyzer_noreturn))
153#define SDL_enabled_assert(condition) \
155 while ( !(condition) ) { \
156 static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; \
157 const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
158 if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
160 } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \
161 SDL_TriggerBreakpoint(); \
165 } while (SDL_NULL_WHILE_LOOP_CONDITION)
168#if SDL_ASSERT_LEVEL == 0
169# define SDL_assert(condition) SDL_disabled_assert(condition)
170# define SDL_assert_release(condition) SDL_disabled_assert(condition)
171# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
172#elif SDL_ASSERT_LEVEL == 1
173# define SDL_assert(condition) SDL_disabled_assert(condition)
174# define SDL_assert_release(condition) SDL_enabled_assert(condition)
175# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
176#elif SDL_ASSERT_LEVEL == 2
177# define SDL_assert(condition) SDL_enabled_assert(condition)
178# define SDL_assert_release(condition) SDL_enabled_assert(condition)
179# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
180#elif SDL_ASSERT_LEVEL == 3
181# define SDL_assert(condition) SDL_enabled_assert(condition)
182# define SDL_assert_release(condition) SDL_enabled_assert(condition)
183# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition)
185# error Unknown assertion level.
189#define SDL_assert_always(condition) SDL_enabled_assert(condition)
312#define SDL_assert_state SDL_AssertState
313#define SDL_assert_data SDL_AssertData
@ SDL_ASSERTION_ALWAYS_IGNORE
SDL_AssertState(* SDL_AssertionHandler)(const SDL_AssertData *data, void *userdata)
SDL_AssertState SDL_ReportAssertion(SDL_AssertData *, const char *, const char *, int)
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)
const struct SDL_AssertData * next
unsigned int trigger_count