From 479a5ac3f17ea53abff60fedd70503d98bdbc04d Mon Sep 17 00:00:00 2001 From: Peter Nemeth Date: Wed, 11 Oct 2023 09:34:42 +0200 Subject: [PATCH 1/3] Fix OS availability check of pthread_threadid_np for iOS (#2897) --- include/spdlog/details/os-inl.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/include/spdlog/details/os-inl.h b/include/spdlog/details/os-inl.h index a154d41a..d15b22e4 100644 --- a/include/spdlog/details/os-inl.h +++ b/include/spdlog/details/os-inl.h @@ -332,15 +332,21 @@ SPDLOG_INLINE size_t _thread_id() SPDLOG_NOEXCEPT { return static_cast(::thr_self()); #elif __APPLE__ uint64_t tid; - // There is no pthread_threadid_np prior to 10.6, and it is not supported on any PPC, + // There is no pthread_threadid_np prior to Mac OS X 10.6, and it is not supported on any PPC, // including 10.6.8 Rosetta. __POWERPC__ is Apple-specific define encompassing ppc and ppc64. - #if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) || defined(__POWERPC__) - tid = pthread_mach_thread_np(pthread_self()); - #elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060 - if (&pthread_threadid_np) { - pthread_threadid_np(nullptr, &tid); - } else { + #ifdef MAC_OS_X_VERSION_MAX_ALLOWED + { + #if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) || defined(__POWERPC__) tid = pthread_mach_thread_np(pthread_self()); + #elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + if (&pthread_threadid_np) { + pthread_threadid_np(nullptr, &tid); + } else { + tid = pthread_mach_thread_np(pthread_self()); + } + #else + pthread_threadid_np(nullptr, &tid); + #endif } #else pthread_threadid_np(nullptr, &tid); From 508d20f0facf33b104f42849c29149041d2324c6 Mon Sep 17 00:00:00 2001 From: Peter Nemeth Date: Wed, 11 Oct 2023 17:21:29 +0200 Subject: [PATCH 2/3] Add .git-blame-ignore-revs to ignore clang-format related commits (#2899) --- .git-blame-ignore-revs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..47b8fed1 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,6 @@ +# clang-format +1a0bfc7a89f2d58e22605a4dc7e18a9a555b65aa +95c226e9c92928e20ccdac0d060e7241859e282b +9d52261185b5f2c454c381d626ec5c84d7b195f4 +4b2a8219d5d1b40062d030441adde7d1fb0d4f84 +0a53eafe18d983c7c8ba4cadd02d0cc7f7308f28 From 0c4fb032e44279e3b4bfe037d84dd8991b8e5c06 Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Fri, 13 Oct 2023 03:00:00 -0400 Subject: [PATCH 3/3] Match SPDLOG_CONSTEXPR_FUNC to FMT_CONSTEXPR (#2901) * Modify the condition of SPDLOG_CONSTEXPR_FUNC to match that of fmt --- include/spdlog/common.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/include/spdlog/common.h b/include/spdlog/common.h index c46c1531..1269c14a 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -65,14 +65,23 @@ #if defined(_MSC_VER) && (_MSC_VER < 1900) #define SPDLOG_NOEXCEPT _NOEXCEPT #define SPDLOG_CONSTEXPR - #define SPDLOG_CONSTEXPR_FUNC inline #else #define SPDLOG_NOEXCEPT noexcept #define SPDLOG_CONSTEXPR constexpr - #if __cplusplus >= 201402L - #define SPDLOG_CONSTEXPR_FUNC constexpr +#endif + +// If building with std::format, can just use constexpr, otherwise if building with fmt +// SPDLOG_CONSTEXPR_FUNC needs to be set the same as FMT_CONSTEXPR to avoid situations where +// a constexpr function in spdlog could end up calling a non-constexpr function in fmt +// depending on the compiler +// If fmt determines it can't use constexpr, we should inline the function instead +#ifdef SPDLOG_USE_STD_FORMAT + #define SPDLOG_CONSTEXPR_FUNC constexpr +#else // Being built with fmt + #if FMT_USE_CONSTEXPR + #define SPDLOG_CONSTEXPR_FUNC FMT_CONSTEXPR #else - #define SPDLOG_CONSTEXPR_FUNC inline + #define SPDLOG_CONSTEXPR_FUNC inline #endif #endif