Skip to content

Commit 9c24e8d

Browse files
committed
Encapsulate the use of macro and leave comment
1 parent 528be9e commit 9c24e8d

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

libcxx/include/__math/traits.h

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,27 @@ namespace __math {
3434
# define _LIBCPP_SIGNBIT_CONSTEXPR
3535
#endif
3636

37-
_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI
38-
#ifdef _LIBCPP_PREFERRED_OVERLOAD
39-
_LIBCPP_PREFERRED_OVERLOAD
37+
// The universal C runtime (UCRT) in the WinSDK provides overloads for all floating point types
38+
// for std::signbit(). We need to work around it as the compilation would otherwise error out
39+
// due to duplicated definitions for clang-cl builds.
40+
#if defined(_LIBCPP_MSVCRT) && defined(_LIBCPP_PREFERRED_OVERLOAD)
41+
# define LIBCPP_SIGNBIT_OVERLOAD _LIBCPP_PREFERRED_OVERLOAD
42+
#else
43+
# define LIBCPP_SIGNBIT_OVERLOAD
4044
#endif
41-
bool
42-
signbit(float __x) _NOEXCEPT {
45+
46+
_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI LIBCPP_SIGNBIT_OVERLOAD bool
47+
signbit(float __x) _NOEXCEPT {
4348
return __builtin_signbit(__x);
4449
}
4550

46-
_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI
47-
#ifdef _LIBCPP_PREFERRED_OVERLOAD
48-
_LIBCPP_PREFERRED_OVERLOAD
49-
#endif
50-
bool
51-
signbit(double __x) _NOEXCEPT {
51+
_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI LIBCPP_SIGNBIT_OVERLOAD bool
52+
signbit(double __x) _NOEXCEPT {
5253
return __builtin_signbit(__x);
5354
}
5455

55-
_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI
56-
#ifdef _LIBCPP_PREFERRED_OVERLOAD
57-
_LIBCPP_PREFERRED_OVERLOAD
58-
#endif
59-
bool
60-
signbit(long double __x) _NOEXCEPT {
56+
_LIBCPP_NODISCARD inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI LIBCPP_SIGNBIT_OVERLOAD bool
57+
signbit(long double __x) _NOEXCEPT {
6158
return __builtin_signbit(__x);
6259
}
6360

0 commit comments

Comments
 (0)