Skip to content

Commit

Permalink
sys.cpp: fix macOS without breaking Linux (#758)
Browse files Browse the repository at this point in the history
  • Loading branch information
barracuda156 authored Jul 25, 2024
1 parent 3cba084 commit c0c601f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/occa/internal/utils/sys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c0c601f

Please sign in to comment.