From 959244b3cdd59bbb7f3d9e4be5c49ecf8e1f69d5 Mon Sep 17 00:00:00 2001 From: Peter Nemeth Date: Wed, 11 Oct 2023 09:34:42 +0200 Subject: [PATCH] Fix OS availability check of pthread_threadid_np for iOS (#2897) --- src/details/os.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/details/os.cpp b/src/details/os.cpp index 98dd59b2..20d19f47 100644 --- a/src/details/os.cpp +++ b/src/details/os.cpp @@ -330,15 +330,21 @@ size_t _thread_id() noexcept { return static_cast(::thr_self()); #elif __APPLE__ uint64_t tid; - // There is no pthread_threadid_np prior to 10.6, and it is not supported on any PPC, + // There is no pthread_threadid_np prior to Mac OS X 10.6, and it is not supported on any PPC, // including 10.6.8 Rosetta. __POWERPC__ is Apple-specific define encompassing ppc and ppc64. - #if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) || defined(__POWERPC__) - tid = pthread_mach_thread_np(pthread_self()); - #elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060 - if (&pthread_threadid_np) { - pthread_threadid_np(nullptr, &tid); - } else { + #ifdef MAC_OS_X_VERSION_MAX_ALLOWED + { + #if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) || defined(__POWERPC__) tid = pthread_mach_thread_np(pthread_self()); + #elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + if (&pthread_threadid_np) { + pthread_threadid_np(nullptr, &tid); + } else { + tid = pthread_mach_thread_np(pthread_self()); + } + #else + pthread_threadid_np(nullptr, &tid); + #endif } #else pthread_threadid_np(nullptr, &tid);