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