Commit 4292d3d9 authored by gabime's avatar gabime

Use gettid() syscall under linux to get thread id

parent a0910792
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
# define WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN
# endif # endif
# include <Windows.h> # include <Windows.h>
#elif __linux__
#include <sys/syscall.h> //Use gettid() syscall under linux to get thread id
#include <unistd.h>
#else #else
#include <pthread.h> #include <pthread.h>
#endif #endif
...@@ -168,12 +171,14 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime()) ...@@ -168,12 +171,14 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime())
#endif #endif
} }
//Return current thread id as 64 bit integer
inline uint64_t thread_id() inline uint64_t thread_id()
{ {
#ifdef _WIN32 #ifdef _WIN32
return ::GetCurrentThreadId(); return ::GetCurrentThreadId();
#elif __linux__
return (uint64_t) syscall(SYS_gettid);
#else #else
return (uint64_t) pthread_self(); return (uint64_t) pthread_self();
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment