about summary refs log tree commit diff stats
path: root/src/libtools
diff options
context:
space:
mode:
authorYang Liu <liuyang22@iscas.ac.cn>2023-05-07 22:13:56 +0800
committerGitHub <noreply@github.com>2023-05-07 16:13:56 +0200
commit9f38e81735b10668d64974033b4bb5097219ee34 (patch)
tree57827cc130a3e79a46c58f4e5ce8946c78f4131a /src/libtools
parent47ecde75ec19a58f458c1131ec1968d11d58e7e1 (diff)
downloadbox64-9f38e81735b10668d64974033b4bb5097219ee34.tar.gz
box64-9f38e81735b10668d64974033b4bb5097219ee34.zip
[WRAPPER] Used RunFunctionFmt for better sign-extend handling (#768)
* [WRAPPER] Used RunFunctionFmt for better sign-extend handling

* [WRAPPER] Fixed some typos

* [WRAPPER] Use L for unsigned long for better portability

* [WRAPPER] More replace from U to L
Diffstat (limited to 'src/libtools')
-rwxr-xr-xsrc/libtools/sdl1rwops.c10
-rwxr-xr-xsrc/libtools/sdl2rwops.c18
2 files changed, 14 insertions, 14 deletions
diff --git a/src/libtools/sdl1rwops.c b/src/libtools/sdl1rwops.c
index c7349af6..373600f3 100755
--- a/src/libtools/sdl1rwops.c
+++ b/src/libtools/sdl1rwops.c
@@ -72,20 +72,20 @@ EXPORT int32_t my_native_close(SDL1_RWops_t *context)
 }
 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);
+    return (int32_t)RunFunctionFmt(my_context, (uintptr_t)context->hidden.my.orig->seek, "pii", 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);
+    return (int32_t)RunFunctionFmt(my_context, (uintptr_t)context->hidden.my.orig->read, "ppii", 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);
+    return (int32_t)RunFunctionFmt(my_context, (uintptr_t)context->hidden.my.orig->write, "ppii", 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);
+    return (int32_t)RunFunctionFmt(my_context, (uintptr_t)context->hidden.my.orig->close, "p", context->hidden.my.orig);
 }
 
 SDL1_RWops_t* AddNativeRW(x64emu_t* emu, SDL1_RWops_t* ops)
@@ -180,4 +180,4 @@ void RWSetType(SDL1_RWops_t* r, int awesome)
 {
     if(r)
         r->type = awesome;  // I like shoot'em up :D
-}
\ No newline at end of file
+}
diff --git a/src/libtools/sdl2rwops.c b/src/libtools/sdl2rwops.c
index 9b18dd8f..9a1f4d07 100755
--- a/src/libtools/sdl2rwops.c
+++ b/src/libtools/sdl2rwops.c
@@ -85,23 +85,23 @@ EXPORT int32_t my2_native_close(SDL2_RWops_t *context)
 }
 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);
+    return (int64_t)RunFunctionFmt(my_context, (uintptr_t)context->hidden.my.orig->size, "p", 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);
+    return (int64_t)RunFunctionFmt(my_context, (uintptr_t)context->hidden.my.orig->seek, "pIi", 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);
+    return (int32_t)RunFunctionFmt(my_context, (uintptr_t)context->hidden.my.orig->read, "ppii", 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);
+    return (int32_t)RunFunctionFmt(my_context, (uintptr_t)context->hidden.my.orig->write, "ppii", context->hidden.my.orig, ptr, size, num);
 }
 EXPORT int32_t my2_emulated_close(SDL2_RWops_t *context)
 {
-    int ret = (int32_t)RunFunction(my_context, (uintptr_t)context->hidden.my.orig->close, 1, context->hidden.my.orig);
+    int ret = (int32_t)RunFunctionFmt(my_context, (uintptr_t)context->hidden.my.orig->close, "p", context->hidden.my.orig);
     context->hidden.my.custom_free(context);
     return ret;
 }
@@ -109,12 +109,12 @@ EXPORT int32_t my2_emulated_close(SDL2_RWops_t *context)
 static uintptr_t emulated_sdl2allocrw = 0;
 EXPORT SDL2_RWops_t* my_wrapped_sdl2allocrw()
 {
-    return (SDL2_RWops_t*)RunFunction(my_context, emulated_sdl2allocrw, 0);
+    return (SDL2_RWops_t*)RunFunctionFmt(my_context, emulated_sdl2allocrw, "");
 }
 static uintptr_t emulated_sdl2freerw = 0;
 EXPORT void my_wrapped_sdl2freerw(SDL2_RWops_t* p)
 {
-    RunFunction(my_context, emulated_sdl2freerw, 1, p);
+    RunFunctionFmt(my_context, emulated_sdl2freerw, "p", p);
 }
 
 static void checkSDL2isNative()
@@ -174,7 +174,7 @@ SDL2_RWops_t* RWNativeStart2(x64emu_t* emu, SDL2_RWops_t* ops)
     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;
@@ -229,4 +229,4 @@ int32_t RWNativeWrite2(SDL2_RWops_t *ops, const void *ptr, int32_t size, int32_t
 int32_t RWNativeClose2(SDL2_RWops_t* ops)
 {
     return ops->close(ops);
-}
\ No newline at end of file
+}