Skip to content

Commit

Permalink
#365: Pthread get thread fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bedwardly-down committed Sep 3, 2024
1 parent c3d07b3 commit 324e413
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/co/co.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include <time.h> // for clock_gettime
#else
#include <sys/time.h> // for gettimeofday
#ifndef __APPLE__
#include <pthread_np.h> // for getting proper threadid on modern BSDs but not Mac OSX
#endif
#endif
#endif

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 324e413

Please sign in to comment.