about summary refs log tree commit diff stats
path: root/src/wrapped/wrappedvulkan.c
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/wrapped/wrappedvulkan.c
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/wrapped/wrappedvulkan.c')
-rwxr-xr-xsrc/wrapped/wrappedvulkan.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/wrapped/wrappedvulkan.c b/src/wrapped/wrappedvulkan.c
index b90747c4..b138ad9b 100755
--- a/src/wrapped/wrappedvulkan.c
+++ b/src/wrapped/wrappedvulkan.c
@@ -53,7 +53,7 @@ static void* resolveSymbol(x64emu_t* emu, void* symbol, const char* rname)
         printf_dlsym(LOG_DEBUG, "%p\n", (void*)ret);
         return (void*)ret; // already bridged
     }
-    // get wrapper    
+    // get wrapper
     khint_t k = kh_get(symbolmap, emu->context->vkwrappers, rname);
     if(k==kh_end(emu->context->vkwrappers) && strstr(rname, "KHR")==NULL) {
         // try again, adding KHR at the end if not present
@@ -74,7 +74,7 @@ static void* resolveSymbol(x64emu_t* emu, void* symbol, const char* rname)
     return (void*)ret;
 }
 
-EXPORT void* my_vkGetDeviceProcAddr(x64emu_t* emu, void* device, void* name) 
+EXPORT void* my_vkGetDeviceProcAddr(x64emu_t* emu, void* device, void* name)
 {
     khint_t k;
     const char* rname = (const char*)name;
@@ -95,7 +95,7 @@ EXPORT void* my_vkGetDeviceProcAddr(x64emu_t* emu, void* device, void* name)
         #define GO(A, W) if(!strcmp(rname, #A)) my->A = (W)my->vkGetDeviceProcAddr(device, name);
         SUPER()
         #undef GO
-    } else 
+    } else
         symbol = my->vkGetDeviceProcAddr(device, name);
     if(!symbol) {
         printf_dlsym(LOG_DEBUG, "%p\n", NULL);
@@ -104,7 +104,7 @@ EXPORT void* my_vkGetDeviceProcAddr(x64emu_t* emu, void* device, void* name)
     return resolveSymbol(emu, symbol, rname);
 }
 
