about summary refs log tree commit diff stats
path: root/src/libtools/threads.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libtools/threads.c')
-rw-r--r--src/libtools/threads.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/libtools/threads.c b/src/libtools/threads.c
index b714b915..47eae9d4 100644
--- a/src/libtools/threads.c
+++ b/src/libtools/threads.c
@@ -378,6 +378,10 @@ EXPORT int my_pthread_attr_setaffinity_np(x64emu_t* emu, pthread_attr_t* attr, s
 	PTHREAD_ATTR_UNALIGN(attr);
 	return ret;
 }
+EXPORT int my_pthread_attr_setaffinity_np_old(x64emu_t* emu, pthread_attr_t* attr, void* cpuset)
+{
+	return my_pthread_attr_setaffinity_np(emu, attr, 128, cpuset);
+}
 #endif
 EXPORT int my_pthread_attr_setdetachstate(x64emu_t* emu, pthread_attr_t* attr, int state)
 {
@@ -779,6 +783,11 @@ EXPORT int my_pthread_getaffinity_np(x64emu_t* emu, pthread_t thread, size_t cpu
 
     return ret;
 }
+EXPORT int my_pthread_getaffinity_np_old(x64emu_t* emu, pthread_t thread, void* cpuset)
+{
+	return my_pthread_getaffinity_np(emu, thread, 128, cpuset);
+}
+
 
 EXPORT int my_pthread_setaffinity_np(x64emu_t* emu, pthread_t thread, size_t cpusetsize, void* cpuset)
 {
@@ -790,6 +799,10 @@ EXPORT int my_pthread_setaffinity_np(x64emu_t* emu, pthread_t thread, size_t cpu
 
     return ret;
 }
+EXPORT int my_my_pthread_setaffinity_np_old(x64emu_t* emu, pthread_t thread, void* cpuset)
+{
+	return my_pthread_setaffinity_np(emu, thread, 128, cpuset);
+}
 #endif
 
 //EXPORT int my_pthread_attr_setaffinity_np(x64emu_t* emu, void* attr, uint32_t cpusetsize, void* cpuset)
@@ -1046,6 +1059,68 @@ EXPORT int my_pthread_cond_broadcast(x64emu_t* emu, pthread_cond_t *pc)
 }
 #endif
 
+typedef struct pthread_cond_old_s {
+	pthread_cond_t* cond;
+} pthread_cond_old_t;
+
+static pthread_cond_t* get_cond(pthread_cond_old_t* cond) {
+	if(!cond->cond) {
+		pthread_cond_t* newcond = box_calloc(1, sizeof(pthread_cond_t));
+		#ifdef DYNAREC
+		if(native_lock_storeifnull(&cond->cond, newcond))
+			box_free(newcond);
+		#else
+		static pthread_mutex_t mutex_cond = PTHREAD_MUTEX_INITIALIZER;
+		pthread_mutex_lock(&mutex_cond);
+		if(!cond->cond)
+			cond->cond = newcond;
+		else
+			box_free(newcond);
+		#endif
+	}
+	return cond->cond;
+}
+
+EXPORT int my_pthread_cond_broadcast_old(x64emu_t* emu, pthread_cond_old_t* cond)
+{
+    (void)emu;
+	pthread_cond_t * c = get_cond(cond);
+	return pthread_cond_broadcast(c);
+}
+EXPORT int my_pthread_cond_destroy_old(x64emu_t* emu, pthread_cond_old_t* cond)
+{
+    (void)emu;
+	pthread_cond_t * c = get_cond(cond);
+	int ret = pthread_cond_destroy(c);
+	box_free(cond->cond);
+	return ret;
+}
+EXPORT int my_pthread_cond_init_old(x64emu_t* emu, pthread_cond_old_t* cond, void* attr)
+{
+    (void)emu;
+	pthread_cond_t *c = get_cond(cond);
+	return pthread_cond_init(c, (const pthread_condattr_t*)attr);
+}
+EXPORT int my_pthread_cond_signal_old(x64emu_t* emu, pthread_cond_old_t* cond)
+{
+    (void)emu;
+	pthread_cond_t * c = get_cond(cond);
+	return pthread_cond_signal(c);
+}
+EXPORT int my_pthread_cond_timedwait_old(x64emu_t* emu, pthread_cond_old_t* cond, void* mutex, void* abstime)
+{
+    (void)emu;
+	pthread_cond_t * c = get_cond(cond);
+	return pthread_cond_timedwait(c, mutex, (const struct timespec*)abstime);
+	#undef T
+}
+EXPORT int my_pthread_cond_wait_old(x64emu_t* emu, pthread_cond_old_t* cond, void* mutex)
+{
+    (void)emu;
+	pthread_cond_t * c = get_cond(cond);
+	return pthread_cond_wait(c, mutex);
+}
+
 typedef union my_barrierattr_s {
 	int						x86;
 	pthread_barrierattr_t 	nat;