dynapi: Remove DISABLE_JUMP_MAGIC.

The "jump magic" codepath was never written, and would have involved a lot
of low-level and platform/processor/compiler specific work.

A better solution is for compilers to treat the function call in the jump
table functions as a tail call, which would effectively produce the same
result in a portable way.

Clang already has a way to do this that we could add later. But this wouldn't
need a separate "jump magic" section.
This commit is contained in:
Ryan C. Gordon 2024-04-21 22:16:48 -04:00
parent 9128f92f38
commit 39d0e62ef5
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
1 changed files with 0 additions and 15 deletions

View File

@ -64,10 +64,6 @@ static void SDL_InitDynamicAPI(void);
/* behold, the macro salsa! */
/* !!! FIXME: ...disabled...until we write it. :) */
#define DISABLE_JUMP_MAGIC 1
#if DISABLE_JUMP_MAGIC
/* Can't use the macro for varargs nonsense. This is atrocious. */
#define SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, logname, prio) \
_static void SDLCALL SDL_Log##logname##name(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) \
@ -178,7 +174,6 @@ static void SDL_InitDynamicAPI(void);
SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Warn, WARN) \
SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Error, ERROR) \
SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Critical, CRITICAL)
#endif
/* Typedefs for function pointers for jump table, and predeclare funcs */
/* The DEFAULT funcs will init jump table and then call real function. */
@ -211,7 +206,6 @@ static SDL_DYNAPI_jump_table jump_table = {
};
/* Default functions init the function table then call right thing. */
#if DISABLE_JUMP_MAGIC
#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) \
static rc SDLCALL fn##_DEFAULT params \
{ \
@ -223,13 +217,8 @@ static SDL_DYNAPI_jump_table jump_table = {
#undef SDL_DYNAPI_PROC
#undef SDL_DYNAPI_PROC_NO_VARARGS
SDL_DYNAPI_VARARGS(static, _DEFAULT, SDL_InitDynamicAPI())
#else
/* !!! FIXME: need the jump magic. */
#error Write me.
#endif
/* Public API functions to jump into the jump table. */
#if DISABLE_JUMP_MAGIC
#define SDL_DYNAPI_PROC(rc, fn, params, args, ret) \
rc SDLCALL fn params \
{ \
@ -240,10 +229,6 @@ SDL_DYNAPI_VARARGS(static, _DEFAULT, SDL_InitDynamicAPI())
#undef SDL_DYNAPI_PROC
#undef SDL_DYNAPI_PROC_NO_VARARGS
SDL_DYNAPI_VARARGS(, , )
#else
/* !!! FIXME: need the jump magic. */
#error Write me.
#endif
/* we make this a static function so we can call the correct one without the
system's dynamic linker resolving to the wrong version of this. */