From c0c601f80eff8f4eb7cc453a6a9db5bdd6554495 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Fri, 26 Jul 2024 00:23:32 +0800 Subject: [PATCH] sys.cpp: fix macOS without breaking Linux (#758) --- src/occa/internal/utils/sys.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/occa/internal/utils/sys.cpp b/src/occa/internal/utils/sys.cpp index 1701ecb69..7c303fd70 100644 --- a/src/occa/internal/utils/sys.cpp +++ b/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;