From 15e151867d44d42e43332f0f2408781c465b8cf6 Mon Sep 17 00:00:00 2001 From: Robin Caloudis Date: Sat, 7 Sep 2024 13:51:44 +0200 Subject: [PATCH] Encapsulate the use of macro and leave comment --- libcxx/include/__math/traits.h | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/libcxx/include/__math/traits.h b/libcxx/include/__math/traits.h index f3b1f03110ab71..a957df1785ac2d 100644 --- a/libcxx/include/__math/traits.h +++ b/libcxx/include/__math/traits.h @@ -34,30 +34,27 @@ namespace __math { # define _LIBCPP_SIGNBIT_CONSTEXPR #endif -_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI +// The universal C runtime (UCRT) in the WinSDK provides overloads for all floating point types +// for std::signbit(). We need to work around it as the compilation would otherwise error out +// due to duplicated definitions for clang-cl builds. #ifdef _LIBCPP_PREFERRED_OVERLOAD -_LIBCPP_PREFERRED_OVERLOAD +# define LIBCPP_SIGNBIT_OVERLOAD _LIBCPP_PREFERRED_OVERLOAD +#else +# define LIBCPP_SIGNBIT_OVERLOAD #endif - bool - signbit(float __x) _NOEXCEPT { + +_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI LIBCPP_SIGNBIT_OVERLOAD bool +signbit(float __x) _NOEXCEPT { return __builtin_signbit(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI -#ifdef _LIBCPP_PREFERRED_OVERLOAD -_LIBCPP_PREFERRED_OVERLOAD -#endif - bool - signbit(double __x) _NOEXCEPT { +_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI LIBCPP_SIGNBIT_OVERLOAD bool +signbit(double __x) _NOEXCEPT { return __builtin_signbit(__x); } -_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI -#ifdef _LIBCPP_PREFERRED_OVERLOAD -_LIBCPP_PREFERRED_OVERLOAD -#endif - bool - signbit(long double __x) _NOEXCEPT { +_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI LIBCPP_SIGNBIT_OVERLOAD bool +signbit(long double __x) _NOEXCEPT { return __builtin_signbit(__x); }