From 4292d3d9af47483cdefa74151fa5e3861d823d60 Mon Sep 17 00:00:00 2001 From: gabime Date: Tue, 7 Apr 2015 21:02:34 +0300 Subject: [PATCH] Use gettid() syscall under linux to get thread id --- include/spdlog/details/os.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index 454bd8f5..42c62d91 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -32,8 +32,11 @@ # define WIN32_LEAN_AND_MEAN # endif # include +#elif __linux__ +#include //Use gettid() syscall under linux to get thread id +#include #else -#include +#include #endif #include "../common.h" @@ -168,13 +171,15 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime()) #endif } - +//Return current thread id as 64 bit integer inline uint64_t thread_id() { #ifdef _WIN32 return ::GetCurrentThreadId(); -#else +#elif __linux__ + return (uint64_t) syscall(SYS_gettid); +#else return (uint64_t) pthread_self(); #endif