summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authorSergey Fedorov <vital.had@gmail.com>2022-05-22 11:02:03 +0800
committerGitHub <noreply@github.com>2022-05-22 15:02:03 +1200
commit539459abda3f4e086ca060620dee2586ebfed873 (patch)
treeb9a4f71f8a74bafb1b7afa81245688b553f255e4 /thread_pthread.c
parent84257244cd67e40daed274c01ff0a6929e1a2b67 (diff)
downloadruby-539459abda3f4e086ca060620dee2586ebfed873.tar.gz
Ruby31: add support for Darwin ppc/ppc64 (#5927)
* add coroutines for ppc & ppc64 * fix universal coroutine to include ppc & ppc64 * add powerpc*-darwin to configure.ac * fix thread_pthread for older systems
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index b52efe6db9..83237e1fe4 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -1765,10 +1765,23 @@ native_thread_native_thread_id(rb_thread_t *target_th)
if (tid == 0) return Qnil;
return INT2FIX(tid);
#elif defined(__APPLE__)
- uint64_t tid;
- int e = pthread_threadid_np(target_th->nt->thread_id, &tid);
- if (e != 0) rb_syserr_fail(e, "pthread_threadid_np");
- return ULL2NUM((unsigned long long)tid);
+ #if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
+ uint64_t tid;
+ tid = pthread_mach_thread_np(pthread_self());
+ #elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+ uint64_t tid;
+ if (&pthread_threadid_np) {
+ int error = pthread_threadid_np(target_th->thread_id, &tid);
+ if (error != 0) rb_syserr_fail(error, "pthread_threadid_np");
+ } else {
+ uint64_t tid;
+ tid = pthread_mach_thread_np(pthread_self());
+ }
+ #else
+ int error = pthread_threadid_np(target_th->thread_id, &tid);
+ if (error != 0) rb_syserr_fail(error, "pthread_threadid_np");
+ return ULL2NUM((unsigned long long)tid);
+ #endif
#endif
}
# define USE_NATIVE_THREAD_NATIVE_THREAD_ID 1