Skip to content

Commit

Permalink
trace: use gettid as thread_id on linux (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers authored Mar 4, 2022
1 parent 947245d commit 9265c8b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
* @file trace.c RE_TRACE helpers
* JSON traces (chrome://tracing)
*/
#define _DEFAULT_SOURCE 1
#define _GNU_SOURCE 1

#include <re_types.h>
#include <re_mem.h>
#include <re_trace.h>
Expand All @@ -17,7 +20,13 @@

#if defined(WIN32)
#include <windows.h>
#else
#endif

#ifdef LINUX
#include <sys/syscall.h>
#endif

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

Expand Down Expand Up @@ -65,6 +74,8 @@ static inline unsigned long get_thread_id(void)
{
#if defined(WIN32)
return (unsigned long)GetCurrentThreadId();
#elif defined(LINUX)
return (unsigned long)syscall(SYS_gettid);
#elif defined(HAVE_PTHREAD)
#if defined(DARWIN) || defined(FREEBSD) || defined(OPENBSD) || \
defined(NETBSD) || defined(DRAGONFLY)
Expand Down

0 comments on commit 9265c8b

Please sign in to comment.