[前][次][番号順一覧][スレッド一覧]

ruby-changes:71920

From: Nobuyoshi <ko1@a...>
Date: Mon, 23 May 2022 12:13:45 +0900 (JST)
Subject: [ruby-changes:71920] 9134e76140 (master): Support old Mac OS X

https://git.ruby-lang.org/ruby.git/commit/?id=9134e76140

From 9134e761407eed2cc10893d53291f81b8270dee3 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Mon, 23 May 2022 11:04:42 +0900
Subject: Support old Mac OS X

`pthread_threadid_np` is available since Mac OS X 10.6, use
`pthread_mach_thread_np` on older systems.
---
 thread_pthread.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/thread_pthread.c b/thread_pthread.c
index b52efe6db9..c825b731a6 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -40,6 +40,10 @@ https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L40
 #include <time.h>
 #include <signal.h>
 
+#if defined __APPLE__
+# include <AvailabilityMacros.h>
+#endif
+
 #if defined(HAVE_SYS_EVENTFD_H) && defined(HAVE_EVENTFD)
 #  define USE_EVENTFD (1)
 #  include <sys/eventfd.h>
@@ -1766,6 +1770,10 @@ native_thread_native_thread_id(rb_thread_t *target_th) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1770
     return INT2FIX(tid);
 #elif defined(__APPLE__)
     uint64_t tid;
+    if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 ||
+        !&pthread_threadid_np /* check weakly linked symbol */) {
+        return ULL2NUM(pthread_mach_thread_np(pthread_self()));
+    }
     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);
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]