From e2b24f7f59f84cae552e2458a11be50b042839f5 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sat, 2 Oct 2021 17:54:30 -0700 Subject: [PATCH] Thunks: Support thunk init function on host Allows library to have an additional initialization function --- ThunkLibs/include/common/Host.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ThunkLibs/include/common/Host.h b/ThunkLibs/include/common/Host.h index 7cb811b55..836874018 100644 --- a/ThunkLibs/include/common/Host.h +++ b/ThunkLibs/include/common/Host.h @@ -14,6 +14,15 @@ typedef void fex_call_callback_t(uintptr_t callback, void *arg0, void* arg1); static fex_call_callback_t* call_guest; #define EXPORTS(name) extern "C" { ExportEntry* fexthunks_exports_##name(void *a0, uintptr_t a1) { call_guest = (fex_call_callback_t*)a0; fexldr_init_##name(); return exports; } } +#define EXPORTS_INIT(name, init_fn) \ + extern "C" { \ + ExportEntry* fexthunks_exports_##name(void *a0, uintptr_t a1) { \ + call_guest = (fex_call_callback_t*)a0; \ + fexldr_init_##name(); \ + init_fn (); \ + return exports; \ + } } + #define EXPORTS_WITH_CALLBACKS(name) extern "C" { ExportEntry* fexthunks_exports_##name(void *a0, uintptr_t a1) { call_guest = (fex_call_callback_t*)a0; (uintptr_t&)callback_unpacks = a1; fexldr_init_##name(); return exports; } } #define LOAD_LIB_INIT(init_fn) \