diff options
author | Nobuyoshi Nakada <[email protected]> | 2022-05-24 20:26:18 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2022-05-27 15:08:30 +0900 |
commit | 45177129a75c5bfd03933b82076e8dc49acc500f () | |
tree | d7add11b8be0302a6caa06c0dd802ddbbbe29be9 | |
parent | 7d9da4c33db6addc4e0f8141adc718391bb10db4 (diff) |
Support old Mac OS X SDK and gcc
Follow up of https://.com/ruby/ruby/pull/5927 `pthread_threadid_np()` is not even be declared in outdated SDKs. Also, the `__API_AVAILABLE` macro does not work on gcc, which does not support the [availability] attribute of clang, so an additional weak symbol declaration is required to check for weakly linked symbols. [availability]: https://clang.llvm.org/docs/AttributeReference.html#availability
-rw-r--r-- | thread_pthread.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -1761,13 +1761,28 @@ native_thread_native_thread_id(rb_thread_t *target_th) 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); #endif } # define USE_NATIVE_THREAD_NATIVE_THREAD_ID 1 |