Go to the documentation of this file.
22 #include "SDL_config.h"
29 #define INCL_DOSERRORS
49 #define SDL_DYNAPI_VERSION 1
61 #define DISABLE_JUMP_MAGIC 1
63 #if DISABLE_JUMP_MAGIC
65 #define SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, logname, prio) \
66 _static void SDLCALL SDL_Log##logname##name(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \
67 va_list ap; initcall; va_start(ap, fmt); \
68 jump_table.SDL_LogMessageV(category, SDL_LOG_PRIORITY_##prio, fmt, ap); \
72 #define SDL_DYNAPI_VARARGS(_static, name, initcall) \
73 _static int SDLCALL SDL_SetError##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \
75 va_list ap; initcall; va_start(ap, fmt); \
76 jump_table.SDL_vsnprintf(buf, sizeof (buf), fmt, ap); \
78 return jump_table.SDL_SetError("%s", buf); \
80 _static int SDLCALL SDL_sscanf##name(const char *buf, SDL_SCANF_FORMAT_STRING const char *fmt, ...) { \
81 int retval; va_list ap; initcall; va_start(ap, fmt); \
82 retval = jump_table.SDL_vsscanf(buf, fmt, ap); \
86 _static int SDLCALL SDL_snprintf##name(SDL_OUT_Z_CAP(maxlen) char *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \
87 int retval; va_list ap; initcall; va_start(ap, fmt); \
88 retval = jump_table.SDL_vsnprintf(buf, maxlen, fmt, ap); \
92 _static void SDLCALL SDL_Log##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \
93 va_list ap; initcall; va_start(ap, fmt); \
94 jump_table.SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap); \
97 _static void SDLCALL SDL_LogMessage##name(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \
98 va_list ap; initcall; va_start(ap, fmt); \
99 jump_table.SDL_LogMessageV(category, priority, fmt, ap); \
102 SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Verbose, VERBOSE) \
103 SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Debug, DEBUG) \
104 SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Info, INFO) \
105 SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Warn, WARN) \
106 SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Error, ERROR) \
107 SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Critical, CRITICAL)
114 #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \
115 typedef rc (SDLCALL *SDL_DYNAPIFN_##fn) params; \
116 static rc SDLCALL fn##_DEFAULT params; \
117 extern rc SDLCALL fn##_REAL params;
119 #undef SDL_DYNAPI_PROC
123 #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) SDL_DYNAPIFN_##fn fn;
125 #undef SDL_DYNAPI_PROC
129 #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) static rc SDLCALL fn##_DEFAULT params;
131 #undef SDL_DYNAPI_PROC
135 #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) fn##_DEFAULT,
137 #undef SDL_DYNAPI_PROC
141 #if DISABLE_JUMP_MAGIC
142 #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \
143 static rc SDLCALL fn##_DEFAULT params { \
144 SDL_InitDynamicAPI(); \
145 ret jump_table.fn args; \
147 #define SDL_DYNAPI_PROC_NO_VARARGS 1
149 #undef SDL_DYNAPI_PROC
150 #undef SDL_DYNAPI_PROC_NO_VARARGS
158 #if DISABLE_JUMP_MAGIC
159 #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \
160 rc SDLCALL fn params { ret jump_table.fn args; }
161 #define SDL_DYNAPI_PROC_NO_VARARGS 1
163 #undef SDL_DYNAPI_PROC
164 #undef SDL_DYNAPI_PROC_NO_VARARGS
186 #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) jump_table.fn = fn##_REAL;
188 #undef SDL_DYNAPI_PROC
215 #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
216 #ifndef WIN32_LEAN_AND_MEAN
217 #define WIN32_LEAN_AND_MEAN 1
222 HANDLE lib = LoadLibraryA(
fname);
225 retval = GetProcAddress(lib, sym);
233 #elif defined(unix) || defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__) || defined(__QNX__)
237 void *lib = dlopen(
fname, RTLD_NOW | RTLD_LOCAL);
248 #elif defined(__OS2__)
254 if (DosLoadModule(error,
sizeof(error),
fname, &hmodule) == NO_ERROR) {
255 if (DosQueryProcAddr(hmodule, 0, sym, &
retval) != NO_ERROR) {
256 DosFreeModule(hmodule);
263 #error Please define your platform.
269 const char *caption =
"SDL Dynamic API Failure!";
271 #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
272 MessageBoxA(
NULL, msg, caption, MB_OK | MB_ICONERROR);
274 fprintf(stderr,
"\n\n%s\n%s\n\n", caption, msg);
282 #if defined(__WATCOMC__)
284 #pragma aux SDL_ExitProcess aborts;
292 const char *libname = SDL_getenv_REAL(
"SDL_DYNAMIC_API");
299 dynapi_warn(
"Couldn't load overriding SDL library. Please fix or remove the SDL_DYNAMIC_API environment variable. Using the default SDL.");
306 dynapi_warn(
"Couldn't override SDL library. Using a newer SDL build might help. Please fix or remove the SDL_DYNAMIC_API environment variable. Using the default SDL.");
317 dynapi_warn(
"Failed to initialize internal SDL dynapi. As this would otherwise crash, we have to abort now.");
344 #if !SDL_ATOMIC_DISABLED
346 SDL_AtomicLock_REAL(&
lock);
349 if (!already_initialized) {
354 #if !SDL_ATOMIC_DISABLED
355 SDL_AtomicUnlock_REAL(&
lock);
SDL_NORETURN void SDL_ExitProcess(int exitcode)
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld fname[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld_src SRC pixld MASK if DST_R else pixld DST_R endif if src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head if pixblock_size cache_preload_simple endif process_pixblock_tail pixinterleave dst_w_basereg irp if pixblock_size chunk_size tst beq if DST_W else pixst DST_W else mov ORIG_W endif add lsl if lsl endif if lsl endif lsl endif lsl endif lsl endif subs mov DST_W if regs_shortage str endif bge start_of_loop_label endm macro generate_composite_function
Sint32 SDL_DYNAPI_entry(Uint32, void *, Uint32)
#define SDL_DYNAPI_VARARGS(_static, name, initcall)
static SDL_INLINE void * get_sdlapi_entry(const char *fname, const char *sym)
static Sint32 initialize_jumptable(Uint32 apiver, void *table, Uint32 tablesize)
static SDL_DYNAPI_jump_table jump_table
static void SDL_InitDynamicAPI(void)
static void SDL_InitDynamicAPILocked(void)
Sint32(* SDL_DYNAPI_ENTRYFN)(Uint32 apiver, void *table, Uint32 tablesize)
#define SDL_DYNAPI_VERSION
static void dynapi_warn(const char *msg)
GLenum GLsizei GLenum GLenum const void * table