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(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) )
68 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" )
69#elif defined(__APPLE__) && defined(__arm__)
70 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" )
71#elif defined(__386__) && defined(__WATCOMC__)
72 #define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
73#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__)
75 #define SDL_TriggerBreakpoint() raise(SIGTRAP)
78 #define SDL_TriggerBreakpoint()
81#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
82# define SDL_FUNCTION __func__
83#elif ((defined(__GNUC__) && (__GNUC__ >= 2)) || defined(_MSC_VER) || defined (__WATCOMC__))
84# define SDL_FUNCTION __FUNCTION__
86# define SDL_FUNCTION "???"
88#define SDL_FILE __FILE__
89#define SDL_LINE __LINE__
109#define SDL_NULL_WHILE_LOOP_CONDITION (0,0)
111#define SDL_NULL_WHILE_LOOP_CONDITION (0)
114#define SDL_disabled_assert(condition) \
115 do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION)
137#if (SDL_ASSERT_LEVEL > 0)
154 const char *file,
int line)
155#if defined(__clang__)
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 = { \
187 0, 0, #condition, 0, 0, 0, 0 \
189 const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
190 if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
192 } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \
193 SDL_AssertBreakpoint(); \
197 } while (SDL_NULL_WHILE_LOOP_CONDITION)
202#if SDL_ASSERT_LEVEL == 0
203# define SDL_assert(condition) SDL_disabled_assert(condition)
204# define SDL_assert_release(condition) SDL_disabled_assert(condition)
205# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
206#elif SDL_ASSERT_LEVEL == 1
207# define SDL_assert(condition) SDL_disabled_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 == 2
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_disabled_assert(condition)
214#elif SDL_ASSERT_LEVEL == 3
215# define SDL_assert(condition) SDL_enabled_assert(condition)
216# define SDL_assert_release(condition) SDL_enabled_assert(condition)
217# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition)
219# error Unknown assertion level.
223#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