about summary refs log tree commit diff stats
path: root/src/libtools
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-12-15 17:04:58 +0100
committerptitSeb <sebastien.chev@gmail.com>2024-12-15 17:04:58 +0100
commitf7754740625b6f1749ee77e09f05956aa146f30b (patch)
treecda5ae49c4300cd5e0f68fcaab796853f9463cc5 /src/libtools
parentc30e012e8d0f86b97c80e3c99281f4cd7705e68a (diff)
downloadbox64-f7754740625b6f1749ee77e09f05956aa146f30b.tar.gz
box64-f7754740625b6f1749ee77e09f05956aa146f30b.zip
[BOX32] Try to impove pthread_cond_t handling
Diffstat (limited to 'src/libtools')
-rwxr-xr-xsrc/libtools/threads32.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libtools/threads32.c b/src/libtools/threads32.c
index 829c76f2..cab37ee2 100755
--- a/src/libtools/threads32.c
+++ b/src/libtools/threads32.c
@@ -449,6 +449,8 @@ kh_mapcond_t *mapcond = NULL;
 
 static pthread_cond_t* add_cond(void* cond)
 {
+	if(((uintptr_t)cond)&7==0)
+		return cond;
 	mutex_lock(&my_context->mutex_thread);
 	khint_t k;
 	int ret;
@@ -464,6 +466,8 @@ static pthread_cond_t* add_cond(void* cond)
 }
 static pthread_cond_t* get_cond(void* cond)
 {
+	if(((uintptr_t)cond)&7==0)
+		return cond;
 	pthread_cond_t* ret;
 	int r;
 	mutex_lock(&my_context->mutex_thread);
@@ -476,7 +480,8 @@ static pthread_cond_t* get_cond(void* cond)
 			k = kh_put(mapcond, mapcond, (uintptr_t)cond, &r);
 			kh_value(mapcond, k) = ret;
 			//*(ptr_t*)cond = to_ptrv(cond);
-			pthread_cond_init(ret, NULL);
+			//pthread_cond_init(ret, NULL);
+			memcpy(ret, cond, sizeof(pthread_cond_t));
 		} else
 			ret = kh_value(mapcond, k);
 	} else
@@ -486,6 +491,8 @@ static pthread_cond_t* get_cond(void* cond)
 }
 static void del_cond(void* cond)
 {
+	if(((uintptr_t)cond)&7==0)
+		return;
 	if(!mapcond)
 		return;
 	mutex_lock(&my_context->mutex_thread);