-EXPORT void* my_vkGetInstanceProcAddr(x64emu_t* emu, void* instance, void* name) 
+EXPORT void* my_vkGetInstanceProcAddr(x64emu_t* emu, void* instance, void* name)
 {
     khint_t k;
     const char* rname = (const char*)name;
@@ -192,10 +192,10 @@ GO(4)
 
 // Allocation ...
 #define GO(A)   \
-static uintptr_t my_Allocation_fct_##A = 0;                                         \
-static void* my_Allocation_##A(void* a, size_t b, size_t c, int d)                  \
-{                                                                                   \
-    return (void*)RunFunction(my_context, my_Allocation_fct_##A, 4, a, b, c, d);    \
+static uintptr_t my_Allocation_fct_##A = 0;                                             \
+static void* my_Allocation_##A(void* a, size_t b, size_t c, int d)                      \
+{                                                                                       \
+    return (void*)RunFunctionFmt(my_context, my_Allocation_fct_##A, "pLLi", a, b, c, d);\
 }
 SUPER()
 #undef GO
@@ -214,10 +214,10 @@ static void* find_Allocation_Fct(void* fct)
 }
 // Reallocation ...
 #define GO(A)   \
-static uintptr_t my_Reallocation_fct_##A = 0;                                           \
-static void* my_Reallocation_##A(void* a, void* b, size_t c, size_t d, int e)           \
-{                                                                                       \
-    return (void*)RunFunction(my_context, my_Reallocation_fct_##A, 5, a, b, c, d, e);   \
+static uintptr_t my_Reallocation_fct_##A = 0;                                                   \
+static void* my_Reallocation_##A(void* a, void* b, size_t c, size_t d, int e)                   \
+{                                                                                               \
+    return (void*)RunFunctionFmt(my_context, my_Reallocation_fct_##A, "ppLLi", a, b, c, d, e);  \
 }
 SUPER()
 #undef GO
@@ -239,7 +239,7 @@ static void* find_Reallocation_Fct(void* fct)
 static uintptr_t my_Free_fct_##A = 0;                       \
 static void my_Free_##A(void* a, void* b)                   \
 {                                                           \
-    RunFunction(my_context, my_Free_fct_##A, 2, a, b);      \
+    RunFunctionFmt(my_context, my_Free_fct_##A, "pp", a, b);\
 }
 SUPER()
 #undef GO
@@ -258,10 +258,10 @@ static void* find_Free_Fct(void* fct)
 }
 // InternalAllocNotification ...
 #define GO(A)   \
-static uintptr_t my_InternalAllocNotification_fct_##A = 0;                          \
-static void my_InternalAllocNotification_##A(void* a, size_t b, int c, int d)       \
-{                                                                                   \
-    RunFunction(my_context, my_InternalAllocNotification_fct_##A, 4, a, b, c, d);   \
+static uintptr_t my_InternalAllocNotification_fct_##A = 0;                                  \
+static void my_InternalAllocNotification_##A(void* a, size_t b, int c, int d)               \
+{                                                                                           \
+    RunFunctionFmt(my_context, my_InternalAllocNotification_fct_##A, "pLii", a, b, c, d);   \
 }
 SUPER()
 #undef GO
@@ -280,10 +280,10 @@ static void* find_InternalAllocNotification_Fct(void* fct)
 }
 // InternalFreeNotification ...
 #define GO(A)   \
-static uintptr_t my_InternalFreeNotification_fct_##A = 0;                           \
-static void my_InternalFreeNotification_##A(void* a, size_t b, int c, int d)        \
-{                                                                                   \
-    RunFunction(my_context, my_InternalFreeNotification_fct_##A, 4, a, b, c, d);    \
+static uintptr_t my_InternalFreeNotification_fct_##A = 0;                                   \
+static void my_InternalFreeNotification_##A(void* a, size_t b, int c, int d)                \
+{                                                                                           \
+    RunFunctionFmt(my_context, my_InternalFreeNotification_fct_##A, "pLii", a, b, c, d);    \
 }
 SUPER()
 #undef GO
@@ -302,10 +302,10 @@ static void* find_InternalFreeNotification_Fct(void* fct)
 }
 // DebugReportCallbackEXT ...
 #define GO(A)   \
-static uintptr_t my_DebugReportCallbackEXT_fct_##A = 0;                                                                             \
-static int my_DebugReportCallbackEXT_##A(int a, int b, uint64_t c, size_t d, int e, void* f, void* g, void* h)                      \
-{                                                                                                                                   \
-    return RunFunction(my_context, my_DebugReportCallbackEXT_fct_##A, 8, a, b, c, d, e, f, g, h);    \
+static uintptr_t my_DebugReportCallbackEXT_fct_##A = 0;                                                         \
+static int my_DebugReportCallbackEXT_##A(int a, int b, uint64_t c, size_t d, int e, void* f, void* g, void* h)  \
+{                                                                                                               \
+    return RunFunctionFmt(my_context, my_DebugReportCallbackEXT_fct_##A, "iiULippp", a, b, c, d, e, f, g, h);   \
 }
 SUPER()
 #undef GO
@@ -618,7 +618,7 @@ EXPORT void my_vkGetPhysicalDeviceMemoryProperties(x64emu_t* emu, void* device,
     my->vkGetPhysicalDeviceMemoryProperties(device, pProps);
 }
 
-EXPORT void my_vkCmdPipelineBarrier(x64emu_t* emu, void* device, int src, int dst, int dep, 
+EXPORT void my_vkCmdPipelineBarrier(x64emu_t* emu, void* device, int src, int dst, int dep,
     uint32_t barrierCount, void* pBarriers, uint32_t bufferCount, void* pBuffers, uint32_t imageCount, void* pImages)
 {
     my->vkCmdPipelineBarrier(device, src, dst, dep, barrierCount, pBarriers, bufferCount, pBuffers, imageCount, pImages);
@@ -632,12 +632,12 @@ typedef struct my_VkDebugReportCallbackCreateInfoEXT_s {
     void*       pUserData;
 } my_VkDebugReportCallbackCreateInfoEXT_t;
 
-EXPORT int my_vkCreateDebugReportCallbackEXT(x64emu_t* emu, void* instance, 
-                                             my_VkDebugReportCallbackCreateInfoEXT_t* create, 
+EXPORT int my_vkCreateDebugReportCallbackEXT(x64emu_t* emu, void* instance,
+                                             my_VkDebugReportCallbackCreateInfoEXT_t* create,
                                              my_VkAllocationCallbacks_t* alloc, void* callback)
 {
     my_VkDebugReportCallbackCreateInfoEXT_t dbg = *create;
-    my_VkAllocationCallbacks_t my_alloc; 
+    my_VkAllocationCallbacks_t my_alloc;
     dbg.pfnCallback = find_DebugReportCallbackEXT_Fct(dbg.pfnCallback);
     return my->vkCreateDebugReportCallbackEXT(instance, &dbg, find_VkAllocationCallbacks(&my_alloc, alloc), callback);
 }
@@ -648,4 +648,4 @@ EXPORT int my_vkDestroyDebugReportCallbackEXT(x64emu_t* emu, void* instance, voi
     return my->vkDestroyDebugReportCallbackEXT(instance, callback, find_VkAllocationCallbacks(&my_alloc, alloc));
 }
 
-CREATE(vkCreateHeadlessSurfaceEXT)
\ No newline at end of file
+CREATE(vkCreateHeadlessSurfaceEXT)