mirror of
https://github.com/gabime/spdlog.git
synced 2025-05-01 12:43:51 +00:00
Fix OS availability check of pthread_threadid_np for iOS (#2897)
This commit is contained in:
parent
82a672a4d3
commit
959244b3cd
@ -330,8 +330,10 @@ size_t _thread_id() noexcept {
|
|||||||
return static_cast<size_t>(::thr_self());
|
return static_cast<size_t>(::thr_self());
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
uint64_t tid;
|
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.
|
// including 10.6.8 Rosetta. __POWERPC__ is Apple-specific define encompassing ppc and ppc64.
|
||||||
|
#ifdef MAC_OS_X_VERSION_MAX_ALLOWED
|
||||||
|
{
|
||||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) || defined(__POWERPC__)
|
#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) || defined(__POWERPC__)
|
||||||
tid = pthread_mach_thread_np(pthread_self());
|
tid = pthread_mach_thread_np(pthread_self());
|
||||||
#elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
#elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||||
@ -343,6 +345,10 @@ size_t _thread_id() noexcept {
|
|||||||
#else
|
#else
|
||||||
pthread_threadid_np(nullptr, &tid);
|
pthread_threadid_np(nullptr, &tid);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
pthread_threadid_np(nullptr, &tid);
|
||||||
|
#endif
|
||||||
return static_cast<size_t>(tid);
|
return static_cast<size_t>(tid);
|
||||||
#else // Default to standard C++11 (other Unix)
|
#else // Default to standard C++11 (other Unix)
|
||||||
return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id()));
|
return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user