From 541adff4d40db9d32076c222c8e1289c5fceb84c Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Wed, 30 Oct 2024 11:12:51 +0100 Subject: Improved clone wrapped function compatibility --- src/include/box64context.h | 1 + src/libtools/threads.c | 5 ++++- src/wrapped/wrappedlibc.c | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/include/box64context.h b/src/include/box64context.h index 8899460e..d27a23af 100644 --- a/src/include/box64context.h +++ b/src/include/box64context.h @@ -267,6 +267,7 @@ int AddTLSPartition(box64context_t* context, int tlssize); // defined in fact in threads.c void thread_set_emu(x64emu_t* emu); +void thread_forget_emu(); x64emu_t* thread_get_emu(void); // unlock mutex that are locked by current thread (for signal handling). Return a mask of unlock mutex diff --git a/src/libtools/threads.c b/src/libtools/threads.c index e19b3fda..afa7a337 100644 --- a/src/libtools/threads.c +++ b/src/libtools/threads.c @@ -161,7 +161,10 @@ static void emuthread_cancel(void* p) et->cancels=NULL; et->cancel_size = et->cancel_cap = 0; } - +void thread_forget_emu() +{ + pthread_setspecific(thread_key, NULL); +} void thread_set_emu(x64emu_t* emu) { emuthread_t *et = (emuthread_t*)pthread_getspecific(thread_key); diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index db57e446..8c9be048 100644 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -3632,6 +3632,7 @@ static int clone_fn(void* p) x64emu_t *emu = arg->emu; R_RSP = arg->stack; emu->flags.quitonexit = 1; + thread_forget_emu(); //TODO: not all will flags needs this, probably just CLONE_VM? thread_set_emu(emu); if(arg->flags&CLONE_NEWUSER) { init_mutexes(my_context); -- cgit 1.4.1