about summary refs log tree commit diff stats
path: root/src/libtools
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2025-03-29 10:03:21 +0100
committerptitSeb <sebastien.chev@gmail.com>2025-03-29 10:03:21 +0100
commitd2817e72468bf460c8758f6ee6bdd804cf317f90 (patch)
tree62410dca20d12e6d36f742da81bded09f06a595a /src/libtools
parent7ae8e9a86fbe963db6e66a2dbc0b267bb93d175b (diff)
downloadbox64-d2817e72468bf460c8758f6ee6bdd804cf317f90.tar.gz
box64-d2817e72468bf460c8758f6ee6bdd804cf317f90.zip
[BOX32] Small changes in pthread_cond_timedwait wrapping to handle malformed timespec
Diffstat (limited to 'src/libtools')
-rwxr-xr-xsrc/libtools/threads32.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libtools/threads32.c b/src/libtools/threads32.c
index 3f43d8db..9ad288e9 100755
--- a/src/libtools/threads32.c
+++ b/src/libtools/threads32.c
@@ -592,7 +592,12 @@ EXPORT int my32_pthread_cond_timedwait_old(x64emu_t* emu, pthread_cond_2_0_t* co
 {
 	pthread_mutex_t* m = getAlignedMutex((pthread_mutex_t*)mutex);
 	pthread_cond_t * c = get_cond_old(cond);
-	return pthread_cond_timedwait(c, m, (const struct timespec*)abstime);
+	struct timespec* atime = abstime;
+	while(atime->tv_nsec>1000000000LL) {
+		atime->tv_nsec-=1000000000LL;
+		++atime->tv_sec;
+	}
+	return pthread_cond_timedwait(c, m, atime);
 }
 EXPORT int my32_pthread_cond_wait_old(x64emu_t* emu, pthread_cond_2_0_t* cond, void* mutex)
 {
@@ -605,7 +610,12 @@ EXPORT int my32_pthread_cond_timedwait(x64emu_t* emu, void* cond, void* mutex, v
 {
 	pthread_mutex_t* m = getAlignedMutex((pthread_mutex_t*)mutex);
 	pthread_cond_t * c = get_cond(cond);
-	return pthread_cond_timedwait(c, m, (const struct timespec*)abstime);
+	struct timespec* atime = abstime;
+	while(atime->tv_nsec>1000000000LL) {
+		atime->tv_nsec-=1000000000LL;
+		++atime->tv_sec;
+	}
+	return pthread_cond_timedwait(c, m, atime);
 }
 EXPORT int my32_pthread_cond_wait(x64emu_t* emu, void* cond, void* mutex)
 {