From e556daebc30703f2558434dfcfe43cb044181b0c Mon Sep 17 00:00:00 2001 From: gabime Date: Sun, 21 Aug 2016 01:36:27 +0300 Subject: [PATCH] better support for thread id in FreeBSD --- include/spdlog/details/os.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index 388cb629..ccadaea3 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -38,8 +38,10 @@ #include #include -#else +#elif __FreeBSD__ +#include //Use thr_self() syscall under FreeBSD to get thread id +#else #include #endif @@ -263,10 +265,15 @@ inline size_t thread_id() # define SYS_gettid __NR_gettid # endif return static_cast(syscall(SYS_gettid)); -#else //Default to standard C++11 (OSX and other Unix) +#elif __FreeBSD__ + long tid; + thr_self(&tid); + return static_cast(tid); +#else //Default to standard C++11 (OSX and other Unix) return static_cast(std::hash()(std::this_thread::get_id())); #endif + }