42 #define SDL_DYNAPI_VERSION 1 54 #define DISABLE_JUMP_MAGIC 1 56 #if DISABLE_JUMP_MAGIC 58 #define SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, logname, prio) \ 59 _static void SDL_Log##logname##name(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ 60 va_list ap; initcall; va_start(ap, fmt); \ 61 jump_table.SDL_LogMessageV(category, SDL_LOG_PRIORITY_##prio, fmt, ap); \ 65 #define SDL_DYNAPI_VARARGS(_static, name, initcall) \ 66 _static int SDL_SetError##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ 68 va_list ap; initcall; va_start(ap, fmt); \ 69 jump_table.SDL_vsnprintf(buf, sizeof (buf), fmt, ap); \ 71 return jump_table.SDL_SetError("%s", buf); \ 73 _static int SDL_sscanf##name(const char *buf, SDL_SCANF_FORMAT_STRING const char *fmt, ...) { \ 74 int retval; va_list ap; initcall; va_start(ap, fmt); \ 75 retval = jump_table.SDL_vsscanf(buf, fmt, ap); \ 79 _static int SDL_snprintf##name(SDL_OUT_Z_CAP(maxlen) char *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ 80 int retval; va_list ap; initcall; va_start(ap, fmt); \ 81 retval = jump_table.SDL_vsnprintf(buf, maxlen, fmt, ap); \ 85 _static void SDL_Log##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ 86 va_list ap; initcall; va_start(ap, fmt); \ 87 jump_table.SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap); \ 90 _static void SDL_LogMessage##name(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ 91 va_list ap; initcall; va_start(ap, fmt); \ 92 jump_table.SDL_LogMessageV(category, priority, fmt, ap); \ 95 SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Verbose, VERBOSE) \ 96 SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Debug, DEBUG) \ 97 SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Info, INFO) \ 98 SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Warn, WARN) \ 99 SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Error, ERROR) \ 100 SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Critical, CRITICAL) 107 #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \ 108 typedef rc (*SDL_DYNAPIFN_##fn) params; \ 109 static rc fn##_DEFAULT params; \ 110 extern rc fn##_REAL params; 112 #undef SDL_DYNAPI_PROC 116 #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) SDL_DYNAPIFN_##fn fn; 118 #undef SDL_DYNAPI_PROC 122 #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) static rc fn##_DEFAULT params; 124 #undef SDL_DYNAPI_PROC 128 #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) fn##_DEFAULT, 130 #undef SDL_DYNAPI_PROC 134 #if DISABLE_JUMP_MAGIC 135 #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \ 136 static rc fn##_DEFAULT params { \ 137 SDL_InitDynamicAPI(); \ 138 ret jump_table.fn args; \ 140 #define SDL_DYNAPI_PROC_NO_VARARGS 1 142 #undef SDL_DYNAPI_PROC 143 #undef SDL_DYNAPI_PROC_NO_VARARGS 151 #if DISABLE_JUMP_MAGIC 152 #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \ 153 rc fn params { ret jump_table.fn args; } 154 #define SDL_DYNAPI_PROC_NO_VARARGS 1 156 #undef SDL_DYNAPI_PROC 157 #undef SDL_DYNAPI_PROC_NO_VARARGS 179 }
else if (tablesize >
sizeof (jump_table)) {
184 #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) jump_table.fn = fn##_REAL; 186 #undef SDL_DYNAPI_PROC 189 if (output_jump_table != &jump_table) {
190 jump_table.SDL_memcpy(output_jump_table, &jump_table, tablesize);
201 #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) 202 #ifndef WIN32_LEAN_AND_MEAN 203 #define WIN32_LEAN_AND_MEAN 1 208 HANDLE lib = LoadLibraryA(fname);
211 retval = GetProcAddress(lib, sym);
219 #elif defined(__HAIKU__) 220 #include <os/kernel/image.h> 223 image_id lib = load_add_on(fname);
226 if (get_image_symbol(lib, sym, B_SYMBOL_TYPE_TEXT, &retval) != B_NO_ERROR) {
233 #elif defined(unix) || defined(__unix__) || defined(__APPLE__) 237 void *lib = dlopen(fname, RTLD_NOW | RTLD_LOCAL);
240 retval = dlsym(lib, sym);
241 if (retval ==
NULL) {
248 #error Please define your platform. 255 const char *libname = SDL_getenv_REAL(
"SDL_DYNAMIC_API");
301 #if !SDL_ATOMIC_DISABLED 303 SDL_AtomicLock_REAL(&lock);
306 if (!already_initialized) {
311 #if !SDL_ATOMIC_DISABLED 312 SDL_AtomicUnlock_REAL(&lock);
GLenum GLsizei GLenum GLenum const void * table
static SDL_INLINE void * get_sdlapi_entry(const char *fname, const char *sym)
uint32_t Uint32
An unsigned 32-bit integer type.
Sint32(* SDL_DYNAPI_ENTRYFN)(Uint32 apiver, void *table, Uint32 tablesize)
#define SDL_DYNAPI_VERSION
static void SDL_InitDynamicAPI(void)
static SDL_DYNAPI_jump_table jump_table
static void SDL_InitDynamicAPILocked(void)
int32_t Sint32
A signed 32-bit integer type.
Sint32 SDL_DYNAPI_entry(Uint32, void *, Uint32)
#define SDL_DYNAPI_VARARGS(_static, name, initcall)
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 local 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