From 324e413380d4fbd562e57bfe7af93c574a713f76 Mon Sep 17 00:00:00 2001 From: Brad D Date: Tue, 3 Sep 2024 00:53:26 -0500 Subject: [PATCH] #365: Pthread get thread fix --- src/co/co.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/co/co.cc b/src/co/co.cc index ebbec011c..08aad350a 100644 --- a/src/co/co.cc +++ b/src/co/co.cc @@ -8,6 +8,9 @@ #include // for clock_gettime #else #include // for gettimeofday +#ifndef __APPLE__ +#include // for getting proper threadid on modern BSDs but not Mac OSX +#endif #endif #endif @@ -100,7 +103,11 @@ uint32 thread_id() { return syscall(SYS_gettid); } #else /* for mac, bsd.. */ uint32 thread_id() { uint64 x; +#ifdef __APPLE__ pthread_threadid_np(0, &x); +#else + x = pthread_getthreadid_np(); +#endif return (uint32)x; } #endif