From ab150305017a6d9aeaf04d8f17763f88e7147b03 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Wed, 1 Jan 2020 10:51:17 +0000 Subject: [PATCH] spdlog: backport support for more Unices https://github.com/gabime/spdlog/commit/53b230801149a35613f33fc4247080bffaf5a289 https://github.com/gabime/spdlog/commit/8d57823e519c05b5cf11672115659c042d83f7c3 --- .../GmmLib/Utility/GmmLog/spdlog/details/os.h | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Source/GmmLib/Utility/GmmLog/spdlog/details/os.h b/Source/GmmLib/Utility/GmmLog/spdlog/details/os.h index 3f9d386..35223ff 100644 --- a/Source/GmmLib/Utility/GmmLog/spdlog/details/os.h +++ b/Source/GmmLib/Utility/GmmLog/spdlog/details/os.h @@ -39,8 +39,20 @@ #include #include -#elif __FreeBSD__ -#include //Use thr_self() syscall under FreeBSD to get thread id +#elif defined(_AIX) +#include // for pthread_getthreadid_np + +#elif defined(__DragonFly__) || defined(__FreeBSD__) +#include // for pthread_getthreadid_np + +#elif defined(__NetBSD__) +#include // for _lwp_self + +#elif defined(__OpenBSD__) +#include // for getthrid + +#elif defined(__sun) +#include // for thr_self #else #include @@ -213,7 +225,7 @@ inline size_t filesize(FILE *f) #else // unix int fd = fileno(f); //64 bits(but not in osx, where fstat64 is deprecated) -#if !defined(__FreeBSD__) && !defined(__APPLE__) && (defined(__x86_64__) || defined(__ppc64__)) +#if (defined(__linux__) || defined(__sun) || defined(_AIX)) && (defined(__LP64__) || defined(_LP64)) struct stat64 st; if (fstat64(fd, &st) == 0) return static_cast(st.st_size); @@ -302,10 +314,14 @@ inline size_t thread_id() # define SYS_gettid __NR_gettid # endif return static_cast(syscall(SYS_gettid)); -#elif __FreeBSD__ - long tid; - thr_self(&tid); - return static_cast(tid); +#elif defined(_AIX) || defined(__DragonFly__) || defined(__FreeBSD__) + return static_cast(pthread_getthreadid_np()); +#elif defined(__NetBSD__) + return static_cast(_lwp_self()); +#elif defined(__OpenBSD__) + return static_cast(getthrid()); +#elif defined(__sun) + return static_cast(thr_self()); #else //Default to standard C++11 (OSX and other Unix) return static_cast(std::hash()(std::this_thread::get_id())); #endif