--- include/spdlog/details/os-inl.h	2021-03-26 03:00:48.000000000 +0800
+++ include/spdlog/details/os-inl.h	2024-04-22 00:29:01.000000000 +0800
@@ -42,6 +42,10 @@
 #include <fcntl.h>
 #include <unistd.h>
 
+#if defined __APPLE__
+#include <AvailabilityMacros.h>
+#endif
+
 #ifdef __linux__
 #include <sys/syscall.h> //Use gettid() syscall under linux to get thread id
 
@@ -336,7 +340,17 @@
     return static_cast<size_t>(::thr_self());
 #elif __APPLE__
     uint64_t tid;
+#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
     return static_cast<size_t>(tid);
 #else // Default to standard C++11 (other Unix)
     return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id()));
