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)
152 const char *file,
int line)
154#if __has_feature(attribute_analyzer_noreturn)
155 __attribute__((analyzer_noreturn))
165#ifndef SDL_AssertBreakpoint
166#if defined(ANDROID) && defined(assert)
168#define SDL_AssertBreakpoint()
170#define SDL_AssertBreakpoint() SDL_TriggerBreakpoint()
181#define SDL_enabled_assert(condition) \
183 while ( !(condition) ) { \
184 static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; \
185 const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
186 if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
188 } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \
189 SDL_AssertBreakpoint(); \
193 } while (SDL_NULL_WHILE_LOOP_CONDITION)
196#if SDL_ASSERT_LEVEL == 0
197# define SDL_assert(condition) SDL_disabled_assert(condition)
198# define SDL_assert_release(condition) SDL_disabled_assert(condition)
199# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
200#elif SDL_ASSERT_LEVEL == 1
201# define SDL_assert(condition) SDL_disabled_assert(condition)
202# define SDL_assert_release(condition) SDL_enabled_assert(condition)
203# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
204#elif SDL_ASSERT_LEVEL == 2
205# define SDL_assert(condition) SDL_enabled_assert(condition)
206# define SDL_assert_release(condition) SDL_enabled_assert(condition)
207# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
208#elif SDL_ASSERT_LEVEL == 3
209# define SDL_assert(condition) SDL_enabled_assert(condition)
210# define SDL_assert_release(condition) SDL_enabled_assert(condition)
211# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition)
213# error Unknown assertion level.
217#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