Added wrapped libSDL1.2, libSDL2.0, libGL, libGLU and libopenal

This commit is contained in:
ptitSeb 2021-03-07 20:19:58 +01:00
parent 343174fd47
commit 4c7cbe4128
23 changed files with 8841 additions and 173 deletions

View File

@ -127,6 +127,8 @@ set(ELFLOADER_SRC
"${BOX64_ROOT}/src/librarian/library.c"
"${BOX64_ROOT}/src/libtools/auxval.c"
"${BOX64_ROOT}/src/libtools/myalign.c"
"${BOX64_ROOT}/src/libtools/sdl1rwops.c"
"${BOX64_ROOT}/src/libtools/sdl2rwops.c"
"${BOX64_ROOT}/src/libtools/signals.c"
"${BOX64_ROOT}/src/libtools/threads.c"
"${BOX64_ROOT}/src/tools/box64stack.c"
@ -145,6 +147,11 @@ set(WRAPPEDS
"${BOX64_ROOT}/src/wrapped/wrappedlibdl.c"
"${BOX64_ROOT}/src/wrapped/wrappedlibpthread.c"
"${BOX64_ROOT}/src/wrapped/wrappedlibrt.c"
"${BOX64_ROOT}/src/wrapped/wrappedlibgl.c"
"${BOX64_ROOT}/src/wrapped/wrappedlibglu.c"
"${BOX64_ROOT}/src/wrapped/wrappedsdl1.c"
"${BOX64_ROOT}/src/wrapped/wrappedsdl2.c"
"${BOX64_ROOT}/src/wrapped/wrappedopenal.c"
"${BOX64_ROOT}/src/wrapped/wrappedldlinux.c"
)

View File

@ -3,7 +3,7 @@
import os
import sys
values = ['E', 'e', 'v', 'c', 'w', 'i', 'I', 'C', 'W', 'u', 'U', 'f', 'd', 'D', 'K', 'l', 'L', 'p', 'V', 'O', 'S', '2', 'P', 'G', 'N', 'M']
values = ['E', 'e', 'v', 'c', 'w', 'i', 'I', 'C', 'W', 'u', 'U', 'f', 'd', 'D', 'K', 'l', 'L', 'p', 'V', 'O', 'S', 'N', 'M', 'H']
def splitchar(s):
try:
ret = [len(s), values.index(s[0])]
@ -224,17 +224,6 @@ def main(root, defines, files, ver):
#include "regs.h"
#include "x64emu.h"
typedef union ui64_s {
int64_t i;
uint64_t u;
uint32_t d[2];
} ui64_t;
typedef struct _2uint_struct_s {
uint32_t a;
uint32_t b;
} _2uint_struct_t;
extern void* my__IO_2_1_stderr_;
extern void* my__IO_2_1_stdin_ ;
extern void* my__IO_2_1_stdout_;
@ -252,33 +241,6 @@ static void* io_convert(void* v)
return v;
}
typedef struct my_GValue_s
{
int g_type;
union {
int v_int;
int64_t v_int64;
uint64_t v_uint64;
float v_float;
double v_double;
void* v_pointer;
} data[2];
} my_GValue_t;
static void alignGValue(my_GValue_t* v, void* value)
{
v->g_type = *(int*)value;
memcpy(v->data, value+4, 2*sizeof(double));
}
static void unalignGValue(void* value, my_GValue_t* v)
{
*(int*)value = v->g_type;
memcpy(value+4, v->data, 2*sizeof(double));
}
void* VulkanFromx86(void* src, void** save);
void VulkanTox86(void* src, void* save);
#define ST0val ST0.d
int of_convert(int);
@ -309,11 +271,9 @@ typedef void (*wrapper_t)(x64emu_t* emu, uintptr_t fnc);
// O = libc O_ flags bitfield
// S = _IO_2_1_stdXXX_ pointer (or FILE*)
// Q = ...
// 2 = struct of 2 uint
// P = Vulkan struture pointer
// G = a single GValue pointer
// N = ... automatically sending 1 arg
// M = ... automatically sending 2 args
// H = Huge 128bits value/struct
"""
}
@ -349,8 +309,8 @@ typedef void (*wrapper_t)(x64emu_t* emu, uintptr_t fnc);
# First part: typedefs
for v in gbl["()"]:
# E e v c w i I C W u U f d D K l L p V O S 2 P G N M
types = ["x64emu_t*", "x64emu_t**", "void", "int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t", "float", "double", "long double", "double", "intptr_t", "uintptr_t", "void*", "void*", "int32_t", "void*", "_2uint_struct_t", "void*", "void*", "...", "..."]
# E e v c w i I C W u U f d D K l L p V O S N M H
types = ["x64emu_t*", "x64emu_t**", "void", "int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t", "float", "double", "long double", "double", "intptr_t", "uintptr_t", "void*", "void*", "int32_t", "void*", "...", "...", "unsigned __int128"]
if len(values) != len(types):
raise NotImplementedError("len(values) = {lenval} != len(types) = {lentypes}".format(lenval=len(values), lentypes=len(types)))
@ -359,8 +319,8 @@ typedef void (*wrapper_t)(x64emu_t* emu, uintptr_t fnc);
for k in gbl_idxs:
file.write("\n#if " + k + "\n")
for v in gbl[k]:
# E e v c w i I C W u U f d D K l L p V O S 2 P G N M
types = ["x64emu_t*", "x64emu_t**", "void", "int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t", "float", "double", "long double", "double", "intptr_t", "uintptr_t", "void*", "void*", "int32_t", "void*", "_2uint_struct_t", "void*", "void*", "...", "..."]
# E e v c w i I C W u U f d D K l L p V O S N M H
types = ["x64emu_t*", "x64emu_t**", "void", "int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t", "float", "double", "long double", "double", "intptr_t", "uintptr_t", "void*", "void*", "int32_t", "void*", "...", "...", "unsigned __int128"]
if len(values) != len(types):
raise NotImplementedError("len(values) = {lenval} != len(types) = {lentypes}".format(lenval=len(values), lentypes=len(types)))
@ -375,17 +335,17 @@ typedef void (*wrapper_t)(x64emu_t* emu, uintptr_t fnc);
# Helper variables
reg_arg = ["R_RDI", "R_RSI", "R_RDX", "R_RCX", "R_R8", "R_R9"]
# vreg: value is in a general register
# E e v c w i I C W u U f d D K l L p V O S 2 P G N, M
vreg = [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 2]
# E e v c w i I C W u U f d D K l L p V O S N M H
vreg = [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 2, 2]
# vxmm: value is in a XMM register
# E e v c w i I C W u U f d D K l L p V O S 2 P G N, M
vxmm = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
# E e v c w i I C W u U f d D K l L p V O S N M H
vxmm = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
# vother: value is elsewere
# E e v c w i I C W u U f d D K l L p V O S 2 P G N, M
vother = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0]
# E e v c w i I C W u U f d D K l L p V O S N M, H
vother = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0]
# vstack: value is on the stack (or out of register)
# E e v c w i I C W u U f d D K l L p V O S 2 P G N, M
vstack = [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 2]
# E e v c w i I C W u U f d D K l L p V O S N M, H
vstack = [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 0, 1, 1, 1, 2, 2]
arg_s = [
"", # E
"", # e
@ -408,11 +368,9 @@ typedef void (*wrapper_t)(x64emu_t* emu, uintptr_t fnc);
"", # V
"of_convert(*(int32_t*)(R_RSP + {p})), ", # O
"io_convert(*(void**)(R_RSP + {p})), ", # S
"(_2uint_struct_t){{*(uintptr_t*)(R_RSP + {p}),*(uintptr_t*)(R_RSP + {p} + 4)}}, ", # 2
"", # P
"", # G
"*(void**)(R_RSP + {p}), ", # N
"*(void**)(R_RSP + {p}),*(void**)(R_RSP + {p} + 8), ", # M
"*(unsigned __int128)(R_RSP + {p}), " # H
]
arg_r = [
"", # E
@ -436,11 +394,9 @@ typedef void (*wrapper_t)(x64emu_t* emu, uintptr_t fnc);
"", # V
"of_convert((int32_t){p}), ", # O
"io_convert((void*){p}), ", # S
"", # 2
"", # P
"", # G
"(void*){p}, ", # N
"(void*){p}, ", # M
"#error use pp instead, ", #H
]
arg_x = [
"", # E
@ -464,11 +420,9 @@ typedef void (*wrapper_t)(x64emu_t* emu, uintptr_t fnc);
"", # V
"", # O
"", # S
"", # 2
"", # P
"", # G
"", # N
"", # M
"", # H
]
arg_o = [
"emu, ", # E
@ -492,11 +446,9 @@ typedef void (*wrapper_t)(x64emu_t* emu, uintptr_t fnc);
"(void*)(R_RSP + {p}), ", # V
"", # O
"", # S
"", # 2
"arg{p}, ", # P
"&arg{p}, ", # G
"", # N
"", # M
"", # H
]
vals = [
@ -521,11 +473,9 @@ typedef void (*wrapper_t)(x64emu_t* emu, uintptr_t fnc);
"\n#error Invalid return type: va_list\n", # V
"\n#error Invalid return type: at_flags\n", # O
"\n#error Invalid return type: _io_file*\n", # S
"\n#error Invalid return type: _2uint_struct\n", # 2
"\n#error Invalid return type: Vulkan Struct\n", # P
"\n#error Invalid return type: GValue Pointer\n", # G
"\n#error Invalid return type: ... with 1 arg\n", # N
"\n#error Invalid return type: ... with 2 args\n", # M
"unsigned __int128 u128 = fn({0}); R_RAX=(u128&0xFFFFFFFFFFFFFFFFL); R_RDX=(u128>>64)&0xFFFFFFFFFFFFFFFFL;", # H
]
# Asserts
if len(values) != len(arg_s):

View File

@ -180,8 +180,8 @@ void FreeBox64Context(box64context_t** context)
FreeBridge(&ctx->system);
// freeGLProcWrapper(ctx);
// freeALProcWrapper(ctx);
freeGLProcWrapper(ctx);
freeALProcWrapper(ctx);
void* ptr;

21
src/include/sdl1rwops.h Executable file
View File

@ -0,0 +1,21 @@
#ifndef __SDL1RWOPS_H__
#define __SDL1RWOPS_H__
typedef struct SDL1_RWops_s SDL1_RWops_t; // the actual SDL1 SDL_RWops
typedef struct x64emu_s x64emu_t;
typedef SDL1_RWops_t* (*sdl1_allocrw)();
typedef void (*sdl1_freerw)(SDL1_RWops_t*);
// each function will be added to dictionary, and each native functions will be wrapped so they run in emulated world
SDL1_RWops_t* AddNativeRW(x64emu_t* emu, SDL1_RWops_t* ops);
SDL1_RWops_t* RWNativeStart(x64emu_t* emu, SDL1_RWops_t* ops); // put Native RW function, wrapping emulated (callback style) ones if needed
void RWNativeEnd(SDL1_RWops_t* ops); // put back emulated function back in place
int32_t RWNativeSeek(SDL1_RWops_t *ops, int32_t offset, int32_t whence);
uint32_t RWNativeRead(SDL1_RWops_t* ops, void* ptr, uint32_t size, uint32_t maxnum);
int32_t RWNativeWrite(SDL1_RWops_t *ops, const void *ptr, int32_t size, int32_t num);
int32_t RWNativeClose(SDL1_RWops_t* ops);
void RWSetType(SDL1_RWops_t* r, int t);
#endif

31
src/include/sdl2rwops.h Executable file
View File

@ -0,0 +1,31 @@
#ifndef __SDL2RWOPS_H__
#define __SDL2RWOPS_H__
typedef struct SDL2_RWops_s SDL2_RWops_t; // the actual SDL1 SDL_RWops
typedef struct x64emu_s x64emu_t;
typedef SDL2_RWops_t* (*sdl2_allocrw)();
typedef void (*sdl2_freerw)(SDL2_RWops_t*);
typedef struct SDL2RWSave_s {
int anyEmu;
void* size;
void* seek;
void* read;
void* write;
void* close;
void* s1;
void* s2;
} SDL2RWSave_t;
// each function will be added to dictionary, and each native functions will be wrapped so they run in emulated world
SDL2_RWops_t* AddNativeRW2(x64emu_t* emu, SDL2_RWops_t* ops);
SDL2_RWops_t* RWNativeStart2(x64emu_t* emu, SDL2_RWops_t* ops); // put Native RW function, wrapping emulated (callback style) ones if needed
void RWNativeEnd2(SDL2_RWops_t* ops); // put back emulated function back in place
int64_t RWNativeSeek2(SDL2_RWops_t *ops, int64_t offset, int32_t whence);
uint32_t RWNativeRead2(SDL2_RWops_t* ops, void* ptr, uint32_t size, uint32_t maxnum);
int32_t RWNativeWrite2(SDL2_RWops_t *ops, const void *ptr, int32_t size, int32_t num);
int32_t RWNativeClose2(SDL2_RWops_t* ops);
#endif

View File

@ -5,22 +5,21 @@
GO("libc.so.6", libc)
GO("libpthread.so.0", libpthread)
GO("librt.so.1", librt)
//GO("libGL.so.1", libgl)
//GO("libGL.so", libgl)
//GO("libGLU.so.1", libglu)
GO("libGL.so.1", libgl)
GO("libGL.so", libgl)
GO("libGLU.so.1", libglu)
//GO("libX11.so.6", libx11)
//GO("libasound.so.2", libasound)
GO("libdl.so.2", libdl)
GO("libm.so.6", libm)
//GO("libSDL2-2.0.so.0", sdl2)
//GO("libSDL2-2.0.so.1", sdl2)
//GO("libSDL2.so", sdl2)
//GO("libsdl2-2.0.so.0", sdl2)
GO("libSDL2-2.0.so.0", sdl2)
GO("libSDL2-2.0.so.1", sdl2)
GO("libSDL2.so", sdl2)
GO("libsdl2-2.0.so.0", sdl2)
//GO("libSDL2_mixer-2.0.so.0", sdl2mixer)
//GO("libSDL2_image-2.0.so.0", sdl2image)
//GO("libSDL2_ttf-2.0.so.0", sdl2ttf)
//GO("libSDL-1.2.so.0", sdl1)
//GO("libSDL-1.1.so.0", sdl1)
GO("libSDL-1.2.so.0", sdl1)
//GO("libSDL_mixer-1.2.so.0", sdl1mixer)
//GO("libSDL_image-1.2.so.0", sdl1image)
//GO("libSDL_ttf-2.0.so.0", sdl1ttf)

182
src/libtools/sdl1rwops.c Executable file
View File

@ -0,0 +1,182 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "sdl1rwops.h"
#include "debug.h"
#include "wrapper.h"
#include "box64context.h"
#include "x64run.h"
#include "x64emu.h"
#include "emu/x64emu_private.h"
#include "librarian/library_private.h"
#include "bridge.h"
#include "callback.h"
typedef struct SDL1_RWops_s SDL1_RWops_t;
typedef int32_t (*sdl1_seek)(SDL1_RWops_t *context, int32_t offset, int32_t whence);
typedef int32_t (*sdl1_read)(SDL1_RWops_t *context, void *ptr, int32_t size, int32_t maxnum);
typedef int32_t (*sdl1_write)(SDL1_RWops_t *context, const void *ptr, int32_t size, int32_t num);
typedef int32_t (*sdl1_close)(SDL1_RWops_t *context);
#define BOX64RW 0xBECF4572 // random signature value
typedef struct SDL1_RWops_s {
sdl1_seek seek;
sdl1_read read;
sdl1_write write;
sdl1_close close;
uint32_t type;
union {
struct {
int autoclose;
FILE *fp;
} stdio;
struct {
uint8_t *base;
uint8_t *here;
uint8_t *stop;
} mem;
struct {
void *data1;
} unknown;
struct {
SDL1_RWops_t *orig;
sdl1_freerw custom_free;
} my;
} hidden;
} SDL1_RWops_t;
EXPORT int32_t my_native_seek(SDL1_RWops_t *context, int32_t offset, int32_t whence)
{
return context->hidden.my.orig->seek(context->hidden.my.orig, offset, whence);
}
EXPORT int32_t my_native_read(SDL1_RWops_t *context, void *ptr, int32_t size, int32_t maxnum)
{
return context->hidden.my.orig->read(context->hidden.my.orig, ptr, size, maxnum);
}
EXPORT int32_t my_native_write(SDL1_RWops_t *context, const void *ptr, int32_t size, int32_t num)
{
return context->hidden.my.orig->write(context->hidden.my.orig, ptr, size, num);
}
EXPORT int32_t my_native_close(SDL1_RWops_t *context)
{
int32_t ret = context->hidden.my.orig->close(context->hidden.my.orig);
context->hidden.my.custom_free(context);
return ret;
}
EXPORT int32_t my_emulated_seek(SDL1_RWops_t *context, int32_t offset, int32_t whence)
{
return (int32_t)RunFunction(my_context, (uintptr_t)context->hidden.my.orig->seek, 3, context->hidden.my.orig, offset, whence);
}
EXPORT int32_t my_emulated_read(SDL1_RWops_t *context, void *ptr, int32_t size, int32_t maxnum)
{
return (int32_t)RunFunction(my_context, (uintptr_t)context->hidden.my.orig->read, 4, context->hidden.my.orig, ptr, size, maxnum);
}
EXPORT int32_t my_emulated_write(SDL1_RWops_t *context, const void *ptr, int32_t size, int32_t num)
{
return (int32_t)RunFunction(my_context, (uintptr_t)context->hidden.my.orig->write, 4, context->hidden.my.orig, ptr, size, num);
}
EXPORT int32_t my_emulated_close(SDL1_RWops_t *context)
{
return (int32_t)RunFunction(my_context, (uintptr_t)context->hidden.my.orig->close, 1, context->hidden.my.orig);
}
SDL1_RWops_t* AddNativeRW(x64emu_t* emu, SDL1_RWops_t* ops)
{
if(!ops)
return NULL;
uintptr_t fnc;
bridge_t* system = emu->context->system;
sdl1_allocrw Alloc = (sdl1_allocrw)emu->context->sdl1allocrw;
sdl1_freerw Free = (sdl1_freerw)emu->context->sdl1freerw;
SDL1_RWops_t* newrw = Alloc();
newrw->type = BOX64RW;
newrw->hidden.my.orig = ops;
newrw->hidden.my.custom_free = Free;
// get or create wrapper, add it to map and change to the emulated one if rw
#define GO(A, W) \
fnc = AddCheckBridge(system, W, my_native_##A, 0); \
newrw->A = (sdl1_##A)fnc;
GO(seek, iFpii)
GO(read, iFppii)
GO(write, iFppii)
GO(close, iFp)
#undef GO
return newrw;
}
// put Native RW function, wrapping emulated (callback style) ones if needed
SDL1_RWops_t* RWNativeStart(x64emu_t* emu, SDL1_RWops_t* ops)
{
if(!ops)
return NULL;
if(ops->type == BOX64RW)
return ops->hidden.my.orig;
sdl1_allocrw Alloc = (sdl1_allocrw)emu->context->sdl1allocrw;
SDL1_RWops_t* newrw = Alloc();
newrw->type = BOX64RW;
newrw->hidden.my.orig = ops;
// create wrapper
#define GO(A, W) \
newrw->A = my_emulated_##A;
GO(seek, iFpii)
GO(read, iFppii)
GO(write, iFppii)
GO(close, iFp)
#undef GO
return newrw;
}
// put back emulated function back in place
void RWNativeEnd(SDL1_RWops_t* ops)
{
if(!ops)
return;
if(ops->type != BOX64RW)
return; // do nothing
ops->hidden.my.custom_free(ops);
}
int32_t RWNativeSeek(SDL1_RWops_t *ops, int32_t offset, int32_t whence)
{
return ops->seek(ops, offset, whence);
}
uint32_t RWNativeRead(SDL1_RWops_t* ops, void* ptr, uint32_t size, uint32_t maxnum)
{
return ops->read(ops, ptr, size, maxnum);
}
int32_t RWNativeWrite(SDL1_RWops_t *ops, const void *ptr, int32_t size, int32_t num)
{
return ops->write(ops, ptr, size, num);
}
int32_t RWNativeClose(SDL1_RWops_t* ops)
{
return ops->close(ops);
}
void RWSetType(SDL1_RWops_t* r, int awesome)
{
if(r)
r->type = awesome; // I like shoot'em up :D
}

185
src/libtools/sdl2rwops.c Executable file
View File

@ -0,0 +1,185 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "sdl2rwops.h"
#include "debug.h"
#include "wrapper.h"
#include "box64context.h"
#include "x64run.h"
#include "x64emu.h"
#include "emu/x64emu_private.h"
#include "librarian/library_private.h"
#include "bridge.h"
#include "callback.h"
typedef struct SDL2_RWops_s SDL2_RWops_t;
typedef int64_t (*sdl2_size)(SDL2_RWops_t *context);
typedef int64_t (*sdl2_seek)(SDL2_RWops_t *context, int64_t offset, int32_t whence);
typedef int32_t (*sdl2_read)(SDL2_RWops_t *context, void *ptr, int32_t size, int32_t maxnum);
typedef int32_t (*sdl2_write)(SDL2_RWops_t *context, const void *ptr, int32_t size, int32_t num);
typedef int32_t (*sdl2_close)(SDL2_RWops_t *context);
#define BOX64RW 0x79 // random signature value
typedef struct SDL2_RWops_s {
sdl2_size size;
sdl2_seek seek;
sdl2_read read;
sdl2_write write;
sdl2_close close;
uint32_t type;
union {
struct {
int autoclose;
FILE *fp;
} stdio;
struct {
uint8_t *base;
uint8_t *here;
uint8_t *stop;
} mem;
struct {
void *data1;
} unknown;
struct {
SDL2_RWops_t *orig;
sdl2_freerw custom_free;
} my;
} hidden;
} SDL2_RWops_t;
EXPORT int64_t my2_native_size(SDL2_RWops_t *context)
{
return context->hidden.my.orig->size(context->hidden.my.orig);
}
EXPORT int64_t my2_native_seek(SDL2_RWops_t *context, int64_t offset, int32_t whence)
{
return context->hidden.my.orig->seek(context->hidden.my.orig, offset, whence);
}
EXPORT int32_t my2_native_read(SDL2_RWops_t *context, void *ptr, int32_t size, int32_t maxnum)
{
return context->hidden.my.orig->read(context->hidden.my.orig, ptr, size, maxnum);
}
EXPORT int32_t my2_native_write(SDL2_RWops_t *context, const void *ptr, int32_t size, int32_t num)
{
return context->hidden.my.orig->write(context->hidden.my.orig, ptr, size, num);
}
EXPORT int32_t my2_native_close(SDL2_RWops_t *context)
{
int32_t ret = context->hidden.my.orig->close(context->hidden.my.orig);
context->hidden.my.custom_free(context);
return ret;
}
EXPORT int64_t my2_emulated_size(SDL2_RWops_t *context)
{
return (int64_t)RunFunction(my_context, (uintptr_t)context->hidden.my.orig->size, 1, context->hidden.my.orig);
}
EXPORT int64_t my2_emulated_seek(SDL2_RWops_t *context, int64_t offset, int32_t whence)
{
return (int64_t)RunFunction(my_context, (uintptr_t)context->hidden.my.orig->seek, 3, context->hidden.my.orig, offset, whence);
}
EXPORT int32_t my2_emulated_read(SDL2_RWops_t *context, void *ptr, int32_t size, int32_t maxnum)
{
return (int32_t)RunFunction(my_context, (uintptr_t)context->hidden.my.orig->read, 4, context->hidden.my.orig, ptr, size, maxnum);
}
EXPORT int32_t my2_emulated_write(SDL2_RWops_t *context, const void *ptr, int32_t size, int32_t num)
{
return (int32_t)RunFunction(my_context, (uintptr_t)context->hidden.my.orig->write, 4, context->hidden.my.orig, ptr, size, num);
}
EXPORT int32_t my2_emulated_close(SDL2_RWops_t *context)
{
return (int32_t)RunFunction(my_context, (uintptr_t)context->hidden.my.orig->close, 1, context->hidden.my.orig);
}
SDL2_RWops_t* AddNativeRW2(x64emu_t* emu, SDL2_RWops_t* ops)
{
if(!ops)
return NULL;
uintptr_t fnc;
bridge_t* system = emu->context->system;
sdl2_allocrw Alloc = (sdl2_allocrw)emu->context->sdl2allocrw;
sdl2_freerw Free = (sdl2_freerw)emu->context->sdl2freerw;
SDL2_RWops_t* newrw = Alloc();
newrw->type = BOX64RW;
newrw->hidden.my.orig = ops;
newrw->hidden.my.custom_free = Free;
// get or create wrapper, add it to map and change to the emulated one if rw
#define GO(A, W) \
fnc = AddCheckBridge(system, W, my2_native_##A, 0); \
newrw->A = (sdl2_##A)fnc;
GO(size, IFp)
GO(seek, IFpIi)
GO(read, iFppii)
GO(write, iFppii)
GO(close, iFp)
#undef GO
return newrw;
}
// put Native RW function, wrapping emulated (callback style) ones if needed
SDL2_RWops_t* RWNativeStart2(x64emu_t* emu, SDL2_RWops_t* ops)
{
if(!ops)
return NULL;
if(ops->type == BOX64RW)
return ops->hidden.my.orig;
sdl2_allocrw Alloc = (sdl2_allocrw)emu->context->sdl2allocrw;
SDL2_RWops_t* newrw = Alloc();
newrw->type = BOX64RW;
newrw->hidden.my.orig = ops;
newrw->hidden.my.custom_free = (sdl2_freerw)emu->context->sdl2freerw;
// create wrapper
#define GO(A, W) \
newrw->A = my2_emulated_##A;
GO(size, IFp)
GO(seek, IFpIi)
GO(read, iFppii)
GO(write, iFppii)
GO(close, iFp)
#undef GO
return newrw;
}
void RWNativeEnd2(SDL2_RWops_t* ops)
{
if(!ops || ops->type != BOX64RW)
return; // do nothing
ops->hidden.my.custom_free(ops);
}
int64_t RWNativeSeek2(SDL2_RWops_t *ops, int64_t offset, int32_t whence)
{
return ops->seek(ops, offset, whence);
}
uint32_t RWNativeRead2(SDL2_RWops_t* ops, void* ptr, uint32_t size, uint32_t maxnum)
{
return ops->read(ops, ptr, size, maxnum);
}
int32_t RWNativeWrite2(SDL2_RWops_t *ops, const void *ptr, int32_t size, int32_t num)
{
return ops->write(ops, ptr, size, num);
}
int32_t RWNativeClose2(SDL2_RWops_t* ops)
{
return ops->close(ops);
}

View File

@ -1,7 +1,13 @@
#() vFE
#() vFv
#() vFi
#() vFu
#() vFf
#() vFd
#() vFp
#() cFi
#() cFu
#() cFp
#() iFE
#() iFv
#() iFi
@ -13,29 +19,75 @@
#() IFf
#() IFd
#() IFp
#() WFi
#() WFp
#() uFv
#() uFi
#() uFu
#() uFp
#() UFv
#() UFV
#() fFi
#() fFf
#() fFp
#() dFi
#() dFd
#() dFp
#() lFp
#() LFv
#() LFp
#() pFE
#() pFv
#() pFi
#() pFu
#() pFL
#() pFp
#() HFi
#() HFp
#() vFEp
#() vFii
#() vFiu
#() vFif
#() vFid
#() vFip
#() vFWW
#() vFui
#() vFuu
#() vFuf
#() vFud
#() vFup
#() vFfi
#() vFff
#() vFfp
#() vFdd
#() vFpi
#() vFpp
#() cFpp
#() iFEp
#() iFii
#() iFip
#() iFIi
#() iFui
#() iFuu
#() iFup
#() iFUU
#() iFLL
#() iFLp
#() iFpi
#() iFpC
#() iFpu
#() iFpf
#() iFpp
#() IFEp
#() CFui
#() CFpi
#() uFEp
#() uFui
#() uFuu
#() uFup
#() uFpi
#() uFpp
#() UFEp
#() fFif
#() fFfi
#() fFff
@ -44,19 +96,101 @@
#() dFdi
#() dFdd
#() dFdp
#() dFpp
#() LFpL
#() pFEp
#() pFii
#() pFui
#() pFuu
#() pFup
#() pFlp
#() pFLL
#() pFpi
#() pFpu
#() pFpL
#() pFpp
#() pFpV
#() HFpi
#() vFEpu
#() vFEpp
#() vFEpV
#() vFiii
#() vFiip
#() vFiui
#() vFiuu
#() vFiup
#() vFiff
#() vFidd
#() vFipi
#() vFipu
#() vFipp
#() vFuii
#() vFuiI
#() vFuiu
#() vFuif
#() vFuid
#() vFuip
#() vFuui
#() vFuuu
#() vFuuf
#() vFuud
#() vFuup
#() vFuff
#() vFudd
#() vFupi
#() vFfff
#() vFfpp
#() vFddd
#() vFdpp
#() vFpii
#() vFpiu
#() vFpif
#() vFpid
#() vFpip
#() vFppi
#() vFppu
#() vFppp
#() iFEip
#() iFEWW
#() iFEup
#() iFEpi
#() iFEpp
#() iFEpV
#() iFiip
#() iFipu
#() iFipp
#() iFuup
#() iFuff
#() iFfff
#() iFpii
#() iFpiu
#() iFpip
#() iFpuu
#() iFpuL
#() iFpup
#() iFpfu
#() iFpff
#() iFppi
#() iFppu
#() iFppL
#() iFppp
#() iFppV
#() IFpIi
#() IFppi
#() uFEpW
#() uFEpu
#() uFEpU
#() uFipu
#() uFuip
#() uFuuu
#() uFuup
#() uFupu
#() uFupp
#() uFpiu
#() uFppi
#() uFppu
#() UFppi
#() fFuii
#() fFfff
#() fFffp
#() dFddd
@ -64,23 +198,392 @@
#() pFEip
#() pFEpi
#() pFEpp
#() pFipi
#() pFipp
#() pFIpi
#() pFuii
#() pFupi
#() pFUpi
#() pFpii
#() pFpiu
#() pFpiL
#() pFpip
#() pFpuu
#() pFppi
#() pFppu
#() pFppL
#() pFppp
#() vFEipV
#() vFEpip
#() vFEpup
#() vFiiii
#() vFiiip
#() vFiuip
#() vFiuuu
#() vFiupu
#() vFiupV
#() vFifff
#() vFiddd
#() vFipup
#() vFippp
#() vFuiii
#() vFuiip
#() vFuiui
#() vFuiuu
#() vFuiup
#() vFuifi
#() vFuiff
#() vFuidd
#() vFuipi
#() vFuipu
#() vFuipp
#() vFuuii
#() vFuuiu
#() vFuuip
#() vFuuui
#() vFuuuu
#() vFuuuf
#() vFuuud
#() vFuuup
#() vFuupi
#() vFuupp
#() vFufff
#() vFuddd
#() vFupii
#() vFuppi
#() vFffff
#() vFdddd
#() vFpiii
#() vFpiip
#() vFpipp
#() vFpdii
#() vFpddd
#() vFppip
#() vFppui
#() vFpppp
#() cFpiii
#() iFEupp
#() iFEpip
#() iFEppi
#() iFEppp
#() iFiiiu
#() iFippp
#() iFuipp
#() iFuuff
#() iFuppp
#() iFpiiu
#() iFpiip
#() iFpipp
#() iFpCCC
#() iFpWWu
#() iFpuup
#() iFpupV
#() iFppii
#() iFppiu
#() iFppip
#() iFpppi
#() iFpppp
#() IFEpIi
#() uFuuuu
#() uFpCCC
#() uFpuip
#() uFpuuu
#() uFpppi
#() LFpLLp
#() pFEupp
#() pFEppi
#() pFEppp
#() pFiiiu
#() pFiiup
#() pFuiii
#() pFpiii
#() pFpipp
#() pFpuii
#() pFppiL
#() pFppuL
#() pFppLL
#() pFpppi
#() pFpppu
#() pFpppL
#() pFpppp
#() vFEpuup
#() vFiiiii
#() vFiiiiu
#() vFiiuup
#() vFiipii
#() vFiuiip
#() vFiuipi
#() vFiuuuu
#() vFiffff
#() vFidddd
#() vFilill
#() vFipipu
#() vFipipp
#() vFipupi
#() vFuiiii
#() vFuiiiu
#() vFuiiip
#() vFuiiup
#() vFuiIII
#() vFuiuii
#() vFuiuiu
#() vFuiuip
#() vFuiuuu
#() vFuiuup
#() vFuiupi
#() vFuiupu
#() vFuifff
#() vFuiddd
#() vFuipii
#() vFuipip
#() vFuipup
#() vFuippp
#() vFuuiii
#() vFuuiui
#() vFuuiuu
#() vFuuiup
#() vFuuipi
#() vFuuipu
#() vFuuipp
#() vFuuuii
#() vFuuuiu
#() vFuuuip
#() vFuuuui
#() vFuuuuu
#() vFuuuup
#() vFuupii
#() vFuffff
#() vFudddd
#() vFupupi
#() vFuppip
#() vFupppp
#() vFfffff
#() vFddddp
#() vFpiiii
#() vFpipii
#() vFpuipp
#() vFpddii
#() vFppWui
#() vFpppii
#() vFppppp
#() iFEppiV
#() iFEpppp
#() iFiiupp
#() iFipppi
#() iFpiiii
#() iFpiiip
#() iFpiiuu
#() iFpipii
#() iFpippp
#() iFpCCCC
#() iFppipi
#() iFppupi
#() iFppppp
#() IFppIII
#() uFEppuu
#() uFiuuuu
#() uFuiiiu
#() uFpCCCC
#() uFpuuuu
#() uFppppp
#() LFppppp
#() pFuiiiu
#() pFuiipp
#() pFpuiii
#() pFppipi
#() pFppuup
#() pFpppip
#() vFEiiipp
#() vFiiiiii
#() vFiiiuil
#() vFiuippp
#() vFiffiff
#() vFiddidd
#() vFuiiiii
#() vFuiiiip
#() vFuiiuii
#() vFuiiuup
#() vFuiuiii
#() vFuiuiip
#() vFuiuiuu
#() vFuiuuip
#() vFuiuuuu
#() vFuiupii
#() vFuiupiu
#() vFuiffff
#() vFuidddd
#() vFuipiup
#() vFuuiiii
#() vFuuiuii
#() vFuuiuiu
#() vFuuiuup
#() vFuuippp
#() vFuuuiup
#() vFuuuipi
#() vFuuuipp
#() vFuuuuii
#() vFuuuuip
#() vFuuuuuu
#() vFuuuuff
#() vFuuuppi
#() vFuuuppp
#() vFuuffff
#() vFuudddd
#() vFuffiip
#() vFufffff
#() vFuddiip
#() vFupupip
#() vFuppppp
#() vFffffff
#() vFdddddd
#() vFpdddii
#() vFppiiii
#() vFppupii
#() vFpppppp
#() iFEpippi
#() iFEpupVV
#() iFiiiiii
#() iFiiiiip
#() iFuppppp
#() iFpiiipp
#() iFppIppp
#() pFEpippp
#() pFiCiiCi
#() pFpiiiiu
#() pFpippip
#() pFpuuuuu
#() pFppiiii
#() vFiiiiiip
#() vFiiiiuup
#() vFiiupuip
#() vFiiffffp
#() vFiupuuup
#() vFuiiiiii
#() vFuiiiuip
#() vFuiiiuup
#() vFuiuiiii
#() vFuiuiiip
#() vFuiuiiuu
#() vFuiupiiu
#() vFuipiiii
#() vFuipffff
#() vFuipdddd
#() vFuuiiiii
#() vFuuiiiip
#() vFuuiiiui
#() vFuuiiiuu
#() vFuuiiuup
#() vFuuiuiii
#() vFuuipppp
#() vFuuuiiii
#() vFuuuiiip
#() vFuuuiuii
#() vFuuuiupi
#() vFuuuuiip
#() vFuuuuuuu
#() vFuuuufff
#() vFuuuffff
#() vFuuudddd
#() vFuuffiip
#() vFuuddiip
#() vFuffffff
#() vFudddddd
#() vFpipipii
#() vFpddiidd
#() iFiiiiiip
#() iFpuuiuui
#() iFppppdpi
#() iFppppppp
#() uFuippppp
#() vFiiiiuuip
#() vFiupuiuup
#() vFiupuuuup
#() vFuiiiiiii
#() vFuiiiiuup
#() vFuiiipiup
#() vFuiuiiiii
#() vFuiuiiiip
#() vFuuiiiiii
#() vFuuiiiuip
#() vFuuiiiuup
#() vFuuiiuupp
#() vFuuiuiiii
#() vFuuiuiiip
#() vFuuuiiiii
#() vFuuuiuiii
#() vFuuuipipp
#() vFuuuuuuuu
#() vFuuuuufff
#() vFffffffff
#() iFEpippppp
#() iFiiiiiiip
#() iFiiupiupi
#() iFuiifpppp
#() iFpupppppp
#() iFppIIIppp
#() iFpppipipi
#() uFuipppppp
#() pFuiiiuuuu
#() vFuiiiiiiii
#() vFuiiiiiuip
#() vFuiiiiiuup
#() vFuiuiiiiip
#() vFuiupuffup
#() vFuuiiiiiii
#() vFuuiuiiiii
#() vFuuiuiiiip
#() vFuuiuiiuup
#() vFuuuiiiiip
#() vFuuuuuuuuu
#() vFuupiuiuuf
#() vFuffffffff
#() vFffuuuufff
#() vFddddddddd
#() iFiiiiiiiip
#() iFiiiipiiip
#() iFdddpppppp
#() pFpiiiiuuuu
#() vFiiiiiiiiiu
#() vFuiiiiiiiii
#() vFuiiiiiiuup
#() vFuiuiiiiuup
#() vFuuiiiiiiii
#() vFuuiiiiiuip
#() vFuuiiiiiuup
#() vFuuiuiiiiip
#() vFuuiuiiiuup
#() vFuuuuuuuiii
#() vFuuuuuuuuuu
#() vFuupiiupuuf
#() vFuffiiffiip
#() vFuddiiddiip
#() vFffffffffff
#() iFiiiiiiiiip
#() vFuiiiiiiiiip
#() vFuiiiiiiiuip
#() vFuiiiiiiiuup
#() vFuiuiiiiiuup
#() vFuuiuiiiiuup
#() vFuuuuuuuuuuu
#() vFuuffiiffiip
#() vFuufffffffff
#() vFuuddiiddiip
#() vFuffffffffff
#() vFpipipiipiii
#() iFiiiiiiiiiip
#() vFuuiiiiiiiuip
#() vFuuiiiiiiiuup
#() vFuuuuuuuuuuuu
#() vFffffffffffff
#() vFuiiiiiiiiiuup
#() vFuuuuuuuuuuuuu
#() vFuffffffffffff
#() iFddddpppddpppp
#() vFuffiiffiiffiip
#() vFuddiiddiiddiip
#() vFuuiiiiuuiiiiiii
#() vFfffffffffffffff
#() vFppuiiiiipuiiiiiiii
#defined(HAVE_LD80BITS) DFD
#defined(HAVE_LD80BITS) DFDD
#defined(HAVE_LD80BITS) DFDp

File diff suppressed because it is too large Load Diff

View File

@ -24,16 +24,20 @@ typedef void (*wrapper_t)(x64emu_t* emu, uintptr_t fnc);
// O = libc O_ flags bitfield
// S = _IO_2_1_stdXXX_ pointer (or FILE*)
// Q = ...
// 2 = struct of 2 uint
// P = Vulkan struture pointer
// G = a single GValue pointer
// N = ... automatically sending 1 arg
// M = ... automatically sending 2 args
// H = Huge 128bits value/struct
void vFE(x64emu_t *emu, uintptr_t fnc);
void vFv(x64emu_t *emu, uintptr_t fnc);
void vFi(x64emu_t *emu, uintptr_t fnc);
void vFu(x64emu_t *emu, uintptr_t fnc);
void vFf(x64emu_t *emu, uintptr_t fnc);
void vFd(x64emu_t *emu, uintptr_t fnc);
void vFp(x64emu_t *emu, uintptr_t fnc);
void cFi(x64emu_t *emu, uintptr_t fnc);
void cFu(x64emu_t *emu, uintptr_t fnc);
void cFp(x64emu_t *emu, uintptr_t fnc);
void iFE(x64emu_t *emu, uintptr_t fnc);
void iFv(x64emu_t *emu, uintptr_t fnc);
void iFi(x64emu_t *emu, uintptr_t fnc);
@ -45,29 +49,75 @@ void iFp(x64emu_t *emu, uintptr_t fnc);
void IFf(x64emu_t *emu, uintptr_t fnc);
void IFd(x64emu_t *emu, uintptr_t fnc);
void IFp(x64emu_t *emu, uintptr_t fnc);
void WFi(x64emu_t *emu, uintptr_t fnc);
void WFp(x64emu_t *emu, uintptr_t fnc);
void uFv(x64emu_t *emu, uintptr_t fnc);
void uFi(x64emu_t *emu, uintptr_t fnc);
void uFu(x64emu_t *emu, uintptr_t fnc);
void uFp(x64emu_t *emu, uintptr_t fnc);
void UFv(x64emu_t *emu, uintptr_t fnc);
void UFV(x64emu_t *emu, uintptr_t fnc);
void fFi(x64emu_t *emu, uintptr_t fnc);
void fFf(x64emu_t *emu, uintptr_t fnc);
void fFp(x64emu_t *emu, uintptr_t fnc);
void dFi(x64emu_t *emu, uintptr_t fnc);
void dFd(x64emu_t *emu, uintptr_t fnc);
void dFp(x64emu_t *emu, uintptr_t fnc);
void lFp(x64emu_t *emu, uintptr_t fnc);
void LFv(x64emu_t *emu, uintptr_t fnc);
void LFp(x64emu_t *emu, uintptr_t fnc);
void pFE(x64emu_t *emu, uintptr_t fnc);
void pFv(x64emu_t *emu, uintptr_t fnc);
void pFi(x64emu_t *emu, uintptr_t fnc);
void pFu(x64emu_t *emu, uintptr_t fnc);
void pFL(x64emu_t *emu, uintptr_t fnc);
void pFp(x64emu_t *emu, uintptr_t fnc);
void HFi(x64emu_t *emu, uintptr_t fnc);
void HFp(x64emu_t *emu, uintptr_t fnc);
void vFEp(x64emu_t *emu, uintptr_t fnc);
void vFii(x64emu_t *emu, uintptr_t fnc);
void vFiu(x64emu_t *emu, uintptr_t fnc);
void vFif(x64emu_t *emu, uintptr_t fnc);
void vFid(x64emu_t *emu, uintptr_t fnc);
void vFip(x64emu_t *emu, uintptr_t fnc);
void vFWW(x64emu_t *emu, uintptr_t fnc);
void vFui(x64emu_t *emu, uintptr_t fnc);
void vFuu(x64emu_t *emu, uintptr_t fnc);
void vFuf(x64emu_t *emu, uintptr_t fnc);
void vFud(x64emu_t *emu, uintptr_t fnc);
void vFup(x64emu_t *emu, uintptr_t fnc);
void vFfi(x64emu_t *emu, uintptr_t fnc);
void vFff(x64emu_t *emu, uintptr_t fnc);
void vFfp(x64emu_t *emu, uintptr_t fnc);
void vFdd(x64emu_t *emu, uintptr_t fnc);
void vFpi(x64emu_t *emu, uintptr_t fnc);
void vFpp(x64emu_t *emu, uintptr_t fnc);
void cFpp(x64emu_t *emu, uintptr_t fnc);
void iFEp(x64emu_t *emu, uintptr_t fnc);
void iFii(x64emu_t *emu, uintptr_t fnc);
void iFip(x64emu_t *emu, uintptr_t fnc);
void iFIi(x64emu_t *emu, uintptr_t fnc);
void iFui(x64emu_t *emu, uintptr_t fnc);
void iFuu(x64emu_t *emu, uintptr_t fnc);
void iFup(x64emu_t *emu, uintptr_t fnc);
void iFUU(x64emu_t *emu, uintptr_t fnc);
void iFLL(x64emu_t *emu, uintptr_t fnc);
void iFLp(x64emu_t *emu, uintptr_t fnc);
void iFpi(x64emu_t *emu, uintptr_t fnc);
void iFpC(x64emu_t *emu, uintptr_t fnc);
void iFpu(x64emu_t *emu, uintptr_t fnc);
void iFpf(x64emu_t *emu, uintptr_t fnc);
void iFpp(x64emu_t *emu, uintptr_t fnc);
void IFEp(x64emu_t *emu, uintptr_t fnc);
void CFui(x64emu_t *emu, uintptr_t fnc);
void CFpi(x64emu_t *emu, uintptr_t fnc);
void uFEp(x64emu_t *emu, uintptr_t fnc);
void uFui(x64emu_t *emu, uintptr_t fnc);
void uFuu(x64emu_t *emu, uintptr_t fnc);
void uFup(x64emu_t *emu, uintptr_t fnc);
void uFpi(x64emu_t *emu, uintptr_t fnc);
void uFpp(x64emu_t *emu, uintptr_t fnc);
void UFEp(x64emu_t *emu, uintptr_t fnc);
void fFif(x64emu_t *emu, uintptr_t fnc);
void fFfi(x64emu_t *emu, uintptr_t fnc);
void fFff(x64emu_t *emu, uintptr_t fnc);
@ -76,19 +126,101 @@ void dFid(x64emu_t *emu, uintptr_t fnc);
void dFdi(x64emu_t *emu, uintptr_t fnc);
void dFdd(x64emu_t *emu, uintptr_t fnc);
void dFdp(x64emu_t *emu, uintptr_t fnc);
void dFpp(x64emu_t *emu, uintptr_t fnc);
void LFpL(x64emu_t *emu, uintptr_t fnc);
void pFEp(x64emu_t *emu, uintptr_t fnc);
void pFii(x64emu_t *emu, uintptr_t fnc);
void pFui(x64emu_t *emu, uintptr_t fnc);
void pFuu(x64emu_t *emu, uintptr_t fnc);
void pFup(x64emu_t *emu, uintptr_t fnc);
void pFlp(x64emu_t *emu, uintptr_t fnc);
void pFLL(x64emu_t *emu, uintptr_t fnc);
void pFpi(x64emu_t *emu, uintptr_t fnc);
void pFpu(x64emu_t *emu, uintptr_t fnc);
void pFpL(x64emu_t *emu, uintptr_t fnc);
void pFpp(x64emu_t *emu, uintptr_t fnc);
void pFpV(x64emu_t *emu, uintptr_t fnc);
void HFpi(x64emu_t *emu, uintptr_t fnc);
void vFEpu(x64emu_t *emu, uintptr_t fnc);
void vFEpp(x64emu_t *emu, uintptr_t fnc);
void vFEpV(x64emu_t *emu, uintptr_t fnc);
void vFiii(x64emu_t *emu, uintptr_t fnc);
void vFiip(x64emu_t *emu, uintptr_t fnc);
void vFiui(x64emu_t *emu, uintptr_t fnc);
void vFiuu(x64emu_t *emu, uintptr_t fnc);
void vFiup(x64emu_t *emu, uintptr_t fnc);
void vFiff(x64emu_t *emu, uintptr_t fnc);
void vFidd(x64emu_t *emu, uintptr_t fnc);
void vFipi(x64emu_t *emu, uintptr_t fnc);
void vFipu(x64emu_t *emu, uintptr_t fnc);
void vFipp(x64emu_t *emu, uintptr_t fnc);
void vFuii(x64emu_t *emu, uintptr_t fnc);
void vFuiI(x64emu_t *emu, uintptr_t fnc);
void vFuiu(x64emu_t *emu, uintptr_t fnc);
void vFuif(x64emu_t *emu, uintptr_t fnc);
void vFuid(x64emu_t *emu, uintptr_t fnc);
void vFuip(x64emu_t *emu, uintptr_t fnc);
void vFuui(x64emu_t *emu, uintptr_t fnc);
void vFuuu(x64emu_t *emu, uintptr_t fnc);
void vFuuf(x64emu_t *emu, uintptr_t fnc);
void vFuud(x64emu_t *emu, uintptr_t fnc);
void vFuup(x64emu_t *emu, uintptr_t fnc);
void vFuff(x64emu_t *emu, uintptr_t fnc);
void vFudd(x64emu_t *emu, uintptr_t fnc);
void vFupi(x64emu_t *emu, uintptr_t fnc);
void vFfff(x64emu_t *emu, uintptr_t fnc);
void vFfpp(x64emu_t *emu, uintptr_t fnc);
void vFddd(x64emu_t *emu, uintptr_t fnc);
void vFdpp(x64emu_t *emu, uintptr_t fnc);
void vFpii(x64emu_t *emu, uintptr_t fnc);
void vFpiu(x64emu_t *emu, uintptr_t fnc);
void vFpif(x64emu_t *emu, uintptr_t fnc);
void vFpid(x64emu_t *emu, uintptr_t fnc);
void vFpip(x64emu_t *emu, uintptr_t fnc);
void vFppi(x64emu_t *emu, uintptr_t fnc);
void vFppu(x64emu_t *emu, uintptr_t fnc);
void vFppp(x64emu_t *emu, uintptr_t fnc);
void iFEip(x64emu_t *emu, uintptr_t fnc);
void iFEWW(x64emu_t *emu, uintptr_t fnc);
void iFEup(x64emu_t *emu, uintptr_t fnc);
void iFEpi(x64emu_t *emu, uintptr_t fnc);
void iFEpp(x64emu_t *emu, uintptr_t fnc);
void iFEpV(x64emu_t *emu, uintptr_t fnc);
void iFiip(x64emu_t *emu, uintptr_t fnc);
void iFipu(x64emu_t *emu, uintptr_t fnc);
void iFipp(x64emu_t *emu, uintptr_t fnc);
void iFuup(x64emu_t *emu, uintptr_t fnc);
void iFuff(x64emu_t *emu, uintptr_t fnc);
void iFfff(x64emu_t *emu, uintptr_t fnc);
void iFpii(x64emu_t *emu, uintptr_t fnc);
void iFpiu(x64emu_t *emu, uintptr_t fnc);
void iFpip(x64emu_t *emu, uintptr_t fnc);
void iFpuu(x64emu_t *emu, uintptr_t fnc);
void iFpuL(x64emu_t *emu, uintptr_t fnc);
void iFpup(x64emu_t *emu, uintptr_t fnc);
void iFpfu(x64emu_t *emu, uintptr_t fnc);
void iFpff(x64emu_t *emu, uintptr_t fnc);
void iFppi(x64emu_t *emu, uintptr_t fnc);
void iFppu(x64emu_t *emu, uintptr_t fnc);
void iFppL(x64emu_t *emu, uintptr_t fnc);
void iFppp(x64emu_t *emu, uintptr_t fnc);
void iFppV(x64emu_t *emu, uintptr_t fnc);
void IFpIi(x64emu_t *emu, uintptr_t fnc);
void IFppi(x64emu_t *emu, uintptr_t fnc);
void uFEpW(x64emu_t *emu, uintptr_t fnc);
void uFEpu(x64emu_t *emu, uintptr_t fnc);
void uFEpU(x64emu_t *emu, uintptr_t fnc);
void uFipu(x64emu_t *emu, uintptr_t fnc);
void uFuip(x64emu_t *emu, uintptr_t fnc);
void uFuuu(x64emu_t *emu, uintptr_t fnc);
void uFuup(x64emu_t *emu, uintptr_t fnc);
void uFupu(x64emu_t *emu, uintptr_t fnc);
void uFupp(x64emu_t *emu, uintptr_t fnc);
void uFpiu(x64emu_t *emu, uintptr_t fnc);
void uFppi(x64emu_t *emu, uintptr_t fnc);
void uFppu(x64emu_t *emu, uintptr_t fnc);
void UFppi(x64emu_t *emu, uintptr_t fnc);
void fFuii(x64emu_t *emu, uintptr_t fnc);
void fFfff(x64emu_t *emu, uintptr_t fnc);
void fFffp(x64emu_t *emu, uintptr_t fnc);
void dFddd(x64emu_t *emu, uintptr_t fnc);
@ -96,23 +228,392 @@ void dFddp(x64emu_t *emu, uintptr_t fnc);
void pFEip(x64emu_t *emu, uintptr_t fnc);
void pFEpi(x64emu_t *emu, uintptr_t fnc);
void pFEpp(x64emu_t *emu, uintptr_t fnc);
void pFipi(x64emu_t *emu, uintptr_t fnc);
void pFipp(x64emu_t *emu, uintptr_t fnc);
void pFIpi(x64emu_t *emu, uintptr_t fnc);
void pFuii(x64emu_t *emu, uintptr_t fnc);
void pFupi(x64emu_t *emu, uintptr_t fnc);
void pFUpi(x64emu_t *emu, uintptr_t fnc);
void pFpii(x64emu_t *emu, uintptr_t fnc);
void pFpiu(x64emu_t *emu, uintptr_t fnc);
void pFpiL(x64emu_t *emu, uintptr_t fnc);
void pFpip(x64emu_t *emu, uintptr_t fnc);
void pFpuu(x64emu_t *emu, uintptr_t fnc);
void pFppi(x64emu_t *emu, uintptr_t fnc);
void pFppu(x64emu_t *emu, uintptr_t fnc);
void pFppL(x64emu_t *emu, uintptr_t fnc);
void pFppp(x64emu_t *emu, uintptr_t fnc);
void vFEipV(x64emu_t *emu, uintptr_t fnc);
void vFEpip(x64emu_t *emu, uintptr_t fnc);
void vFEpup(x64emu_t *emu, uintptr_t fnc);
void vFiiii(x64emu_t *emu, uintptr_t fnc);
void vFiiip(x64emu_t *emu, uintptr_t fnc);
void vFiuip(x64emu_t *emu, uintptr_t fnc);
void vFiuuu(x64emu_t *emu, uintptr_t fnc);
void vFiupu(x64emu_t *emu, uintptr_t fnc);
void vFiupV(x64emu_t *emu, uintptr_t fnc);
void vFifff(x64emu_t *emu, uintptr_t fnc);
void vFiddd(x64emu_t *emu, uintptr_t fnc);
void vFipup(x64emu_t *emu, uintptr_t fnc);
void vFippp(x64emu_t *emu, uintptr_t fnc);
void vFuiii(x64emu_t *emu, uintptr_t fnc);
void vFuiip(x64emu_t *emu, uintptr_t fnc);
void vFuiui(x64emu_t *emu, uintptr_t fnc);
void vFuiuu(x64emu_t *emu, uintptr_t fnc);
void vFuiup(x64emu_t *emu, uintptr_t fnc);
void vFuifi(x64emu_t *emu, uintptr_t fnc);
void vFuiff(x64emu_t *emu, uintptr_t fnc);
void vFuidd(x64emu_t *emu, uintptr_t fnc);
void vFuipi(x64emu_t *emu, uintptr_t fnc);
void vFuipu(x64emu_t *emu, uintptr_t fnc);
void vFuipp(x64emu_t *emu, uintptr_t fnc);
void vFuuii(x64emu_t *emu, uintptr_t fnc);
void vFuuiu(x64emu_t *emu, uintptr_t fnc);
void vFuuip(x64emu_t *emu, uintptr_t fnc);
void vFuuui(x64emu_t *emu, uintptr_t fnc);
void vFuuuu(x64emu_t *emu, uintptr_t fnc);
void vFuuuf(x64emu_t *emu, uintptr_t fnc);
void vFuuud(x64emu_t *emu, uintptr_t fnc);
void vFuuup(x64emu_t *emu, uintptr_t fnc);
void vFuupi(x64emu_t *emu, uintptr_t fnc);
void vFuupp(x64emu_t *emu, uintptr_t fnc);
void vFufff(x64emu_t *emu, uintptr_t fnc);
void vFuddd(x64emu_t *emu, uintptr_t fnc);
void vFupii(x64emu_t *emu, uintptr_t fnc);
void vFuppi(x64emu_t *emu, uintptr_t fnc);
void vFffff(x64emu_t *emu, uintptr_t fnc);
void vFdddd(x64emu_t *emu, uintptr_t fnc);
void vFpiii(x64emu_t *emu, uintptr_t fnc);
void vFpiip(x64emu_t *emu, uintptr_t fnc);
void vFpipp(x64emu_t *emu, uintptr_t fnc);
void vFpdii(x64emu_t *emu, uintptr_t fnc);
void vFpddd(x64emu_t *emu, uintptr_t fnc);
void vFppip(x64emu_t *emu, uintptr_t fnc);
void vFppui(x64emu_t *emu, uintptr_t fnc);
void vFpppp(x64emu_t *emu, uintptr_t fnc);
void cFpiii(x64emu_t *emu, uintptr_t fnc);
void iFEupp(x64emu_t *emu, uintptr_t fnc);
void iFEpip(x64emu_t *emu, uintptr_t fnc);
void iFEppi(x64emu_t *emu, uintptr_t fnc);
void iFEppp(x64emu_t *emu, uintptr_t fnc);
void iFiiiu(x64emu_t *emu, uintptr_t fnc);
void iFippp(x64emu_t *emu, uintptr_t fnc);
void iFuipp(x64emu_t *emu, uintptr_t fnc);
void iFuuff(x64emu_t *emu, uintptr_t fnc);
void iFuppp(x64emu_t *emu, uintptr_t fnc);
void iFpiiu(x64emu_t *emu, uintptr_t fnc);
void iFpiip(x64emu_t *emu, uintptr_t fnc);
void iFpipp(x64emu_t *emu, uintptr_t fnc);
void iFpCCC(x64emu_t *emu, uintptr_t fnc);
void iFpWWu(x64emu_t *emu, uintptr_t fnc);
void iFpuup(x64emu_t *emu, uintptr_t fnc);
void iFpupV(x64emu_t *emu, uintptr_t fnc);
void iFppii(x64emu_t *emu, uintptr_t fnc);
void iFppiu(x64emu_t *emu, uintptr_t fnc);
void iFppip(x64emu_t *emu, uintptr_t fnc);
void iFpppi(x64emu_t *emu, uintptr_t fnc);
void iFpppp(x64emu_t *emu, uintptr_t fnc);
void IFEpIi(x64emu_t *emu, uintptr_t fnc);
void uFuuuu(x64emu_t *emu, uintptr_t fnc);
void uFpCCC(x64emu_t *emu, uintptr_t fnc);
void uFpuip(x64emu_t *emu, uintptr_t fnc);
void uFpuuu(x64emu_t *emu, uintptr_t fnc);
void uFpppi(x64emu_t *emu, uintptr_t fnc);
void LFpLLp(x64emu_t *emu, uintptr_t fnc);
void pFEupp(x64emu_t *emu, uintptr_t fnc);
void pFEppi(x64emu_t *emu, uintptr_t fnc);
void pFEppp(x64emu_t *emu, uintptr_t fnc);
void pFiiiu(x64emu_t *emu, uintptr_t fnc);
void pFiiup(x64emu_t *emu, uintptr_t fnc);
void pFuiii(x64emu_t *emu, uintptr_t fnc);
void pFpiii(x64emu_t *emu, uintptr_t fnc);
void pFpipp(x64emu_t *emu, uintptr_t fnc);
void pFpuii(x64emu_t *emu, uintptr_t fnc);
void pFppiL(x64emu_t *emu, uintptr_t fnc);
void pFppuL(x64emu_t *emu, uintptr_t fnc);
void pFppLL(x64emu_t *emu, uintptr_t fnc);
void pFpppi(x64emu_t *emu, uintptr_t fnc);
void pFpppu(x64emu_t *emu, uintptr_t fnc);
void pFpppL(x64emu_t *emu, uintptr_t fnc);
void pFpppp(x64emu_t *emu, uintptr_t fnc);
void vFEpuup(x64emu_t *emu, uintptr_t fnc);
void vFiiiii(x64emu_t *emu, uintptr_t fnc);
void vFiiiiu(x64emu_t *emu, uintptr_t fnc);
void vFiiuup(x64emu_t *emu, uintptr_t fnc);
void vFiipii(x64emu_t *emu, uintptr_t fnc);
void vFiuiip(x64emu_t *emu, uintptr_t fnc);
void vFiuipi(x64emu_t *emu, uintptr_t fnc);
void vFiuuuu(x64emu_t *emu, uintptr_t fnc);
void vFiffff(x64emu_t *emu, uintptr_t fnc);
void vFidddd(x64emu_t *emu, uintptr_t fnc);
void vFilill(x64emu_t *emu, uintptr_t fnc);
void vFipipu(x64emu_t *emu, uintptr_t fnc);
void vFipipp(x64emu_t *emu, uintptr_t fnc);
void vFipupi(x64emu_t *emu, uintptr_t fnc);
void vFuiiii(x64emu_t *emu, uintptr_t fnc);
void vFuiiiu(x64emu_t *emu, uintptr_t fnc);
void vFuiiip(x64emu_t *emu, uintptr_t fnc);
void vFuiiup(x64emu_t *emu, uintptr_t fnc);
void vFuiIII(x64emu_t *emu, uintptr_t fnc);
void vFuiuii(x64emu_t *emu, uintptr_t fnc);
void vFuiuiu(x64emu_t *emu, uintptr_t fnc);
void vFuiuip(x64emu_t *emu, uintptr_t fnc);
void vFuiuuu(x64emu_t *emu, uintptr_t fnc);
void vFuiuup(x64emu_t *emu, uintptr_t fnc);
void vFuiupi(x64emu_t *emu, uintptr_t fnc);
void vFuiupu(x64emu_t *emu, uintptr_t fnc);
void vFuifff(x64emu_t *emu, uintptr_t fnc);
void vFuiddd(x64emu_t *emu, uintptr_t fnc);
void vFuipii(x64emu_t *emu, uintptr_t fnc);
void vFuipip(x64emu_t *emu, uintptr_t fnc);
void vFuipup(x64emu_t *emu, uintptr_t fnc);
void vFuippp(x64emu_t *emu, uintptr_t fnc);
void vFuuiii(x64emu_t *emu, uintptr_t fnc);
void vFuuiui(x64emu_t *emu, uintptr_t fnc);
void vFuuiuu(x64emu_t *emu, uintptr_t fnc);
void vFuuiup(x64emu_t *emu, uintptr_t fnc);
void vFuuipi(x64emu_t *emu, uintptr_t fnc);
void vFuuipu(x64emu_t *emu, uintptr_t fnc);
void vFuuipp(x64emu_t *emu, uintptr_t fnc);
void vFuuuii(x64emu_t *emu, uintptr_t fnc);
void vFuuuiu(x64emu_t *emu, uintptr_t fnc);
void vFuuuip(x64emu_t *emu, uintptr_t fnc);
void vFuuuui(x64emu_t *emu, uintptr_t fnc);
void vFuuuuu(x64emu_t *emu, uintptr_t fnc);
void vFuuuup(x64emu_t *emu, uintptr_t fnc);
void vFuupii(x64emu_t *emu, uintptr_t fnc);
void vFuffff(x64emu_t *emu, uintptr_t fnc);
void vFudddd(x64emu_t *emu, uintptr_t fnc);
void vFupupi(x64emu_t *emu, uintptr_t fnc);
void vFuppip(x64emu_t *emu, uintptr_t fnc);
void vFupppp(x64emu_t *emu, uintptr_t fnc);
void vFfffff(x64emu_t *emu, uintptr_t fnc);
void vFddddp(x64emu_t *emu, uintptr_t fnc);
void vFpiiii(x64emu_t *emu, uintptr_t fnc);
void vFpipii(x64emu_t *emu, uintptr_t fnc);
void vFpuipp(x64emu_t *emu, uintptr_t fnc);
void vFpddii(x64emu_t *emu, uintptr_t fnc);
void vFppWui(x64emu_t *emu, uintptr_t fnc);
void vFpppii(x64emu_t *emu, uintptr_t fnc);
void vFppppp(x64emu_t *emu, uintptr_t fnc);
void iFEppiV(x64emu_t *emu, uintptr_t fnc);
void iFEpppp(x64emu_t *emu, uintptr_t fnc);
void iFiiupp(x64emu_t *emu, uintptr_t fnc);
void iFipppi(x64emu_t *emu, uintptr_t fnc);
void iFpiiii(x64emu_t *emu, uintptr_t fnc);
void iFpiiip(x64emu_t *emu, uintptr_t fnc);
void iFpiiuu(x64emu_t *emu, uintptr_t fnc);
void iFpipii(x64emu_t *emu, uintptr_t fnc);
void iFpippp(x64emu_t *emu, uintptr_t fnc);
void iFpCCCC(x64emu_t *emu, uintptr_t fnc);
void iFppipi(x64emu_t *emu, uintptr_t fnc);
void iFppupi(x64emu_t *emu, uintptr_t fnc);
void iFppppp(x64emu_t *emu, uintptr_t fnc);
void IFppIII(x64emu_t *emu, uintptr_t fnc);
void uFEppuu(x64emu_t *emu, uintptr_t fnc);
void uFiuuuu(x64emu_t *emu, uintptr_t fnc);
void uFuiiiu(x64emu_t *emu, uintptr_t fnc);
void uFpCCCC(x64emu_t *emu, uintptr_t fnc);
void uFpuuuu(x64emu_t *emu, uintptr_t fnc);
void uFppppp(x64emu_t *emu, uintptr_t fnc);
void LFppppp(x64emu_t *emu, uintptr_t fnc);
void pFuiiiu(x64emu_t *emu, uintptr_t fnc);
void pFuiipp(x64emu_t *emu, uintptr_t fnc);
void pFpuiii(x64emu_t *emu, uintptr_t fnc);
void pFppipi(x64emu_t *emu, uintptr_t fnc);
void pFppuup(x64emu_t *emu, uintptr_t fnc);
void pFpppip(x64emu_t *emu, uintptr_t fnc);
void vFEiiipp(x64emu_t *emu, uintptr_t fnc);
void vFiiiiii(x64emu_t *emu, uintptr_t fnc);
void vFiiiuil(x64emu_t *emu, uintptr_t fnc);
void vFiuippp(x64emu_t *emu, uintptr_t fnc);
void vFiffiff(x64emu_t *emu, uintptr_t fnc);
void vFiddidd(x64emu_t *emu, uintptr_t fnc);
void vFuiiiii(x64emu_t *emu, uintptr_t fnc);
void vFuiiiip(x64emu_t *emu, uintptr_t fnc);
void vFuiiuii(x64emu_t *emu, uintptr_t fnc);
void vFuiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuiuiii(x64emu_t *emu, uintptr_t fnc);
void vFuiuiip(x64emu_t *emu, uintptr_t fnc);
void vFuiuiuu(x64emu_t *emu, uintptr_t fnc);
void vFuiuuip(x64emu_t *emu, uintptr_t fnc);
void vFuiuuuu(x64emu_t *emu, uintptr_t fnc);
void vFuiupii(x64emu_t *emu, uintptr_t fnc);
void vFuiupiu(x64emu_t *emu, uintptr_t fnc);
void vFuiffff(x64emu_t *emu, uintptr_t fnc);
void vFuidddd(x64emu_t *emu, uintptr_t fnc);
void vFuipiup(x64emu_t *emu, uintptr_t fnc);
void vFuuiiii(x64emu_t *emu, uintptr_t fnc);
void vFuuiuii(x64emu_t *emu, uintptr_t fnc);
void vFuuiuiu(x64emu_t *emu, uintptr_t fnc);
void vFuuiuup(x64emu_t *emu, uintptr_t fnc);
void vFuuippp(x64emu_t *emu, uintptr_t fnc);
void vFuuuiup(x64emu_t *emu, uintptr_t fnc);
void vFuuuipi(x64emu_t *emu, uintptr_t fnc);
void vFuuuipp(x64emu_t *emu, uintptr_t fnc);
void vFuuuuii(x64emu_t *emu, uintptr_t fnc);
void vFuuuuip(x64emu_t *emu, uintptr_t fnc);
void vFuuuuuu(x64emu_t *emu, uintptr_t fnc);
void vFuuuuff(x64emu_t *emu, uintptr_t fnc);
void vFuuuppi(x64emu_t *emu, uintptr_t fnc);
void vFuuuppp(x64emu_t *emu, uintptr_t fnc);
void vFuuffff(x64emu_t *emu, uintptr_t fnc);
void vFuudddd(x64emu_t *emu, uintptr_t fnc);
void vFuffiip(x64emu_t *emu, uintptr_t fnc);
void vFufffff(x64emu_t *emu, uintptr_t fnc);
void vFuddiip(x64emu_t *emu, uintptr_t fnc);
void vFupupip(x64emu_t *emu, uintptr_t fnc);
void vFuppppp(x64emu_t *emu, uintptr_t fnc);
void vFffffff(x64emu_t *emu, uintptr_t fnc);
void vFdddddd(x64emu_t *emu, uintptr_t fnc);
void vFpdddii(x64emu_t *emu, uintptr_t fnc);
void vFppiiii(x64emu_t *emu, uintptr_t fnc);
void vFppupii(x64emu_t *emu, uintptr_t fnc);
void vFpppppp(x64emu_t *emu, uintptr_t fnc);
void iFEpippi(x64emu_t *emu, uintptr_t fnc);
void iFEpupVV(x64emu_t *emu, uintptr_t fnc);
void iFiiiiii(x64emu_t *emu, uintptr_t fnc);
void iFiiiiip(x64emu_t *emu, uintptr_t fnc);
void iFuppppp(x64emu_t *emu, uintptr_t fnc);
void iFpiiipp(x64emu_t *emu, uintptr_t fnc);
void iFppIppp(x64emu_t *emu, uintptr_t fnc);
void pFEpippp(x64emu_t *emu, uintptr_t fnc);
void pFiCiiCi(x64emu_t *emu, uintptr_t fnc);
void pFpiiiiu(x64emu_t *emu, uintptr_t fnc);
void pFpippip(x64emu_t *emu, uintptr_t fnc);
void pFpuuuuu(x64emu_t *emu, uintptr_t fnc);
void pFppiiii(x64emu_t *emu, uintptr_t fnc);
void vFiiiiiip(x64emu_t *emu, uintptr_t fnc);
void vFiiiiuup(x64emu_t *emu, uintptr_t fnc);
void vFiiupuip(x64emu_t *emu, uintptr_t fnc);
void vFiiffffp(x64emu_t *emu, uintptr_t fnc);
void vFiupuuup(x64emu_t *emu, uintptr_t fnc);
void vFuiiiiii(x64emu_t *emu, uintptr_t fnc);
void vFuiiiuip(x64emu_t *emu, uintptr_t fnc);
void vFuiiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuiuiiii(x64emu_t *emu, uintptr_t fnc);
void vFuiuiiip(x64emu_t *emu, uintptr_t fnc);
void vFuiuiiuu(x64emu_t *emu, uintptr_t fnc);
void vFuiupiiu(x64emu_t *emu, uintptr_t fnc);
void vFuipiiii(x64emu_t *emu, uintptr_t fnc);
void vFuipffff(x64emu_t *emu, uintptr_t fnc);
void vFuipdddd(x64emu_t *emu, uintptr_t fnc);
void vFuuiiiii(x64emu_t *emu, uintptr_t fnc);
void vFuuiiiip(x64emu_t *emu, uintptr_t fnc);
void vFuuiiiui(x64emu_t *emu, uintptr_t fnc);
void vFuuiiiuu(x64emu_t *emu, uintptr_t fnc);
void vFuuiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuuiuiii(x64emu_t *emu, uintptr_t fnc);
void vFuuipppp(x64emu_t *emu, uintptr_t fnc);
void vFuuuiiii(x64emu_t *emu, uintptr_t fnc);
void vFuuuiiip(x64emu_t *emu, uintptr_t fnc);
void vFuuuiuii(x64emu_t *emu, uintptr_t fnc);
void vFuuuiupi(x64emu_t *emu, uintptr_t fnc);
void vFuuuuiip(x64emu_t *emu, uintptr_t fnc);
void vFuuuuuuu(x64emu_t *emu, uintptr_t fnc);
void vFuuuufff(x64emu_t *emu, uintptr_t fnc);
void vFuuuffff(x64emu_t *emu, uintptr_t fnc);
void vFuuudddd(x64emu_t *emu, uintptr_t fnc);
void vFuuffiip(x64emu_t *emu, uintptr_t fnc);
void vFuuddiip(x64emu_t *emu, uintptr_t fnc);
void vFuffffff(x64emu_t *emu, uintptr_t fnc);
void vFudddddd(x64emu_t *emu, uintptr_t fnc);
void vFpipipii(x64emu_t *emu, uintptr_t fnc);
void vFpddiidd(x64emu_t *emu, uintptr_t fnc);
void iFiiiiiip(x64emu_t *emu, uintptr_t fnc);
void iFpuuiuui(x64emu_t *emu, uintptr_t fnc);
void iFppppdpi(x64emu_t *emu, uintptr_t fnc);
void iFppppppp(x64emu_t *emu, uintptr_t fnc);
void uFuippppp(x64emu_t *emu, uintptr_t fnc);
void vFiiiiuuip(x64emu_t *emu, uintptr_t fnc);
void vFiupuiuup(x64emu_t *emu, uintptr_t fnc);
void vFiupuuuup(x64emu_t *emu, uintptr_t fnc);
void vFuiiiiiii(x64emu_t *emu, uintptr_t fnc);
void vFuiiiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuiiipiup(x64emu_t *emu, uintptr_t fnc);
void vFuiuiiiii(x64emu_t *emu, uintptr_t fnc);
void vFuiuiiiip(x64emu_t *emu, uintptr_t fnc);
void vFuuiiiiii(x64emu_t *emu, uintptr_t fnc);
void vFuuiiiuip(x64emu_t *emu, uintptr_t fnc);
void vFuuiiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuuiiuupp(x64emu_t *emu, uintptr_t fnc);
void vFuuiuiiii(x64emu_t *emu, uintptr_t fnc);
void vFuuiuiiip(x64emu_t *emu, uintptr_t fnc);
void vFuuuiiiii(x64emu_t *emu, uintptr_t fnc);
void vFuuuiuiii(x64emu_t *emu, uintptr_t fnc);
void vFuuuipipp(x64emu_t *emu, uintptr_t fnc);
void vFuuuuuuuu(x64emu_t *emu, uintptr_t fnc);
void vFuuuuufff(x64emu_t *emu, uintptr_t fnc);
void vFffffffff(x64emu_t *emu, uintptr_t fnc);
void iFEpippppp(x64emu_t *emu, uintptr_t fnc);
void iFiiiiiiip(x64emu_t *emu, uintptr_t fnc);
void iFiiupiupi(x64emu_t *emu, uintptr_t fnc);
void iFuiifpppp(x64emu_t *emu, uintptr_t fnc);
void iFpupppppp(x64emu_t *emu, uintptr_t fnc);
void iFppIIIppp(x64emu_t *emu, uintptr_t fnc);
void iFpppipipi(x64emu_t *emu, uintptr_t fnc);
void uFuipppppp(x64emu_t *emu, uintptr_t fnc);
void pFuiiiuuuu(x64emu_t *emu, uintptr_t fnc);
void vFuiiiiiiii(x64emu_t *emu, uintptr_t fnc);
void vFuiiiiiuip(x64emu_t *emu, uintptr_t fnc);
void vFuiiiiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuiuiiiiip(x64emu_t *emu, uintptr_t fnc);
void vFuiupuffup(x64emu_t *emu, uintptr_t fnc);
void vFuuiiiiiii(x64emu_t *emu, uintptr_t fnc);
void vFuuiuiiiii(x64emu_t *emu, uintptr_t fnc);
void vFuuiuiiiip(x64emu_t *emu, uintptr_t fnc);
void vFuuiuiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuuuiiiiip(x64emu_t *emu, uintptr_t fnc);
void vFuuuuuuuuu(x64emu_t *emu, uintptr_t fnc);
void vFuupiuiuuf(x64emu_t *emu, uintptr_t fnc);
void vFuffffffff(x64emu_t *emu, uintptr_t fnc);
void vFffuuuufff(x64emu_t *emu, uintptr_t fnc);
void vFddddddddd(x64emu_t *emu, uintptr_t fnc);
void iFiiiiiiiip(x64emu_t *emu, uintptr_t fnc);
void iFiiiipiiip(x64emu_t *emu, uintptr_t fnc);
void iFdddpppppp(x64emu_t *emu, uintptr_t fnc);
void pFpiiiiuuuu(x64emu_t *emu, uintptr_t fnc);
void vFiiiiiiiiiu(x64emu_t *emu, uintptr_t fnc);
void vFuiiiiiiiii(x64emu_t *emu, uintptr_t fnc);
void vFuiiiiiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuiuiiiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuuiiiiiiii(x64emu_t *emu, uintptr_t fnc);
void vFuuiiiiiuip(x64emu_t *emu, uintptr_t fnc);
void vFuuiiiiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuuiuiiiiip(x64emu_t *emu, uintptr_t fnc);
void vFuuiuiiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuuuuuuuiii(x64emu_t *emu, uintptr_t fnc);
void vFuuuuuuuuuu(x64emu_t *emu, uintptr_t fnc);
void vFuupiiupuuf(x64emu_t *emu, uintptr_t fnc);
void vFuffiiffiip(x64emu_t *emu, uintptr_t fnc);
void vFuddiiddiip(x64emu_t *emu, uintptr_t fnc);
void vFffffffffff(x64emu_t *emu, uintptr_t fnc);
void iFiiiiiiiiip(x64emu_t *emu, uintptr_t fnc);
void vFuiiiiiiiiip(x64emu_t *emu, uintptr_t fnc);
void vFuiiiiiiiuip(x64emu_t *emu, uintptr_t fnc);
void vFuiiiiiiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuiuiiiiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuuiuiiiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuuuuuuuuuuu(x64emu_t *emu, uintptr_t fnc);
void vFuuffiiffiip(x64emu_t *emu, uintptr_t fnc);
void vFuufffffffff(x64emu_t *emu, uintptr_t fnc);
void vFuuddiiddiip(x64emu_t *emu, uintptr_t fnc);
void vFuffffffffff(x64emu_t *emu, uintptr_t fnc);
void vFpipipiipiii(x64emu_t *emu, uintptr_t fnc);
void iFiiiiiiiiiip(x64emu_t *emu, uintptr_t fnc);
void vFuuiiiiiiiuip(x64emu_t *emu, uintptr_t fnc);
void vFuuiiiiiiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuuuuuuuuuuuu(x64emu_t *emu, uintptr_t fnc);
void vFffffffffffff(x64emu_t *emu, uintptr_t fnc);
void vFuiiiiiiiiiuup(x64emu_t *emu, uintptr_t fnc);
void vFuuuuuuuuuuuuu(x64emu_t *emu, uintptr_t fnc);
void vFuffffffffffff(x64emu_t *emu, uintptr_t fnc);
void iFddddpppddpppp(x64emu_t *emu, uintptr_t fnc);
void vFuffiiffiiffiip(x64emu_t *emu, uintptr_t fnc);
void vFuddiiddiiddiip(x64emu_t *emu, uintptr_t fnc);
void vFuuiiiiuuiiiiiii(x64emu_t *emu, uintptr_t fnc);
void vFfffffffffffffff(x64emu_t *emu, uintptr_t fnc);
void vFppuiiiiipuiiiiiiii(x64emu_t *emu, uintptr_t fnc);
#if defined(HAVE_LD80BITS)
void DFD(x64emu_t *emu, uintptr_t fnc);

View File

@ -1840,7 +1840,7 @@ EXPORT int32_t my_posix_spawnp(x64emu_t* emu, pid_t* pid, const char* path,
// fullpath is gone, so the search will only be on PATH, not on BOX86_PATH (is that an issue?)
return posix_spawnp(pid, path, actions, attrp, argv, envp);
}
#endif
EXPORT void my__Jv_RegisterClasses() {}
EXPORT int32_t my___cxa_thread_atexit_impl(x64emu_t* emu, void* dtor, void* obj, void* dso)
@ -1857,7 +1857,7 @@ EXPORT unsigned long int my___fdelt_chk (unsigned long int d)
return d / __NFDBITS;
}
#if 0
EXPORT int32_t my_getrandom(x64emu_t* emu, void* buf, uint32_t buflen, uint32_t flags)
{
// not always implemented on old linux version...

View File

@ -73,6 +73,7 @@ GO(atoll, IFp)
//GO(__backtrace_symbols_fd,
//GOW(backtrace_symbols_fd,
//GOW(basename,
//GOI(bcmp,
//GO(bcopy,
//GO(bdflush,
//GOW(bind,
@ -609,6 +610,8 @@ GOM(getcontext, iFEp) //Weak
//GO(getspnam_r,
//GO(getsubopt,
//GOW(gettext,
//GOI(__gettimeofday,
//GOI(gettimeofday,
//GOW(getttyent,
//GOW(getttynam,
//GOW(getuid,
@ -677,6 +680,7 @@ GOM(getcontext, iFEp) //Weak
//GOW(if_nametoindex,
//GOW(imaxabs,
//GOW(imaxdiv,
//GOI(index,
//GO(inet6_opt_append,
//GO(inet6_opt_find,
//GO(inet6_opt_finish,
@ -1442,6 +1446,8 @@ GOW(puts, iFp)
//GOW(random,
//GOW(random_r,
//GO(rand_r,
//GOI(__rawmemchr,
//GOI(rawmemchr,
//GO(rcmd,
//GO(rcmd_af,
//DATAB(__rcmd_errstr,
@ -1521,6 +1527,7 @@ GOW(puts, iFp)
//GO(rexec,
//GO(rexec_af,
//DATAB(rexecoptions,
//GOI(rindex,
//GOW(rmdir,
//DATAB(rpc_createerr,
//GO(_rpc_dtablesize,
@ -1546,6 +1553,7 @@ GOW(puts, iFp)
//GO(scandirat64,
//GO(scanf,
//GO(__sched_cpualloc,
//GOI(__sched_cpucount,
//GO(__sched_cpufree,
//GO(sched_getaffinity,
//GO(sched_getaffinity,
@ -1729,18 +1737,31 @@ DATA(stdin, 8)
DATA(stdout, 8)
//GOW(step,
//GO(stime,
//GOI(__stpcpy,
//GOI(stpcpy,
//GO(__stpcpy_chk,
//GO(__stpcpy_small,
//GOI(__stpncpy,
//GOI(stpncpy,
//GO(__stpncpy_chk,
//GOI(__strcasecmp,
//GOI(strcasecmp,
//GOI(__strcasecmp_l,
//GOI(strcasecmp_l,
//GO(__strcasestr,
//GOW(strcasestr,
//GOI(strcat,
//GO(__strcat_chk,
//GOI(strchr,
//GOI(strchrnul,
GO(strcmp, iFpp)
//GO(strcoll,
//GO(__strcoll_l,
//GOW(strcoll_l,
//GOI(strcpy,
//GO(__strcpy_chk,
//GO(__strcpy_small,
//GOI(strcspn,
//GO(__strcspn_c1,
//GO(__strcspn_c2,
//GO(__strcspn_c3,
@ -1766,23 +1787,34 @@ GO(strcmp, iFpp)
//GO(__strftime_l,
//GOW(strftime_l,
GO(strlen, LFp)
//GO(__strncat_chk,
//GO(__strncpy_chk,
//GO(__strndup,
//GOW(strndup,
GO(strncasecmp, iFppL)
//GOI(__strncasecmp_l,
//GOI(strncasecmp_l,
GO(strncat, pFppL)
GO(__strncat_chk, pFppLL)
GO(strncmp, iFppL)
GO(strncpy, pFppL)
GO(__strncpy_chk, pFppLL)
GO(__strndup, pFpL)
GOW(strndup, pFpL)
GO(strnlen, LFpL)
GO(strpbrk, pFpp)
//GO(__strpbrk_c2,
//GO(__strpbrk_c3,
//GO(strptime,
//GOW(strptime_l,
//GOI(strrchr,
//GOW(strsep,
//GO(__strsep_1c,
//GO(__strsep_2c,
//GO(__strsep_3c,
//GO(__strsep_g,
//GO(strsignal,
//GOI(strspn,
//GO(__strspn_c1,
//GO(__strspn_c2,
//GO(__strspn_c3,
//GOI(strstr,
//GO(strtod,
//GO(__strtod_internal,
//GO(__strtod_l,
@ -1927,6 +1959,7 @@ GOM(syscall, iFEv)
//GO(thrd_equal,
//GO(thrd_sleep,
//GO(thrd_yield,
//GOI(time,
//GO(timegm,
//GOW(timelocal,
//GO(timerfd_create,
@ -2063,26 +2096,33 @@ GO(usleep, iFu)
//GOW(wcscasecmp_l,
//GOW(wcscat,
//GO(__wcscat_chk,
//GOI(wcschr,
//GOW(wcschrnul,
//GOI(wcscmp,
//GOW(wcscoll,
//GO(__wcscoll_l,
//GOW(wcscoll_l,
//GOI(wcscpy,
//GO(__wcscpy_chk,
//GO(wcscspn,
//GO(wcsdup,
//GO(wcsftime,
//GO(__wcsftime_l,
//GOW(wcsftime_l,
//GOI(wcslen,
//GOW(wcsncasecmp,
//GO(__wcsncasecmp_l,
//GOW(wcsncasecmp_l,
//GO(wcsncat,
//GO(__wcsncat_chk,
//GOI(wcsncmp,
//GOW(wcsncpy,
//GO(__wcsncpy_chk,
//GOW(wcsnrtombs,
//GO(__wcsnrtombs_chk,
//GOI(wcsnlen,
//GO(wcspbrk,
//GOI(wcsrchr,
//GOW(wcsrtombs,
//GO(__wcsrtombs_chk,
//GO(wcsspn,
@ -2148,12 +2188,16 @@ GOW(wctype, uFp)
GOW(wctype_l, uFpp)
GO(__wctype_l, uFpp)
//GO(wcwidth,
//GOI(wmemchr,
//GOI(wmemcmp,
//GOW(wmemcpy,
//GO(__wmemcpy_chk,
//GOW(wmemmove,
//GO(__wmemmove_chk,
//GOW(wmempcpy,
//GO(__wmempcpy_chk,
//GOI(wmemset,
//GOI(__wmemset_chk,
//GO(wordexp,
//GO(wordfree,
//GO(__woverflow,
@ -2247,55 +2291,11 @@ GO(__wctype_l, uFpp)
//GO(__xstat,
//GO(__xstat64,
GOM(_Jv_RegisterClasses, vFv) // dummy
GOM(_ITM_addUserCommitAction, vFEpup)
GOM(_ITM_registerTMCloneTable, vFEpu)
GOM(_ITM_deregisterTMCloneTable, vFEp)
GOM(__register_frame_info, vFpp) // faked function
GOM(__deregister_frame_info, pFp)
//GOI(bcmp,
//GOI(__gettimeofday,
//GOI(gettimeofday,
//GOI(index,
//GOI(__rawmemchr,
//GOI(rawmemchr,
//GOI(rindex,
//GOI(__sched_cpucount,
//GOI(__stpcpy,
//GOI(stpcpy,
//GOI(__stpncpy,
//GOI(stpncpy,
//GOI(__strcasecmp,
//GOI(strcasecmp,
//GOI(__strcasecmp_l,
//GOI(strcasecmp_l,
//GOI(strcat,
//GOI(strchr,
//GOI(strchrnul,
//GOI(strcmp,
//GOI(strcpy,
//GOI(strcspn,
//GOI(strncasecmp,
//GOI(__strncasecmp_l,
//GOI(strncasecmp_l,
//GOI(strncat,
//GOI(strncmp,
//GOI(strncpy,
//GOI(strnlen,
//GOI(strpbrk,
//GOI(strrchr,
//GOI(strspn,
//GOI(strstr,
//GOI(time,
//GOI(wcschr,
//GOI(wcscmp,
//GOI(wcscpy,
//GOI(wcslen,
//GOI(wcsncmp,
//GOI(wcsnlen,
//GOI(wcsrchr,
//GOI(wmemchr,
//GOI(wmemcmp,
//GOI(wmemset,
//GOI(__wmemset_chk,

193
src/wrapped/wrappedlibgl.c Executable file
View File

@ -0,0 +1,193 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include "wrappedlibs.h"
#include "debug.h"
#include "wrapper.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "emu/x64emu_private.h"
#include "box64context.h"
#include "librarian.h"
#include "callback.h"
extern char* libGL;
const char* libglName = "libGL.so.1";
#define LIBNAME libgl
void fillGLProcWrapper(box64context_t*);
void freeProcWrapper(kh_symbolmap_t** symbolmap);
EXPORT void* my_glXGetProcAddress(x64emu_t* emu, void* name)
{
khint_t k;
const char* rname = (const char*)name;
if(dlsym_error && box64_log<LOG_DEBUG) printf_log(LOG_NONE, "Calling glXGetProcAddress(\"%s\") => ", rname);
if(!emu->context->glwrappers)
fillGLProcWrapper(emu->context);
// check if glxprocaddress is filled, and search for lib and fill it if needed
// get proc adress using actual glXGetProcAddress
k = kh_get(symbolmap, emu->context->glmymap, rname);
int is_my = (k==kh_end(emu->context->glmymap))?0:1;
void* symbol;
if(is_my) {
// try again, by using custom "my_" now...
char tmp[200];
strcpy(tmp, "my_");
strcat(tmp, rname);
symbol = dlsym(emu->context->box64lib, tmp);
} else
symbol = emu->context->glxprocaddress(rname);
if(!symbol) {
if(dlsym_error && box64_log<LOG_DEBUG) printf_log(LOG_NONE, "%p\n", NULL);
return NULL; // easy
}
// check if alread bridged
uintptr_t ret = CheckBridged(emu->context->system, symbol);
if(ret) {
if(dlsym_error && box64_log<LOG_DEBUG) printf_log(LOG_NONE, "%p\n", (void*)ret);
return (void*)ret; // already bridged
}
// get wrapper
k = kh_get(symbolmap, emu->context->glwrappers, rname);
if(k==kh_end(emu->context->glwrappers) && strstr(rname, "ARB")==NULL) {
// try again, adding ARB at the end if not present
char tmp[200];
strcpy(tmp, rname);
strcat(tmp, "ARB");
k = kh_get(symbolmap, emu->context->glwrappers, tmp);
}
if(k==kh_end(emu->context->glwrappers) && strstr(rname, "EXT")==NULL) {
// try again, adding EXT at the end if not present
char tmp[200];
strcpy(tmp, rname);
strcat(tmp, "EXT");
k = kh_get(symbolmap, emu->context->glwrappers, tmp);
}
if(k==kh_end(emu->context->glwrappers)) {
if(dlsym_error && box64_log<LOG_DEBUG) printf_log(LOG_NONE, "%p\n", NULL);
if(dlsym_error && box64_log<LOG_INFO) printf_log(LOG_NONE, "Warning, no wrapper for %s\n", rname);
return NULL;
}
AddOffsetSymbol(emu->context->maplib, symbol, rname);
ret = AddBridge(emu->context->system, kh_value(emu->context->glwrappers, k), symbol, 0);
if(dlsym_error && box64_log<LOG_DEBUG) printf_log(LOG_NONE, "%p\n", (void*)ret);
return (void*)ret;
}
EXPORT void* my_glXGetProcAddressARB(x64emu_t* emu, void* name) __attribute__((alias("my_glXGetProcAddress")));
typedef int (*iFi_t)(int);
typedef void (*vFpp_t)(void*, void*);
typedef void (*debugProc_t)(int32_t, int32_t, uint32_t, int32_t, int32_t, void*, void*);
#define SUPER() \
GO(0) \
GO(1) \
GO(2) \
GO(3) \
GO(4)
// debug_callback ...
#define GO(A) \
static uintptr_t my_debug_callback_fct_##A = 0; \
static void my_debug_callback_##A(int32_t a, int32_t b, uint32_t c, int32_t d, int32_t e, const char* f, const void* g) \
{ \
RunFunction(my_context, my_debug_callback_fct_##A, 7, a, b, c, d, e, f, g); \
}
SUPER()
#undef GO
static void* find_debug_callback_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_debug_callback_fct_##A == (uintptr_t)fct) return my_debug_callback_##A;
SUPER()
#undef GO
#define GO(A) if(my_debug_callback_fct_##A == 0) {my_debug_callback_fct_##A = (uintptr_t)fct; return my_debug_callback_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for libGL debug_callback callback\n");
return NULL;
}
#undef SUPER
EXPORT void my_glDebugMessageCallback(x64emu_t* emu, void* prod, void* param)
{
static vFpp_t DebugMessageCallback = NULL;
static int init = 1;
if(init) {
DebugMessageCallback = emu->context->glxprocaddress("glDebugMessageCallback");
init = 0;
}
if(!DebugMessageCallback)
return;
DebugMessageCallback(find_debug_callback_Fct(prod), param);
}
EXPORT void my_glDebugMessageCallbackARB(x64emu_t* emu, void* prod, void* param) __attribute__((alias("my_glDebugMessageCallback")));
EXPORT int my_glXSwapIntervalMESA(int interval)
{
static iFi_t SwapIntervalMESA = NULL;
static int init = 1;
if(init) {
SwapIntervalMESA = my_context->glxprocaddress("glXSwapIntervalMESA");
init = 0;
}
if(!SwapIntervalMESA)
return 0;
return SwapIntervalMESA(interval);
}
#define PRE_INIT if(libGL) {lib->priv.w.lib = dlopen(libGL, RTLD_LAZY | RTLD_GLOBAL); lib->path = strdup(libGL);} else
#define CUSTOM_INIT \
lib->priv.w.priv = dlsym(lib->priv.w.lib, "glXGetProcAddress"); \
box64->glxprocaddress = lib->priv.w.priv;
#include "wrappedlib_init.h"
void fillGLProcWrapper(box64context_t* context)
{
int cnt, ret;
khint_t k;
kh_symbolmap_t * symbolmap = kh_init(symbolmap);
// populates maps...
cnt = sizeof(libglsymbolmap)/sizeof(map_onesymbol_t);
for (int i=0; i<cnt; ++i) {
k = kh_put(symbolmap, symbolmap, libglsymbolmap[i].name, &ret);
kh_value(symbolmap, k) = libglsymbolmap[i].w;
}
// and the my_ symbols map
cnt = sizeof(MAPNAME(mysymbolmap))/sizeof(map_onesymbol_t);
for (int i=0; i<cnt; ++i) {
k = kh_put(symbolmap, symbolmap, libglmysymbolmap[i].name, &ret);
kh_value(symbolmap, k) = libglmysymbolmap[i].w;
}
context->glwrappers = symbolmap;
// my_* map
symbolmap = kh_init(symbolmap);
cnt = sizeof(MAPNAME(mysymbolmap))/sizeof(map_onesymbol_t);
for (int i=0; i<cnt; ++i) {
k = kh_put(symbolmap, symbolmap, libglmysymbolmap[i].name, &ret);
kh_value(symbolmap, k) = libglmysymbolmap[i].w;
}
context->glmymap = symbolmap;
}
void freeGLProcWrapper(box64context_t* context)
{
if(!context)
return;
if(context->glwrappers)
kh_destroy(symbolmap, context->glwrappers);
if(context->glmymap)
kh_destroy(symbolmap, context->glmymap);
context->glwrappers = NULL;
context->glmymap = NULL;
}

3005
src/wrapped/wrappedlibgl_private.h Executable file

File diff suppressed because it is too large Load Diff

174
src/wrapped/wrappedlibglu.c Executable file
View File

@ -0,0 +1,174 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include "wrappedlibs.h"
#include "debug.h"
#include "wrapper.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "emu/x64emu_private.h"
#include "callback.h"
#include "librarian.h"
#include "box64context.h"
#include "emu/x64emu_private.h"
#include "myalign.h"
typedef void (*vFpip_t)(void*, int32_t, void*);
static library_t* my_lib = NULL;
#define SUPER() \
GO(gluQuadricCallback, vFpip_t) \
GO(gluTessCallback, vFpip_t) \
GO(gluNurbsCallback, vFpip_t)
typedef struct libglu_my_s {
// functions
#define GO(A, B) B A;
SUPER()
#undef GO
} libglu_my_t;
void* getGLUMy(library_t* lib)
{
libglu_my_t* my = (libglu_my_t*)calloc(1, sizeof(libglu_my_t));
#define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A);
SUPER()
#undef GO
return my;
}
void freeGLUMy(void* lib)
{
//libglu_my_t *my = (libglu_my_t *)lib;
}
#undef SUPER
#define SUPER() \
GO(0) \
GO(1) \
GO(2) \
GO(3) \
GO(4) \
GO(5) \
GO(6) \
GO(7) \
GO(8) \
GO(9) \
// glu_callback
#define GO(A) \
static uintptr_t my_glu_callback_fct_##A = 0; \
static void my_glu_callback_##A(void* a, void* b) \
{ \
RunFunction(my_context, my_glu_callback_fct_##A, 2, a, b); \
}
SUPER()
#undef GO
static void* findglu_callbackFct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_glu_callback_fct_##A == (uintptr_t)fct) return my_glu_callback_##A;
SUPER()
#undef GO
#define GO(A) if(my_glu_callback_fct_##A == 0) {my_glu_callback_fct_##A = (uintptr_t)fct; return my_glu_callback_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for Jpeg glu_callback callback\n");
return NULL;
}
// glu_callback4
#define GO(A) \
static uintptr_t my_glu_callback4_fct_##A = 0; \
static void my_glu_callback4_##A(void* a, void* b, void* c, void* d) \
{ \
RunFunction(my_context, my_glu_callback4_fct_##A, 4, a, b, c, d); \
}
SUPER()
#undef GO
static void* findglu_callback4Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_glu_callback4_fct_##A == (uintptr_t)fct) return my_glu_callback4_##A;
SUPER()
#undef GO
#define GO(A) if(my_glu_callback4_fct_##A == 0) {my_glu_callback4_fct_##A = (uintptr_t)fct; return my_glu_callback4_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for Jpeg glu_callback4 callback\n");
return NULL;
}
// glu_callback5
#define GO(A) \
static uintptr_t my_glu_callback5_fct_##A = 0; \
static void my_glu_callback5_##A(void* a, void* b, void* c, void* d, void* e) \
{ \
RunFunction(my_context, my_glu_callback5_fct_##A, 5, a, b, c, d, e); \
}
SUPER()
#undef GO
static void* findglu_callback5Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_glu_callback5_fct_##A == (uintptr_t)fct) return my_glu_callback5_##A;
SUPER()
#undef GO
#define GO(A) if(my_glu_callback5_fct_##A == 0) {my_glu_callback5_fct_##A = (uintptr_t)fct; return my_glu_callback5_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for Jpeg glu_callback5 callback\n");
return NULL;
}
#undef SUPER
// There are many callback signatures: vFv, vFi, vFp, vFip and vFpp... so a generic wrapping to vFpp works
// except for GLU_TESS_COMBINE and GLU_TESS_COMBINE_DATA
#define GLU_TESS_COMBINE 100105
#define GLU_TESS_COMBINE_DATA 100111
void EXPORT my_gluQuadricCallback(x64emu_t* emu, void* a, int32_t b, void* cb)
{
libglu_my_t *my = (libglu_my_t*)my_lib->priv.w.p2;
my->gluQuadricCallback(a, b, findglu_callbackFct(cb));
}
void EXPORT my_gluTessCallback(x64emu_t* emu, void* a, int32_t b, void* cb)
{
libglu_my_t *my = (libglu_my_t*)my_lib->priv.w.p2;
if(b==GLU_TESS_COMBINE)
my->gluTessCallback(a, b, findglu_callback4Fct(cb));
else if(b==GLU_TESS_COMBINE_DATA)
my->gluTessCallback(a, b, findglu_callback5Fct(cb));
else
my->gluTessCallback(a, b, findglu_callbackFct(cb));
}
void EXPORT my_gluNurbsCallback(x64emu_t* emu, void* a, int32_t b, void* cb)
{
libglu_my_t *my = (libglu_my_t*)my_lib->priv.w.p2;
my->gluNurbsCallback(a, b, findglu_callbackFct(cb));
}
const char* libgluName = "libGLU.so.1";
#define LIBNAME libglu
#define CUSTOM_INIT \
my_lib = lib; \
lib->priv.w.p2 = getGLUMy(lib); \
lib->priv.w.needed = 1; \
lib->priv.w.neededlibs = (char**)calloc(lib->priv.w.needed, sizeof(char*)); \
lib->priv.w.neededlibs[0] = strdup("libGL.so.1"); \
#define CUSTOM_FINI \
freeGLUMy(lib->priv.w.p2); \
free(lib->priv.w.p2); \
my_lib = NULL;
#include "wrappedlib_init.h"

View File

@ -0,0 +1,63 @@
#if defined(GO) && defined(GOM) && defined(GO2) && defined(DATA)
GO(gluBeginCurve,vFp)
GO(gluBeginPolygon,vFp)
GO(gluBeginSurface,vFp)
GO(gluBeginTrim,vFp)
GO(gluBuild1DMipmapLevels,iFiiiiiiiip)
GO(gluBuild1DMipmaps,iFiiiiip)
GO(gluBuild2DMipmapLevels,iFiiiiiiiiip)
GO(gluBuild2DMipmaps,iFiiiiiip)
GO(gluBuild3DMipmapLevels,iFiiiiiiiiiip)
GO(gluBuild3DMipmaps,iFiiiiiiip)
GO(gluCheckExtension,iFpp)
GO(gluCylinder,vFpdddii)
GO(gluDeleteNurbsRenderer,vFp)
GO(gluDeleteQuadric,vFp)
GO(gluDeleteTess,vFp)
GO(gluDisk,vFpddii)
GO(gluEndCurve,vFp)
GO(gluEndPolygon,vFp)
GO(gluEndSurface,vFp)
GO(gluEndTrim,vFp)
GO(gluErrorString,pFi)
GO(gluGetNurbsProperty,vFpip)
GO(gluGetString,pFi)
GO(gluGetTessProperty,vFpip)
GO(gluLoadSamplingMatrices,vFpppp)
GO(gluLookAt,vFddddddddd)
GO(gluNewNurbsRenderer,pFv)
GO(gluNewQuadric,pFv)
GO(gluNewTess,pFv)
GO(gluNextContour,vFpi)
GOM(gluNurbsCallback,vFEpip)
GO(gluNurbsCallbackData,vFpp) // to check
GO(gluNurbsCallbackDataEXT,vFpp) // to check
GO(gluNurbsCurve,vFpipipii)
GO(gluNurbsProperty,vFpif)
GO(gluNurbsSurface,vFpipipiipiii)
GO(gluOrtho2D,vFdddd)
GO(gluPartialDisk,vFpddiidd)
GO(gluPerspective,vFdddd)
GO(gluPickMatrix,vFddddp)
GO(gluProject,iFdddpppppp)
GO(gluPwlCurve,vFpipii)
GOM(gluQuadricCallback,vFEpip)
GO(gluQuadricDrawStyle,vFpi)
GO(gluQuadricNormals,vFpi)
GO(gluQuadricOrientation,vFpi)
GO(gluQuadricTexture,vFpi)
GO(gluScaleImage,iFiiiipiiip)
GO(gluSphere,vFpdii)
GO(gluTessBeginContour,vFp)
GO(gluTessBeginPolygon,vFpp)
GOM(gluTessCallback,vFEpip)
GO(gluTessEndContour,vFp)
GO(gluTessEndPolygon,vFp)
GO(gluTessNormal,vFpddd)
GO(gluTessProperty,vFpid)
GO(gluTessVertex,vFppp)
GO(gluUnProject,iFdddpppppp)
GO(gluUnProject4,iFddddpppddpppp)
#endif

224
src/wrapped/wrappedopenal.c Executable file
View File

@ -0,0 +1,224 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include "wrappedlibs.h"
#include "debug.h"
#include "wrapper.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "emu/x64emu_private.h"
#include "callback.h"
#include "box64context.h"
#include "librarian.h"
#include "myalign.h"
static char* libname = NULL;
typedef void* (*pFp_t)(void*);
typedef void* (*pFpp_t)(void*, void*);
typedef void (*vFv_t)();
typedef void (*vFiiipp_t)(int32_t, int32_t, int32_t, void*, void*);
typedef struct openal_my_s {
// functions
pFp_t alGetProcAddress;
pFpp_t alcGetProcAddress;
vFiiipp_t alRequestFoldbackStart;
vFv_t alRequestFoldbackStop;
} openal_my_t;
void* getOpenALMy(library_t* lib)
{
openal_my_t* my = (openal_my_t*)calloc(1, sizeof(openal_my_t));
#define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A);
GO(alGetProcAddress, pFp_t)
GO(alcGetProcAddress, pFpp_t)
GO(alRequestFoldbackStart, vFiiipp_t)
GO(alRequestFoldbackStop, vFv_t)
#undef GO
return my;
}
void freeOpenALMy(void* lib)
{
//openal_my_t *my = (openal_my_t *)lib;
}
#define SUPER() \
GO(0) \
GO(1) \
GO(2) \
GO(3) \
GO(4)
// Request ...
#define GO(A) \
static uintptr_t my_Request_fct_##A = 0; \
static void my_Request_##A(int32_t a, int32_t b) \
{ \
RunFunction(my_context, my_Request_fct_##A, 2, a, b); \
}
SUPER()
#undef GO
static void* find_Request_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_Request_fct_##A == (uintptr_t)fct) return my_Request_##A;
SUPER()
#undef GO
#define GO(A) if(my_Request_fct_##A == 0) {my_Request_fct_##A = (uintptr_t)fct; return my_Request_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for zlib Request callback\n");
return NULL;
}
#undef SUPER
void* my_alGetProcAddress(x64emu_t* emu, void* name);
void* my_alcGetProcAddress(x64emu_t* emu, void* device, void* name);
void my_alRequestFoldbackStart(x64emu_t *emu, int32_t mode, int32_t count, int32_t length, void* mem, void* cb);
void my_alRequestFoldbackStop(x64emu_t* emu);
const char* openalName = "libopenal.so.1";
#define LIBNAME openal
#define CUSTOM_INIT \
libname = lib->name; \
lib->priv.w.p2 = getOpenALMy(lib);
#define CUSTOM_FINI \
freeOpenALMy(lib->priv.w.p2); \
free(lib->priv.w.p2);
#include "wrappedlib_init.h"
void fillALProcWrapper(box64context_t* context)
{
int cnt, ret;
khint_t k;
kh_symbolmap_t * symbolmap = kh_init(symbolmap);
// populates maps...
cnt = sizeof(openalsymbolmap)/sizeof(map_onesymbol_t);
for (int i=0; i<cnt; ++i) {
k = kh_put(symbolmap, symbolmap, openalsymbolmap[i].name, &ret);
kh_value(symbolmap, k) = openalsymbolmap[i].w;
}
// and the my_ symbols map
cnt = sizeof(MAPNAME(mysymbolmap))/sizeof(map_onesymbol_t);
for (int i=0; i<cnt; ++i) {
k = kh_put(symbolmap, symbolmap, openalmysymbolmap[i].name, &ret);
kh_value(symbolmap, k) = openalmysymbolmap[i].w;
}
context->alwrappers = symbolmap;
// fill my_* map
symbolmap = kh_init(symbolmap);
cnt = sizeof(MAPNAME(mysymbolmap))/sizeof(map_onesymbol_t);
for (int i=0; i<cnt; ++i) {
k = kh_put(symbolmap, symbolmap, openalmysymbolmap[i].name, &ret);
kh_value(symbolmap, k) = openalmysymbolmap[i].w;
}
context->almymap = symbolmap;
}
void freeALProcWrapper(box64context_t* context)
{
if(!context)
return;
if(context->alwrappers)
kh_destroy(symbolmap, context->alwrappers);
if(context->almymap)
kh_destroy(symbolmap, context->almymap);
context->alwrappers = NULL;
context->almymap = NULL;
}
EXPORT void* my_alGetProcAddress(x64emu_t* emu, void* name)
{
khint_t k;
openal_my_t* my = (openal_my_t*)GetLibInternal(libname)->priv.w.p2;
const char* rname = (const char*)name;
printf_log(LOG_DEBUG, "Calling alGetProcAddress(%s)\n", rname);
if(!emu->context->alwrappers) // could be moved in "my" structure...
fillALProcWrapper(emu->context);
// get proc adress using actual alGetProcAddress
k = kh_get(symbolmap, emu->context->almymap, rname);
int is_my = (k==kh_end(emu->context->almymap))?0:1;
void* symbol;
if(is_my) {
// try again, by using custom "my_" now...
char tmp[200];
strcpy(tmp, "my_");
strcat(tmp, rname);
symbol = dlsym(emu->context->box64lib, tmp);
} else
symbol = my->alGetProcAddress(name);
if(!symbol)
return NULL; // easy
// check if alread bridged
uintptr_t ret = CheckBridged(emu->context->system, symbol);
if(ret)
return (void*)ret; // already bridged
// get wrapper
k = kh_get(symbolmap, emu->context->alwrappers, rname);
if(k==kh_end(emu->context->alwrappers)) {
printf_log(LOG_INFO, "Warning, no wrapper for %s\n", rname);
return NULL;
}
AddOffsetSymbol(emu->context->maplib, symbol, rname);
return (void*)AddBridge(emu->context->system, kh_value(emu->context->alwrappers, k), symbol, 0);
}
EXPORT void* my_alcGetProcAddress(x64emu_t* emu, void* device, void* name)
{
khint_t k;
openal_my_t* my = (openal_my_t*)GetLibInternal(libname)->priv.w.p2;
const char* rname = (const char*)name;
printf_log(LOG_DEBUG, "Calling alcGetProcAddress(%p, %s)\n", device, rname);
if(!emu->context->alwrappers) // could be moved in "my" structure...
fillALProcWrapper(emu->context);
// get proc adress using actual alGetProcAddress
k = kh_get(symbolmap, emu->context->almymap, rname);
int is_my = (k==kh_end(emu->context->almymap))?0:1;
void* symbol;
if(is_my) {
// try again, by using custom "my_" now...
char tmp[200];
strcpy(tmp, "my_");
strcat(tmp, rname);
symbol = dlsym(emu->context->box64lib, tmp);
} else
symbol = my->alcGetProcAddress(device, name);
if(!symbol)
return NULL; // easy
uintptr_t ret = CheckBridged(emu->context->system, symbol);
if(ret)
return (void*)ret; // already bridged
// get wrapper
k = kh_get(symbolmap, emu->context->alwrappers, rname);
if(k==kh_end(emu->context->alwrappers)) {
printf_log(LOG_INFO, "Warning, no wrapper for %s\n", rname);
return NULL;
}
AddOffsetSymbol(emu->context->maplib, symbol, rname);
return (void*)AddBridge(emu->context->system, kh_value(emu->context->alwrappers, k), symbol, 0);
}
EXPORT void my_alRequestFoldbackStart(x64emu_t *emu, int32_t mode, int32_t count, int32_t length, void* mem, void* cb)
{
openal_my_t* my = (openal_my_t*)GetLibInternal(libname)->priv.w.p2;
my->alRequestFoldbackStart(mode, count, length, mem, find_Request_Fct(cb));
}
EXPORT void my_alRequestFoldbackStop(x64emu_t* emu)
{
openal_my_t* my = (openal_my_t*)GetLibInternal(libname)->priv.w.p2;
my->alRequestFoldbackStop();
}

View File

@ -0,0 +1,167 @@
#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA))
#error Meh...
#endif
GO(alDopplerFactor,vFf)
GO(alDopplerVelocity,vFf)
GO(alSpeedOfSound,vFf)
GO(alDistanceModel,vFi)
GO(alEnable,vFi)
GO(alDisable,vFi)
GO(alIsEnabled,cFi)
GO(alGetString,pFi)
GO(alGetBooleanv,vFip)
GO(alGetIntegerv,vFip)
GO(alGetFloatv,vFip)
GO(alGetDoublev,vFip)
GO(alGetBoolean,iFi)
GO(alGetInteger,iFi)
GO(alGetFloat,fFi)
GO(alGetDouble,dFi)
GO(alGetError,iFv)
GO(alIsExtensionPresent,cFp)
GOM(alGetProcAddress,pFEp)
GO(alGetEnumValue,iFp)
GO(alListenerf,vFif)
GO(alListener3f,vFifff)
GO(alListenerfv,vFip)
GO(alListeneri,vFii)
GO(alListener3i,vFiiii)
GO(alListeneriv,vFip)
GO(alGetListenerf,vFip)
GO(alGetListener3f,vFippp)
GO(alGetListenerfv,vFip)
GO(alGetListeneri,vFip)
GO(alGetListener3i,vFippp)
GO(alGetListeneriv,vFip)
GO(alGenSources,vFip)
GO(alDeleteSources,vFip)
GO(alIsSource,cFu)
GO(alSourcef,vFuif)
GO(alSource3f,vFuifff)
GO(alSourcefv,vFuip)
GO(alSourcei,vFuii)
GO(alSource3i,vFuiiii)
GO(alSourceiv,vFuip)
GO(alGetSourcef,vFuip)
GO(alGetSource3f,vFuippp)
GO(alGetSourcefv,vFuip)
GO(alGetSourcei,vFuip)
GO(alGetSource3i,vFuippp)
GO(alGetSourceiv,vFuip)
GO(alSourcePlayv,vFip)
GO(alSourceStopv,vFip)
GO(alSourceRewindv,vFip)
GO(alSourcePausev,vFip)
GO(alSourcePlay,vFu)
GO(alSourceStop,vFu)
GO(alSourceRewind,vFu)
GO(alSourcePause,vFu)
GO(alSourceQueueBuffers,vFuip)
GO(alSourceUnqueueBuffers,vFuip)
GO(alGenBuffers,vFip)
GO(alDeleteBuffers,vFip)
GO(alIsBuffer,cFu)
GO(alBufferData,vFuipii)
GO(alBufferf,vFuif)
GO(alBuffer3f,vFuifff)
GO(alBufferfv,vFuip)
GO(alBufferi,vFuii)
GO(alBuffer3i,vFuiiii)
GO(alBufferiv,vFuip)
GO(alGetBufferf,vFuip)
GO(alGetBuffer3f,vFuippp)
GO(alGetBufferfv,vFuip)
GO(alGetBufferi,vFuip)
GO(alGetBuffer3i,vFuippp)
GO(alGetBufferiv,vFuip)
GO(alcCreateContext,pFpp)
GO(alcMakeContextCurrent,iFp)
GO(alcProcessContext,vFp)
GO(alcSuspendContext,vFp)
GO(alcDestroyContext,vFp)
GO(alcGetCurrentContext,pFv)
GO(alcGetContextsDevice,pFp)
GO(alcOpenDevice,pFp)
GO(alcCloseDevice,iFp)
GO(alcGetError,iFp)
GO(alcIsExtensionPresent,cFpp)
GOM(alcGetProcAddress,pFEpp)
GO(alcGetEnumValue,iFpp)
GO(alcGetString,pFpi)
GO(alcGetIntegerv,vFpiip)
GO(alcCaptureOpenDevice,pFpuii)
GO(alcCaptureCloseDevice,iFp)
GO(alcCaptureStart,vFp)
GO(alcCaptureStop,vFp)
GO(alcCaptureSamples,vFppi)
GO(alcGetThreadContext, pFv)
GO(alcSetThreadContext, iFp)
GO(alcLoopbackOpenDeviceSOFT, pFp)
GO(alcIsRenderFormatSupportedSOFT, cFpiii)
GO(alcRenderSamplesSOFT, vFppi)
GO(alcDevicePauseSOFT, vFp)
GO(alcDeviceResumeSOFT, vFp)
GO(alcGetStringiSOFT, pFpii)
GO(alcResetDeviceSOFT, iFpp)
GO(alcGetInteger64vSOFT, vFpiip)
GO(alBufferDataStatic,vFiipii)
GO(alBufferSubDataSOFT,vFuipii)
GOM(alRequestFoldbackStart,vFEiiipp)
GOM(alRequestFoldbackStop,vFE)
GO(alBufferSamplesSOFT,vFuuiiiip)
GO(alBufferSubSamplesSOFT,vFuiiiip)
GO(alGetBufferSamplesSOFT,vFuiiiip)
GO(alIsBufferFormatSupportedSOFT,cFi)
GO(alSourcedSOFT,vFuid)
GO(alSource3dSOFT,vFuiddd)
GO(alSourcedvSOFT,vFuip)
GO(alGetSourcedSOFT,vFuip)
GO(alGetSource3dSOFT,vFuippp)
GO(alGetSourcedvSOFT,vFuip)
GO(alSourcei64SOFT,vFuiI)
GO(alSource3i64SOFT,vFuiIII)
GO(alSourcei64vSOFT,vFuip)
GO(alGetSourcei64SOFT,vFuip)
GO(alGetSource3i64SOFT,vFuippp)
GO(alGetSourcei64vSOFT,vFuip)
GO(alDeferUpdatesSOFT,vFv)
GO(alProcessUpdatesSOFT,vFv)
GO(alGetStringiSOFT,pFii)
GO(alGenEffects,vFip)
GO(alDeleteEffects,vFip)
GO(alIsEffect,cFu)
GO(alEffecti,vFuii)
GO(alEffectiv,vFuip)
GO(alEffectf,vFuif)
GO(alEffectfv,vFuip)
GO(alGetEffecti,vFuip)
GO(alGetEffectiv,vFuip)
GO(alGetEffectf,vFuip)
GO(alGetEffectfv,vFuip)
GO(alGenFilters,vFip)
GO(alDeleteFilters,vFip)
GO(alIsFilter,cFu)
GO(alFilteri,vFuii)
GO(alFilteriv,vFuip)
GO(alFilterf,vFuif)
GO(alFilterfv,vFuip)
GO(alGetFilteri,vFuip)
GO(alGetFilteriv,vFuip)
GO(alGetFilterf,vFuip)
GO(alGetFilterfv,vFuip)
GO(alGenAuxiliaryEffectSlots,vFip)
GO(alDeleteAuxiliaryEffectSlots,vFip)
GO(alIsAuxiliaryEffectSlot,cFu)
GO(alAuxiliaryEffectSloti,vFuii)
GO(alAuxiliaryEffectSlotiv,vFuip)
GO(alAuxiliaryEffectSlotf,vFuif)
GO(alAuxiliaryEffectSlotfv,vFuip)
GO(alGetAuxiliaryEffectSloti,vFuip)
GO(alGetAuxiliaryEffectSlotiv,vFuip)
GO(alGetAuxiliaryEffectSlotf,vFuip)
GO(alGetAuxiliaryEffectSlotfv,vFuip)

574
src/wrapped/wrappedsdl1.c Executable file
View File

@ -0,0 +1,574 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include "wrappedlibs.h"
#include "wrapper.h"
#include "debug.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "callback.h"
#include "librarian.h"
#include "emu/x64emu_private.h"
#include "box64context.h"
#include "sdl1rwops.h"
#include "x64trace.h"
#include "threads.h"
const char* sdl1Name = "libSDL-1.2.so.0";
#define LIBNAME sdl1
int sdl_Yes() { return 1; }
int sdl_No() { return 0; }
int EXPORT my_SDL_Has3DNow() __attribute__((alias("sdl_No")));
int EXPORT my_SDL_Has3DNowExt() __attribute__((alias("sdl_No")));
int EXPORT my_SDL_HasAltiVec() __attribute__((alias("sdl_No")));
int EXPORT my_SDL_HasMMX() __attribute__((alias("sdl_Yes")));
int EXPORT my_SDL_HasMMXExt() __attribute__((alias("sdl_Yes")));
int EXPORT my_SDL_HasRDTSC() __attribute__((alias("sdl_Yes")));
int EXPORT my_SDL_HasSSE() __attribute__((alias("sdl_Yes")));
int EXPORT my_SDL_HasSSE2() __attribute__((alias("sdl_Yes")));
typedef struct {
int32_t freq;
uint16_t format;
uint8_t channels;
uint8_t silence;
uint16_t samples;
uint32_t size;
void (*callback)(void *userdata, uint8_t *stream, int32_t len);
void *userdata;
} SDL_AudioSpec;
// TODO: put the wrapper type in a dedicate include
typedef void (*vFv_t)();
typedef void* (*pFv_t)();
typedef void* (*pFpi_t)(void*, int32_t);
typedef void* (*pFp_t)(void*);
typedef void* (*pFpp_t)(void*, void*);
typedef int (*iFup_t)(uint32_t, void*);
typedef int32_t (*iFp_t)(void*);
typedef int32_t (*iFppi_t)(void*, void*, int32_t);
typedef void* (*pFpippp_t)(void*, int32_t, void*, void*, void*);
typedef void (*vFp_t)(void*);
typedef void* (*pFpp_t)(void*, void*);
typedef uint32_t (*uFp_t)(void*);
typedef uint64_t (*UFp_t)(void*);
typedef uint32_t (*uFu_t)(uint32_t);
typedef int32_t (*iFpp_t)(void*, void*);
typedef uint32_t (*uFpW_t)(void*, uint16_t);
typedef uint32_t (*uFpu_t)(void*, uint32_t);
typedef uint32_t (*uFpU_t)(void*, uint64_t);
typedef uint32_t (*uFupp_t)(uint32_t, void*, void*);
#define SUPER() \
GO(SDL_Quit, vFv_t) \
GO(SDL_AllocRW, sdl1_allocrw) \
GO(SDL_FreeRW, sdl1_freerw) \
GO(SDL_OpenAudio, iFpp_t) \
GO(SDL_LoadBMP_RW, pFpi_t) \
GO(SDL_RWFromConstMem, pFpi_t) \
GO(SDL_RWFromFP, pFpi_t) \
GO(SDL_RWFromFile, pFpp_t) \
GO(SDL_RWFromMem, pFpi_t) \
GO(SDL_SaveBMP_RW, iFppi_t) \
GO(SDL_LoadWAV_RW, pFpippp_t) \
GO(SDL_ReadBE16, uFp_t) \
GO(SDL_ReadBE32, uFp_t) \
GO(SDL_ReadBE64, UFp_t) \
GO(SDL_ReadLE16, uFp_t) \
GO(SDL_ReadLE32, uFp_t) \
GO(SDL_ReadLE64, UFp_t) \
GO(SDL_WriteBE16, uFpW_t) \
GO(SDL_WriteBE32, uFpu_t) \
GO(SDL_WriteBE64, uFpU_t) \
GO(SDL_WriteLE16, uFpW_t) \
GO(SDL_WriteLE32, uFpu_t) \
GO(SDL_WriteLE64, uFpU_t) \
GO(SDL_AddTimer, uFupp_t) \
GO(SDL_RemoveTimer, uFu_t) \
GO(SDL_CreateThread, pFpp_t) \
GO(SDL_KillThread, vFp_t) \
GO(SDL_SetEventFilter, vFp_t) \
GO(SDL_GL_GetProcAddress, pFp_t) \
GO(SDL_GetWMInfo, iFp_t) \
GO(SDL_SetTimer, iFup_t) \
GO(SDL_GetEventFilter, pFv_t) \
typedef struct sdl1_my_s {
// functions
#define GO(A, B) B A;
#define GO(A, B) B A;
SUPER()
#undef GO
} sdl1_my_t;
// event filter. Needs to be global, but there is only one, so that's should be fine
x64emu_t *sdl1_evtfilter = NULL;
void* sdl1_evtfnc = NULL;
int sdl1_evtautofree = 0;
int sdl1_evtinside = 0;
void* getSDL1My(library_t* lib)
{
sdl1_my_t* my = (sdl1_my_t*)calloc(1, sizeof(sdl1_my_t));
#define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A);
SUPER()
#undef GO
return my;
}
#undef SUPER
void freeSDL1My(void* lib)
{
//sdl1_my_t *my = (sdl1_my_t *)lib;
}
#define SUPER() \
GO(0) \
GO(1) \
GO(2) \
GO(3) \
GO(4)
// AudioCallback ...
#define GO(A) \
static uintptr_t my_AudioCallback_fct_##A = 0; \
static void my_AudioCallback_##A(void *userdata, uint8_t *stream, int32_t len) \
{ \
RunFunction(my_context, my_AudioCallback_fct_##A, 3, userdata, stream, len); \
}
SUPER()
#undef GO
static void* find_AudioCallback_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_AudioCallback_fct_##A == (uintptr_t)fct) return my_AudioCallback_##A;
SUPER()
#undef GO
#define GO(A) if(my_AudioCallback_fct_##A == 0) {my_AudioCallback_fct_##A = (uintptr_t)fct; return my_AudioCallback_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for SDL1 AudioCallback callback\n");
return NULL;
}
// TimerCallback ...
#define GO(A) \
static uintptr_t my_TimerCallback_fct_##A = 0; \
static uint32_t my_TimerCallback_##A(uint32_t interval, void *userdata) \
{ \
return (uint32_t)RunFunction(my_context, my_TimerCallback_fct_##A, 2, interval, userdata); \
}
SUPER()
#undef GO
static void* find_TimerCallback_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_TimerCallback_fct_##A == (uintptr_t)fct) return my_TimerCallback_##A;
SUPER()
#undef GO
#define GO(A) if(my_TimerCallback_fct_##A == 0) {my_TimerCallback_fct_##A = (uintptr_t)fct; return my_TimerCallback_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for SDL1 TimerCallback callback\n");
return NULL;
}
// EvtFilter ...
#define GO(A) \
static uintptr_t my_EvtFilter_fct_##A = 0; \
static int my_EvtFilter_##A(void* p) \
{ \
return RunFunction(my_context, my_EvtFilter_fct_##A, 1, p); \
}
SUPER()
#undef GO
static void* find_EvtFilter_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_EvtFilter_fct_##A == (uintptr_t)fct) return my_EvtFilter_##A;
SUPER()
#undef GO
#define GO(A) if(my_EvtFilter_fct_##A == 0) {my_EvtFilter_fct_##A = (uintptr_t)fct; return my_EvtFilter_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for SDL1 EvtFilter callback\n");
return NULL;
}
static void* reverse_EvtFilterFct(void* fct)
{
if(!fct) return fct;
library_t* my_lib = my_context->sdl1lib;
if(CheckBridged(my_lib->priv.w.bridge, fct))
return (void*)CheckBridged(my_lib->priv.w.bridge, fct);
#define GO(A) if(my_EvtFilter_##A == fct) return (void*)my_EvtFilter_fct_##A;
SUPER()
#undef GO
return (void*)AddBridge(my_lib->priv.w.bridge, iFp, fct, 0);
}
#undef SUPER
// TODO: track the memory for those callback
int EXPORT my_SDL_OpenAudio(x64emu_t* emu, void* d, void* o)
{
SDL_AudioSpec *desired = (SDL_AudioSpec*)d;
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
// create a callback
void *fnc = (void*)desired->callback;
desired->callback = find_AudioCallback_Fct(desired->callback);
int ret = my->SDL_OpenAudio(desired, (SDL_AudioSpec*)o);
if (ret!=0) {
// error, clean the callback...
desired->callback = fnc;
return ret;
}
// put back stuff in place?
desired->callback = fnc;
return ret;
}
void EXPORT *my_SDL_LoadBMP_RW(x64emu_t* emu, void* a, int b)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a);
void* r = my->SDL_LoadBMP_RW(rw, b);
if(b==0)
RWNativeEnd(rw);
return r;
}
int32_t EXPORT my_SDL_SaveBMP_RW(x64emu_t* emu, void* a, void* b, int c)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a);
int32_t r = my->SDL_SaveBMP_RW(rw, b, c);
if(c==0)
RWNativeEnd(rw);
return r;
}
void EXPORT *my_SDL_LoadWAV_RW(x64emu_t* emu, void* a, int b, void* c, void* d, void* e)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a);
void* r = my->SDL_LoadWAV_RW(rw, b, c, d, e);
if(b==0)
RWNativeEnd(rw);
return r;
}
uint32_t EXPORT my_SDL_ReadBE16(x64emu_t* emu, void* a)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a);
uint32_t r = my->SDL_ReadBE16(rw);
RWNativeEnd(rw);
return r;
}
uint32_t EXPORT my_SDL_ReadBE32(x64emu_t* emu, void* a)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a);
uint32_t r = my->SDL_ReadBE32(rw);
RWNativeEnd(rw);
return r;
}
uint64_t EXPORT my_SDL_ReadBE64(x64emu_t* emu, void* a)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a);
uint64_t r = my->SDL_ReadBE64(rw);
RWNativeEnd(rw);
return r;
}
uint32_t EXPORT my_SDL_ReadLE16(x64emu_t* emu, void* a)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a);
uint32_t r = my->SDL_ReadLE16(rw);
RWNativeEnd(rw);
return r;
}
uint32_t EXPORT my_SDL_ReadLE32(x64emu_t* emu, void* a)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a);
uint32_t r = my->SDL_ReadLE32(rw);
RWNativeEnd(rw);
return r;
}
uint64_t EXPORT my_SDL_ReadLE64(x64emu_t* emu, void* a)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a);
uint64_t r = my->SDL_ReadLE64(rw);
RWNativeEnd(rw);
return r;
}
uint32_t EXPORT my_SDL_WriteBE16(x64emu_t* emu, void* a, uint16_t v)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a);
uint32_t r = my->SDL_WriteBE16(rw, v);
RWNativeEnd(rw);
return r;
}
uint32_t EXPORT my_SDL_WriteBE32(x64emu_t* emu, void* a, uint32_t v)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a);
uint32_t r = my->SDL_WriteBE32(rw, v);
RWNativeEnd(rw);
return r;
}
uint32_t EXPORT my_SDL_WriteBE64(x64emu_t* emu, void* a, uint64_t v)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a);
uint32_t r = my->SDL_WriteBE64(rw, v);
RWNativeEnd(rw);
return r;
}
uint32_t EXPORT my_SDL_WriteLE16(x64emu_t* emu, void* a, uint16_t v)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a);
uint32_t r = my->SDL_WriteLE16(rw, v);
RWNativeEnd(rw);
return r;
}
uint32_t EXPORT my_SDL_WriteLE32(x64emu_t* emu, void* a, uint32_t v)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a);
uint32_t r = my->SDL_WriteLE32(rw, v);
RWNativeEnd(rw);
return r;
}
uint32_t EXPORT my_SDL_WriteLE64(x64emu_t* emu, void* a, uint64_t v)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a);
uint32_t r = my->SDL_WriteLE64(rw, v);
RWNativeEnd(rw);
return r;
}
// SDL1 doesn't really used rw_ops->type, but box64 does, so set sensible value (from SDL2)....
void EXPORT *my_SDL_RWFromConstMem(x64emu_t* emu, void* a, int b)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* r = (SDL1_RWops_t*)my->SDL_RWFromConstMem(a, b);
RWSetType(r, 5);
return AddNativeRW(emu, r);
}
void EXPORT *my_SDL_RWFromFP(x64emu_t* emu, void* a, int b)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* r = (SDL1_RWops_t*)my->SDL_RWFromFP(a, b);
RWSetType(r, 2);
return AddNativeRW(emu, r);
}
void EXPORT *my_SDL_RWFromFile(x64emu_t* emu, void* a, void* b)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* r = (SDL1_RWops_t*)my->SDL_RWFromFile(a, b);
RWSetType(r, 2);
return AddNativeRW(emu, r);
}
void EXPORT *my_SDL_RWFromMem(x64emu_t* emu, void* a, int b)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
SDL1_RWops_t* r = (SDL1_RWops_t*)my->SDL_RWFromMem(a, b);
RWSetType(r, 4);
return AddNativeRW(emu, r);
}
uint32_t EXPORT my_SDL_AddTimer(x64emu_t* emu, uint32_t a, void* cb, void* p)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
return my->SDL_AddTimer(a, find_TimerCallback_Fct(cb), p);
}
void EXPORT my_SDL_RemoveTimer(x64emu_t* emu, uint32_t t)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
my->SDL_RemoveTimer(t);
}
int32_t EXPORT my_SDL_SetTimer(x64emu_t* emu, uint32_t t, void* p)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
return my->SDL_SetTimer(t, find_TimerCallback_Fct(p));
}
#if 0
int32_t EXPORT my_SDL_BuildAudioCVT(x64emu_t* emu, void* a, uint32_t b, uint32_t c, int32_t d, uint32_t e, uint32_t f, int32_t g)
{
printf_log(LOG_NONE, "Error, using Unimplemented SDL1 SDL_BuildAudioCVT\n");
emu->quit = 1;
return 0;
}
int32_t EXPORT my_SDL_ConvertAudio(x64emu_t* emu, void* a)
{
printf_log(LOG_NONE, "Error, using Unimplemented SDL1 SDL_ConvertAudio\n");
emu->quit = 1;
return 0;
}
#endif
void EXPORT my_SDL_SetEventFilter(x64emu_t* emu, void* a)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
my->SDL_SetEventFilter(find_EvtFilter_Fct(a));
}
void EXPORT *my_SDL_GetEventFilter(x64emu_t* emu)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
return reverse_EvtFilterFct(my->SDL_GetEventFilter());
}
void EXPORT *my_SDL_CreateThread(x64emu_t* emu, void* cb, void* p)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
void* et = NULL;
return my->SDL_CreateThread(my_prepare_thread(emu, cb, p, 0, &et), et);
}
void EXPORT my_SDL_KillThread(x64emu_t* emu, void* p)
{
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
my->SDL_KillThread(p);
}
void fillGLProcWrapper(box64context_t* context);
EXPORT void* my_SDL_GL_GetProcAddress(x64emu_t* emu, void* name)
{
khint_t k;
const char* rname = (const char*)name;
printf_log(LOG_DEBUG, "Calling SDL_GL_GetProcAddress(%s)\n", rname);
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
// check if glxprocaddress is filled, and search for lib and fill it if needed
if(!emu->context->glwrappers)
fillGLProcWrapper(emu->context);
// get proc adress using actual glXGetProcAddress
k = kh_get(symbolmap, emu->context->glmymap, rname);
int is_my = (k==kh_end(emu->context->glmymap))?0:1;
void* symbol;
if(is_my) {
// try again, by using custom "my_" now...
char tmp[200];
strcpy(tmp, "my_");
strcat(tmp, rname);
symbol = dlsym(emu->context->box64lib, tmp);
} else
symbol = my->SDL_GL_GetProcAddress(name);
if(!symbol)
return NULL; // easy
// check if alread bridged
uintptr_t ret = CheckBridged(emu->context->system, symbol);
if(ret)
return (void*)ret; // already bridged
// get wrapper
k = kh_get(symbolmap, emu->context->glwrappers, rname);
if(k==kh_end(emu->context->glwrappers) && strstr(rname, "ARB")==NULL) {
// try again, adding ARB at the end if not present
char tmp[200];
strcpy(tmp, rname);
strcat(tmp, "ARB");
k = kh_get(symbolmap, emu->context->glwrappers, tmp);
}
if(k==kh_end(emu->context->glwrappers) && strstr(rname, "EXT")==NULL) {
// try again, adding EXT at the end if not present
char tmp[200];
strcpy(tmp, rname);
strcat(tmp, "EXT");
k = kh_get(symbolmap, emu->context->glwrappers, tmp);
}
if(k==kh_end(emu->context->glwrappers)) {
printf_log(LOG_INFO, "Warning, no wrapper for %s\n", rname);
return NULL;
}
AddOffsetSymbol(emu->context->maplib, symbol, rname);
return (void*)AddBridge(emu->context->system, kh_value(emu->context->glwrappers, k), symbol, 0);
}
// DL functions from wrappedlibdl.c
void* my_dlopen(x64emu_t* emu, void *filename, int flag);
int my_dlclose(x64emu_t* emu, void *handle);
void* my_dlsym(x64emu_t* emu, void *handle, void *symbol);
EXPORT void* my_SDL_LoadObject(x64emu_t* emu, void* sofile)
{
return my_dlopen(emu, sofile, 0); // TODO: check correct flag value...
}
EXPORT void my_SDL_UnloadObject(x64emu_t* emu, void* handle)
{
my_dlclose(emu, handle);
}
EXPORT void* my_SDL_LoadFunction(x64emu_t* emu, void* handle, void* name)
{
return my_dlsym(emu, handle, name);
}
typedef struct my_SDL_version {
uint8_t major;
uint8_t minor;
uint8_t patch;
} my_SDL_version;
typedef struct {
my_SDL_version version;
int subsystem;
union {
struct {
void* display;
void* window;
void (*lock_func)(void);
void (*unlock_func)(void);
void* fswindow;
void* wmwindow;
void* gfxdisplay;
} x11;
} info;
} my_SDL_SysWMinfo;
EXPORT int32_t my_SDL_GetWMInfo(x64emu_t* emu, void* p)
{
// does SDL_SysWMinfo needs alignment?
sdl1_my_t *my = (sdl1_my_t *)emu->context->sdl1lib->priv.w.p2;
int ret = my->SDL_GetWMInfo(p);
my_SDL_SysWMinfo *info = (my_SDL_SysWMinfo*)p;
if(info->info.x11.lock_func)
info->info.x11.lock_func = (void*)AddBridge(emu->context->system, vFv, info->info.x11.lock_func, 0);
if(info->info.x11.unlock_func)
info->info.x11.unlock_func = (void*)AddBridge(emu->context->system, vFv, info->info.x11.unlock_func, 0);
return ret;
}
#define CUSTOM_INIT \
box64->sdl1lib = lib; \
lib->priv.w.p2 = getSDL1My(lib); \
box64->sdl1allocrw = ((sdl1_my_t*)lib->priv.w.p2)->SDL_AllocRW; \
box64->sdl1freerw = ((sdl1_my_t*)lib->priv.w.p2)->SDL_FreeRW; \
lib->priv.w.needed = 3; \
lib->priv.w.neededlibs = (char**)calloc(lib->priv.w.needed, sizeof(char*)); \
lib->priv.w.neededlibs[0] = strdup("libm.so.6"); \
lib->priv.w.neededlibs[1] = strdup("libdl.so.2"); \
lib->priv.w.neededlibs[2] = strdup("librt.so.1");
#define CUSTOM_FINI \
((sdl1_my_t *)lib->priv.w.p2)->SDL_Quit(); \
freeSDL1My(lib->priv.w.p2); \
free(lib->priv.w.p2); \
((box64context_t*)(lib->context))->sdl1lib = NULL; \
((box64context_t*)(lib->context))->sdl1allocrw = NULL; \
((box64context_t*)(lib->context))->sdl1freerw = NULL;
#include "wrappedlib_init.h"

238
src/wrapped/wrappedsdl1_private.h Executable file
View File

@ -0,0 +1,238 @@
#if defined(GO) && defined(GOM) && defined(GO2) && defined(DATA)
// _fini
// _init
GOM(SDL_AddTimer, pFEupp)
GO(SDL_AllocRW, pFv) // no need to use a my_ version here
GO(SDL_CDClose, vFp)
GO(SDL_CDEject, iFp)
GO(SDL_CDName, pFi)
GO(SDL_CDNumDrives, iFv)
GO(SDL_CDOpen, pFi)
GO(SDL_CDPause, iFp)
GO(SDL_CDPlay, iFpii)
GO(SDL_CDPlayTracks, iFpiiii)
GO(SDL_CDResume, iFp)
GO(SDL_CDStatus, iFp)
GO(SDL_CDStop, iFp)
GO(SDL_ClearError, vFv)
GO(SDL_CondBroadcast, iFp)
GO(SDL_CondSignal, iFp)
GO(SDL_CondWait, iFpp)
GO(SDL_CondWaitTimeout, iFppu)
GO(SDL_ConvertSurface, pFppu)
GO(SDL_CreateCond, pFv)
GO(SDL_CreateCursor, pFppiiii)
GO(SDL_CreateMutex, pFv)
GO(SDL_CreateRGBSurface, pFuiiiuuuu)
GO(SDL_CreateRGBSurfaceFrom, pFpiiiiuuuu)
GO(SDL_CreateSemaphore, pFu)
GOM(SDL_CreateThread, pFEpp)
GO(SDL_CreateYUVOverlay, pFiiup)
GO(SDL_Delay, vFu)
GO(SDL_DestroyCond, vFp)
GO(SDL_DestroyMutex, vFp)
GO(SDL_DestroySemaphore, vFp)
GO(SDL_DisplayFormat, pFp)
GO(SDL_DisplayFormatAlpha, pFp)
GO(SDL_DisplayYUVOverlay, iFpp)
GO(SDL_EnableKeyRepeat, iFii)
GO(SDL_EnableUNICODE, iFi)
GO(SDL_Error, vFi)
GO(SDL_EventState, uFui)
GO(SDL_FillRect, iFppu)
GO(SDL_Flip, iFp)
GO(SDL_FreeCursor, vFp)
GO(SDL_FreeRW, vFp)
GO(SDL_FreeSurface, vFp)
GO(SDL_FreeYUVOverlay, vFp)
GO(SDL_GL_GetAttribute, iFup)
GOM(SDL_GL_GetProcAddress, pFEp)
GO(SDL_GL_LoadLibrary, iFp)
GO(SDL_GL_Lock, vFv)
GO(SDL_GL_SetAttribute, iFui)
GO(SDL_GL_SwapBuffers, vFv)
GO(SDL_GL_Unlock, vFv)
GO(SDL_GL_UpdateRects, vFip)
GO(SDL_GetAppState, uFv)
GO(SDL_GetClipRect, vFpp)
GO(SDL_GetCursor, pFv)
GO(SDL_GetError, pFv)
GOM(SDL_GetEventFilter, pFEv)
GO(SDL_GetGammaRamp, iFppp)
GO(SDL_GetKeyName, pFi)
GO(SDL_GetKeyRepeat, vFpp)
GO(SDL_GetKeyState, pFp)
GO(SDL_GetModState, iFv)
GO(SDL_GetMouseState, uFpp)
GO(SDL_GetRGB, vFupppp)
GO(SDL_GetRGBA, vFuppppp)
GO(SDL_GetRelativeMouseState, uFpp)
GO(SDL_GetThreadID, uFp)
GO(SDL_GetTicks, uFv)
GO(SDL_GetVideoInfo, pFv)
GO(SDL_GetVideoSurface, pFv)
GOM(SDL_GetWMInfo, iFEp)
GOM(SDL_Has3DNow, iFv)
GOM(SDL_Has3DNowExt, iFv)
GOM(SDL_HasAltiVec, iFv)
GOM(SDL_HasMMX, iFv)
GOM(SDL_HasMMXExt, iFv)
GOM(SDL_HasRDTSC, iFv)
GOM(SDL_HasSSE, iFv)
GOM(SDL_HasSSE2, iFv)
GO(SDL_Init, iFu)
GO(SDL_InitQuickDraw, vFp)
GO(SDL_InitSubSystem, iFu)
GO(SDL_JoystickClose, vFp)
GO(SDL_JoystickEventState, iFi)
GO(SDL_JoystickGetAxis, iFpi)
GO(SDL_JoystickGetBall, iFpipp)
GO(SDL_JoystickGetButton, uFpi)
GO(SDL_JoystickGetHat, uFpi)
GO(SDL_JoystickIndex, iFp)
GO(SDL_JoystickName, pFi)
GO(SDL_JoystickNumAxes, iFp)
GO(SDL_JoystickNumBalls, iFp)
GO(SDL_JoystickNumButtons, iFp)
GO(SDL_JoystickNumHats, iFp)
GO(SDL_JoystickOpen, pFi)
GO(SDL_JoystickOpened, iFi)
GO(SDL_JoystickUpdate, vFv)
GOM(SDL_KillThread, vFEp)
GO(SDL_Linked_Version, pFv)
GO(SDL_ListModes, pFpu)
GOM(SDL_LoadBMP_RW, pFEpi)
GOM(SDL_LoadFunction, pFEpp)
GOM(SDL_LoadObject, pFEp)
GO(SDL_LockSurface, iFp)
GO(SDL_LockYUVOverlay, iFp)
GO(SDL_LowerBlit, iFpppp)
GO(SDL_MapRGB, uFpuuu)
GO(SDL_MapRGBA, uFpuuuu)
GO(SDL_NumJoysticks, iFv)
GO(SDL_PeepEvents, iFpiiu)
GO(SDL_PollEvent, iFp)
GO(SDL_PumpEvents, vFv)
GO(SDL_PushEvent, iFp)
GO(SDL_Quit, vFv)
GO(SDL_QuitSubSystem, vFu)
GOM(SDL_RWFromConstMem, pFEpi)
GOM(SDL_RWFromFP, pFEpi)
GOM(SDL_RWFromFile, pFEpp)
GOM(SDL_RWFromMem, pFEpi)
GOM(SDL_ReadBE16, uFEp)
GOM(SDL_ReadBE32, uFEp)
GOM(SDL_ReadBE64, UFEp)
GOM(SDL_ReadLE16, uFEp)
GOM(SDL_ReadLE32, uFEp)
GOM(SDL_ReadLE64, UFEp)
GO(SDL_RegisterApp, iFpup)
GOM(SDL_RemoveTimer, iFEp)
GOM(SDL_SaveBMP_RW, iFEppi)
GO(SDL_SemPost, iFp)
GO(SDL_SemTryWait, iFp)
GO(SDL_SemValue, uFp)
GO(SDL_SemWait, iFp)
GO(SDL_SemWaitTimeout, iFpu)
GO(SDL_SetAlpha, iFpuu)
GO(SDL_SetClipRect, iFpp)
GO(SDL_SetColorKey, iFpuu)
GO(SDL_SetColors, iFppii)
GO(SDL_SetCursor, vFp)
GO(SDL_SetError, vFpppppp) // use ..., so putting arbitrary number of arguments...
GOM(SDL_SetEventFilter, vFEp)
GO(SDL_SetGamma, iFfff)
GO(SDL_SetGammaRamp, iFppp)
GO(SDL_SetModState, vFi)
GO(SDL_SetModuleHandle, vFp)
GO(SDL_SetPalette, iFpipii)
GOM(SDL_SetTimer, iFEup)
GO(SDL_SetVideoMode, pFiiiu)
GO(SDL_ShowCursor, iFi)
GO(SDL_SoftStretch, iFpppp)
GO(SDL_ThreadID, uFv)
GOM(SDL_UnloadObject, vFEp)
GO(SDL_UnlockSurface, vFp)
GO(SDL_UnlockYUVOverlay, vFp)
GO(SDL_UnregisterApp, vFv)
GO(SDL_UpdateRect, vFpiiii)
GO(SDL_UpdateRects, vFpip)
GO(SDL_UpperBlit, iFpppp)
GO(SDL_VideoDriverName, pFpi)
GO(SDL_VideoInit, iFpu)
GO(SDL_VideoModeOK, iFiiiu)
GO(SDL_VideoQuit, vFv)
GO(SDL_WM_GetCaption, vFpp)
GO(SDL_WM_GrabInput, iFi)
GO(SDL_WM_IconifyWindow, iFv)
GO(SDL_WM_SetCaption, vFpp)
GO(SDL_WM_SetIcon, vFpp)
GO(SDL_WM_ToggleFullScreen, iFp)
GO(SDL_WaitEvent, iFp)
GO(SDL_WaitThread, vFpp)
GO(SDL_WarpMouse, vFWW)
GO(SDL_WasInit, uFu)
GOM(SDL_WriteBE16, uFEpW)
GOM(SDL_WriteBE32, uFEpu)
GOM(SDL_WriteBE64, uFEpU)
GOM(SDL_WriteLE16, uFEpW)
GOM(SDL_WriteLE32, uFEpu)
GOM(SDL_WriteLE64, uFEpU)
GO(SDL_framerateDelay, uFp)
GO(SDL_getFramecount, iFp)
GO(SDL_getFramerate, iFp)
GO(SDL_iconv, uFppppp)
GO(SDL_iconv_close, iFp)
GO(SDL_iconv_open, pFpp)
GO(SDL_iconv_string, pFpppu)
GO(SDL_initFramerate, vFp)
GO(SDL_lltoa, pFIpi)
GO(SDL_ltoa, pFipi)
GO(SDL_main, iFip)
GO(SDL_memcmp, iFppu)
GO(SDL_mutexP, iFp)
GO(SDL_mutexV, iFp)
GO(SDL_revcpy, pFppu)
GO(SDL_setFramerate, iFpu)
GO(SDL_snprintf, iFpupppppp) // use ...
GO(SDL_sscanf, iFppppppp) // use ...
GO(SDL_strcasecmp, iFpp)
GO(SDL_strchr, pFpi)
GO(SDL_strcmp, iFpp)
GO(SDL_strdup, pFp)
GO(SDL_strlcat, uFppu)
GO(SDL_strlcpy, uFppu)
GO(SDL_strlen, uFp)
GO(SDL_strlwr, pFp)
GO(SDL_strncasecmp, iFppu)
GO(SDL_strncmp, iFppu)
GO(SDL_strrchr, pFpi)
GO(SDL_strrev, pFp)
GO(SDL_strstr, pFpp)
GO(SDL_strtod, dFpp)
GO(SDL_strtol, iFppi)
GO(SDL_strtoll, IFppi)
GO(SDL_strtoul, uFppi)
GO(SDL_strtoull, UFppi)
GO(SDL_strupr, pFp)
GO(SDL_ulltoa, pFUpi)
GO(SDL_ultoa, pFupi)
GO(SDL_vsnprintf, iFpupV)
GOM(SDL_OpenAudio, iFEpp)
GO(SDL_LockAudio, vFv)
GO(SDL_UnlockAudio, vFv)
GO(SDL_PauseAudio, vFi)
GO(SDL_GetAudioStatus, iFv)
GO(SDL_LoadWAV, pFpppp)
GO(SDL_FreeWAV, vFp)
GOM(SDL_LoadWAV_RW, pFEpippp)
GO(SDL_BuildAudioCVT, iFpuuiuui)
GO(SDL_ConvertAudio, iFp)
GO(SDL_AudioInit, iFp)
GO(SDL_AudioQuit, vFv) // should free callback
GO(SDL_MixAudio, vFppui)
GO(SDL_CloseAudio, vFv) // should free callback
GO(SDL_AudioDriverName, pFpi)
#endif

994
src/wrapped/wrappedsdl2.c Executable file
View File

@ -0,0 +1,994 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include <stdarg.h>
#include "wrappedlibs.h"
#include "debug.h"
#include "wrapper.h"
#include "bridge.h"
#include "callback.h"
#include "librarian.h"
#include "librarian/library_private.h"
#include "emu/x64emu_private.h"
#include "box64context.h"
#include "sdl2rwops.h"
#include "myalign.h"
#include "threads.h"
static int sdl_Yes() { return 1;}
static int sdl_No() { return 0;}
int EXPORT my2_SDL_Has3DNow() __attribute__((alias("sdl_No")));
int EXPORT my2_SDL_Has3DNowExt() __attribute__((alias("sdl_No")));
int EXPORT my2_SDL_HasAltiVec() __attribute__((alias("sdl_No")));
int EXPORT my2_SDL_HasMMX() __attribute__((alias("sdl_Yes")));
int EXPORT my2_SDL_HasMMXExt() __attribute__((alias("sdl_Yes")));
int EXPORT my2_SDL_HasNEON() __attribute__((alias("sdl_No"))); // No neon in x86 ;)
int EXPORT my2_SDL_HasRDTSC() __attribute__((alias("sdl_Yes")));
int EXPORT my2_SDL_HasSSE() __attribute__((alias("sdl_Yes")));
int EXPORT my2_SDL_HasSSE2() __attribute__((alias("sdl_Yes")));
int EXPORT my2_SDL_HasSSE3() __attribute__((alias("sdl_Yes")));
int EXPORT my2_SDL_HasSSE41() __attribute__((alias("sdl_No")));
int EXPORT my2_SDL_HasSSE42() __attribute__((alias("sdl_No")));
typedef struct {
int32_t freq;
uint16_t format;
uint8_t channels;
uint8_t silence;
uint16_t samples;
uint32_t size;
void (*callback)(void *userdata, uint8_t *stream, int32_t len);
void *userdata;
} SDL2_AudioSpec;
typedef struct {
uint8_t data[16];
} SDL_JoystickGUID;
typedef union {
SDL_JoystickGUID guid;
uint32_t u[4];
} SDL_JoystickGUID_Helper;
typedef struct
{
int32_t bindType; // enum
union
{
int button;
int axis;
struct {
int hat;
int hat_mask;
} hat;
} value;
} SDL_GameControllerButtonBind;
// TODO: put the wrapper type in a dedicate include
typedef void (*vFv_t)();
typedef void* (*pFv_t)();
typedef int32_t (*iFp_t)(void*);
typedef int32_t (*iFip_t)(int32_t, void*);
typedef int32_t (*iFWW_t)(uint16_t, uint16_t);
typedef void* (*pFpi_t)(void*, int32_t);
typedef void* (*pFp_t)(void*);
typedef void* (*pFpp_t)(void*, void*);
typedef int32_t (*iFppi_t)(void*, void*, int32_t);
typedef int32_t (*iFpippi_t)(void*, int32_t, void*, void*, int32_t);
typedef int32_t (*iFppp_t)(void*, void*, void*);
typedef void* (*pFpippp_t)(void*, int32_t, void*, void*, void*);
typedef void* (*pFpp_t)(void*, void*);
typedef void* (*pFppp_t)(void*, void*, void*);
typedef void (*vFp_t)(void*);
typedef void (*vFpp_t)(void*, void*);
typedef void (*vFiupp_t)(int32_t, uint32_t, void*, void*);
typedef int32_t (*iFpupp_t)(void*, uint32_t, void*, void*);
typedef uint32_t (*uFu_t)(uint32_t);
typedef uint32_t (*uFp_t)(void*);
typedef uint32_t (*uFupp_t)(uint32_t, void*, void*);
typedef int64_t (*IFp_t)(void*);
typedef uint64_t (*UFp_t)(void*);
typedef int32_t (*iFpi_t)(void*, int32_t);
typedef int32_t (*iFpp_t)(void*, void*);
typedef int32_t (*iFUU_t)(uint64_t, uint64_t);
typedef int32_t (*iFupp_t)(uint32_t, void*, void*);
typedef uint32_t (*uFpC_t)(void*, uint8_t);
typedef uint32_t (*uFpW_t)(void*, uint16_t);
typedef uint32_t (*uFpu_t)(void*, uint32_t);
typedef uint32_t (*uFpU_t)(void*, uint64_t);
#define SUPER() \
GO(SDL_Quit, vFv_t) \
GO(SDL_OpenAudio, iFpp_t) \
GO(SDL_OpenAudioDevice, iFpippi_t) \
GO(SDL_LoadFile_RW, pFpi_t) \
GO(SDL_LoadBMP_RW, pFpi_t) \
GO(SDL_RWFromConstMem, pFpi_t) \
GO(SDL_RWFromFP, pFpi_t) \
GO(SDL_RWFromFile, pFpp_t) \
GO(SDL_RWFromMem, pFpi_t) \
GO(SDL_SaveBMP_RW, iFppi_t) \
GO(SDL_LoadWAV_RW, pFpippp_t) \
GO(SDL_GameControllerAddMappingsFromRW, iFpi_t) \
GO(SDL_AllocRW, sdl2_allocrw) \
GO(SDL_FreeRW, sdl2_freerw) \
GO(SDL_ReadU8, uFp_t) \
GO(SDL_ReadBE16, uFp_t) \
GO(SDL_ReadBE32, uFp_t) \
GO(SDL_ReadBE64, UFp_t) \
GO(SDL_ReadLE16, uFp_t) \
GO(SDL_ReadLE32, uFp_t) \
GO(SDL_ReadLE64, UFp_t) \
GO(SDL_WriteU8, uFpC_t) \
GO(SDL_WriteBE16, uFpW_t) \
GO(SDL_WriteBE32, uFpu_t) \
GO(SDL_WriteBE64, uFpU_t) \
GO(SDL_WriteLE16, uFpW_t) \
GO(SDL_WriteLE32, uFpu_t) \
GO(SDL_WriteLE64, uFpU_t) \
GO(SDL_AddTimer, uFupp_t) \
GO(SDL_RemoveTimer, uFu_t) \
GO(SDL_CreateThread, pFppp_t) \
GO(SDL_KillThread, vFp_t) \
GO(SDL_GetEventFilter, iFpp_t) \
GO(SDL_SetEventFilter, vFpp_t) \
GO(SDL_LogGetOutputFunction, vFpp_t) \
GO(SDL_LogSetOutputFunction, vFpp_t) \
GO(SDL_LogMessageV, vFiupp_t) \
GO(SDL_GL_GetProcAddress, pFp_t) \
GO(SDL_TLSSet, iFupp_t) \
GO(SDL_AddEventWatch, vFpp_t) \
GO(SDL_DelEventWatch, vFpp_t) \
GO(SDL_SaveAllDollarTemplates, iFp_t) \
GO(SDL_SaveDollarTemplate, iFip_t) \
GO(SDL_IsJoystickPS4, iFWW_t) \
GO(SDL_IsJoystickNintendoSwitchPro, iFWW_t) \
GO(SDL_IsJoystickSteamController, iFWW_t) \
GO(SDL_IsJoystickXbox360, iFWW_t) \
GO(SDL_IsJoystickXboxOne, iFWW_t) \
GO(SDL_IsJoystickXInput, iFUU_t) \
GO(SDL_IsJoystickHIDAPI, iFUU_t) \
GO(SDL_Vulkan_GetVkGetInstanceProcAddr, pFv_t) \
typedef struct sdl2_my_s {
#define GO(A, B) B A;
SUPER()
#undef GO
} sdl2_my_t;
void* getSDL2My(library_t* lib)
{
sdl2_my_t* my = (sdl2_my_t*)calloc(1, sizeof(sdl2_my_t));
#define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A);
SUPER()
#undef GO
return my;
}
void freeSDL2My(void* lib)
{
/*sdl2_my_t *my = (sdl2_my_t *)lib;*/
}
#undef SUPER
#define SUPER() \
GO(0) \
GO(1) \
GO(2) \
GO(3) \
GO(4)
// Timer
#define GO(A) \
static uintptr_t my_Timer_fct_##A = 0; \
static uint32_t my_Timer_##A(uint32_t a, void* b) \
{ \
return (uint32_t)RunFunction(my_context, my_Timer_fct_##A, 2, a, b); \
}
SUPER()
#undef GO
static void* find_Timer_Fct(void* fct)
{
if(!fct) return NULL;
void* p;
if((p = GetNativeFnc((uintptr_t)fct))) return p;
#define GO(A) if(my_Timer_fct_##A == (uintptr_t)fct) return my_Timer_##A;
SUPER()
#undef GO
#define GO(A) if(my_Timer_fct_##A == 0) {my_Timer_fct_##A = (uintptr_t)fct; return my_Timer_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for SDL2 Timer callback\n");
return NULL;
}
// AudioCallback
#define GO(A) \
static uintptr_t my_AudioCallback_fct_##A = 0; \
static void my_AudioCallback_##A(void* a, void* b, int c) \
{ \
RunFunction(my_context, my_AudioCallback_fct_##A, 3, a, b, c); \
}
SUPER()
#undef GO
static void* find_AudioCallback_Fct(void* fct)
{
if(!fct) return NULL;
void* p;
if((p = GetNativeFnc((uintptr_t)fct))) return p;
#define GO(A) if(my_AudioCallback_fct_##A == (uintptr_t)fct) return my_AudioCallback_##A;
SUPER()
#undef GO
#define GO(A) if(my_AudioCallback_fct_##A == 0) {my_AudioCallback_fct_##A = (uintptr_t)fct; return my_AudioCallback_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for SDL2 AudioCallback callback\n");
return NULL;
}
// eventfilter
#define GO(A) \
static uintptr_t my_eventfilter_fct_##A = 0; \
static int my_eventfilter_##A(void* userdata, void* event) \
{ \
return (int)RunFunction(my_context, my_eventfilter_fct_##A, 2, userdata, event); \
}
SUPER()
#undef GO
static void* find_eventfilter_Fct(void* fct)
{
if(!fct) return NULL;
void* p;
if((p = GetNativeFnc((uintptr_t)fct))) return p;
#define GO(A) if(my_eventfilter_fct_##A == (uintptr_t)fct) return my_eventfilter_##A;
SUPER()
#undef GO
#define GO(A) if(my_eventfilter_fct_##A == 0) {my_eventfilter_fct_##A = (uintptr_t)fct; return my_eventfilter_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for SDL2 eventfilter callback\n");
return NULL;
}
static void* reverse_eventfilter_Fct(void* fct)
{
if(!fct) return fct;
if(CheckBridged(my_context->sdl2lib->priv.w.bridge, fct))
return (void*)CheckBridged(my_context->sdl2lib->priv.w.bridge, fct);
#define GO(A) if(my_eventfilter_##A == fct) return (void*)my_eventfilter_fct_##A;
SUPER()
#undef GO
return (void*)AddBridge(my_context->sdl2lib->priv.w.bridge, iFpp, fct, 0);
}
// LogOutput
#define GO(A) \
static uintptr_t my_LogOutput_fct_##A = 0; \
static void my_LogOutput_##A(void* a, int b, int c, void* d) \
{ \
RunFunction(my_context, my_LogOutput_fct_##A, 4, a, b, c, d); \
}
SUPER()
#undef GO
static void* find_LogOutput_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_LogOutput_fct_##A == (uintptr_t)fct) return my_LogOutput_##A;
SUPER()
#undef GO
#define GO(A) if(my_LogOutput_fct_##A == 0) {my_LogOutput_fct_##A = (uintptr_t)fct; return my_LogOutput_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for SDL2 LogOutput callback\n");
return NULL;
}
static void* reverse_LogOutput_Fct(void* fct)
{
if(!fct) return fct;
if(CheckBridged(my_context->sdl2lib->priv.w.bridge, fct))
return (void*)CheckBridged(my_context->sdl2lib->priv.w.bridge, fct);
#define GO(A) if(my_LogOutput_##A == fct) return (void*)my_LogOutput_fct_##A;
SUPER()
#undef GO
return (void*)AddBridge(my_context->sdl2lib->priv.w.bridge, vFpiip, fct, 0);
}
#undef SUPER
// TODO: track the memory for those callback
EXPORT int32_t my2_SDL_OpenAudio(x64emu_t* emu, void* d, void* o)
{
SDL2_AudioSpec *desired = (SDL2_AudioSpec*)d;
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
// create a callback
void *fnc = (void*)desired->callback;
desired->callback = find_AudioCallback_Fct(fnc);
int ret = my->SDL_OpenAudio(desired, (SDL2_AudioSpec*)o);
if (ret!=0) {
// error, clean the callback...
desired->callback = fnc;
return ret;
}
// put back stuff in place?
desired->callback = fnc;
return ret;
}
EXPORT int32_t my2_SDL_OpenAudioDevice(x64emu_t* emu, void* device, int32_t iscapture, void* d, void* o, int32_t allowed)
{
SDL2_AudioSpec *desired = (SDL2_AudioSpec*)d;
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
// create a callback
void *fnc = (void*)desired->callback;
desired->callback = find_AudioCallback_Fct(fnc);
int ret = my->SDL_OpenAudioDevice(device, iscapture, desired, (SDL2_AudioSpec*)o, allowed);
if (ret<=0) {
// error, clean the callback...
desired->callback = fnc;
return ret;
}
// put back stuff in place?
desired->callback = fnc;
return ret;
}
EXPORT void *my2_SDL_LoadFile_RW(x64emu_t* emu, void* a, int b)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
void* r = my->SDL_LoadFile_RW(rw, b);
if(b==0)
RWNativeEnd2(rw);
return r;
}
EXPORT void *my2_SDL_LoadBMP_RW(x64emu_t* emu, void* a, int b)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
void* r = my->SDL_LoadBMP_RW(rw, b);
if(b==0)
RWNativeEnd2(rw);
return r;
}
EXPORT int32_t my2_SDL_SaveBMP_RW(x64emu_t* emu, void* a, void* b, int c)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
int32_t r = my->SDL_SaveBMP_RW(rw, b, c);
if(c==0)
RWNativeEnd2(rw);
return r;
}
EXPORT void *my2_SDL_LoadWAV_RW(x64emu_t* emu, void* a, int b, void* c, void* d, void* e)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
void* r = my->SDL_LoadWAV_RW(rw, b, c, d, e);
if(b==0)
RWNativeEnd2(rw);
return r;
}
EXPORT int32_t my2_SDL_GameControllerAddMappingsFromRW(x64emu_t* emu, void* a, int b)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
int32_t r = my->SDL_GameControllerAddMappingsFromRW(rw, b);
if(b==0)
RWNativeEnd2(rw);
return r;
}
EXPORT uint32_t my2_SDL_ReadU8(x64emu_t* emu, void* a)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t r = my->SDL_ReadU8(rw);
RWNativeEnd2(rw);
return r;
}
EXPORT uint32_t my2_SDL_ReadBE16(x64emu_t* emu, void* a)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t r = my->SDL_ReadBE16(rw);
RWNativeEnd2(rw);
return r;
}
EXPORT uint32_t my2_SDL_ReadBE32(x64emu_t* emu, void* a)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t r = my->SDL_ReadBE32(rw);
RWNativeEnd2(rw);
return r;
}
EXPORT uint64_t my2_SDL_ReadBE64(x64emu_t* emu, void* a)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint64_t r = my->SDL_ReadBE64(rw);
RWNativeEnd2(rw);
return r;
}
EXPORT uint32_t my2_SDL_ReadLE16(x64emu_t* emu, void* a)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t r = my->SDL_ReadLE16(rw);
RWNativeEnd2(rw);
return r;
}
EXPORT uint32_t my2_SDL_ReadLE32(x64emu_t* emu, void* a)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t r = my->SDL_ReadLE32(rw);
RWNativeEnd2(rw);
return r;
}
EXPORT uint64_t my2_SDL_ReadLE64(x64emu_t* emu, void* a)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint64_t r = my->SDL_ReadLE64(rw);
RWNativeEnd2(rw);
return r;
}
EXPORT uint32_t my2_SDL_WriteU8(x64emu_t* emu, void* a, uint8_t v)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t r = my->SDL_WriteU8(rw, v);
RWNativeEnd2(rw);
return r;
}
EXPORT uint32_t my2_SDL_WriteBE16(x64emu_t* emu, void* a, uint16_t v)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t r = my->SDL_WriteBE16(rw, v);
RWNativeEnd2(rw);
return r;
}
EXPORT uint32_t my2_SDL_WriteBE32(x64emu_t* emu, void* a, uint32_t v)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t r = my->SDL_WriteBE32(rw, v);
RWNativeEnd2(rw);
return r;
}
EXPORT uint32_t my2_SDL_WriteBE64(x64emu_t* emu, void* a, uint64_t v)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t r = my->SDL_WriteBE64(rw, v);
RWNativeEnd2(rw);
return r;
}
EXPORT uint32_t my2_SDL_WriteLE16(x64emu_t* emu, void* a, uint16_t v)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t r = my->SDL_WriteLE16(rw, v);
RWNativeEnd2(rw);
return r;
}
EXPORT uint32_t my2_SDL_WriteLE32(x64emu_t* emu, void* a, uint32_t v)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t r = my->SDL_WriteLE32(rw, v);
RWNativeEnd2(rw);
return r;
}
EXPORT uint32_t my2_SDL_WriteLE64(x64emu_t* emu, void* a, uint64_t v)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t r = my->SDL_WriteLE64(rw, v);
RWNativeEnd2(rw);
return r;
}
EXPORT void *my2_SDL_RWFromConstMem(x64emu_t* emu, void* a, int b)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
void* r = my->SDL_RWFromConstMem(a, b);
return AddNativeRW2(emu, (SDL2_RWops_t*)r);
}
EXPORT void *my2_SDL_RWFromFP(x64emu_t* emu, void* a, int b)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
void* r = my->SDL_RWFromFP(a, b);
return AddNativeRW2(emu, (SDL2_RWops_t*)r);
}
EXPORT void *my2_SDL_RWFromFile(x64emu_t* emu, void* a, void* b)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
void* r = my->SDL_RWFromFile(a, b);
return AddNativeRW2(emu, (SDL2_RWops_t*)r);
}
EXPORT void *my2_SDL_RWFromMem(x64emu_t* emu, void* a, int b)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
void* r = my->SDL_RWFromMem(a, b);
return AddNativeRW2(emu, (SDL2_RWops_t*)r);
}
EXPORT int64_t my2_SDL_RWseek(x64emu_t* emu, void* a, int64_t offset, int32_t whence)
{
//sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
int64_t ret = RWNativeSeek2(rw, offset, whence);
RWNativeEnd2(rw);
return ret;
}
EXPORT int64_t my2_SDL_RWtell(x64emu_t* emu, void* a)
{
//sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
int64_t ret = RWNativeSeek2(rw, 0, 1); //1 == RW_SEEK_CUR
RWNativeEnd2(rw);
return ret;
}
EXPORT uint32_t my2_SDL_RWread(x64emu_t* emu, void* a, void* ptr, uint32_t size, uint32_t maxnum)
{
//sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t ret = RWNativeRead2(rw, ptr, size, maxnum);
RWNativeEnd2(rw);
return ret;
}
EXPORT uint32_t my2_SDL_RWwrite(x64emu_t* emu, void* a, const void* ptr, uint32_t size, uint32_t maxnum)
{
//sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t ret = RWNativeWrite2(rw, ptr, size, maxnum);
RWNativeEnd2(rw);
return ret;
}
EXPORT int my2_SDL_RWclose(x64emu_t* emu, void* a)
{
//sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
return RWNativeClose2(rw);
}
EXPORT int my2_SDL_SaveAllDollarTemplates(x64emu_t* emu, void* a)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t ret = my->SDL_SaveAllDollarTemplates(rw);
RWNativeEnd2(rw);
return ret;
}
EXPORT int my2_SDL_SaveDollarTemplate(x64emu_t* emu, int gesture, void* a)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
SDL2_RWops_t *rw = RWNativeStart2(emu, (SDL2_RWops_t*)a);
uint32_t ret = my->SDL_SaveDollarTemplate(gesture, rw);
RWNativeEnd2(rw);
return ret;
}
EXPORT uint32_t my2_SDL_AddTimer(x64emu_t* emu, uint32_t a, void* f, void* p)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
return my->SDL_AddTimer(a, find_Timer_Fct(f), p);
}
EXPORT void my2_SDL_RemoveTimer(x64emu_t* emu, uint32_t t)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
my->SDL_RemoveTimer(t);
}
EXPORT void my2_SDL_SetEventFilter(x64emu_t* emu, void* p, void* userdata)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
my->SDL_SetEventFilter(find_eventfilter_Fct(p), userdata);
}
EXPORT int my2_SDL_GetEventFilter(x64emu_t* emu, void** f, void* userdata)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
int ret = my->SDL_GetEventFilter(f, userdata);
*f = reverse_eventfilter_Fct(*f);
return ret;
}
EXPORT void my2_SDL_LogGetOutputFunction(x64emu_t* emu, void** f, void* arg)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
my->SDL_LogGetOutputFunction(f, arg);
if(*f) *f = reverse_LogOutput_Fct(*f);
}
EXPORT void my2_SDL_LogSetOutputFunction(x64emu_t* emu, void* f, void* arg)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
my->SDL_LogSetOutputFunction(find_LogOutput_Fct(f), arg);
}
EXPORT int my2_SDL_vsnprintf(x64emu_t* emu, void* buff, uint32_t s, void * fmt, void * b, va_list V)
{
#ifndef NOALIGN
// need to align on arm
myStackAlign((const char*)fmt, *(uint32_t**)b, emu->scratch);
PREPARE_VALIST;
void* f = vsnprintf;
int r = ((iFpupp_t)f)(buff, s, fmt, VARARGS);
return r;
#else
void* f = vsnprintf;
int r = ((iFpupp_t)f)(buff, s, fmt, *(uint32_t**)b);
return r;
#endif
}
EXPORT void* my2_SDL_CreateThread(x64emu_t* emu, void* f, void* n, void* p)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
void* et = NULL;
return my->SDL_CreateThread(my_prepare_thread(emu, f, p, 0, &et), n, et);
}
EXPORT int my2_SDL_snprintf(x64emu_t* emu, void* buff, uint32_t s, void * fmt, void * b, va_list V) {
#ifndef NOALIGN
// need to align on arm
myStackAlign((const char*)fmt, b, emu->scratch);
PREPARE_VALIST;
void* f = vsnprintf;
return ((iFpupp_t)f)(buff, s, fmt, VARARGS);
#else
return vsnprintf((char*)buff, s, (char*)fmt, V);
#endif
}
char EXPORT *my2_SDL_GetBasePath(x64emu_t* emu) {
char* p = strdup(emu->context->fullpath);
char* b = strrchr(p, '/');
if(b)
*(b+1) = '\0';
return p;
}
EXPORT void my2_SDL_LogCritical(x64emu_t* emu, int32_t cat, void* fmt, void *b) {
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
// SDL_LOG_PRIORITY_CRITICAL == 6
#ifndef NOALIGN
myStackAlign((const char*)fmt, b, emu->scratch);
PREPARE_VALIST;
my->SDL_LogMessageV(cat, 6, fmt, VARARGS);
#else
my->SDL_LogMessageV(cat, 6, fmt, b);
#endif
}
EXPORT void my2_SDL_LogError(x64emu_t* emu, int32_t cat, void* fmt, void *b) {
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
// SDL_LOG_PRIORITY_ERROR == 5
#ifndef NOALIGN
myStackAlign((const char*)fmt, b, emu->scratch);
PREPARE_VALIST;
my->SDL_LogMessageV(cat, 5, fmt, VARARGS);
#else
my->SDL_LogMessageV(cat, 5, fmt, b);
#endif
}
EXPORT void my2_SDL_LogWarn(x64emu_t* emu, int32_t cat, void* fmt, void *b) {
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
// SDL_LOG_PRIORITY_WARN == 4
#ifndef NOALIGN
myStackAlign((const char*)fmt, b, emu->scratch);
PREPARE_VALIST;
my->SDL_LogMessageV(cat, 4, fmt, VARARGS);
#else
my->SDL_LogMessageV(cat, 4, fmt, b);
#endif
}
EXPORT void my2_SDL_LogInfo(x64emu_t* emu, int32_t cat, void* fmt, void *b) {
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
// SDL_LOG_PRIORITY_INFO == 3
#ifndef NOALIGN
myStackAlign((const char*)fmt, b, emu->scratch);
PREPARE_VALIST;
my->SDL_LogMessageV(cat, 3, fmt, VARARGS);
#else
my->SDL_LogMessageV(cat, 3, fmt, b);
#endif
}
EXPORT void my2_SDL_LogDebug(x64emu_t* emu, int32_t cat, void* fmt, void *b) {
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
// SDL_LOG_PRIORITY_DEBUG == 2
#ifndef NOALIGN
myStackAlign((const char*)fmt, b, emu->scratch);
PREPARE_VALIST;
my->SDL_LogMessageV(cat, 2, fmt, VARARGS);
#else
my->SDL_LogMessageV(cat, 2, fmt, b);
#endif
}
EXPORT void my2_SDL_LogVerbose(x64emu_t* emu, int32_t cat, void* fmt, void *b) {
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
// SDL_LOG_PRIORITY_VERBOSE == 1
#ifndef NOALIGN
myStackAlign((const char*)fmt, b, emu->scratch);
PREPARE_VALIST;
my->SDL_LogMessageV(cat, 1, fmt, VARARGS);
#else
my->SDL_LogMessageV(cat, 1, fmt, b);
#endif
}
EXPORT void my2_SDL_Log(x64emu_t* emu, void* fmt, void *b) {
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
// SDL_LOG_PRIORITY_INFO == 3
// SDL_LOG_CATEGORY_APPLICATION == 0
#ifndef NOALIGN
myStackAlign((const char*)fmt, b, emu->scratch);
PREPARE_VALIST;
my->SDL_LogMessageV(0, 3, fmt, VARARGS);
#else
my->SDL_LogMessageV(0, 3, fmt, b);
#endif
}
void fillGLProcWrapper(box64context_t*);
EXPORT void* my2_SDL_GL_GetProcAddress(x64emu_t* emu, void* name)
{
khint_t k;
const char* rname = (const char*)name;
printf_log(LOG_DEBUG, "Calling SDL_GL_GetProcAddress(%s)\n", rname);
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
// check if glxprocaddress is filled, and search for lib and fill it if needed
if(!emu->context->glwrappers)
fillGLProcWrapper(emu->context);
// get proc adress using actual glXGetProcAddress
k = kh_get(symbolmap, emu->context->glmymap, rname);
int is_my = (k==kh_end(emu->context->glmymap))?0:1;
void* symbol;
if(is_my) {
// try again, by using custom "my_" now...
char tmp[200];
strcpy(tmp, "my_");
strcat(tmp, rname);
symbol = dlsym(emu->context->box64lib, tmp);
} else
symbol = my->SDL_GL_GetProcAddress(name);
if(!symbol)
return NULL; // easy
// check if alread bridged
uintptr_t ret = CheckBridged(emu->context->system, symbol);
if(ret)
return (void*)ret; // already bridged
// get wrapper
k = kh_get(symbolmap, emu->context->glwrappers, rname);
if(k==kh_end(emu->context->glwrappers) && strstr(rname, "ARB")==NULL) {
// try again, adding ARB at the end if not present
char tmp[200];
strcpy(tmp, rname);
strcat(tmp, "ARB");
k = kh_get(symbolmap, emu->context->glwrappers, tmp);
}
if(k==kh_end(emu->context->glwrappers) && strstr(rname, "EXT")==NULL) {
// try again, adding EXT at the end if not present
char tmp[200];
strcpy(tmp, rname);
strcat(tmp, "EXT");
k = kh_get(symbolmap, emu->context->glwrappers, tmp);
}
if(k==kh_end(emu->context->glwrappers)) {
printf_log(LOG_INFO, "Warning, no wrapper for %s\n", rname);
return NULL;
}
AddOffsetSymbol(emu->context->maplib, symbol, rname);
return (void*)AddBridge(emu->context->system, kh_value(emu->context->glwrappers, k), symbol, 0);
}
#define nb_once 16
typedef void(*sdl2_tls_dtor)(void*);
static uintptr_t dtor_emu[nb_once] = {0};
static void tls_dtor_callback(int n, void* a)
{
if(dtor_emu[n]) {
RunFunction(my_context, dtor_emu[n], 1, a);
}
}
#define GO(N) \
void tls_dtor_callback_##N(void* a) \
{ \
tls_dtor_callback(N, a); \
}
GO(0)
GO(1)
GO(2)
GO(3)
GO(4)
GO(5)
GO(6)
GO(7)
GO(8)
GO(9)
GO(10)
GO(11)
GO(12)
GO(13)
GO(14)
GO(15)
#undef GO
static const sdl2_tls_dtor dtor_cb[nb_once] = {
tls_dtor_callback_0, tls_dtor_callback_1, tls_dtor_callback_2, tls_dtor_callback_3
,tls_dtor_callback_4, tls_dtor_callback_5, tls_dtor_callback_6, tls_dtor_callback_7
,tls_dtor_callback_8, tls_dtor_callback_9, tls_dtor_callback_10,tls_dtor_callback_11
,tls_dtor_callback_12,tls_dtor_callback_13,tls_dtor_callback_14,tls_dtor_callback_15
};
EXPORT int32_t my2_SDL_TLSSet(x64emu_t* emu, uint32_t id, void* value, void* dtor)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
if(!dtor)
return my->SDL_TLSSet(id, value, NULL);
int n = 0;
while (n<nb_once) {
if(!dtor_emu[n] || (dtor_emu[n])==((uintptr_t)dtor)) {
dtor_emu[n] = (uintptr_t)dtor;
return my->SDL_TLSSet(id, value, dtor_cb[n]);
}
++n;
}
printf_log(LOG_NONE, "Error: SDL2 SDL_TLSSet with destructor: no more slot!\n");
//emu->quit = 1;
return -1;
}
EXPORT void my2_SDL_AddEventWatch(x64emu_t* emu, void* p, void* userdata)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
my->SDL_AddEventWatch(find_eventfilter_Fct(p), userdata);
}
EXPORT void my2_SDL_DelEventWatch(x64emu_t* emu, void* p, void* userdata)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
my->SDL_DelEventWatch(find_eventfilter_Fct(p), userdata);
}
// DL functions from wrappedlibdl.c
void* my_dlopen(x64emu_t* emu, void *filename, int flag);
int my_dlclose(x64emu_t* emu, void *handle);
void* my_dlsym(x64emu_t* emu, void *handle, void *symbol);
EXPORT void* my2_SDL_LoadObject(x64emu_t* emu, void* sofile)
{
return my_dlopen(emu, sofile, 0); // TODO: check correct flag value...
}
EXPORT void my2_SDL_UnloadObject(x64emu_t* emu, void* handle)
{
my_dlclose(emu, handle);
}
EXPORT void* my2_SDL_LoadFunction(x64emu_t* emu, void* handle, void* name)
{
return my_dlsym(emu, handle, name);
}
EXPORT int32_t my2_SDL_IsJoystickPS4(x64emu_t* emu, uint16_t vendor, uint16_t product_id)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
if(my->SDL_IsJoystickPS4)
return my->SDL_IsJoystickPS4(vendor, product_id);
// fallback
return 0;
}
EXPORT int32_t my2_SDL_IsJoystickNintendoSwitchPro(x64emu_t* emu, uint16_t vendor, uint16_t product_id)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
if(my->SDL_IsJoystickNintendoSwitchPro)
return my->SDL_IsJoystickNintendoSwitchPro(vendor, product_id);
// fallback
return 0;
}
EXPORT int32_t my2_SDL_IsJoystickSteamController(x64emu_t* emu, uint16_t vendor, uint16_t product_id)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
if(my->SDL_IsJoystickSteamController)
return my->SDL_IsJoystickSteamController(vendor, product_id);
// fallback
return 0;
}
EXPORT int32_t my2_SDL_IsJoystickXbox360(x64emu_t* emu, uint16_t vendor, uint16_t product_id)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
if(my->SDL_IsJoystickXbox360)
return my->SDL_IsJoystickXbox360(vendor, product_id);
// fallback
return 0;
}
EXPORT int32_t my2_SDL_IsJoystickXboxOne(x64emu_t* emu, uint16_t vendor, uint16_t product_id)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
if(my->SDL_IsJoystickXboxOne)
return my->SDL_IsJoystickXboxOne(vendor, product_id);
// fallback
return 0;
}
EXPORT int32_t my2_SDL_IsJoystickXInput(x64emu_t* emu, uint64_t a, uint64_t b)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
if(my->SDL_IsJoystickXInput)
return my->SDL_IsJoystickXInput(a, b);
// fallback
return 0;
}
EXPORT int32_t my2_SDL_IsJoystickHIDAPI(x64emu_t* emu, uint64_t a, uint64_t b)
{
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
if(my->SDL_IsJoystickHIDAPI)
return my->SDL_IsJoystickHIDAPI(a, b);
// fallback
return 0;
}
void* my_vkGetInstanceProcAddr(x64emu_t* emu, void* device, void* name);
EXPORT void* my2_SDL_Vulkan_GetVkGetInstanceProcAddr(x64emu_t* emu)
{
// sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
// if(!emu->context->vkprocaddress)
// emu->context->vkprocaddress = (vkprocaddess_t)my->SDL_Vulkan_GetVkGetInstanceProcAddr();
// if(emu->context->vkprocaddress)
// return (void*)AddCheckBridge(my_context->sdl2lib->priv.w.bridge, pFEpp, my_vkGetInstanceProcAddr, 0);
return NULL;
}
const char* sdl2Name = "libSDL2-2.0.so.0";
#define LIBNAME sdl2
#define CUSTOM_INIT \
box64->sdl2lib = lib; \
lib->priv.w.p2 = getSDL2My(lib); \
box64->sdl2allocrw = ((sdl2_my_t*)lib->priv.w.p2)->SDL_AllocRW; \
box64->sdl2freerw = ((sdl2_my_t*)lib->priv.w.p2)->SDL_FreeRW; \
lib->altmy = strdup("my2_"); \
lib->priv.w.needed = 4; \
lib->priv.w.neededlibs = (char**)calloc(lib->priv.w.needed, sizeof(char*)); \
lib->priv.w.neededlibs[0] = strdup("libdl.so.2"); \
lib->priv.w.neededlibs[1] = strdup("libm.so.6"); \
lib->priv.w.neededlibs[2] = strdup("librt.so.1"); \
lib->priv.w.neededlibs[3] = strdup("libpthread.so.0");
#define CUSTOM_FINI \
((sdl2_my_t *)lib->priv.w.p2)->SDL_Quit(); \
freeSDL2My(lib->priv.w.p2); \
free(lib->priv.w.p2); \
((box64context_t*)(lib->context))->sdl2lib = NULL; \
((box64context_t*)(lib->context))->sdl2allocrw = NULL; \
((box64context_t*)(lib->context))->sdl2freerw = NULL;
#include "wrappedlib_init.h"

689
src/wrapped/wrappedsdl2_private.h Executable file
View File

@ -0,0 +1,689 @@
#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA))
#error Meh!
#endif
// _fini
// _init
GO(SDL_abs, iFi)
GO(SDL_acos, dFd)
GO(SDL_acosf, fFf)
GOM(SDL_AddEventWatch, vFEpp)
// SDL_AddHintCallback
GOM(SDL_AddTimer, pFEupp)
GO(SDL_AllocFormat, pFu)
GO(SDL_AllocPalette, pFi)
GO(SDL_AllocRW, pFv) // no need to create a "my_" probably
GO(SDL_asin, dFd)
GO(SDL_asinf, fFf)
GO(SDL_atan, dFd)
GO(SDL_atan2, dFdd)
GO(SDL_atan2f, fFff)
GO(SDL_atanf, fFf)
GO(SDL_atof, dFp)
GO(SDL_atoi, iFp)
GO(SDL_AtomicAdd, iFpi)
GO(SDL_AtomicCAS, iFpii)
GO(SDL_AtomicCASPtr, iFppp)
GO(SDL_AtomicGet, iFp)
GO(SDL_AtomicGetPtr, pFp)
GO(SDL_AtomicLock, vFp)
GO(SDL_AtomicSet, iFpi)
GO(SDL_AtomicSetPtr, pFpp)
GO(SDL_AtomicTryLock, iFp)
GO(SDL_AtomicUnlock, vFp)
GO(SDL_AudioInit, iFp)
GO(SDL_AudioQuit, vFv)
GO(SDL_AudioStreamAvailable, iFp)
GO(SDL_AudioStreamClear, vFp)
GO(SDL_AudioStreamFlush, iFp)
GO(SDL_AudioStreamGet, iFppi)
GO(SDL_AudioStreamPut, iFppi)
GO(SDL_BuildAudioCVT, iFpuuiuui)
GO(SDL_CalculateGammaRamp, vFfp)
GO(SDL_calloc, pFuu)
GO(SDL_CaptureMouse, iFi)
GO(SDL_ceil, dFd)
GO(SDL_ceilf, fFf)
GO(SDL_ClearError, vFv)
GO(SDL_ClearHints, vFv)
GO(SDL_ClearQueuedAudio, vFu)
GO(SDL_CloseAudio, vFv)
GO(SDL_CloseAudioDevice, vFi)
GO(SDL_ComposeCustomBlendMode, iFiiiiii)
GO(SDL_CondBroadcast, iFp)
GO(SDL_CondSignal, iFp)
GO(SDL_CondWait, iFpp)
GO(SDL_CondWaitTimeout, iFppu)
GO(SDL_ConvertAudio, iFp)
GO(SDL_ConvertPixels, iFiiupiupi)
GO(SDL_ConvertSurface, pFppu)
GO(SDL_ConvertSurfaceFormat, pFpuu)
GO(SDL_copysign, dFdd)
GO(SDL_copysignf, fFff)
GO(SDL_cos, dFd)
GO(SDL_cosf, fFf)
GO(SDL_CreateColorCursor, pFpii)
GO(SDL_CreateCond, pFv)
GO(SDL_CreateCursor, pFppiiii)
GO(SDL_CreateMutex, pFv)
GO(SDL_CreateRenderer, pFpiu)
GO(SDL_CreateRGBSurface, pFuiiiuuuu)
GO(SDL_CreateRGBSurfaceFrom, pFpiiiiuuuu)
GO(SDL_CreateRGBSurfaceWithFormat, pFuiiiu)
GO(SDL_CreateRGBSurfaceWithFormatFrom, pFpiiiiu)
GO(SDL_CreateSemaphore, pFu)
GO(SDL_CreateShapedWindow, pFpuuuuu)
GO(SDL_CreateSoftwareRenderer, pFp)
GO(SDL_CreateSystemCursor, pFu)
GO(SDL_CreateTexture, pFpuiii)
GO(SDL_CreateTextureFromSurface, pFpp)
GOM(SDL_CreateThread, pFEppp)
// SDL_CreateThreadWithStackSize
GO(SDL_CreateWindow, pFpiiiiu)
GO(SDL_CreateWindowAndRenderer, iFiiupp)
GO(SDL_CreateWindowFrom, pFp)
GO(SDL_Delay, vFu)
GOM(SDL_DelEventWatch, vFEpp)
// SDL_DelHintCallback
GO(SDL_DequeueAudio, uFupu)
GO(SDL_DestroyCond, vFp)
GO(SDL_DestroyMutex, vFp)
GO(SDL_DestroyRenderer, vFp)
GO(SDL_DestroySemaphore, vFp)
GO(SDL_DestroyTexture, vFp)
GO(SDL_DestroyWindow, vFp)
GO(SDL_DetachThread, vFp)
GO(SDL_DisableScreenSaver, vFv)
GO(SDL_DuplicateSurface, pFp)
// SDL_DYNAPI_entry
GO(SDL_EnableScreenSaver, vFv)
GO(SDL_EnclosePoints, iFpipp)
GO(SDL_Error, iFi)
GO(SDL_EventState, CFui)
GO(SDL_exp, dFd)
GO(SDL_expf, fFf)
GO(SDL_fabs, dFd)
GO(SDL_fabsf, fFf)
GO(SDL_FillRect, iFppu)
GO(SDL_FillRects, iFppiu)
// SDL_FilterEvents
GO(SDL_floor, dFd)
GO(SDL_floorf,fFf)
GO(SDL_FlushEvent, vFu)
GO(SDL_FlushEvents, vFuu)
GO(SDL_fmod, dFdd)
GO(SDL_fmodf, fFff)
GO(SDL_free, vFp)
GO(SDL_FreeAudioStream, vFp)
GO(SDL_FreeCursor, vFp)
GO(SDL_FreeFormat, vFp)
GO(SDL_FreePalette, vFp)
GO(SDL_FreeRW, vFp)
GO(SDL_FreeSurface, vFp)
GO(SDL_FreeWAV, vFp)
GO(SDL_GameControllerAddMapping, iFp)
GOM(SDL_GameControllerAddMappingsFromRW, iFEpi)
GO(SDL_GameControllerClose, vFp)
GO(SDL_GameControllerEventState, iFi)
GO(SDL_GameControllerFromInstanceID, pFi)
GO(SDL_GameControllerGetAttached, iFp)
GO(SDL_GameControllerGetAxis, iFpi)
GO(SDL_GameControllerGetAxisFromString, uFp)
GO(SDL_GameControllerGetBindForAxis, HFpi)
GO(SDL_GameControllerGetBindForButton, HFpi)
GO(SDL_GameControllerGetButton, uFpi)
GO(SDL_GameControllerGetButtonFromString, uFp)
GO(SDL_GameControllerGetJoystick, pFp)
GO(SDL_GameControllerGetPlayerIndex, iFp)
GO(SDL_GameControllerGetProduct, WFp)
GO(SDL_GameControllerGetProductVersion, WFp)
GO(SDL_GameControllerGetStringForAxis, pFp)
GO(SDL_GameControllerGetStringForButton, pFu)
GO(SDL_GameControllerGetVendor, WFp)
GO(SDL_GameControllerMapping, pFp)
GO(SDL_GameControllerMappingForDeviceIndex, pFi)
GOM(SDL_GameControllerMappingForGUID, pFpp) // SDL_GameControllerMappingForGUID structure
GO(SDL_GameControllerMappingForIndex, pFi)
GO(SDL_GameControllerName, pFp)
GO(SDL_GameControllerNameForIndex, pFi)
GO(SDL_GameControllerNumMappings, iFv)
GO(SDL_GameControllerOpen, pFi)
GO(SDL_GameControllerRumble, iFpWWu)
GO(SDL_GameControllerUpdate, vFv)
// SDL_GetAssertionHandler
GO(SDL_GetAssertionReport, pFv)
GO(SDL_GetAudioDeviceName, pFii)
GO(SDL_GetAudioDeviceStatus, iFi)
GO(SDL_GetAudioDriver, pFi)
GO(SDL_GetAudioStatus, iFv)
GOM(SDL_GetBasePath, pFE)
GO(SDL_GetClipboardText, pFv)
GO(SDL_GetClipRect, vFpp)
GO(SDL_GetClosestDisplayMode, pFipp)
GO(SDL_GetColorKey, iFpp)
GO(SDL_GetCPUCacheLineSize, iFv)
GO(SDL_GetCPUCount, iFv)
GO(SDL_GetCurrentAudioDriver, pFv)
GO(SDL_GetCurrentDisplayMode, iFip)
GO(SDL_GetCurrentVideoDriver, pFv)
GO(SDL_GetCursor, pFv)
// SDL_GetDefaultAssertionHandler
GO(SDL_GetDefaultCursor, pFv)
GO(SDL_GetDesktopDisplayMode, iFip)
GO(SDL_GetDisplayBounds, iFip)
GO(SDL_GetDisplayDPI, iFippp)
GO(SDL_GetDisplayMode, iFiip)
GO(SDL_GetDisplayName, pFi)
GO(SDL_GetDisplayOrientation, iFi)
GO(SDL_GetDisplayUsableBounds, iFip)
GO(SDL_getenv, pFp)
GO(SDL_GetError, pFv)
GOM(SDL_GetEventFilter, iFpp)
GO(SDL_GetGlobalMouseState, uFpp)
GO(SDL_GetGrabbedWindow, pFv)
GO(SDL_GetHint, pFp)
GO(SDL_GetHintBoolean, iFpi)
GO(SDL_GetJoystickGUIDInfo, vFppppp) // the flat SDL_JoystickGUID stuct in 1st argument is same as 2 uint64
GO(SDL_GetKeyboardFocus, pFv)
GO(SDL_GetKeyboardState, pFp)
GO(SDL_GetKeyFromName, pFp)
GO(SDL_GetKeyFromScancode, uFu)
GO(SDL_GetKeyName, pFu)
GO(SDL_GetMemoryFunctions, iFpi)
GO(SDL_GetModState, pFv)
GO(SDL_GetMouseFocus, pFv)
GO(SDL_GetMouseState, uFpp)
GO(SDL_GetNumAllocations, iFv)
GO(SDL_GetNumAudioDevices, iFi)
GO(SDL_GetNumAudioDrivers, iFv)
GO(SDL_GetNumDisplayModes, iFi)
GO(SDL_GetNumRenderDrivers, iFv)
GO(SDL_GetNumTouchDevices, iFv)
GO(SDL_GetNumTouchFingers, iFu)
GO(SDL_GetNumVideoDisplays, iFv)
GO(SDL_GetNumVideoDrivers, iFv)
GO(SDL_GetPerformanceCounter, UFv)
GO(SDL_GetPerformanceFrequency, UFv)
GO(SDL_GetPixelFormatName, pFu)
GO(SDL_GetPlatform, pFv)
GO(SDL_GetPowerInfo, iFpp)
GO(SDL_GetPrefPath, pFpp)
GO(SDL_GetQueuedAudioSize, uFi)
GO(SDL_GetRelativeMouseMode, iFv)
GO(SDL_GetRelativeMouseState, uFpp)
GO(SDL_GetRenderDrawBlendMode, iFpp)
GO(SDL_GetRenderDrawColor, iFppppp)
GO(SDL_GetRenderDriverInfo, iFip)
GO(SDL_GetRenderer, pFp)
GO(SDL_GetRendererInfo, iFpp)
GO(SDL_GetRendererOutputSize, iFppp)
GO(SDL_GetRenderTarget, pFp)
GO(SDL_GetRevision, pFv)
GO(SDL_GetRevisionNumber, iFv)
GO(SDL_GetRGB, vFupppp)
GO(SDL_GetRGBA, vFuppppp)
GO(SDL_GetScancodeFromKey, uFu)
GO(SDL_GetScancodeFromName, iFp)
GO(SDL_GetScancodeName, pFu)
GO(SDL_GetShapedWindowMode, iFpp)
GO(SDL_GetSurfaceAlphaMod, iFpp)
GO(SDL_GetSurfaceBlendMode, iFpp)
GO(SDL_GetSurfaceColorMod, iFpppp)
GO(SDL_GetSystemRAM, iFv)
GO(SDL_GetTextureAlphaMod, iFpp)
GO(SDL_GetTextureBlendMode, iFpp)
GO(SDL_GetTextureColorMod, iFpppp)
GO(SDL_GetThreadID, uFp)
GO(SDL_GetThreadName, pFp)
GO(SDL_GetTicks, uFv)
GO(SDL_GetTouchDevice, uFi)
GO(SDL_GetTouchDeviceType, iFi)
GO(SDL_GetTouchFinger, pFui)
GO(SDL_GetVersion, vFp)
GO(SDL_GetVideoDriver, pFi)
GO(SDL_GetWindowBordersSize, iFppppp)
GO(SDL_GetWindowBrightness, fFp)
GO(SDL_GetWindowData, pFpp)
GO(SDL_GetWindowDisplayIndex, iFp)
GO(SDL_GetWindowDisplayMode, iFpp)
GO(SDL_GetWindowFlags, uFp)
GO(SDL_GetWindowFromID, pFu)
GO(SDL_GetWindowGammaRamp, iFpppp)
GO(SDL_GetWindowGrab, iFp)
GO(SDL_GetWindowID, uFp)
GO(SDL_GetWindowMaximumSize, vFppp)
GO(SDL_GetWindowMinimumSize, vFppp)
GO(SDL_GetWindowOpacity, iFpp)
GO(SDL_GetWindowPixelFormat, uFp)
GO(SDL_GetWindowPosition, vFppp)
GO(SDL_GetWindowSize, vFppp)
GO(SDL_GetWindowSurface, pFp)
GO(SDL_GetWindowTitle, pFp)
GO(SDL_GetWindowWMInfo, iFpp)
GO(SDL_GetYUVConversionMode, iFv)
GO(SDL_GetYUVConversionModeForResolution, iFii)
GO(SDL_GL_BindTexture, iFppp)
GO(SDL_GL_CreateContext, pFp)
GO(SDL_GL_DeleteContext, vFp)
GO(SDL_GL_ExtensionSupported, iFp)
GO(SDL_GL_GetAttribute, iFup)
GO(SDL_GL_GetCurrentContext, pFv)
GO(SDL_GL_GetCurrentWindow, pFv)
GO(SDL_GL_GetDrawableSize, vFppp)
GOM(SDL_GL_GetProcAddress, pFEp)
GO(SDL_GL_GetSwapInterval, iFv)
GO(SDL_GL_LoadLibrary, iFp)
GO(SDL_GL_MakeCurrent, iFpp)
GO(SDL_GL_ResetAttributes, vFv)
GO(SDL_GL_SetAttribute, iFui)
GO(SDL_GL_SetSwapInterval, iFi)
GO(SDL_GL_SwapWindow, vFp)
GO(SDL_GL_UnbindTexture, iFp)
GO(SDL_GL_UnloadLibrary, vFv)
GO(SDL_HapticClose, vFp)
GO(SDL_HapticDestroyEffect, vFpi)
GO(SDL_HapticEffectSupported, iFpp)
GO(SDL_HapticGetEffectStatus, iFpi)
GO(SDL_HapticIndex, iFp)
GO(SDL_HapticName, pFi)
GO(SDL_HapticNewEffect, iFpp)
GO(SDL_HapticNumAxes, iFp)
GO(SDL_HapticNumEffects, iFp)
GO(SDL_HapticNumEffectsPlaying, iFp)
GO(SDL_HapticOpen, pFi)
GO(SDL_HapticOpened, iFi)
GO(SDL_HapticOpenFromJoystick, pFp)
GO(SDL_HapticOpenFromMouse, pFv)
GO(SDL_HapticPause, iFp)
GO(SDL_HapticQuery, uFp)
GO(SDL_HapticRumbleInit, iFp)
GO(SDL_HapticRumblePlay, iFpfu)
GO(SDL_HapticRumbleStop, iFp)
GO(SDL_HapticRumbleSupported, iFp)
GO(SDL_HapticRunEffect, iFpiu)
GO(SDL_HapticSetAutocenter, iFpi)
GO(SDL_HapticSetGain, iFpi)
GO(SDL_HapticStopAll, iFp)
GO(SDL_HapticStopEffect, iFpi)
GO(SDL_HapticUnpause, iFp)
GO(SDL_HapticUpdateEffect, iFpip)
GOM(SDL_Has3DNow, iFv)
GOM(SDL_HasAltiVec, iFv)
GOM(SDL_HasAVX, iFv)
GOM(SDL_HasAVX2, iFv)
GOM(SDL_HasAVX512F, iFv)
GO(SDL_HasClipboardText, iFv)
GO(SDL_HasColorKey, iFv)
GO(SDL_HasEvent, iFv)
GO(SDL_HasEvents, iFv)
GO(SDL_HasIntersection, iFv)
GOM(SDL_HasMMX, iFv)
GOM(SDL_HasNEON, iFv)
GOM(SDL_HasRDTSC, iFv)
GO(SDL_HasScreenKeyboardSupport, iFv)
GOM(SDL_HasSSE, iFv)
GOM(SDL_HasSSE2, iFv)
GOM(SDL_HasSSE3, iFv)
GOM(SDL_HasSSE41, iFv)
GOM(SDL_HasSSE42, iFv)
GO(SDL_HideWindow, vFp)
GO(SDL_iconv, LFppppp)
GO(SDL_iconv_close, iFp)
GO(SDL_iconv_open, pFpp)
GO(SDL_iconv_string, pFpppL)
GO(SDL_Init, iFu)
GO(SDL_InitSubSystem, iFu)
GO(SDL_IntersectRect, iFppp)
GO(SDL_IntersectRectAndLine, iFppppp)
GO(SDL_isdigit, iFi)
GO(SDL_IsGameController, iFi)
GO(SDL_IsScreenKeyboardShown, iFp)
GO(SDL_IsScreenSaverEnabled, iFv)
GO(SDL_IsShapedWindow, iFp)
GO(SDL_isspace, iFi)
GO(SDL_IsTablet, iFv)
GO(SDL_IsTextInputActive, iFv)
GO(SDL_itoa, pFipi)
GO(SDL_JoystickClose, vFp)
GO(SDL_JoystickCurrentPowerLevel, iFp)
GO(SDL_JoystickEventState, iFi)
GO(SDL_JoystickFromInstanceID, pFi)
GO(SDL_JoystickGetAttached, iFp)
GO(SDL_JoystickGetAxis, iFpi)
GO(SDL_JoystickGetAxisInitialState, iFpip)
GO(SDL_JoystickGetBall, iFpipp)
GO(SDL_JoystickGetButton, CFpi)
GO(SDL_JoystickGetDeviceGUID, HFi) // return a struct that is "uint8_t data[16]"
GO(SDL_JoystickGetDeviceInstanceID, iFi)
GO(SDL_JoystickGetDevicePlayerIndex, iFi)
GO(SDL_JoystickGetDeviceProduct, WFi)
GO(SDL_JoystickGetDeviceProductVersion, WFi)
GO(SDL_JoystickGetDeviceType, iFi)
GO(SDL_JoystickGetDeviceVendor, WFi)
GO(SDL_JoystickGetGUID, HFp)
GO(SDL_JoystickGetGUIDFromString, HFp)
GO(SDL_JoystickGetGUIDString, vFupi)
GO(SDL_JoystickGetHat, CFpi)
GO(SDL_JoystickGetPlayerIndex, iFp)
GO(SDL_JoystickGetProduct, WFp)
GO(SDL_JoystickGetProductVersion, WFp)
GO(SDL_JoystickGetType, iFp)
GO(SDL_JoystickGetVendor, WFp)
GO(SDL_JoystickInstanceID, iFp)
GO(SDL_JoystickIsHaptic, iFp)
GO(SDL_JoystickName, pFp)
GO(SDL_JoystickNameForIndex, pFi)
GO(SDL_JoystickNumAxes, iFp)
GO(SDL_JoystickNumBalls, iFp)
GO(SDL_JoystickNumButtons, iFp)
GO(SDL_JoystickNumHats, iFp)
GO(SDL_JoystickOpen, pFi)
GO(SDL_JoystickRumble, iFpWWu)
GO(SDL_JoystickUpdate, vFv)
GO(SDL_LinuxSetThreadPriority, iFIi)
GO(SDL_lltoa, pFIpi)
GOM(SDL_LoadBMP_RW, pFEpi)
GO(SDL_LoadDollarTemplates, iFip)
GOM(SDL_LoadFile_RW, pFEppi)
GOM(SDL_LoadFunction, pFEpp)
GOM(SDL_LoadObject, pFEp)
GOM(SDL_LoadWAV_RW, pFEpippp)
GO(SDL_LockAudio, vFv)
GO(SDL_LockAudioDevice, vFi)
GO(SDL_LockJoysticks, vFv)
GO(SDL_LockMutex, iFp)
GO(SDL_LockSurface, iFp)
GO(SDL_LockTexture, iFpppp)
GO(SDL_log, dFd)
GOM(SDL_Log, vFEpV)
GO(SDL_log10, dFd)
GO(SDL_log10f, fFf)
GOM(SDL_LogCritical, vFEipV)
GOM(SDL_LogDebug, vFEipV)
GOM(SDL_LogError, vFEipV)
GO(SDL_logf, fFf)
GOM(SDL_LogGetOutputFunction, vFEpp)
GO(SDL_LogGetPriority, iFi)
GOM(SDL_LogInfo, vFEipV)
GO2(SDL_LogMessage, vFiupV, SDL_LogMessageV)
GO(SDL_LogMessageV, vFiupV)
GO(SDL_LogResetPriorities, vFv)
GO(SDL_LogSetAllPriority, vFu)
GOM(SDL_LogSetOutputFunction, vFEpp)
GO(SDL_LogSetPriority, vFiu)
GOM(SDL_LogVerbose, vFEipV)
GOM(SDL_LogWarn, vFEipV)
GO(SDL_LowerBlit, iFpppp)
GO(SDL_LowerBlitScaled, iFpppp)
GO(SDL_ltoa, pFlp)
GO(SDL_malloc, pFu)
GO(SDL_MapRGB, uFpCCC)
GO(SDL_MapRGBA, uFpCCCC)
GO(SDL_MasksToPixelFormatEnum, uFiuuuu)
GO(SDL_MaximizeWindow, vFp)
GO(SDL_memcmp, iFppu)
GO(SDL_memcpy, pFppu)
GO(SDL_memmove, pFppu)
GO(SDL_MemoryBarrierAcquireFunction, vFv)
GO(SDL_MemoryBarrierReleaseFunction, vFv)
GO(SDL_memset, pFpiu)
GO(SDL_MinimizeWindow, vFp)
GO(SDL_MixAudio, vFppui)
GO(SDL_MixAudioFormat, vFppWui)
GO(SDL_MouseIsHaptic, iFv)
GO(SDL_NewAudioStream, pFiCiiCi)
GO(SDL_NumHaptics, iFv)
GO(SDL_NumJoysticks, iFv)
GO(SDL_NumSensors, iFv)
GOM(SDL_OpenAudio, iFEpp)
GOM(SDL_OpenAudioDevice, iFEpippi)
GO(SDL_PauseAudio, vFi)
GO(SDL_PauseAudioDevice, vFii)
GO(SDL_PeepEvents, iFpiiuu)
GO(SDL_PixelFormatEnumToMasks, iFuppppp)
GO(SDL_PollEvent, iFp)
GO(SDL_pow, dFdd)
GO(SDL_powf, fFff)
GO(SDL_PumpEvents, vFv)
GO(SDL_PushEvent, iFp)
GO2(SDL_qsort, vFEpuup, my_qsort)
GO(SDL_QueryTexture, iFppppp)
GO(SDL_QueueAudio, iFipu)
GO(SDL_Quit, vFv)
GO(SDL_QuitSubSystem, vFu)
GO(SDL_RaiseWindow, vFp)
GOM(SDL_ReadBE16, uFEp)
GOM(SDL_ReadBE32, uFEp)
GOM(SDL_ReadBE64, UFEp)
GOM(SDL_ReadLE16, uFEp)
GOM(SDL_ReadLE32, uFEp)
GOM(SDL_ReadLE64, UFEp)
GOM(SDL_ReadU8, uFEp)
GO(SDL_realloc, pFpu)
GO(SDL_RecordGesture, iFi)
GO(SDL_RegisterEvents, uFi)
GOM(SDL_RemoveTimer, iFEp)
GO(SDL_RenderClear, iFp)
GO(SDL_RenderCopy, iFpppp)
GO(SDL_RenderCopyEx, iFppppdpi)
// SDL_RenderCopyExF
// SDL_RenderCopyF
GO(SDL_RenderDrawLine, iFpiiii)
// SDL_RenderDrawLineF
GO(SDL_RenderDrawLines, iFppi)
// SDL_RenderDrawLinesF
GO(SDL_RenderDrawPoint, iFpii)
// SDL_RenderDrawPointF
GO(SDL_RenderDrawPoints, iFppi)
// SDL_RenderDrawPointsF
GO(SDL_RenderDrawRect, iFpp)
// SDL_RenderDrawRectF
GO(SDL_RenderDrawRects, iFppi)
// SDL_RenderDrawRectsF
GO(SDL_RenderFillRect, iFpp)
// SDL_RenderFillRectF
GO(SDL_RenderFillRects, iFppi)
// SDL_RenderFillRectsF
// SDL_RenderFlush
GO(SDL_RenderGetClipRect, vFpp)
GO(SDL_RenderGetIntegerScale, iFp)
GO(SDL_RenderGetLogicalSize, vFppp)
// SDL_RenderGetMetalCommandEncoder
// SDL_RenderGetMetalLayer
GO(SDL_RenderGetScale, vFppp)
GO(SDL_RenderGetViewport, vFpp)
GO(SDL_RenderIsClipEnabled, iFp)
GO(SDL_RenderPresent, vFp)
GO(SDL_RenderReadPixels, iFppupi)
GO(SDL_RenderSetClipRect, iFpp)
GO(SDL_RenderSetIntegerScale, iFpi)
GO(SDL_RenderSetLogicalSize, iFpii)
GO(SDL_RenderSetScale, iFpff)
GO(SDL_RenderSetViewport, iFpp)
GO(SDL_RenderTargetSupported, iFp)
GO(SDL_ReportAssertion, uFpppi)
GO(SDL_ResetAssertionReport, vFv)
GO(SDL_RestoreWindow, vFp)
GOM(SDL_RWFromConstMem, pFEpi)
GOM(SDL_RWFromFP, pFEpi)
GOM(SDL_RWFromFile, pFEpp)
GOM(SDL_RWFromMem, pFEpi)
GOM(SDL_SaveAllDollarTemplates, pFEp)
GOM(SDL_SaveBMP_RW, iFEppi)
GOM(SDL_SaveDollarTemplate, iFEip)
// SDL_scalbn
// SDL_scalbnf
GO(SDL_SemPost, iFp)
GO(SDL_SemTryWait, iFp)
GO(SDL_SemValue, uFp)
GO(SDL_SemWait, iFp)
GO(SDL_SemWaitTimeout, iFpu)
// SDL_SensorClose
// SDL_SensorFromInstanceID
// SDL_SensorGetData
// SDL_SensorGetDeviceInstanceID
// SDL_SensorGetDeviceName
// SDL_SensorGetDeviceNonPortableType
// SDL_SensorGetDeviceType
// SDL_SensorGetInstanceID
// SDL_SensorGetName
// SDL_SensorGetNonPortableType
// SDL_SensorGetType
// SDL_SensorOpen
// SDL_SensorUpdate
// SDL_SetAssertionHandler
GO(SDL_SetClipboardText, iFp)
GO(SDL_SetClipRect, iFpp)
GO(SDL_SetColorKey, iFpiu)
GO(SDL_SetCursor, vFp)
GO(SDL_setenv, iFppi)
GO(SDL_SetError, iFppppp) // it use ..., so putarbitrary 4 args
GOM(SDL_SetEventFilter, vFEpp)
GO(SDL_SetHint, iFpp)
GO(SDL_SetHintWithPriority, iFppi)
GO(SDL_SetMainReady, vFv)
// SDL_SetMemoryFunctions
GO(SDL_SetModState, vFi)
// SDL_SetPaletteColors
// SDL_SetPixelFormatPalette
GO(SDL_SetRelativeMouseMode, iFi)
GO(SDL_SetRenderDrawBlendMode, iFpu)
GO(SDL_SetRenderDrawColor, iFpCCCC)
GO(SDL_SetRenderTarget, iFpp)
GO(SDL_SetSurfaceAlphaMod, iFpC)
GO(SDL_SetSurfaceBlendMode, iFpu)
// SDL_SetSurfaceColorMod
GO(SDL_SetSurfacePalette, iFpp)
GO(SDL_SetSurfaceRLE, iFpi)
GO(SDL_SetTextInputRect, vFp)
GO(SDL_SetTextureAlphaMod, iFpC)
GO(SDL_SetTextureBlendMode, iFpu)
GO(SDL_SetTextureColorMod, iFpCCC)
GO(SDL_SetThreadPriority, iFu)
GO(SDL_SetWindowBordered, vFpi)
GO(SDL_SetWindowBrightness, iFpf)
GO(SDL_SetWindowData, pFppp)
GO(SDL_SetWindowDisplayMode, iFpp)
GO(SDL_SetWindowFullscreen, iFpu)
GO(SDL_SetWindowGammaRamp, iFpppp)
GO(SDL_SetWindowGrab, vFpi)
// SDL_SetWindowHitTest
GO(SDL_SetWindowIcon, vFpp)
// SDL_SetWindowInputFocus
GO(SDL_SetWindowMaximumSize, vFpii)
GO(SDL_SetWindowMinimumSize, vFpii)
// SDL_SetWindowModalFor
// SDL_SetWindowOpacity
GO(SDL_SetWindowPosition, vFpii)
GO(SDL_SetWindowResizable, vFpi)
GO(SDL_SetWindowShape, iFppp)
GO(SDL_SetWindowSize, vFpii)
GO(SDL_SetWindowTitle, vFpp)
// SDL_SetYUVConversionMode
GO(SDL_ShowCursor, iFi)
GO(SDL_ShowMessageBox, iFpp)
GO(SDL_ShowSimpleMessageBox, iFuppp)
GO(SDL_ShowWindow, vFp)
GO(SDL_sin, dFd)
GO(SDL_sinf, fFf)
GOM(SDL_snprintf, iFEpupVV)
GO(SDL_SoftStretch, iFpppp)
GO(SDL_sqrt, dFd)
GO(SDL_sqrtf, fFf)
GO2(SDL_sscanf, iFppV, SDL_vsscanf)
GO(SDL_StartTextInput, vFv)
GO(SDL_StopTextInput, vFv)
GO(SDL_strcasecmp, iFpp)
GO(SDL_strchr, pFpi)
GO(SDL_strcmp, iFpp)
GO(SDL_strdup, pFp)
GO(SDL_strlcat, uFppu)
GO(SDL_strlcpy, uFppu)
GO(SDL_strlen, uFp)
GO(SDL_strlwr, pFp)
GO(SDL_strncasecmp, iFppu)
GO(SDL_strncmp, iFppu)
GO(SDL_strrchr, pFpi)
GO(SDL_strrev, pFp)
GO(SDL_strstr, pFpp)
GO(SDL_strtod, dFpp)
GO(SDL_strtol, iFppi)
GO(SDL_strtoll, IFppi)
GO(SDL_strtoul, uFppi)
GO(SDL_strtoull, UFppi)
GO(SDL_strupr, pFp)
GO(SDL_tan, dFd)
GO(SDL_tanf, fFf)
GO(SDL_ThreadID, uFv)
GO(SDL_TLSCreate, uFv)
GO(SDL_TLSGet, pFu)
GOM(SDL_TLSSet, iFEupp)
GO(SDL_tolower, iFi)
GO(SDL_toupper, iFi)
GO(SDL_TryLockMutex, iFp)
GO(SDL_uitoa, pFupi)
GO(SDL_ulltoa, pFUpi)
GO(SDL_ultoa, pFupi)
GO(SDL_UnionRect, vFppp)
GOM(SDL_UnloadObject, vFEp)
GO(SDL_UnlockAudio, vFv)
GO(SDL_UnlockAudioDevice, vFi)
GO(SDL_UnlockJoysticks, vFv)
GO(SDL_UnlockMutex, iFp)
GO(SDL_UnlockSurface, vFp)
GO(SDL_UnlockTexture, vFp)
GO(SDL_UpdateTexture, iFpppi)
GO(SDL_UpdateWindowSurface, iFp)
// SDL_UpdateWindowSurfaceRects
GO(SDL_UpdateYUVTexture, iFpppipipi)
GO(SDL_UpperBlit, iFpppp)
GO(SDL_UpperBlitScaled, iFpppp)
GO(SDL_utf8strlcpy, uFppu)
// SDL_utf8strlen
GO(SDL_VideoInit, iFp)
GO(SDL_VideoQuit, vFv)
GOM(SDL_vsnprintf, iFEpupVV)
// SDL_vsscanf
GO(SDL_Vulkan_CreateSurface, iFppp)
GO(SDL_Vulkan_GetDrawableSize, vFppp)
GO(SDL_Vulkan_GetInstanceExtensions, iFppp)
GOM(SDL_Vulkan_GetVkGetInstanceProcAddr, pFEv)
GO(SDL_Vulkan_LoadLibrary, iFp) //TODO: wrap to also call my_dlopen with path?
GO(SDL_Vulkan_UnloadLibrary, vFv)
GO(SDL_WaitEvent, iFp)
GO(SDL_WaitEventTimeout, iFpi)
GO(SDL_WaitThread, vFpp)
GO(SDL_WarpMouseGlobal, iFii)
GO(SDL_WarpMouseInWindow, vFpii)
GO(SDL_WasInit, uFu)
// SDL_wcscmp
// SDL_wcsdup
// SDL_wcslcat
// SDL_wcslcpy
GO(SDL_wcslen, uFp)
GOM(SDL_WriteBE16, uFEpW)
GOM(SDL_WriteBE32, uFEpu)
GOM(SDL_WriteBE64, uFEpU)
GOM(SDL_WriteLE16, uFEpW)
GOM(SDL_WriteLE32, uFEpu)
GOM(SDL_WriteLE64, uFEpU)
GOM(SDL_WriteU8, uFEpu)
GOM(SDL_RWseek, IFEpIi)
GOM(SDL_RWtell, IFEp)
GOM(SDL_RWread, uFEppuu)
GOM(SDL_RWwrite, uFEppuu)
GOM(SDL_RWclose, iFEp)
GO2(SDL_mutexP, iFp, SDL_LockMutex)
GO2(SDL_mutexV, iFp, SDL_UnlockMutex)
GO(SDL_doesntexist, IFpIi)
GOM(SDL_IsJoystickPS4, iFEWW)
GOM(SDL_IsJoystickNintendoSwitchPro, iFEWW)
GOM(SDL_IsJoystickSteamController, iFEWW)
GOM(SDL_IsJoystickXbox360, iFEWW)
GOM(SDL_IsJoystickXboxOne, iFEWW)
GOM(SDL_IsJoystickXInput, iFUU)
GOM(SDL_IsJoystickHIDAPI, iFUU)