about summary refs log tree commit diff stats
path: root/src/libtools/threads.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-09-23 19:45:13 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-09-23 19:45:13 +0200
commit7317472b5f62316e5817f9e89ae2ddf99862412d (patch)
treefa07f9df10da8400097c372289ec58094de5f6e2 /src/libtools/threads.c
parent9271684e5a9f356056a6038f652ec1c15ed16ed2 (diff)
downloadbox64-7317472b5f62316e5817f9e89ae2ddf99862412d.tar.gz
box64-7317472b5f62316e5817f9e89ae2ddf99862412d.zip
[BOX32][WRAPPER] More 32bits wrapped functions, and a few fixes on threads handling
Diffstat (limited to 'src/libtools/threads.c')
-rw-r--r--src/libtools/threads.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/libtools/threads.c b/src/libtools/threads.c
index f0632154..6ca80bba 100644
--- a/src/libtools/threads.c
+++ b/src/libtools/threads.c
@@ -129,13 +129,13 @@ void my_longjmp(x64emu_t* emu, /*struct __jmp_buf_tag __env[1]*/void *p, int32_t
 
 static pthread_key_t thread_key;
 
-static void emuthread_destroy(void* p)
+void emuthread_destroy(void* p)
 {
 	emuthread_t *et = (emuthread_t*)p;
 	if(!et)
 		return;
 	#ifdef BOX32
-	if(!et->join && et->fnc)
+	if(et->is32bits && !et->join && et->fnc)
 		to_hash_d(et->self);
 	#endif
 	FreeX64Emu(&et->emu);
@@ -180,6 +180,7 @@ void thread_set_emu(x64emu_t* emu)
 	et->emu->type = EMUTYPE_MAIN;
 	#ifdef BOX32
 	if(box64_is32bits) {
+		et->is32bits = 1;
 		et->self = (uintptr_t)pthread_self();
 		et->hself = to_hash(et->self);
 	}
@@ -213,6 +214,16 @@ x64emu_t* thread_get_emu()
 	return et->emu;
 }
 
+emuthread_t* thread_get_et()
+{
+	return (emuthread_t*)pthread_getspecific(thread_key);
+}
+
+void thread_set_et(emuthread_t* et)
+{
+	pthread_setspecific(thread_key, et);
+}
+
 static void* pthread_routine(void* p)
 {
 	// free current emuthread if it exist