Skip to content

Commit

Permalink
Merge pull request #371 from bedwardly-down/master
Browse files Browse the repository at this point in the history
#365: FreeBSD Pthread get thread fix
  • Loading branch information
idealvin authored Sep 3, 2024
2 parents c3d07b3 + 324e413 commit c52438b
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 c52438b

Please sign in to comment.