diff options
Diffstat (limited to 'src/libtools/threads.c')
| -rw-r--r-- | src/libtools/threads.c | 46 |
1 files changed, 7 insertions, 39 deletions
diff --git a/src/libtools/threads.c b/src/libtools/threads.c index 812e1943..90c665e2 100644 --- a/src/libtools/threads.c +++ b/src/libtools/threads.c @@ -14,7 +14,6 @@ #include "box64context.h" #include "threads.h" #include "emu/x64emu_private.h" -#include "tools/bridge_private.h" #include "x64run.h" #include "x64emu.h" #include "box64stack.h" @@ -215,7 +214,7 @@ x64emu_t* thread_get_emu() } void* stack = my_mmap(NULL, NULL, stacksize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_GROWSDOWN, -1, 0); x64emu_t *emu = NewX64Emu(my_context, 0, (uintptr_t)stack, stacksize, 1); - SetupX64Emu(emu); + SetupX64Emu(emu, NULL); thread_set_emu(emu); return emu; } @@ -490,7 +489,7 @@ EXPORT int my_pthread_create(x64emu_t *emu, void* t, void* attr, void* start_rou emuthread_t *et = (emuthread_t*)box_calloc(1, sizeof(emuthread_t)); x64emu_t *emuthread = NewX64Emu(my_context, (uintptr_t)start_routine, (uintptr_t)stack, stacksize, own); - SetupX64Emu(emuthread); + SetupX64Emu(emuthread, emu); //SetFS(emuthread, GetFS(emu)); et->emu = emuthread; et->fnc = (uintptr_t)start_routine; @@ -498,7 +497,7 @@ EXPORT int my_pthread_create(x64emu_t *emu, void* t, void* attr, void* start_rou #ifdef DYNAREC if(box64_dynarec) { // pre-creation of the JIT code for the entry point of the thread - DBGetBlock(emu, (uintptr_t)start_routine, 1); + DBGetBlock(emu, (uintptr_t)start_routine, 1, 0); // function wrapping are 64bits only on box64 } #endif // create thread @@ -512,14 +511,14 @@ void* my_prepare_thread(x64emu_t *emu, void* f, void* arg, int ssize, void** pet void* stack = my_mmap(NULL, NULL, stacksize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_GROWSDOWN, -1, 0); emuthread_t *et = (emuthread_t*)box_calloc(1, sizeof(emuthread_t)); x64emu_t *emuthread = NewX64Emu(emu->context, (uintptr_t)f, (uintptr_t)stack, stacksize, 1); - SetupX64Emu(emuthread); + SetupX64Emu(emuthread, emu ); //SetFS(emuthread, GetFS(emu)); et->emu = emuthread; et->fnc = (uintptr_t)f; et->arg = arg; #ifdef DYNAREC // pre-creation of the JIT code for the entry point of the thread - DBGetBlock(emu, (uintptr_t)f, 1); + DBGetBlock(emu, (uintptr_t)f, 1, 0); // function wrapping are 64bits only on box64 #endif *pet = et; return pthread_routine; @@ -619,7 +618,7 @@ GO(29) static uintptr_t my_key_destructor_fct_##A = 0; \ static void my_key_destructor_##A(void* a) \ { \ - RunFunction(my_context, my_key_destructor_fct_##A, 1, a);\ + RunFunction(my_key_destructor_fct_##A, 1, a);\ } SUPER() #undef GO @@ -641,7 +640,7 @@ static void* findkey_destructorFct(void* fct) static uintptr_t my_cleanup_routine_fct_##A = 0; \ static void my_cleanup_routine_##A(void* a) \ { \ - RunFunction(my_context, my_cleanup_routine_fct_##A, 1, a);\ + RunFunction(my_cleanup_routine_fct_##A, 1, a);\ } SUPER() #undef GO @@ -1067,28 +1066,6 @@ EXPORT int my_pthread_barrier_init(x64emu_t* emu, pthread_barrier_t* bar, my_bar #endif -static void emujmpbuf_destroy(void* p) -{ - emu_jmpbuf_t *ej = (emu_jmpbuf_t*)p; - if(ej) { - box_free(ej->jmpbuf); - box_free(ej); - } -} - -static pthread_key_t jmpbuf_key; - -emu_jmpbuf_t* GetJmpBuf() -{ - emu_jmpbuf_t *ejb = (emu_jmpbuf_t*)pthread_getspecific(jmpbuf_key); - if(!ejb) { - ejb = (emu_jmpbuf_t*)box_calloc(1, sizeof(emu_jmpbuf_t)); - ejb->jmpbuf = box_calloc(1, sizeof(struct __jmp_buf_tag)); - pthread_setspecific(jmpbuf_key, ejb); - } - return ejb; -} - void init_pthread_helper() { real_pthread_cleanup_push_defer = (vFppp_t)dlsym(NULL, "_pthread_cleanup_push_defer"); @@ -1109,8 +1086,6 @@ void init_pthread_helper() } InitCancelThread(); - pthread_key_create(&jmpbuf_key, emujmpbuf_destroy); - pthread_setspecific(jmpbuf_key, NULL); pthread_key_create(&thread_key, emuthread_destroy); pthread_setspecific(thread_key, NULL); } @@ -1119,11 +1094,6 @@ void fini_pthread_helper(box64context_t* context) { FreeCancelThread(context); CleanStackSize(context); - emu_jmpbuf_t *ejb = (emu_jmpbuf_t*)pthread_getspecific(jmpbuf_key); - if(ejb) { - pthread_setspecific(jmpbuf_key, NULL); - emujmpbuf_destroy(ejb); - } emuthread_t *et = (emuthread_t*)pthread_getspecific(thread_key); if(et) { pthread_setspecific(thread_key, NULL); @@ -1131,7 +1101,6 @@ void fini_pthread_helper(box64context_t* context) } } -#ifndef DYNAREC int checkUnlockMutex(void* m) { pthread_mutex_t* mutex = (pthread_mutex_t*)m; @@ -1141,4 +1110,3 @@ int checkUnlockMutex(void* m) } return 0; } -#endif |