From 66a2c4993bb9685d009a2e98e82cb7f84975fbe9 Mon Sep 17 00:00:00 2001 From: sheldonlyr Date: Sat, 24 Jun 2017 15:38:18 +0800 Subject: [PATCH] More meaningful thread id for OSX --- include/spdlog/details/os.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index 76aacf6d..735f6014 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -330,7 +330,11 @@ inline size_t _thread_id() long tid; thr_self(&tid); return static_cast(tid); -#else //Default to standard C++11 (OSX and other Unix) +#elif __APPLE__ + uint64_t tid; + pthread_threadid_np(nullptr, &tid); + return static_cast(tid); +#else //Default to standard C++11 (other Unix) return static_cast(std::hash()(std::this_thread::get_id())); #endif }