diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-06-14 14:53:20 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-06-14 14:53:20 +0200 |
| commit | 730e129a800f2406ff7b879931c433438b69c6cd (patch) | |
| tree | 79191eb6c15a0b813a1c0462d9e95eb5f103d738 /src | |
| parent | 883fc1681d214efe8c2d43089e2e38900d6d7db2 (diff) | |
| download | box64-730e129a800f2406ff7b879931c433438b69c6cd.tar.gz box64-730e129a800f2406ff7b879931c433438b69c6cd.zip | |
Change the way locked mutex are detected (taken from box86)
Diffstat (limited to 'src')
| -rwxr-xr-x | src/box64context.c | 3 | ||||
| -rw-r--r-- | src/custommem.c | 3 | ||||
| -rwxr-xr-x | src/include/threads.h | 4 | ||||
| -rwxr-xr-x | src/libtools/threads.c | 9 |
4 files changed, 7 insertions, 12 deletions
diff --git a/src/box64context.c b/src/box64context.c index 0202dba1..c3b228e6 100755 --- a/src/box64context.c +++ b/src/box64context.c @@ -73,9 +73,8 @@ int unlockMutex() int ret = unlockCustommemMutex(); int i; #define GO(A, B) \ - i = checkMutex(&A); \ + i = checkUnlockMutex(&A); \ if(i) { \ - pthread_mutex_unlock(&A); \ ret|=(1<<B); \ } diff --git a/src/custommem.c b/src/custommem.c index 8bc25ac0..bfedc35a 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -898,9 +898,8 @@ int unlockCustommemMutex() int ret = 0; int i = 0; #define GO(A, B) \ - i = checkMutex(&A); \ + i = checkUnlockMutex(&A); \ if(i) { \ - pthread_mutex_unlock(&A); \ ret|=(1<<B); \ } GO(mutex_blocks, 0) diff --git a/src/include/threads.h b/src/include/threads.h index 19d3c9bc..847d4ee6 100755 --- a/src/include/threads.h +++ b/src/include/threads.h @@ -20,7 +20,7 @@ void fini_pthread_helper(box64context_t* context); // prepare an "emuthread structure" in pet and return address of function pointer for a "thread creation routine" void* my_prepare_thread(x64emu_t *emu, void* f, void* arg, int ssize, void** pet); -//check if a mutex is locked by current thread (works only for PTHREAD_MUTEX_ERRORCHECK typed mutex) -int checkMutex(void* m); +//check and unlock if a mutex is locked by current thread (works only for PTHREAD_MUTEX_ERRORCHECK typed mutex) +int checkUnlockMutex(void* m); #endif //_THREADS_H_ \ No newline at end of file diff --git a/src/libtools/threads.c b/src/libtools/threads.c index 83de0da9..93219381 100755 --- a/src/libtools/threads.c +++ b/src/libtools/threads.c @@ -1103,15 +1103,12 @@ void fini_pthread_helper(box64context_t* context) } } -int checkMutex(void* m) +int checkUnlockMutex(void* m) { pthread_mutex_t* mutex = (pthread_mutex_t*)m; - int ret = pthread_mutex_trylock(mutex); + int ret = pthread_mutex_unlock(mutex); if(ret==0) { - pthread_mutex_unlock(mutex); - return 0; - } - if(ret==EDEADLK) return 1; + } return 0; } |