From 1152433df99a5b9ee35d1d459e68edc1ee32a086 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Wed, 17 Sep 2025 19:24:02 +0200 Subject: [PATCH 1/2] Add SDL_internal macro for internal use --- src/SDL_internal.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/SDL_internal.h b/src/SDL_internal.h index 0d5d203f8f4ea..3d027f794bd89 100644 --- a/src/SDL_internal.h +++ b/src/SDL_internal.h @@ -266,6 +266,24 @@ extern "C" { #include "SDL_utils_c.h" #include "SDL_hashtable.h" +/* SDL_ExitProcess is not declared in any public header, although + it is shared between some parts of SDL, because we don't want + anything calling it without an extremely good reason. */ +#ifdef __WATCOMC__ +extern void SDL_ExitProcess(int exitcode); +#pragma aux SDL_ExitProcess aborts; +#endif +extern SDL_NORETURN void SDL_ExitProcess(int exitcode); + +#ifdef HAVE_LIBC +#define SDL_abort() abort() +#else +#define SDL_abort() do { \ + SDL_TriggerBreakpoint(); \ + SDL_ExitProcess(42); \ + } while (0) +#endif + #define PUSH_SDL_ERROR() \ { char *_error = SDL_strdup(SDL_GetError()); From c014e49b27b7a9b0a3cdfee3fdc6f586c3d1299b Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Wed, 17 Sep 2025 19:32:27 +0200 Subject: [PATCH 2/2] Use SDL_abort when encountering a internal fatal SDL_assertion error --- src/SDL_assert.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/SDL_assert.c b/src/SDL_assert.c index 2440d04b1ec34..93ddf8b585242 100644 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -120,15 +120,6 @@ static void SDL_GenerateAssertionReport(void) } } -/* This is not declared in any header, although it is shared between some - parts of SDL, because we don't want anything calling it without an - extremely good reason. */ -#ifdef __WATCOMC__ -extern void SDL_ExitProcess(int exitcode); -#pragma aux SDL_ExitProcess aborts; -#endif -extern SDL_NORETURN void SDL_ExitProcess(int exitcode); - #ifdef __WATCOMC__ static void SDL_AbortAssertion(void); #pragma aux SDL_AbortAssertion aborts; @@ -136,7 +127,7 @@ static void SDL_AbortAssertion(void); static SDL_NORETURN void SDL_AbortAssertion(void) { SDL_Quit(); - SDL_ExitProcess(42); + SDL_abort(); } static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, void *userdata) @@ -361,7 +352,7 @@ SDL_AssertState SDL_ReportAssertion(SDL_AssertData *data, const char *func, cons if (assertion_running == 2) { SDL_AbortAssertion(); } else if (assertion_running == 3) { // Abort asserted! - SDL_ExitProcess(42); + SDL_abort(); } else { while (1) { // do nothing but spin; what else can you do?! }