diff options
| -rw-r--r-- | src/libtools/threads.c | 75 | ||||
| -rw-r--r-- | src/wrapped/generated/functions_list.txt | 9 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedlibpthreadtypes.h | 9 | ||||
| -rw-r--r-- | src/wrapped/wrappedlibpthread_private.h | 9 |
4 files changed, 102 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; diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index e6566da1..f7a44172 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -4796,8 +4796,11 @@ wrappedlibpthread: - pthread_barrierattr_destroy - pthread_barrierattr_init - pthread_cond_broadcast + - pthread_cond_broadcast@GLIBC_2.2.5 - pthread_cond_destroy + - pthread_cond_destroy@GLIBC_2.2.5 - pthread_cond_signal + - pthread_cond_signal@GLIBC_2.2.5 - pthread_condattr_destroy - pthread_condattr_init - pthread_getattr_default_np @@ -4840,13 +4843,17 @@ wrappedlibpthread: - pthread_attr_getscope - pthread_attr_getstackaddr - pthread_attr_getstacksize + - pthread_attr_setaffinity_np@GLIBC_2.3.3 - pthread_attr_setschedparam - pthread_attr_setstackaddr - pthread_barrierattr_getpshared - pthread_cond_init + - pthread_cond_init@GLIBC_2.2.5 - pthread_cond_wait + - pthread_cond_wait@GLIBC_2.2.5 - pthread_condattr_getclock - pthread_condattr_getpshared + - pthread_getaffinity_np@GLIBC_2.3.3 - pthread_key_create - pthread_mutex_init - pthread_mutexattr_getkind_np @@ -4854,6 +4861,7 @@ wrappedlibpthread: - pthread_mutexattr_getrobust - pthread_mutexattr_gettype - pthread_once + - pthread_setaffinity_np@GLIBC_2.3.3 - vFppp: - _pthread_cleanup_push - _pthread_cleanup_push_defer @@ -4870,6 +4878,7 @@ wrappedlibpthread: - pthread_atfork - pthread_attr_getstack - pthread_cond_timedwait + - pthread_cond_timedwait@GLIBC_2.2.5 - iFppip: - pthread_cond_clockwait - iFpppp: diff --git a/src/wrapped/generated/wrappedlibpthreadtypes.h b/src/wrapped/generated/wrappedlibpthreadtypes.h index 5db511a6..2620f07e 100644 --- a/src/wrapped/generated/wrappedlibpthreadtypes.h +++ b/src/wrapped/generated/wrappedlibpthreadtypes.h @@ -39,8 +39,11 @@ typedef int32_t (*iFpppp_t)(void*, void*, void*, void*); GO(pthread_barrierattr_destroy, iFp_t) \ GO(pthread_barrierattr_init, iFp_t) \ GO(pthread_cond_broadcast, iFp_t) \ + GO(pthread_cond_broadcast@GLIBC_2.2.5, iFp_t) \ GO(pthread_cond_destroy, iFp_t) \ + GO(pthread_cond_destroy@GLIBC_2.2.5, iFp_t) \ GO(pthread_cond_signal, iFp_t) \ + GO(pthread_cond_signal@GLIBC_2.2.5, iFp_t) \ GO(pthread_condattr_destroy, iFp_t) \ GO(pthread_condattr_init, iFp_t) \ GO(pthread_getattr_default_np, iFp_t) \ @@ -78,13 +81,17 @@ typedef int32_t (*iFpppp_t)(void*, void*, void*, void*); GO(pthread_attr_getscope, iFpp_t) \ GO(pthread_attr_getstackaddr, iFpp_t) \ GO(pthread_attr_getstacksize, iFpp_t) \ + GO(pthread_attr_setaffinity_np@GLIBC_2.3.3, iFpp_t) \ GO(pthread_attr_setschedparam, iFpp_t) \ GO(pthread_attr_setstackaddr, iFpp_t) \ GO(pthread_barrierattr_getpshared, iFpp_t) \ GO(pthread_cond_init, iFpp_t) \ + GO(pthread_cond_init@GLIBC_2.2.5, iFpp_t) \ GO(pthread_cond_wait, iFpp_t) \ + GO(pthread_cond_wait@GLIBC_2.2.5, iFpp_t) \ GO(pthread_condattr_getclock, iFpp_t) \ GO(pthread_condattr_getpshared, iFpp_t) \ + GO(pthread_getaffinity_np@GLIBC_2.3.3, iFpp_t) \ GO(pthread_key_create, iFpp_t) \ GO(pthread_mutex_init, iFpp_t) \ GO(pthread_mutexattr_getkind_np, iFpp_t) \ @@ -92,6 +99,7 @@ typedef int32_t (*iFpppp_t)(void*, void*, void*, void*); GO(pthread_mutexattr_getrobust, iFpp_t) \ GO(pthread_mutexattr_gettype, iFpp_t) \ GO(pthread_once, iFpp_t) \ + GO(pthread_setaffinity_np@GLIBC_2.3.3, iFpp_t) \ GO(_pthread_cleanup_push, vFppp_t) \ GO(_pthread_cleanup_push_defer, vFppp_t) \ GO(pthread_attr_setaffinity_np, iFpLp_t) \ @@ -103,6 +111,7 @@ typedef int32_t (*iFpppp_t)(void*, void*, void*, void*); GO(pthread_atfork, iFppp_t) \ GO(pthread_attr_getstack, iFppp_t) \ GO(pthread_cond_timedwait, iFppp_t) \ + GO(pthread_cond_timedwait@GLIBC_2.2.5, iFppp_t) \ GO(pthread_cond_clockwait, iFppip_t) \ GO(pthread_create, iFpppp_t) diff --git a/src/wrapped/wrappedlibpthread_private.h b/src/wrapped/wrappedlibpthread_private.h index 7e6a27f7..cdb241c6 100644 --- a/src/wrapped/wrappedlibpthread_private.h +++ b/src/wrapped/wrappedlibpthread_private.h @@ -60,6 +60,7 @@ GOM(pthread_attr_setschedpolicy, iFEpi) GOM(pthread_attr_setscope, iFEpi) GOM(pthread_attr_setstackaddr, iFEpp) #endif +GO2(pthread_attr_setaffinity_np@GLIBC_2.3.3, iFEpp, my_pthread_attr_setaffinity_np_old) GOM(pthread_attr_setstack, iFEppL) GOM(pthread_attr_setstacksize, iFEpL) #ifdef NOALIGN @@ -110,11 +111,18 @@ GOM(pthread_cond_init, iFEpp) GOM(pthread_cond_signal, iFEp) GOM(pthread_cond_timedwait, iFEppp) GOM(pthread_cond_wait, iFEpp) +GO2(pthread_cond_broadcast@GLIBC_2.2.5, iFEp, my_pthread_cond_broadcast_old) +GO2(pthread_cond_destroy@GLIBC_2.2.5, iFEp, my_pthread_cond_destroy_old) +GO2(pthread_cond_init@GLIBC_2.2.5, iFEpp, my_pthread_cond_init_old) +GO2(pthread_cond_signal@GLIBC_2.2.5, iFEp, my_pthread_cond_signal_old) +GO2(pthread_cond_timedwait@GLIBC_2.2.5, iFEppp, my_pthread_cond_timedwait_old) +GO2(pthread_cond_wait@GLIBC_2.2.5, iFEpp, my_pthread_cond_wait_old) GOM(pthread_create, iFEpppp) GOM(pthread_cond_clockwait, iFEppip) GO(pthread_detach, iFL) GO(pthread_equal, iFLL) GO(pthread_exit, vFp) +GO2(pthread_getaffinity_np@GLIBC_2.3.3, iFEpp, my_pthread_getaffinity_np_old) GOM(pthread_getaffinity_np, iFEpLp) #ifdef NOALIGN GO(pthread_getattr_np, iFLp) @@ -232,6 +240,7 @@ GO(pthread_rwlock_unlock, iFp) GO(__pthread_rwlock_wrlock, iFp) GO(pthread_rwlock_wrlock, iFp) GO(pthread_self, LFv) +GO2(pthread_setaffinity_np@GLIBC_2.3.3, iFEpp, my_pthread_setaffinity_np_old) GOM(pthread_setaffinity_np, iFEpLp) GO(pthread_setcancelstate, iFip) GO(pthread_setcanceltype, iFip) |