39#ifndef SDL_ASSERT_LEVEL
40#ifdef SDL_DEFAULT_ASSERT_LEVEL
41#define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL
42#elif defined(_DEBUG) || defined(DEBUG) || \
43 (defined(__GNUC__) && !defined(__OPTIMIZE__))
44#define SDL_ASSERT_LEVEL 2
46#define SDL_ASSERT_LEVEL 1
58 extern void __cdecl __debugbreak(
void);
59 #define SDL_TriggerBreakpoint() __debugbreak()
62 #define SDL_TriggerBreakpoint() assert(0)
63#elif SDL_HAS_BUILTIN(__builtin_debugtrap)
64 #define SDL_TriggerBreakpoint() __builtin_debugtrap()
65#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))
66 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
67#elif (defined(__GNUC__) || defined(__clang__)) && defined(__riscv)
68 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "ebreak\n\t" )
69#elif ( defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) )
70 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" )
71#elif defined(__APPLE__) && defined(__arm__)
72 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" )
73#elif defined(__386__) && defined(__WATCOMC__)
74 #define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
75#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__)
77 #define SDL_TriggerBreakpoint() raise(SIGTRAP)
80 #define SDL_TriggerBreakpoint()
83#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
84# define SDL_FUNCTION __func__
85#elif ((defined(__GNUC__) && (__GNUC__ >= 2)) || defined(_MSC_VER) || defined (__WATCOMC__))
86# define SDL_FUNCTION __FUNCTION__
88# define SDL_FUNCTION "???"
90#define SDL_FILE __FILE__
91#define SDL_LINE __LINE__
111#define SDL_NULL_WHILE_LOOP_CONDITION (0,0)
113#define SDL_NULL_WHILE_LOOP_CONDITION (0)
116#define SDL_disabled_assert(condition) \
117 do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION)
154 const char *file,
int line)
156#if __has_feature(attribute_analyzer_noreturn)
157 __attribute__((analyzer_noreturn))
167#ifndef SDL_AssertBreakpoint
168#if defined(ANDROID) && defined(assert)
170#define SDL_AssertBreakpoint()
172#define SDL_AssertBreakpoint() SDL_TriggerBreakpoint()
183#define SDL_enabled_assert(condition) \
185 while ( !(condition) ) { \
186 static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; \
187 const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
188 if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
190 } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \
191 SDL_AssertBreakpoint(); \
195 } while (SDL_NULL_WHILE_LOOP_CONDITION)
198#if SDL_ASSERT_LEVEL == 0
199# define SDL_assert(condition) SDL_disabled_assert(condition)
200# define SDL_assert_release(condition) SDL_disabled_assert(condition)
201# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
202#elif SDL_ASSERT_LEVEL == 1
203# define SDL_assert(condition) SDL_disabled_assert(condition)
204# define SDL_assert_release(condition) SDL_enabled_assert(condition)
205# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
206#elif SDL_ASSERT_LEVEL == 2
207# define SDL_assert(condition) SDL_enabled_assert(condition)
208# define SDL_assert_release(condition) SDL_enabled_assert(condition)
209# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
210#elif SDL_ASSERT_LEVEL == 3
211# define SDL_assert(condition) SDL_enabled_assert(condition)
212# define SDL_assert_release(condition) SDL_enabled_assert(condition)
213# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition)
215# error Unknown assertion level.
219#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)
This is a general header that includes C language support.
const struct SDL_AssertData * next
unsigned int trigger_count