2015-06-21 17:33:46 +02:00
|
|
|
/*
|
|
|
|
|
Simple DirectMedia Layer
|
2025-01-01 07:45:41 -08:00
|
|
|
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
2015-06-21 17:33:46 +02:00
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
|
appreciated but is not required.
|
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
|
misrepresented as being the original software.
|
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
|
*/
|
2022-11-29 18:34:15 -08:00
|
|
|
#include "SDL_internal.h"
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2024-09-05 23:59:23 -04:00
|
|
|
#if defined(SDL_PLATFORM_WINDOWS)
|
2015-06-21 17:33:46 +02:00
|
|
|
#include "core/windows/SDL_windows.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "SDL_assert_c.h"
|
|
|
|
|
#include "video/SDL_sysvideo.h"
|
|
|
|
|
|
2024-09-05 23:59:23 -04:00
|
|
|
#if defined(SDL_PLATFORM_WINDOWS)
|
2015-06-21 17:33:46 +02:00
|
|
|
#ifndef WS_OVERLAPPEDWINDOW
|
|
|
|
|
#define WS_OVERLAPPEDWINDOW 0
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-01-24 02:40:51 +01:00
|
|
|
#ifdef SDL_PLATFORM_EMSCRIPTEN
|
2025-03-16 18:43:19 +01:00
|
|
|
#include <emscripten.h>
|
2017-05-19 14:51:03 -04:00
|
|
|
#endif
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// The size of the stack buffer to use for rendering assert messages.
|
2022-04-29 14:05:15 +02:00
|
|
|
#define SDL_MAX_ASSERT_MESSAGE_STACK 256
|
2017-05-19 14:51:03 -04:00
|
|
|
|
2022-12-10 17:19:00 +01:00
|
|
|
static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, void *userdata);
|
2015-06-21 17:33:46 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* We keep all triggered assertions in a singly-linked list so we can
|
|
|
|
|
* generate a report later.
|
|
|
|
|
*/
|
2022-12-10 17:19:00 +01:00
|
|
|
static SDL_AssertData *triggered_assertions = NULL;
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2017-05-19 12:54:17 -04:00
|
|
|
#ifndef SDL_THREADS_DISABLED
|
2023-04-28 07:31:12 -07:00
|
|
|
static SDL_Mutex *assertion_mutex = NULL;
|
2017-05-19 12:54:17 -04:00
|
|
|
#endif
|
|
|
|
|
|
2015-06-21 17:33:46 +02:00
|
|
|
static SDL_AssertionHandler assertion_handler = SDL_PromptAssertion;
|
|
|
|
|
static void *assertion_userdata = NULL;
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
2022-11-30 12:51:59 -08:00
|
|
|
static void debug_print(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
|
2015-06-21 17:33:46 +02:00
|
|
|
#endif
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
static void debug_print(const char *fmt, ...)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
|
|
|
|
va_list ap;
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
|
SDL_LogMessageV(SDL_LOG_CATEGORY_ASSERT, SDL_LOG_PRIORITY_WARN, fmt, ap);
|
|
|
|
|
va_end(ap);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-10 17:19:00 +01:00
|
|
|
static void SDL_AddAssertionToReport(SDL_AssertData *data)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
|
|
|
|
/* (data) is always a static struct defined with the assert macros, so
|
|
|
|
|
we don't have to worry about copying or allocating them. */
|
|
|
|
|
data->trigger_count++;
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
if (data->trigger_count == 1) { // not yet added?
|
2015-06-21 17:33:46 +02:00
|
|
|
data->next = triggered_assertions;
|
|
|
|
|
triggered_assertions = data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-05 23:59:23 -04:00
|
|
|
#if defined(SDL_PLATFORM_WINDOWS)
|
2022-11-30 12:51:59 -08:00
|
|
|
#define ENDLINE "\r\n"
|
2022-05-11 19:39:30 +02:00
|
|
|
#else
|
2022-11-30 12:51:59 -08:00
|
|
|
#define ENDLINE "\n"
|
2022-05-11 19:39:30 +02:00
|
|
|
#endif
|
|
|
|
|
|
2022-12-10 17:19:00 +01:00
|
|
|
static int SDL_RenderAssertMessage(char *buf, size_t buf_len, const SDL_AssertData *data)
|
2022-11-30 12:51:59 -08:00
|
|
|
{
|
2022-05-11 19:39:30 +02:00
|
|
|
return SDL_snprintf(buf, buf_len,
|
2022-11-30 12:51:59 -08:00
|
|
|
"Assertion failure at %s (%s:%d), triggered %u %s:" ENDLINE " '%s'",
|
|
|
|
|
data->function, data->filename, data->linenum,
|
|
|
|
|
data->trigger_count, (data->trigger_count == 1) ? "time" : "times",
|
|
|
|
|
data->condition);
|
2022-05-11 19:39:30 +02:00
|
|
|
}
|
2015-06-21 17:33:46 +02:00
|
|
|
|
|
|
|
|
static void SDL_GenerateAssertionReport(void)
|
|
|
|
|
{
|
2022-12-10 17:19:00 +01:00
|
|
|
const SDL_AssertData *item = triggered_assertions;
|
2015-06-21 17:33:46 +02:00
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// only do this if the app hasn't assigned an assertion handler.
|
2023-11-09 22:29:15 +01:00
|
|
|
if ((item) && (assertion_handler != SDL_PromptAssertion)) {
|
2015-06-21 17:33:46 +02:00
|
|
|
debug_print("\n\nSDL assertion report.\n");
|
|
|
|
|
debug_print("All SDL assertions between last init/quit:\n\n");
|
|
|
|
|
|
2023-11-09 22:29:15 +01:00
|
|
|
while (item) {
|
2015-06-21 17:33:46 +02:00
|
|
|
debug_print(
|
|
|
|
|
"'%s'\n"
|
|
|
|
|
" * %s (%s:%d)\n"
|
|
|
|
|
" * triggered %u time%s.\n"
|
|
|
|
|
" * always ignore: %s.\n",
|
|
|
|
|
item->condition, item->function, item->filename,
|
|
|
|
|
item->linenum, item->trigger_count,
|
|
|
|
|
(item->trigger_count == 1) ? "" : "s",
|
|
|
|
|
item->always_ignore ? "yes" : "no");
|
|
|
|
|
item = item->next;
|
|
|
|
|
}
|
|
|
|
|
debug_print("\n");
|
|
|
|
|
|
|
|
|
|
SDL_ResetAssertionReport();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 12:41:06 -04:00
|
|
|
/* 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. */
|
2023-03-30 20:26:31 +02:00
|
|
|
#ifdef __WATCOMC__
|
2019-10-30 15:43:49 +01:00
|
|
|
extern void SDL_ExitProcess(int exitcode);
|
2018-06-13 14:45:02 +03:00
|
|
|
#pragma aux SDL_ExitProcess aborts;
|
|
|
|
|
#endif
|
2019-10-30 15:43:49 +01:00
|
|
|
extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2023-03-30 20:26:31 +02:00
|
|
|
#ifdef __WATCOMC__
|
2022-11-30 12:51:59 -08:00
|
|
|
static void SDL_AbortAssertion(void);
|
2018-06-13 14:45:02 +03:00
|
|
|
#pragma aux SDL_AbortAssertion aborts;
|
|
|
|
|
#endif
|
2019-06-12 15:35:06 -04:00
|
|
|
static SDL_NORETURN void SDL_AbortAssertion(void)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
|
|
|
|
SDL_Quit();
|
|
|
|
|
SDL_ExitProcess(42);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-10 17:19:00 +01:00
|
|
|
static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, void *userdata)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
2022-12-10 17:19:00 +01:00
|
|
|
SDL_AssertState state = SDL_ASSERTION_ABORT;
|
2015-06-21 17:33:46 +02:00
|
|
|
SDL_Window *window;
|
|
|
|
|
SDL_MessageBoxData messagebox;
|
|
|
|
|
SDL_MessageBoxButtonData buttons[] = {
|
2022-11-30 12:51:59 -08:00
|
|
|
{ 0, SDL_ASSERTION_RETRY, "Retry" },
|
|
|
|
|
{ 0, SDL_ASSERTION_BREAK, "Break" },
|
|
|
|
|
{ 0, SDL_ASSERTION_ABORT, "Abort" },
|
|
|
|
|
{ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT,
|
|
|
|
|
SDL_ASSERTION_IGNORE, "Ignore" },
|
|
|
|
|
{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT,
|
|
|
|
|
SDL_ASSERTION_ALWAYS_IGNORE, "Always Ignore" }
|
2015-06-21 17:33:46 +02:00
|
|
|
};
|
|
|
|
|
int selected;
|
|
|
|
|
|
2022-04-29 14:05:15 +02:00
|
|
|
char stack_buf[SDL_MAX_ASSERT_MESSAGE_STACK];
|
|
|
|
|
char *message = stack_buf;
|
|
|
|
|
size_t buf_len = sizeof(stack_buf);
|
2022-05-11 19:39:30 +02:00
|
|
|
int len;
|
2022-04-29 14:05:15 +02:00
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
(void)userdata; // unused in default handler.
|
2015-06-21 17:33:46 +02:00
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Assume the output will fit...
|
2022-05-11 19:39:30 +02:00
|
|
|
len = SDL_RenderAssertMessage(message, buf_len, data);
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// .. and if it didn't, try to allocate as much room as we actually need.
|
2022-05-15 09:33:28 -07:00
|
|
|
if (len >= (int)buf_len) {
|
2024-09-02 12:56:44 -07:00
|
|
|
if (SDL_size_add_check_overflow(len, 1, &buf_len)) {
|
2022-04-29 14:05:15 +02:00
|
|
|
message = (char *)SDL_malloc(buf_len);
|
2022-05-11 19:39:30 +02:00
|
|
|
if (message) {
|
|
|
|
|
len = SDL_RenderAssertMessage(message, buf_len, data);
|
|
|
|
|
} else {
|
|
|
|
|
message = stack_buf;
|
2022-04-29 14:05:15 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-05-11 19:39:30 +02:00
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Something went very wrong
|
2022-05-11 19:39:30 +02:00
|
|
|
if (len < 0) {
|
|
|
|
|
if (message != stack_buf) {
|
|
|
|
|
SDL_free(message);
|
|
|
|
|
}
|
|
|
|
|
return SDL_ASSERTION_ABORT;
|
|
|
|
|
}
|
2015-06-21 17:33:46 +02:00
|
|
|
|
|
|
|
|
debug_print("\n\n%s\n\n", message);
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// let env. variable override, so unit tests won't block in a GUI.
|
2024-08-18 20:53:07 -04:00
|
|
|
const char *hint = SDL_GetHint(SDL_HINT_ASSERT);
|
|
|
|
|
if (hint) {
|
2022-04-29 14:05:15 +02:00
|
|
|
if (message != stack_buf) {
|
|
|
|
|
SDL_free(message);
|
|
|
|
|
}
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2024-08-18 20:53:07 -04:00
|
|
|
if (SDL_strcmp(hint, "abort") == 0) {
|
2015-06-21 17:33:46 +02:00
|
|
|
return SDL_ASSERTION_ABORT;
|
2024-08-18 20:53:07 -04:00
|
|
|
} else if (SDL_strcmp(hint, "break") == 0) {
|
2015-06-21 17:33:46 +02:00
|
|
|
return SDL_ASSERTION_BREAK;
|
2024-08-18 20:53:07 -04:00
|
|
|
} else if (SDL_strcmp(hint, "retry") == 0) {
|
2015-06-21 17:33:46 +02:00
|
|
|
return SDL_ASSERTION_RETRY;
|
2024-08-18 20:53:07 -04:00
|
|
|
} else if (SDL_strcmp(hint, "ignore") == 0) {
|
2015-06-21 17:33:46 +02:00
|
|
|
return SDL_ASSERTION_IGNORE;
|
2024-08-18 20:53:07 -04:00
|
|
|
} else if (SDL_strcmp(hint, "always_ignore") == 0) {
|
2015-06-21 17:33:46 +02:00
|
|
|
return SDL_ASSERTION_ALWAYS_IGNORE;
|
|
|
|
|
} else {
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
return SDL_ASSERTION_ABORT; // oh well.
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Leave fullscreen mode, if possible (scary!)
|
2023-09-16 15:36:01 -04:00
|
|
|
window = SDL_GetToplevelForKeyboardFocus();
|
2015-06-21 17:33:46 +02:00
|
|
|
if (window) {
|
2023-02-01 11:45:31 -08:00
|
|
|
if (window->fullscreen_exclusive) {
|
2015-06-21 17:33:46 +02:00
|
|
|
SDL_MinimizeWindow(window);
|
|
|
|
|
} else {
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// !!! FIXME: ungrab the input if we're not fullscreen?
|
|
|
|
|
// No need to mess with the window
|
2015-06-21 17:33:46 +02:00
|
|
|
window = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Show a messagebox if we can, otherwise fall back to stdio
|
2015-06-21 17:33:46 +02:00
|
|
|
SDL_zero(messagebox);
|
|
|
|
|
messagebox.flags = SDL_MESSAGEBOX_WARNING;
|
|
|
|
|
messagebox.window = window;
|
|
|
|
|
messagebox.title = "Assertion Failed";
|
|
|
|
|
messagebox.message = message;
|
|
|
|
|
messagebox.numbuttons = SDL_arraysize(buttons);
|
|
|
|
|
messagebox.buttons = buttons;
|
|
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
if (SDL_ShowMessageBox(&messagebox, &selected)) {
|
2015-06-21 17:33:46 +02:00
|
|
|
if (selected == -1) {
|
|
|
|
|
state = SDL_ASSERTION_IGNORE;
|
|
|
|
|
} else {
|
2022-12-10 17:19:00 +01:00
|
|
|
state = (SDL_AssertState)selected;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2022-11-27 17:38:43 +01:00
|
|
|
} else {
|
2024-10-15 18:02:07 -04:00
|
|
|
#ifdef SDL_PLATFORM_PRIVATE_ASSERT
|
|
|
|
|
SDL_PRIVATE_PROMPTASSERTION();
|
|
|
|
|
#elif defined(SDL_PLATFORM_EMSCRIPTEN)
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// This is nasty, but we can't block on a custom UI.
|
2022-11-30 12:51:59 -08:00
|
|
|
for (;;) {
|
2024-08-22 09:21:26 -07:00
|
|
|
bool okay = true;
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
/* *INDENT-OFF* */ // clang-format off
|
2025-03-16 18:43:19 +01:00
|
|
|
int reply = MAIN_THREAD_EM_ASM_INT({
|
2017-05-19 14:51:03 -04:00
|
|
|
var str =
|
2019-01-29 12:19:03 +00:00
|
|
|
UTF8ToString($0) + '\n\n' +
|
2017-05-19 14:51:03 -04:00
|
|
|
'Abort/Retry/Ignore/AlwaysIgnore? [ariA] :';
|
|
|
|
|
var reply = window.prompt(str, "i");
|
|
|
|
|
if (reply === null) {
|
|
|
|
|
reply = "i";
|
|
|
|
|
}
|
2025-03-16 18:43:19 +01:00
|
|
|
return reply.length === 1 ? reply.charCodeAt(0) : -1;
|
2017-05-19 14:51:03 -04:00
|
|
|
}, message);
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
/* *INDENT-ON* */ // clang-format on
|
2017-05-19 14:51:03 -04:00
|
|
|
|
2025-03-16 18:43:19 +01:00
|
|
|
switch (reply) {
|
|
|
|
|
case 'a':
|
2017-05-19 14:51:03 -04:00
|
|
|
state = SDL_ASSERTION_ABORT;
|
2025-03-16 18:43:19 +01:00
|
|
|
break;
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
#if 0 // (currently) no break functionality on Emscripten
|
2025-03-16 18:43:19 +01:00
|
|
|
case 'b':
|
2022-11-30 12:51:59 -08:00
|
|
|
state = SDL_ASSERTION_BREAK;
|
2025-03-16 18:43:19 +01:00
|
|
|
break;
|
2022-11-30 12:51:59 -08:00
|
|
|
#endif
|
2025-03-16 18:43:19 +01:00
|
|
|
case 'r':
|
2017-05-19 14:51:03 -04:00
|
|
|
state = SDL_ASSERTION_RETRY;
|
2025-03-16 18:43:19 +01:00
|
|
|
break;
|
|
|
|
|
case 'i':
|
2017-05-19 14:51:03 -04:00
|
|
|
state = SDL_ASSERTION_IGNORE;
|
2025-03-16 18:43:19 +01:00
|
|
|
break;
|
|
|
|
|
case 'A':
|
2017-05-19 14:51:03 -04:00
|
|
|
state = SDL_ASSERTION_ALWAYS_IGNORE;
|
2025-03-16 18:43:19 +01:00
|
|
|
break;
|
|
|
|
|
default:
|
2024-08-22 09:21:26 -07:00
|
|
|
okay = false;
|
2025-03-16 18:43:19 +01:00
|
|
|
break;
|
2017-05-19 14:51:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (okay) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-12 21:54:16 +01:00
|
|
|
#elif defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_3DS)
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// this is a little hacky.
|
2022-11-30 12:51:59 -08:00
|
|
|
for (;;) {
|
2015-06-21 17:33:46 +02:00
|
|
|
char buf[32];
|
2022-12-01 16:07:03 -05:00
|
|
|
(void)fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : ");
|
|
|
|
|
(void)fflush(stderr);
|
2022-11-30 12:51:59 -08:00
|
|
|
if (fgets(buf, sizeof(buf), stdin) == NULL) {
|
2015-06-21 17:33:46 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-15 21:21:19 -07:00
|
|
|
if (SDL_strncmp(buf, "a", 1) == 0) {
|
2015-06-21 17:33:46 +02:00
|
|
|
state = SDL_ASSERTION_ABORT;
|
|
|
|
|
break;
|
2017-10-15 21:21:19 -07:00
|
|
|
} else if (SDL_strncmp(buf, "b", 1) == 0) {
|
2015-06-21 17:33:46 +02:00
|
|
|
state = SDL_ASSERTION_BREAK;
|
|
|
|
|
break;
|
2017-10-15 21:21:19 -07:00
|
|
|
} else if (SDL_strncmp(buf, "r", 1) == 0) {
|
2015-06-21 17:33:46 +02:00
|
|
|
state = SDL_ASSERTION_RETRY;
|
|
|
|
|
break;
|
2017-10-15 21:21:19 -07:00
|
|
|
} else if (SDL_strncmp(buf, "i", 1) == 0) {
|
2015-06-21 17:33:46 +02:00
|
|
|
state = SDL_ASSERTION_IGNORE;
|
|
|
|
|
break;
|
2017-10-15 21:21:19 -07:00
|
|
|
} else if (SDL_strncmp(buf, "A", 1) == 0) {
|
2015-06-21 17:33:46 +02:00
|
|
|
state = SDL_ASSERTION_ALWAYS_IGNORE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-12 21:54:16 +01:00
|
|
|
#else
|
|
|
|
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Assertion Failed", message, window);
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
#endif // HAVE_STDIO_H
|
2017-05-19 14:51:03 -04:00
|
|
|
}
|
2015-06-21 17:33:46 +02:00
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Re-enter fullscreen mode
|
2015-06-21 17:33:46 +02:00
|
|
|
if (window) {
|
|
|
|
|
SDL_RestoreWindow(window);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-29 14:05:15 +02:00
|
|
|
if (message != stack_buf) {
|
|
|
|
|
SDL_free(message);
|
|
|
|
|
}
|
2015-06-21 17:33:46 +02:00
|
|
|
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-23 11:29:41 -07:00
|
|
|
SDL_AssertState SDL_ReportAssertion(SDL_AssertData *data, const char *func, const char *file, int line)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
2022-12-10 17:19:00 +01:00
|
|
|
SDL_AssertState state = SDL_ASSERTION_IGNORE;
|
2017-05-19 12:54:17 -04:00
|
|
|
static int assertion_running = 0;
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2017-05-19 12:54:17 -04:00
|
|
|
#ifndef SDL_THREADS_DISABLED
|
|
|
|
|
static SDL_SpinLock spinlock = 0;
|
2024-01-18 03:39:55 -08:00
|
|
|
SDL_LockSpinlock(&spinlock);
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
if (!assertion_mutex) { // never called SDL_Init()?
|
2015-06-21 17:33:46 +02:00
|
|
|
assertion_mutex = SDL_CreateMutex();
|
2023-11-09 22:29:15 +01:00
|
|
|
if (!assertion_mutex) {
|
2024-01-18 03:39:55 -08:00
|
|
|
SDL_UnlockSpinlock(&spinlock);
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
return SDL_ASSERTION_IGNORE; // oh well, I guess.
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
2024-01-18 03:39:55 -08:00
|
|
|
SDL_UnlockSpinlock(&spinlock);
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2022-12-13 14:03:40 -08:00
|
|
|
SDL_LockMutex(assertion_mutex);
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
#endif // !SDL_THREADS_DISABLED
|
2015-06-21 17:33:46 +02:00
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// doing this because Visual C is upset over assigning in the macro.
|
2015-06-21 17:33:46 +02:00
|
|
|
if (data->trigger_count == 0) {
|
|
|
|
|
data->function = func;
|
|
|
|
|
data->filename = file;
|
|
|
|
|
data->linenum = line;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_AddAssertionToReport(data);
|
|
|
|
|
|
|
|
|
|
assertion_running++;
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
if (assertion_running > 1) { // assert during assert! Abort.
|
2015-06-21 17:33:46 +02:00
|
|
|
if (assertion_running == 2) {
|
|
|
|
|
SDL_AbortAssertion();
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
} else if (assertion_running == 3) { // Abort asserted!
|
2015-06-21 17:33:46 +02:00
|
|
|
SDL_ExitProcess(42);
|
|
|
|
|
} else {
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
while (1) { // do nothing but spin; what else can you do?!
|
2022-11-30 12:51:59 -08:00
|
|
|
}
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!data->always_ignore) {
|
|
|
|
|
state = assertion_handler(data, assertion_userdata);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
switch (state) {
|
|
|
|
|
case SDL_ASSERTION_ALWAYS_IGNORE:
|
|
|
|
|
state = SDL_ASSERTION_IGNORE;
|
2024-08-22 09:21:26 -07:00
|
|
|
data->always_ignore = true;
|
2022-11-30 12:51:59 -08:00
|
|
|
break;
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
case SDL_ASSERTION_IGNORE:
|
|
|
|
|
case SDL_ASSERTION_RETRY:
|
|
|
|
|
case SDL_ASSERTION_BREAK:
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
break; // macro handles these.
|
2019-06-14 22:29:13 -04:00
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
case SDL_ASSERTION_ABORT:
|
|
|
|
|
SDL_AbortAssertion();
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// break; ...shouldn't return, but oh well.
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assertion_running--;
|
2017-05-19 12:54:17 -04:00
|
|
|
|
|
|
|
|
#ifndef SDL_THREADS_DISABLED
|
2015-06-21 17:33:46 +02:00
|
|
|
SDL_UnlockMutex(assertion_mutex);
|
2017-05-19 12:54:17 -04:00
|
|
|
#endif
|
2015-06-21 17:33:46 +02:00
|
|
|
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SDL_AssertionsQuit(void)
|
|
|
|
|
{
|
2022-02-05 10:44:26 +01:00
|
|
|
#if SDL_ASSERT_LEVEL > 0
|
2015-06-21 17:33:46 +02:00
|
|
|
SDL_GenerateAssertionReport();
|
2017-05-19 12:54:17 -04:00
|
|
|
#ifndef SDL_THREADS_DISABLED
|
2023-11-09 22:29:15 +01:00
|
|
|
if (assertion_mutex) {
|
2015-06-21 17:33:46 +02:00
|
|
|
SDL_DestroyMutex(assertion_mutex);
|
|
|
|
|
assertion_mutex = NULL;
|
|
|
|
|
}
|
2017-05-19 12:54:17 -04:00
|
|
|
#endif
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
#endif // SDL_ASSERT_LEVEL > 0
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SDL_SetAssertionHandler(SDL_AssertionHandler handler, void *userdata)
|
|
|
|
|
{
|
|
|
|
|
if (handler != NULL) {
|
|
|
|
|
assertion_handler = handler;
|
|
|
|
|
assertion_userdata = userdata;
|
|
|
|
|
} else {
|
|
|
|
|
assertion_handler = SDL_PromptAssertion;
|
|
|
|
|
assertion_userdata = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-10 17:19:00 +01:00
|
|
|
const SDL_AssertData *SDL_GetAssertionReport(void)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
|
|
|
|
return triggered_assertions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SDL_ResetAssertionReport(void)
|
|
|
|
|
{
|
2022-12-10 17:19:00 +01:00
|
|
|
SDL_AssertData *next = NULL;
|
|
|
|
|
SDL_AssertData *item;
|
2023-11-09 22:29:15 +01:00
|
|
|
for (item = triggered_assertions; item; item = next) {
|
2022-12-10 17:19:00 +01:00
|
|
|
next = (SDL_AssertData *)item->next;
|
2024-08-22 09:21:26 -07:00
|
|
|
item->always_ignore = false;
|
2015-06-21 17:33:46 +02:00
|
|
|
item->trigger_count = 0;
|
|
|
|
|
item->next = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
triggered_assertions = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_AssertionHandler SDL_GetDefaultAssertionHandler(void)
|
|
|
|
|
{
|
|
|
|
|
return SDL_PromptAssertion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_AssertionHandler SDL_GetAssertionHandler(void **userdata)
|
|
|
|
|
{
|
2023-11-09 22:29:15 +01:00
|
|
|
if (userdata) {
|
2015-06-21 17:33:46 +02:00
|
|
|
*userdata = assertion_userdata;
|
|
|
|
|
}
|
|
|
|
|
return assertion_handler;
|
|
|
|
|
}
|