about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-10-11 10:05:00 +0200
committerptitSeb <sebastien.chev@gmail.com>2023-10-11 10:05:00 +0200
commitae75a502f0601b5e4614edecea9901b44c17ca6f (patch)
treee1ad46f770d46818c8e559f35124aa3881027db9 /src
parent6ac200f5978d7d14c97eb2d993393ee28ee93b89 (diff)
downloadbox64-ae75a502f0601b5e4614edecea9901b44c17ca6f.tar.gz
box64-ae75a502f0601b5e4614edecea9901b44c17ca6f.zip
Added a few libgomp wrapped function (for #1019)
Diffstat (limited to 'src')
-rw-r--r--src/wrapped/generated/functions_list.txt3
-rw-r--r--src/wrapped/generated/wrappedgomptypes.h4
-rw-r--r--src/wrapped/generated/wrapper.c2
-rw-r--r--src/wrapped/generated/wrapper.h1
-rw-r--r--src/wrapped/wrappedgomp.c55
-rw-r--r--src/wrapped/wrappedgomp_private.h8
6 files changed, 68 insertions, 5 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index 84055259..eb83ef69 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -1253,6 +1253,7 @@
 #() vFEpLLp
 #() vFEppip
 #() vFEppiV
+#() vFEppuu
 #() vFEppup
 #() vFEpppi
 #() vFEpppp
@@ -3555,6 +3556,8 @@ wrappedgobject2:
 - uFpLippppLuA:
   - g_signal_new_valist
 wrappedgomp:
+- vFppuu:
+  - GOMP_parallel
 wrappedgssapi:
 wrappedgssapikrb5:
 wrappedgstallocators:
diff --git a/src/wrapped/generated/wrappedgomptypes.h b/src/wrapped/generated/wrappedgomptypes.h
index 8b28dc5c..349db52a 100644
--- a/src/wrapped/generated/wrappedgomptypes.h
+++ b/src/wrapped/generated/wrappedgomptypes.h
@@ -11,7 +11,9 @@
 #define ADDED_FUNCTIONS() 
 #endif
 
+typedef void (*vFppuu_t)(void*, void*, uint32_t, uint32_t);
 
-#define SUPER() ADDED_FUNCTIONS()
+#define SUPER() ADDED_FUNCTIONS() \
+	GO(GOMP_parallel, vFppuu_t)
 
 #endif // __wrappedgompTYPES_H_
diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c
index c5b5ff31..68cf4375 100644
--- a/src/wrapped/generated/wrapper.c
+++ b/src/wrapped/generated/wrapper.c
@@ -1289,6 +1289,7 @@ typedef void (*vFEpupA_t)(x64emu_t*, void*, uint32_t, void*, void*);
 typedef void (*vFEpLLp_t)(x64emu_t*, void*, uintptr_t, uintptr_t, void*);
 typedef void (*vFEppip_t)(x64emu_t*, void*, void*, int32_t, void*);
 typedef void (*vFEppiV_t)(x64emu_t*, void*, void*, int32_t, void*);
+typedef void (*vFEppuu_t)(x64emu_t*, void*, void*, uint32_t, uint32_t);
 typedef void (*vFEppup_t)(x64emu_t*, void*, void*, uint32_t, void*);
 typedef void (*vFEpppi_t)(x64emu_t*, void*, void*, void*, int32_t);
 typedef void (*vFEpppp_t)(x64emu_t*, void*, void*, void*, void*);
@@ -4238,6 +4239,7 @@ void vFEpupA(x64emu_t *emu, uintptr_t fcn) { vFEpupA_t fn = (vFEpupA_t)fcn; fn(e
 void vFEpLLp(x64emu_t *emu, uintptr_t fcn) { vFEpLLp_t fn = (vFEpLLp_t)fcn; fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (uintptr_t)R_RDX, (void*)R_RCX); }
 void vFEppip(x64emu_t *emu, uintptr_t fcn) { vFEppip_t fn = (vFEppip_t)fcn; fn(emu, (void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (void*)R_RCX); }
 void vFEppiV(x64emu_t *emu, uintptr_t fcn) { vFEppiV_t fn = (vFEppiV_t)fcn; fn(emu, (void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (void*)(R_RSP + 8)); }
+void vFEppuu(x64emu_t *emu, uintptr_t fcn) { vFEppuu_t fn = (vFEppuu_t)fcn; fn(emu, (void*)R_RDI, (void*)R_RSI, (uint32_t)R_RDX, (uint32_t)R_RCX); }
 void vFEppup(x64emu_t *emu, uintptr_t fcn) { vFEppup_t fn = (vFEppup_t)fcn; fn(emu, (void*)R_RDI, (void*)R_RSI, (uint32_t)R_RDX, (void*)R_RCX); }
 void vFEpppi(x64emu_t *emu, uintptr_t fcn) { vFEpppi_t fn = (vFEpppi_t)fcn; fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (int32_t)R_RCX); }
 void vFEpppp(x64emu_t *emu, uintptr_t fcn) { vFEpppp_t fn = (vFEpppp_t)fcn; fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX); }
diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h
index 4293da3f..f5a974bb 100644
--- a/src/wrapped/generated/wrapper.h
+++ b/src/wrapped/generated/wrapper.h
@@ -1290,6 +1290,7 @@ void vFEpupA(x64emu_t *emu, uintptr_t fnc);
 void vFEpLLp(x64emu_t *emu, uintptr_t fnc);
 void vFEppip(x64emu_t *emu, uintptr_t fnc);
 void vFEppiV(x64emu_t *emu, uintptr_t fnc);
+void vFEppuu(x64emu_t *emu, uintptr_t fnc);
 void vFEppup(x64emu_t *emu, uintptr_t fnc);
 void vFEpppi(x64emu_t *emu, uintptr_t fnc);
 void vFEpppp(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped/wrappedgomp.c b/src/wrapped/wrappedgomp.c
index 650da53a..6cf9f200 100644
--- a/src/wrapped/wrappedgomp.c
+++ b/src/wrapped/wrappedgomp.c
@@ -6,13 +6,68 @@
 
 #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 "gtkclass.h"
+#include "myalign.h"
 
 const char* gompName = "libgomp.so.1";
 #define LIBNAME gomp
 
+#define ADDED_FUNCTIONS()           \
+
+#include "generated/wrappedgomptypes.h"
+
+#include "wrappercallback.h"
+
+#define SUPER() \
+GO(0)   \
+GO(1)   \
+GO(2)   \
+GO(3)   \
+
+// parallel
+#define GO(A)   \
+static uintptr_t my_parallel_fct_##A = 0;           \
+static void my_parallel_##A(void* a)                \
+{                                                   \
+    RunFunctionFmt(my_parallel_fct_##A, "p", a);    \
+}
+SUPER()
+#undef GO
+static void* find_parallel_Fct(void* fct)
+{
+    if(!fct) return fct;
+    #define GO(A) if(my_parallel_fct_##A == (uintptr_t)fct) return my_parallel_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_parallel_fct_##A == 0) {my_parallel_fct_##A = (uintptr_t)fct; return my_parallel_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for libgomp Boxed parallel callback\n");
+    return NULL;
+}
+
+#undef SUPER
+
+EXPORT void my_GOMP_parallel(x64emu_t* emu, void* f, void* data, unsigned num_threads, uint32_t flags)
+{
+    my->GOMP_parallel(find_parallel_Fct(f), data, num_threads, flags);
+}
+
+#define CUSTOM_INIT \
+    getMy(lib);     \
+
+#define CUSTOM_FINI \
+    freeMy();
+
 #include "wrappedlib_init.h"
 
diff --git a/src/wrapped/wrappedgomp_private.h b/src/wrapped/wrappedgomp_private.h
index 33b19706..c7ccd76d 100644
--- a/src/wrapped/wrappedgomp_private.h
+++ b/src/wrapped/wrappedgomp_private.h
@@ -220,7 +220,7 @@
 //GO(GOMP_offload_unregister_ver, 
 //GO(GOMP_ordered_end, 
 //GO(GOMP_ordered_start, 
-//GO(GOMP_parallel, 
+GOM(GOMP_parallel, vFEppuu)
 //GO(GOMP_parallel_end, 
 //GO(GOMP_parallel_loop_dynamic, 
 //GO(GOMP_parallel_loop_dynamic_start, 
@@ -339,7 +339,7 @@
 //GO(omp_get_max_task_priority_, 
 //GO(omp_get_max_teams, 
 //GO(omp_get_max_teams_, 
-//GO(omp_get_max_threads, 
+GO(omp_get_max_threads, iFv)
 //GO(omp_get_max_threads_, 
 //GO(omp_get_nested, 
 //GO(omp_get_nested_, 
@@ -351,7 +351,7 @@
 //GO(omp_get_num_procs_, 
 //GO(omp_get_num_teams, 
 //GO(omp_get_num_teams_, 
-//GO(omp_get_num_threads, 
+GO(omp_get_num_threads, iFv)
 //GO(omp_get_num_threads_, 
 //GO(omp_get_partition_num_places, 
 //GO(omp_get_partition_num_places_, 
@@ -382,7 +382,7 @@
 //GO(omp_get_teams_thread_limit_, 
 //GO(omp_get_thread_limit, 
 //GO(omp_get_thread_limit_, 
-//GO(omp_get_thread_num, 
+GO(omp_get_thread_num, iFv)
 //GO(omp_get_thread_num_, 
 //GO(omp_get_wtick, 
 //GO(omp_get_wtick_,