From 53b230801149a35613f33fc4247080bffaf5a289 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Fri, 20 Sep 2019 12:47:59 +0000 Subject: [PATCH 1/2] Implement _thread_id() on more Unices --- include/spdlog/details/os-inl.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/include/spdlog/details/os-inl.h b/include/spdlog/details/os-inl.h index b4f43956..57f72bd5 100644 --- a/include/spdlog/details/os-inl.h +++ b/include/spdlog/details/os-inl.h @@ -50,8 +50,17 @@ #ifdef __linux__ #include //Use gettid() syscall under linux to get thread id -#elif defined(__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(__sun) +#include // for thr_self #endif #endif // unix @@ -316,10 +325,14 @@ SPDLOG_INLINE size_t _thread_id() SPDLOG_NOEXCEPT #define SYS_gettid __NR_gettid #endif return static_cast(syscall(SYS_gettid)); -#elif defined(__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()); #elif __APPLE__ uint64_t tid; pthread_threadid_np(nullptr, &tid); From 8d57823e519c05b5cf11672115659c042d83f7c3 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Fri, 20 Sep 2019 12:53:54 +0000 Subject: [PATCH 2/2] fstat64 is missing on other DragonFly, NetBSD, OpenBSD Modern operating systems don't need to implement transitional extensions for large file support. --- include/spdlog/details/os-inl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/spdlog/details/os-inl.h b/include/spdlog/details/os-inl.h index 57f72bd5..8252921e 100644 --- a/include/spdlog/details/os-inl.h +++ b/include/spdlog/details/os-inl.h @@ -230,7 +230,7 @@ SPDLOG_INLINE size_t filesize(FILE *f) #else // unix int fd = fileno(f); // 64 bits(but not in osx or cygwin, where fstat64 is deprecated) -#if !defined(__FreeBSD__) && !defined(__APPLE__) && (defined(__x86_64__) || defined(__ppc64__)) && !defined(__CYGWIN__) +#if (defined(__linux__) || defined(__sun) || defined(_AIX)) && (defined(__LP64__) || defined(_LP64)) struct stat64 st; if (::fstat64(fd, &st) == 0) {