Skip to content

Commit

Permalink
Merge pull request #72 from smortex/add-freebsd-support
Browse files Browse the repository at this point in the history
Add support for FreeBSD
  • Loading branch information
jhawthorn committed May 10, 2024
2 parents 4669dcc + 0e38da9 commit a8200bb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ext/vernier/vernier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@

#include <sys/time.h>
#include <signal.h>
#ifdef __APPLE__
#if defined(__APPLE__)
/* macOS */
#include <dispatch/dispatch.h>
#elif defined(__FreeBSD__)
/* FreeBSD */
#include <pthread_np.h>
#include <semaphore.h>
#else
/* Linux */
#include <semaphore.h>
Expand Down Expand Up @@ -786,11 +790,13 @@ class SampleTranslator {

typedef uint64_t native_thread_id_t;
static native_thread_id_t get_native_thread_id() {
#ifdef __APPLE__
#if defined(__APPLE__)
uint64_t thread_id;
int e = pthread_threadid_np(pthread_self(), &thread_id);
if (e != 0) rb_syserr_fail(e, "pthread_threadid_np");
return thread_id;
#elif defined(__FreeBSD__)
return pthread_getthreadid_np();
#else
// gettid() is only available as of glibc 2.30
pid_t tid = syscall(SYS_gettid);
Expand Down

0 comments on commit a8200bb

Please sign in to comment.