Files

37 lines
1.2 KiB
Diff
Raw Permalink Normal View History

2024-07-27 20:59:16 +08:00
From 8f14d575640cfa0f5662c6b6ab03ff6e0e129116 Mon Sep 17 00:00:00 2001
From: barracuda156 <vital.had@gmail.com>
Date: Tue, 4 Jun 2024 15:11:10 +0800
Subject: [PATCH] sys.cpp: fix macOS without breaking Linux
---
src/occa/internal/utils/sys.cpp | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git src/occa/internal/utils/sys.cpp src/occa/internal/utils/sys.cpp
index 1701ecb6..7c303fd7 100644
--- src/occa/internal/utils/sys.cpp
+++ src/occa/internal/utils/sys.cpp
@@ -402,11 +402,17 @@ namespace occa {
int getTID() {
#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_MACOS_OS))
-#if OCCA_OS == OCCA_MACOS_OS & (MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)
- uint64_t tid64;
- pthread_threadid_np(nullptr, &tid64);
- pid_t tid = (pid_t)tid64;
-#else
+#if (OCCA_OS == OCCA_MACOS_OS)
+ // pthread_threadid_np is hidden for ppc in Libc of 10.6.8
+ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 && !defined(__ppc__)
+ uint64_t tid64;
+ pthread_threadid_np(nullptr, &tid64);
+ pid_t tid = (pid_t)tid64;
+ #else
+ uint64_t tid;
+ tid = pthread_mach_thread_np(pthread_self());
+ #endif
+#else // Linux
pid_t tid = syscall(SYS_gettid);
#endif
return tid;