Skip to content

Commit

Permalink
Add support for building on FreeBSD (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
zebrapurring authored May 9, 2024
1 parent c405d15 commit 9d8c956
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/viztracer/modules/snaptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
#include <time.h>
#if _WIN32
#include <windows.h>
#elif __APPLE
#elif defined(__APPLE__)
#include <pthread.h>
#elif defined(__FreeBSD__)
#include <pthread_np.h>
#else
#include <pthread.h>
#include <sys/syscall.h>
Expand Down Expand Up @@ -1503,13 +1505,15 @@ static struct ThreadInfo* snaptrace_createthreadinfo(TracerObject* self) {

#if _WIN32
info->tid = GetCurrentThreadId();
#elif __APPLE__
#elif defined(__APPLE__)
__uint64_t tid = 0;
if (pthread_threadid_np(NULL, &tid)) {
info->tid = (unsigned long)pthread_self();
} else {
info->tid = tid;
}
#elif defined(__FreeBSD__)
info->tid = pthread_getthreadid_np();
#else
info->tid = syscall(SYS_gettid);
#endif
Expand Down

0 comments on commit 9d8c956

Please sign in to comment.