forked from OSchip/llvm-project
[libc++][math.h] move #undefs to the top and guard explicitly against MSVCRT instead
Reviewed By: ldionne, #libc Spies: #libc_vendors, EricWF, libcxx-commits Differential Revision: https://reviews.llvm.org/D137502
This commit is contained in:
parent
650da4a690
commit
ba1e13d524
|
@ -312,11 +312,56 @@ extern "C++" {
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
// signbit
|
|
||||||
|
# ifdef fpclassify
|
||||||
|
# undef fpclassify
|
||||||
|
# endif
|
||||||
|
|
||||||
# ifdef signbit
|
# ifdef signbit
|
||||||
# undef signbit
|
# undef signbit
|
||||||
# endif // signbit
|
# endif
|
||||||
|
|
||||||
|
# ifdef isfinite
|
||||||
|
# undef isfinite
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef isinf
|
||||||
|
# undef isinf
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef isnan
|
||||||
|
# undef isnan
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef isnormal
|
||||||
|
# undef isnormal
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef isgreater
|
||||||
|
# undef isgreater
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef isgreaterequal
|
||||||
|
# undef isgreaterequal
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef isless
|
||||||
|
# undef isless
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef islessequal
|
||||||
|
# undef islessequal
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef islessgreater
|
||||||
|
# undef islessgreater
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef isunordered
|
||||||
|
# undef isunordered
|
||||||
|
# endif
|
||||||
|
|
||||||
|
// signbit
|
||||||
|
|
||||||
template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
|
template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
|
||||||
inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
|
inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
|
||||||
|
@ -335,10 +380,6 @@ inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT {
|
||||||
|
|
||||||
// fpclassify
|
// fpclassify
|
||||||
|
|
||||||
# ifdef fpclassify
|
|
||||||
# undef fpclassify
|
|
||||||
# endif // fpclassify
|
|
||||||
|
|
||||||
template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
|
template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
|
||||||
inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
|
inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
|
||||||
return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
|
return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
|
||||||
|
@ -349,10 +390,10 @@ inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
|
||||||
return __x == 0 ? FP_ZERO : FP_NORMAL;
|
return __x == 0 ? FP_ZERO : FP_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// isfinite
|
// The MSVC runtime already provides these functions as templates
|
||||||
|
#ifndef _LIBCPP_MSVCRT
|
||||||
|
|
||||||
# ifdef isfinite
|
// isfinite
|
||||||
# undef isfinite
|
|
||||||
|
|
||||||
template <class _A1,
|
template <class _A1,
|
||||||
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
|
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
|
||||||
|
@ -366,13 +407,8 @@ inline _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif // isfinite
|
|
||||||
|
|
||||||
// isinf
|
// isinf
|
||||||
|
|
||||||
# ifdef isinf
|
|
||||||
# undef isinf
|
|
||||||
|
|
||||||
template <class _A1,
|
template <class _A1,
|
||||||
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
|
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
|
||||||
inline _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT {
|
inline _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT {
|
||||||
|
@ -394,13 +430,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _
|
||||||
inline _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { return __builtin_isinf(__x); }
|
inline _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { return __builtin_isinf(__x); }
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# endif // isinf
|
|
||||||
|
|
||||||
// isnan
|
// isnan
|
||||||
|
|
||||||
# ifdef isnan
|
|
||||||
# undef isnan
|
|
||||||
|
|
||||||
template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
|
template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
|
||||||
inline _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT {
|
inline _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT {
|
||||||
return __builtin_isnan(__x);
|
return __builtin_isnan(__x);
|
||||||
|
@ -419,13 +450,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _
|
||||||
inline _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { return __builtin_isnan(__x); }
|
inline _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { return __builtin_isnan(__x); }
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# endif // isnan
|
|
||||||
|
|
||||||
// isnormal
|
// isnormal
|
||||||
|
|
||||||
# ifdef isnormal
|
|
||||||
# undef isnormal
|
|
||||||
|
|
||||||
template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
|
template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
|
||||||
inline _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
|
inline _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
|
||||||
return __builtin_isnormal(__x);
|
return __builtin_isnormal(__x);
|
||||||
|
@ -436,13 +462,8 @@ inline _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
|
||||||
return __x != 0;
|
return __x != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif // isnormal
|
|
||||||
|
|
||||||
// isgreater
|
// isgreater
|
||||||
|
|
||||||
# ifdef isgreater
|
|
||||||
# undef isgreater
|
|
||||||
|
|
||||||
template <class _A1,
|
template <class _A1,
|
||||||
class _A2,
|
class _A2,
|
||||||
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
|
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
|
||||||
|
@ -451,13 +472,8 @@ inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
|
||||||
return __builtin_isgreater((type)__x, (type)__y);
|
return __builtin_isgreater((type)__x, (type)__y);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif // isgreater
|
|
||||||
|
|
||||||
// isgreaterequal
|
// isgreaterequal
|
||||||
|
|
||||||
# ifdef isgreaterequal
|
|
||||||
# undef isgreaterequal
|
|
||||||
|
|
||||||
template <class _A1,
|
template <class _A1,
|
||||||
class _A2,
|
class _A2,
|
||||||
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
|
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
|
||||||
|
@ -466,13 +482,8 @@ inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
|
||||||
return __builtin_isgreaterequal((type)__x, (type)__y);
|
return __builtin_isgreaterequal((type)__x, (type)__y);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif // isgreaterequal
|
|
||||||
|
|
||||||
// isless
|
// isless
|
||||||
|
|
||||||
# ifdef isless
|
|
||||||
# undef isless
|
|
||||||
|
|
||||||
template <class _A1,
|
template <class _A1,
|
||||||
class _A2,
|
class _A2,
|
||||||
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
|
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
|
||||||
|
@ -481,13 +492,8 @@ inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT {
|
||||||
return __builtin_isless((type)__x, (type)__y);
|
return __builtin_isless((type)__x, (type)__y);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif // isless
|
|
||||||
|
|
||||||
// islessequal
|
// islessequal
|
||||||
|
|
||||||
# ifdef islessequal
|
|
||||||
# undef islessequal
|
|
||||||
|
|
||||||
template <class _A1,
|
template <class _A1,
|
||||||
class _A2,
|
class _A2,
|
||||||
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
|
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
|
||||||
|
@ -496,13 +502,8 @@ inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
|
||||||
return __builtin_islessequal((type)__x, (type)__y);
|
return __builtin_islessequal((type)__x, (type)__y);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif // islessequal
|
|
||||||
|
|
||||||
// islessgreater
|
// islessgreater
|
||||||
|
|
||||||
# ifdef islessgreater
|
|
||||||
# undef islessgreater
|
|
||||||
|
|
||||||
template <class _A1,
|
template <class _A1,
|
||||||
class _A2,
|
class _A2,
|
||||||
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
|
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
|
||||||
|
@ -511,13 +512,8 @@ inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
|
||||||
return __builtin_islessgreater((type)__x, (type)__y);
|
return __builtin_islessgreater((type)__x, (type)__y);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif // islessgreater
|
|
||||||
|
|
||||||
// isunordered
|
// isunordered
|
||||||
|
|
||||||
# ifdef isunordered
|
|
||||||
# undef isunordered
|
|
||||||
|
|
||||||
template <class _A1,
|
template <class _A1,
|
||||||
class _A2,
|
class _A2,
|
||||||
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
|
std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
|
||||||
|
@ -526,7 +522,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
|
||||||
return __builtin_isunordered((type)__x, (type)__y);
|
return __builtin_isunordered((type)__x, (type)__y);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif // isunordered
|
#endif // _LIBCPP_MSVCRT
|
||||||
|
|
||||||
// abs
|
// abs
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue