diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -226,6 +226,24 @@ __chrono/year_month.h __chrono/year_month_day.h __chrono/year_month_weekday.h + __cmath/angular_functions.h + __cmath/arithmetic.h + __cmath/compare.h + __cmath/copysign.h + __cmath/fabs.h + __cmath/fdim.h + __cmath/fminmax.h + __cmath/frexp.h + __cmath/logarithm.h + __cmath/modf.h + __cmath/nextafter.h + __cmath/nexttoward.h + __cmath/remainder.h + __cmath/remquo.h + __cmath/rounding.h + __cmath/signbit.h + __cmath/tgamma.h + __cmath/traits.h __compare/common_comparison_category.h __compare/compare_partial_order_fallback.h __compare/compare_strong_order_fallback.h diff --git a/libcxx/include/__cmath/angular_functions.h b/libcxx/include/__cmath/angular_functions.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/angular_functions.h @@ -0,0 +1,223 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_ANGULAR_FUNCTIONS_H +#define _LIBCPP___CMATH_ANGULAR_FUNCTIONS_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_HIDE_FROM_ABI float acos(float __v) _NOEXCEPT { return __builtin_acosf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double acos(double __v) _NOEXCEPT { + return __builtin_acos(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __v) _NOEXCEPT { return __builtin_acosl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double acos(_Tp __v) _NOEXCEPT { + return __builtin_acos(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float asin(float __v) _NOEXCEPT { return __builtin_asinf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double asin(double __v) _NOEXCEPT { + return __builtin_asin(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __v) _NOEXCEPT { return __builtin_asinl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double asin(_Tp __v) _NOEXCEPT { + return __builtin_asin(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float atan(float __v) _NOEXCEPT { return __builtin_atanf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double atan(double __v) _NOEXCEPT { + return __builtin_atan(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __v) _NOEXCEPT { return __builtin_atanl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double atan(_Tp __v) { + return __builtin_atan(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) { return __builtin_atan2f(__y, __x); } + +template +_LIBCPP_HIDE_FROM_ABI double atan2(double __y, double __x) { + return __builtin_atan2(__y, __x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) { return __builtin_atan2l(__y, __x); } + +template ::value && is_arithmetic<_Tp>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI typename __promote<_Tp, _Up>::type atan2(_Tp __y, _Up __x) { + using __result_type = typename __promote<_Tp, _Up>::type; + return std::atan2(static_cast<__result_type>(__y), static_cast<__result_type>(__x)); +} + +inline _LIBCPP_HIDE_FROM_ABI float cos(float __v) _NOEXCEPT { return __builtin_cosf(__v); } + +template +inline _LIBCPP_HIDE_FROM_ABI double cos(double __v) _NOEXCEPT { + return __builtin_cos(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __v) _NOEXCEPT { return __builtin_cosl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double cos(_Tp __v) _NOEXCEPT { + return __builtin_cos(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float cosh(float __v) _NOEXCEPT { return __builtin_coshf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double cosh(double __v) _NOEXCEPT { + return __builtin_cosh(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __v) { return __builtin_coshl(__v); } + +template ::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double cosh(_Tp __v) _NOEXCEPT { + return __builtin_cosh(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float sin(float __v) _NOEXCEPT { return __builtin_sinf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double sin(double __v) _NOEXCEPT { + return __builtin_sin(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __v) _NOEXCEPT { return __builtin_sinl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double sin(_Tp __v) _NOEXCEPT { + return __builtin_sin(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float sinh(float __v) _NOEXCEPT { return __builtin_sinhf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double sinh(double __v) _NOEXCEPT { + return __builtin_sinh(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __v) _NOEXCEPT { return __builtin_sinhl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double sinh(_Tp __v) _NOEXCEPT { + return __builtin_sinh(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI float tan(float __v) _NOEXCEPT { return __builtin_tanf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double tan(double __v) _NOEXCEPT { + return __builtin_tan(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __v) _NOEXCEPT { return __builtin_tanl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double tan(_Tp __v) _NOEXCEPT { + return __builtin_tan(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI float tanh(float __v) _NOEXCEPT { return __builtin_tanhf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double tanh(double __v) _NOEXCEPT { + return __builtin_tanh(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __v) _NOEXCEPT { return __builtin_tanhl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double tanh(_Tp __v) _NOEXCEPT { + return __builtin_tanh(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI float acosh(float __v) _NOEXCEPT { return __builtin_acoshf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double acosh(double __v) _NOEXCEPT { + return __builtin_acosh(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __v) _NOEXCEPT { return __builtin_acoshl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double acosh(_Tp __v) _NOEXCEPT { + return __builtin_acosh(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI float asinh(float __v) _NOEXCEPT { return __builtin_asinhf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double asinh(double __v) _NOEXCEPT { + return __builtin_asinh(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __v) _NOEXCEPT { return __builtin_asinhl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double asinh(_Tp __v) _NOEXCEPT { + return __builtin_asinh(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI float atanh(float __v) _NOEXCEPT { return __builtin_atanhf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double atanh(double __v) _NOEXCEPT { + return __builtin_atanh(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __v) _NOEXCEPT { return __builtin_atanhl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double atanh(_Tp __v) _NOEXCEPT { + return __builtin_atanh(__v); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::acos; +using std::asin; +using std::atan; +using std::atan2; +using std::cos; +using std::cosh; +using std::sin; +using std::sinh; +using std::tan; +using std::tanh; +using std::acosh; +using std::asinh; +using std::atanh; + +#endif // _LIBCPP___CMATH_ANGULAR_FUNCTIONS_H diff --git a/libcxx/include/__cmath/arithmetic.h b/libcxx/include/__cmath/arithmetic.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/arithmetic.h @@ -0,0 +1,260 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_ARITHMETIC_H +#define _LIBCPP___CMATH_ARITHMETIC_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_HIDE_FROM_ABI float exp(float __v) _NOEXCEPT { return __builtin_expf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double exp(double __v) _NOEXCEPT { + return __builtin_exp(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __v) _NOEXCEPT { return __builtin_expl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double exp(_Tp __v) _NOEXCEPT { + return __builtin_exp(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT { return __builtin_fmodf(__x, __y); } + +template +_LIBCPP_HIDE_FROM_ABI double fmod(double __x, double __y) _NOEXCEPT { + return __builtin_fmod(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) _NOEXCEPT { + return __builtin_fmodl(__x, __y); +} + +template ::value && is_arithmetic<_Up>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI typename __promote<_Tp, _Up>::type fmod(_Tp __x, _Up __y) _NOEXCEPT { + using __result_type = typename __promote<_Tp, _Up>::type; + return std::fmod(static_cast<__result_type>(__x), static_cast<__result_type>(__y)); +} + +inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __exp) _NOEXCEPT { return __builtin_ldexpf(__x, __exp); } + +template +_LIBCPP_HIDE_FROM_ABI double ldexp(double __x, int __exp) _NOEXCEPT { + return __builtin_ldexp(__x, __exp); +} + +inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __exp) _NOEXCEPT { + return __builtin_ldexpl(__x, __exp); +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double ldexp(_Tp __x, int __exp) { + return __builtin_ldexp(static_cast(__x), __exp); +} + +inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT { return __builtin_powf(__x, __y); } + +template +_LIBCPP_HIDE_FROM_ABI double pow(double __x, double __y) _NOEXCEPT { + return __builtin_pow(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _NOEXCEPT { + return __builtin_powl(__x, __y); +} + +template ::value && is_arithmetic<_Up>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI typename __promote<_Tp, _Up>::type pow(_Tp __x, _Up __y) _NOEXCEPT { + using __result_type = typename __promote<_Tp, _Up>::type; + return std::pow(static_cast<__result_type>(__x), static_cast<__result_type>(__y)); +} + +inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT { return __builtin_sqrtf(__x); } + +template +_LIBCPP_HIDE_FROM_ABI double sqrt(double __x) _NOEXCEPT { + return __builtin_sqrt(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT { return __builtin_sqrtl(__x); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double sqrt(_Tp __v) _NOEXCEPT { + return __builtin_sqrt(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT { return __builtin_cbrtf(__x); } + +template +_LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT { + return __builtin_cbrt(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT { return __builtin_cbrtl(__x); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double cbrt(_Tp __v) _NOEXCEPT { + return __builtin_cbrt(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float exp2(float __v) _NOEXCEPT { return __builtin_exp2f(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double exp2(double __v) _NOEXCEPT { + return __builtin_exp2(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __v) _NOEXCEPT { return __builtin_exp2l(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double exp2(_Tp __v) _NOEXCEPT { + return __builtin_exp2(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float expm1(float __v) _NOEXCEPT { return __builtin_expm1f(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double expm1(double __v) _NOEXCEPT { + return __builtin_expm1(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __v) _NOEXCEPT { return __builtin_expm1l(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double expm1(_Tp __v) _NOEXCEPT { + return __builtin_expm1(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float erf(float __v) _NOEXCEPT { return __builtin_erff(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double erf(double __v) _NOEXCEPT { + return __builtin_erf(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __v) _NOEXCEPT { return __builtin_erfl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double erf(_Tp __v) _NOEXCEPT { + return __builtin_erf(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float erfc(float __v) _NOEXCEPT { return __builtin_erfcf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double erfc(double __v) _NOEXCEPT { + return __builtin_erfc(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __v) _NOEXCEPT { return __builtin_erfcl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double erfc(_Tp __v) { + return __builtin_erfc(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT { + return __builtin_fmaf(__x, __y, __z); +} + +template +_LIBCPP_HIDE_FROM_ABI double fma(double __x, double __y, double __z) _NOEXCEPT { + return __builtin_fma(__x, __y, __z); +} + +inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT { + return __builtin_fmal(__x, __y, __z); +} + +template ::value && is_arithmetic<_T2>::value && is_arithmetic<_T3>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI typename __promote<_T1, _T2, _T3>::type fma(_T1 __x, _T2 __y, _T3 __z) _NOEXCEPT { + using __result_type = typename __promote<_T1, _T2, _T3>::type; + return std::fma(static_cast<__result_type>(__x), static_cast<__result_type>(__y), static_cast<__result_type>(__z)); +} + +inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT { return __builtin_hypotf(__x, __y); } + +template +_LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y) _NOEXCEPT { + return __builtin_hypot(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) _NOEXCEPT { + return __builtin_hypotl(__x, __y); +} + +template ::value && is_arithmetic<_Up>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI typename __promote<_Tp, _Up>::type hypot(_Tp __x, _Up __y) _NOEXCEPT { + using __result_type = typename __promote<_Tp, _Up>::type; + return std::hypot(static_cast<__result_type>(__x), static_cast<__result_type>(__y)); +} + +inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __exp) _NOEXCEPT { return __builtin_scalblnf(__x, __exp); } + +template +_LIBCPP_HIDE_FROM_ABI double scalbln(double __x, long __exp) _NOEXCEPT { + return __builtin_scalbln(__x, __exp); +} + +inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __exp) _NOEXCEPT { + return __builtin_scalblnl(__x, __exp); +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double scalbln(_Tp __v, long __exp) _NOEXCEPT { + return __builtin_scalbln(static_cast(__v), __exp); +} + +inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __exp) _NOEXCEPT { return __builtin_scalbnf(__x, __exp); } + +template +_LIBCPP_HIDE_FROM_ABI double scalbn(double __x, int __exp) _NOEXCEPT { + return __builtin_scalbn(__x, __exp); +} + +inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __exp) _NOEXCEPT { + return __builtin_scalbnl(__x, __exp); +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double scalbn(_Tp __x, int __exp) _NOEXCEPT { + return __builtin_scalbn(static_cast(__x), __exp); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::cbrt; +using std::erf; +using std::erfc; +using std::exp; +using std::exp2; +using std::expm1; +using std::fma; +using std::fmod; +using std::hypot; +using std::ldexp; +using std::pow; +using std::scalbln; +using std::scalbn; +using std::sqrt; + +#endif // _LIBCPP___CMATH_ARITHMETIC_H diff --git a/libcxx/include/__cmath/compare.h b/libcxx/include/__cmath/compare.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/compare.h @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_COMPARE_H +#define _LIBCPP___CMATH_COMPARE_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template ::value && std::is_arithmetic<_Up>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI bool isless(_Tp __lhs, _Up __rhs) _NOEXCEPT { + return __builtin_isless(__lhs, __rhs); +} + +template ::value && std::is_arithmetic<_Up>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI bool islessequal(_Tp __lhs, _Up __rhs) _NOEXCEPT { + return __builtin_islessequal(__lhs, __rhs); +} + +template ::value && std::is_arithmetic<_Up>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI bool islessgreater(_Tp __lhs, _Up __rhs) _NOEXCEPT { + return __builtin_islessgreater(__lhs, __rhs); +} + +template ::value && std::is_arithmetic<_Up>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_Tp __lhs, _Up __rhs) _NOEXCEPT { + return __builtin_isgreaterequal(__lhs, __rhs); +} + +template ::value && std::is_arithmetic<_Up>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI bool isgreater(_Tp __lhs, _Up __rhs) _NOEXCEPT { + return __builtin_isgreater(__lhs, __rhs); +} + +template ::value && std::is_arithmetic<_Up>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI bool isunordered(_Tp __lhs, _Up __rhs) _NOEXCEPT { + return __builtin_isunordered(__lhs, __rhs); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::isless; +using std::islessequal; +using std::islessgreater; +using std::isgreaterequal; +using std::isgreater; +using std::isunordered; + +#endif // _LIBCPP___CMATH_COMPARE_H diff --git a/libcxx/include/__cmath/copysign.h b/libcxx/include/__cmath/copysign.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/copysign.h @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_COPYSIGN_H +#define _LIBCPP___CMATH_COPYSIGN_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_INLINE_VISIBILITY float copysign(float __x, float __y) _NOEXCEPT { + return __builtin_copysignf(__x, __y); +} + +template +_LIBCPP_HIDE_FROM_ABI double copysign(double __x, double __y) _NOEXCEPT { + return __builtin_copysign(__x, __y); +} + +inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __x, long double __y) _NOEXCEPT { + return __builtin_copysignl(__x, __y); +} + +template ::value && std::is_arithmetic<_Up>::value, int> = 0> +inline _LIBCPP_INLINE_VISIBILITY typename __promote<_Tp, _Up>::type copysign(_Tp __x, _Up __y) _NOEXCEPT { + using __result_type = typename __promote<_Tp, _Up>::type; + return std::copysign(static_cast<__result_type>(__x), static_cast<__result_type>(__y)); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::copysign; + +#endif // _LIBCPP___CMATH_COPYSIGN_H diff --git a/libcxx/include/__cmath/fabs.h b/libcxx/include/__cmath/fabs.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/fabs.h @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_FABS_H +#define _LIBCPP___CMATH_FABS_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_HIDE_FROM_ABI float fabs(float __v) _NOEXCEPT { + return __builtin_fabsf(__v); +} + +template +_LIBCPP_HIDE_FROM_ABI double fabs(double __v) _NOEXCEPT { + return __builtin_fabs(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __v) _NOEXCEPT { + return __builtin_fabsl(__v); +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double fabs(_Tp __v) _NOEXCEPT { + return __builtin_fabs(static_cast(__v)); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::fabs; + +#endif // _LIBCPP___CMATH_FABS_H diff --git a/libcxx/include/__cmath/fdim.h b/libcxx/include/__cmath/fdim.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/fdim.h @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_FDIM_H +#define _LIBCPP___CMATH_FDIM_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT { return __builtin_fdimf(__x, __y); } + +template +_LIBCPP_HIDE_FROM_ABI double fdim(double __x, double __y) _NOEXCEPT { + return __builtin_fdim(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) _NOEXCEPT { + return __builtin_fdiml(__x, __y); +} + +template ::value && is_arithmetic<_Up>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI typename __promote<_Tp, _Up>::type fdim(_Tp __x, _Up __y) _NOEXCEPT { + using __result_type = typename __promote<_Tp, _Up>::type; + return std::fdim(static_cast<__result_type>(__x), static_cast<__result_type>(__y)); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::fdim; + +#endif // _LIBCPP___CMATH_FDIM_H diff --git a/libcxx/include/__cmath/fminmax.h b/libcxx/include/__cmath/fminmax.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/fminmax.h @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_FMINMAX_H +#define _LIBCPP___CMATH_FMINMAX_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT { return __builtin_fmaxf(__x, __y); } + +template +_LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT { + return __builtin_fmax(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT { + return __builtin_fmaxl(__x, __y); +} + +template ::value && is_arithmetic<_Up>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI typename __promote<_Tp, _Up>::type fmax(_Tp __x, _Up __y) _NOEXCEPT { + using __result_type = typename __promote<_Tp, _Up>::type; + return std::fmax(static_cast<__result_type>(__x), static_cast<__result_type>(__y)); +} + +inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT { return __builtin_fminf(__x, __y); } + +template +_LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT { + return __builtin_fmin(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT { + return __builtin_fminl(__x, __y); +} + +template ::value && is_arithmetic<_Up>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI typename __promote<_Tp, _Up>::type fmin(_Tp __x, _Up __y) _NOEXCEPT { + using __result_type = typename __promote<_Tp, _Up>::type; + return std::fmin(static_cast<__result_type>(__x), static_cast<__result_type>(__y)); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::fmax; +using std::fmin; + +#endif // _LIBCPP___CMATH_FMINMAX_H diff --git a/libcxx/include/__cmath/frexp.h b/libcxx/include/__cmath/frexp.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/frexp.h @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_FREXP_H +#define _LIBCPP___CMATH_FREXP_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_floating_point.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __exp) _NOEXCEPT { return __builtin_frexpf(__x, __exp); } + +template +_LIBCPP_HIDE_FROM_ABI double frexp(double __x, int* __exp) _NOEXCEPT { + return __builtin_frexp(__x, __exp); +} + +inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __exp) _NOEXCEPT { + return __builtin_frexpl(__x, __exp); +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double frexp(_Tp __x, int* __exp) _NOEXCEPT { + return __builtin_frexp(static_cast(__x), __exp); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::frexp; + +#endif // _LIBCPP___CMATH_FREXP_H diff --git a/libcxx/include/__cmath/logarithm.h b/libcxx/include/__cmath/logarithm.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/logarithm.h @@ -0,0 +1,130 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_ISNORMAL_H +#define _LIBCPP___CMATH_ISNORMAL_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT { return __builtin_logf(__x); } + +template +_LIBCPP_HIDE_FROM_ABI double log(double __x) _NOEXCEPT { + return __builtin_log(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT { return __builtin_logl(__x); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double log(_Tp __x) _NOEXCEPT { + return __builtin_log(static_cast(__x)); +} + +inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT { return __builtin_log10f(__x); } + +template +_LIBCPP_HIDE_FROM_ABI double log10(double __x) _NOEXCEPT { + return __builtin_log10(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT { return __builtin_log10l(__x); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double log10(_Tp __v) _NOEXCEPT { + return __builtin_log10(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT { return __builtin_log2f(__x); } + +template +_LIBCPP_HIDE_FROM_ABI double log2(double __x) _NOEXCEPT { + return __builtin_log2(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT { return __builtin_log2l(__x); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double log2(_Tp __v) _NOEXCEPT { + return __builtin_log2(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float log1p(float __v) _NOEXCEPT { return __builtin_log1pf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double log1p(double __v) _NOEXCEPT { + return __builtin_log1p(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __v) _NOEXCEPT { return __builtin_log1pl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double log1p(_Tp __v) _NOEXCEPT { + return __builtin_log1p(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float logb(float __v) _NOEXCEPT { return __builtin_logbf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double logb(double __v) _NOEXCEPT { + return __builtin_logb(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __v) _NOEXCEPT { return __builtin_logbl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double logb(_Tp __v) _NOEXCEPT { + return __builtin_logb(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __v) _NOEXCEPT { return __builtin_ilogbf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI int ilogb(double __v) _NOEXCEPT { + return __builtin_ilogb(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __v) _NOEXCEPT { return __builtin_ilogbl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI int ilogb(_Tp __v) { + return __builtin_ilogb(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __v) _NOEXCEPT { return __builtin_lgammaf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double lgamma(double __v) _NOEXCEPT { + return __builtin_lgamma(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __v) _NOEXCEPT { return __builtin_lgammal(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double lgamma(_Tp __v) _NOEXCEPT { + return __builtin_lgamma(static_cast(__v)); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::ilogb; +using std::lgamma; +using std::log; +using std::log10; +using std::log1p; +using std::log2; +using std::logb; + +#endif // _LIBCPP___CMATH_ISNORMAL_H diff --git a/libcxx/include/__cmath/modf.h b/libcxx/include/__cmath/modf.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/modf.h @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_MODF_H +#define _LIBCPP___CMATH_MODF_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT { + return __builtin_modff(__x, __y); +} + +template +_LIBCPP_HIDE_FROM_ABI double modf(double __x, double* __y) _NOEXCEPT { + return __builtin_modf(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double modf(long double __x, long double* __y) _NOEXCEPT { + return __builtin_modfl(__x, __y); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::modf; + +#endif // _LIBCPP___CMATH_MODF_H diff --git a/libcxx/include/__cmath/nextafter.h b/libcxx/include/__cmath/nextafter.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/nextafter.h @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_NEXTAFTER_H +#define _LIBCPP___CMATH_NEXTAFTER_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT { + return __builtin_nextafterf(__x, __y); +} + +template +_LIBCPP_HIDE_FROM_ABI double nextafter(double __x, double __y) _NOEXCEPT { + return __builtin_nextafter(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double __y) _NOEXCEPT { + return __builtin_nextafterl(__x, __y); +} + +template ::value && is_arithmetic<_Up>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI typename __promote<_Tp, _Up>::type nextafter(_Tp __x, _Up __y) _NOEXCEPT { + using __result_type = typename __promote<_Tp, _Up>::type; + return std::nextafter(static_cast<__result_type>(__x), static_cast<__result_type>(__y)); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::nextafter; + +#endif // _LIBCPP___CMATH_NEXTAFTER_H diff --git a/libcxx/include/__cmath/nexttoward.h b/libcxx/include/__cmath/nexttoward.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/nexttoward.h @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_NEXTTOWARD_H +#define _LIBCPP___CMATH_NEXTTOWARD_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT { + return __builtin_nexttowardf(__x, __y); +} + +template +_LIBCPP_HIDE_FROM_ABI double nexttoward(double __x, long double __y) _NOEXCEPT { + return __builtin_nexttoward(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double nexttoward(long double __x, long double __y) _NOEXCEPT { + return __builtin_nexttowardl(__x, __y); +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double nexttoward(_Tp __x, long double __y) _NOEXCEPT { + return __builtin_nexttoward(static_cast(__x), __y); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::nexttoward; + +#endif // _LIBCPP___CMATH_NEXTTOWARD_H diff --git a/libcxx/include/__cmath/remainder.h b/libcxx/include/__cmath/remainder.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/remainder.h @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_REMAINDER_H +#define _LIBCPP___CMATH_REMAINDER_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT { return __builtin_remainderf(__x, __y); } + +template +_LIBCPP_HIDE_FROM_ABI double remainder(double __x, double __y) _NOEXCEPT { + return __builtin_remainder(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double __y) _NOEXCEPT { + return __builtin_remainderl(__x, __y); +} + +template ::value && is_arithmetic<_Up>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI typename __promote<_Tp, _Up>::type remainder(_Tp __x, _Up __y) _NOEXCEPT { + using __result_type = typename __promote<_Tp, _Up>::type; + return std::remainder(static_cast<__result_type>(__x), static_cast<__result_type>(__y)); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::remainder; + +#endif // _LIBCPP___CMATH_REMAINDER_H diff --git a/libcxx/include/__cmath/remquo.h b/libcxx/include/__cmath/remquo.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/remquo.h @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_REMQUO_H +#define _LIBCPP___CMATH_REMQUO_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT { + return __builtin_remquof(__x, __y, __z); +} + +template +_LIBCPP_HIDE_FROM_ABI double remquo(double __x, double __y, int* __z) _NOEXCEPT { + return __builtin_remquo(__x, __y, __z); +} + +inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y, int* __z) _NOEXCEPT { + return __builtin_remquol(__x, __y, __z); +} + +template ::value && is_arithmetic<_Up>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI typename __promote<_Tp, _Up>::type remquo(_Tp __x, _Up __y, int* __z) _NOEXCEPT { + using __result_type = typename __promote<_Tp, _Up>::type; + return std::remquo(static_cast<__result_type>(__x), static_cast<__result_type>(__y), __z); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::remquo; + +#endif // _LIBCPP___CMATH_REMQUO_H diff --git a/libcxx/include/__cmath/rounding.h b/libcxx/include/__cmath/rounding.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/rounding.h @@ -0,0 +1,175 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_ROUNDING_H +#define _LIBCPP___CMATH_ROUNDING_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_HIDE_FROM_ABI float ceil(float __v) _NOEXCEPT { return __builtin_ceilf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double ceil(double __v) { + return __builtin_ceil(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __v) _NOEXCEPT { return __builtin_ceill(__v); } + +template ::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double ceil(_Tp __v) _NOEXCEPT { + return __builtin_ceil(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float floor(float __v) { return __builtin_floorf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double floor(double __v) { + return __builtin_ceil(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __v) { return __builtin_floorl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double floor(_Tp __v) { + return __builtin_floor(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI long long llround(float __v) _NOEXCEPT { return __builtin_llroundf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI long long llround(double __v) _NOEXCEPT { + return __builtin_llround(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __v) _NOEXCEPT { return __builtin_llroundl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI long long llround(_Tp __v) _NOEXCEPT { + return __builtin_llround(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI long lrint(float __v) _NOEXCEPT { return __builtin_lrintf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI long lrint(double __v) _NOEXCEPT { + return __builtin_lrint(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __v) _NOEXCEPT { return __builtin_lrintl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI long lrint(_Tp __v) _NOEXCEPT { + return __builtin_lrint(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __v) _NOEXCEPT { return __builtin_llrintf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI long long llrint(double __v) _NOEXCEPT { + return __builtin_llrint(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __v) _NOEXCEPT { return __builtin_llrintl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI long long llrint(_Tp __v) _NOEXCEPT { + return __builtin_llrint(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI long lround(float __v) _NOEXCEPT { return __builtin_lroundf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI long lround(double __v) _NOEXCEPT { + return __builtin_lround(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long lround(long double __v) _NOEXCEPT { return __builtin_lroundl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI long lround(_Tp __v) _NOEXCEPT { + return __builtin_lround(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __v) _NOEXCEPT { return __builtin_nearbyintf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double nearbyint(double __v) _NOEXCEPT { + return __builtin_nearbyint(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __v) _NOEXCEPT { return __builtin_nearbyintl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double nearbyint(_Tp __v) _NOEXCEPT { + return __builtin_nearbyint(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float rint(float __v) _NOEXCEPT { return __builtin_rintf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double rint(double __v) _NOEXCEPT { + return __builtin_rint(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __v) _NOEXCEPT { return __builtin_rintl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double rint(_Tp __v) { + return __builtin_rint(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float round(float __v) _NOEXCEPT { return __builtin_roundf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double round(double __v) _NOEXCEPT { + return __builtin_round(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double round(long double __v) _NOEXCEPT { return __builtin_roundl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double round(_Tp __v) { + return __builtin_round(static_cast(__v)); +} + +inline _LIBCPP_HIDE_FROM_ABI float trunc(float __v) _NOEXCEPT { return __builtin_truncf(__v); } + +template +_LIBCPP_HIDE_FROM_ABI double trunc(double __v) _NOEXCEPT { + return __builtin_trunc(__v); +} + +inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __v) _NOEXCEPT { return __builtin_truncl(__v); } + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI double trunc(_Tp __v) _NOEXCEPT { + return __builtin_trunc(static_cast(__v)); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::ceil; +using std::floor; +using std::llrint; +using std::llround; +using std::lrint; +using std::lround; +using std::nearbyint; +using std::rint; +using std::round; +using std::trunc; + +#endif // _LIBCPP___CMATH_ROUNDING_H diff --git a/libcxx/include/__cmath/signbit.h b/libcxx/include/__cmath/signbit.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/signbit.h @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_SIGNBIT_H +#define _LIBCPP___CMATH_SIGNBIT_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_floating_point.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/is_signed.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI bool signbit(_Tp __v) _NOEXCEPT { + return __builtin_signbit(__v); +} + +template ::value && std::is_signed<_Tp>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI bool signbit(_Tp __v) _NOEXCEPT { + return __v < 0; +} + +template ::value && !std::is_signed<_Tp>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI bool signbit(_Tp) _NOEXCEPT { + return false; +} + +_LIBCPP_END_NAMESPACE_STD + +using std::signbit; + +#endif // _LIBCPP___CMATH_SIGNBIT_H diff --git a/libcxx/include/__cmath/tgamma.h b/libcxx/include/__cmath/tgamma.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/tgamma.h @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_TGAMMA_H +#define _LIBCPP___CMATH_TGAMMA_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT { + return __builtin_tgammaf(__x); +} + +template +_LIBCPP_HIDE_FROM_ABI double tgamma(double __x) _NOEXCEPT { + return __builtin_tgamma(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT { + return __builtin_tgammal(__x); +} + +template ::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double tgamma(_Tp __x) _NOEXCEPT { + return __builtin_tgamma(static_cast(__x)); +} + +_LIBCPP_END_NAMESPACE_STD + +using std::tgamma; + +#endif // _LIBCPP___CMATH_TGAMMA_H diff --git a/libcxx/include/__cmath/traits.h b/libcxx/include/__cmath/traits.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__cmath/traits.h @@ -0,0 +1,74 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___CMATH_TRAITS_H +#define _LIBCPP___CMATH_TRAITS_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template ::value && std::numeric_limits<_Tp>::has_infinity, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI bool isfinite(_Tp __lcpp_x) _NOEXCEPT { + return __builtin_isfinite(__lcpp_x); +} + +template ::value && !std::numeric_limits<_Tp>::has_infinity, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI bool isfinite(_Tp) _NOEXCEPT { + return true; +} + +template ::value && std::numeric_limits<_Tp>::has_infinity, int> = 0> +_LIBCPP_HIDE_FROM_ABI bool isinf(_Tp __v) _NOEXCEPT { + return __builtin_isinf(__v); +} + +template ::value && !std::numeric_limits<_Tp>::has_infinity, int> = 0> +_LIBCPP_HIDE_FROM_ABI bool isinf(_Tp) _NOEXCEPT { + return false; +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI bool isnan(_Tp __v) _NOEXCEPT { + return __builtin_isnan(__v); +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI bool isnan(_Tp) _NOEXCEPT { + return false; +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI bool isnormal(_Tp __v) _NOEXCEPT { + return __builtin_isnormal(__v); +} + +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI bool isnormal(_Tp __v) _NOEXCEPT { + return __v != 0; +} + +_LIBCPP_END_NAMESPACE_STD + +using std::isfinite; +using std::isinf; +using std::isnan; +using std::isnormal; + +#endif // _LIBCPP___CMATH_TRAITS_H diff --git a/libcxx/include/__compare/strong_order.h b/libcxx/include/__compare/strong_order.h --- a/libcxx/include/__compare/strong_order.h +++ b/libcxx/include/__compare/strong_order.h @@ -10,12 +10,14 @@ #define _LIBCPP___COMPARE_STRONG_ORDER #include <__bit/bit_cast.h> +#include <__cmath/frexp.h> +#include <__cmath/signbit.h> +#include <__cmath/traits.h> #include <__compare/compare_three_way.h> #include <__compare/ordering.h> #include <__config> #include <__utility/forward.h> #include <__utility/priority_tag.h> -#include #include #include #include diff --git a/libcxx/include/__compare/weak_order.h b/libcxx/include/__compare/weak_order.h --- a/libcxx/include/__compare/weak_order.h +++ b/libcxx/include/__compare/weak_order.h @@ -15,7 +15,6 @@ #include <__config> #include <__utility/forward.h> #include <__utility/priority_tag.h> -#include #include #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table --- a/libcxx/include/__hash_table +++ b/libcxx/include/__hash_table @@ -14,6 +14,7 @@ #include <__algorithm/min.h> #include <__assert> #include <__bits> // __libcpp_clz +#include <__cmath/rounding.h> #include <__config> #include <__debug> #include <__functional/hash.h> @@ -29,7 +30,6 @@ #include <__utility/move.h> #include <__utility/pair.h> #include <__utility/swap.h> -#include #include #include #include @@ -1160,11 +1160,11 @@ _LIBCPP_INLINE_VISIBILITY void __rehash_multi(size_type __n) { __rehash(__n); } _LIBCPP_INLINE_VISIBILITY void __reserve_unique(size_type __n) { - __rehash_unique(static_cast(ceil(__n / max_load_factor()))); + __rehash_unique(static_cast(std::ceil(__n / max_load_factor()))); } _LIBCPP_INLINE_VISIBILITY void __reserve_multi(size_type __n) { - __rehash_multi(static_cast(ceil(__n / max_load_factor()))); + __rehash_multi(static_cast(std::ceil(__n / max_load_factor()))); } _LIBCPP_INLINE_VISIBILITY diff --git a/libcxx/include/__random/binomial_distribution.h b/libcxx/include/__random/binomial_distribution.h --- a/libcxx/include/__random/binomial_distribution.h +++ b/libcxx/include/__random/binomial_distribution.h @@ -9,6 +9,7 @@ #ifndef _LIBCPP___RANDOM_BINOMIAL_DISTRIBUTION_H #define _LIBCPP___RANDOM_BINOMIAL_DISTRIBUTION_H +#include <__cmath/arithmetic.h> #include <__config> #include <__random/is_valid.h> #include <__random/uniform_real_distribution.h> diff --git a/libcxx/include/__random/cauchy_distribution.h b/libcxx/include/__random/cauchy_distribution.h --- a/libcxx/include/__random/cauchy_distribution.h +++ b/libcxx/include/__random/cauchy_distribution.h @@ -9,10 +9,10 @@ #ifndef _LIBCPP___RANDOM_CAUCHY_DISTRIBUTION_H #define _LIBCPP___RANDOM_CAUCHY_DISTRIBUTION_H +#include <__cmath/angular_functions.h> #include <__config> #include <__random/is_valid.h> #include <__random/uniform_real_distribution.h> -#include #include #include diff --git a/libcxx/include/__random/extreme_value_distribution.h b/libcxx/include/__random/extreme_value_distribution.h --- a/libcxx/include/__random/extreme_value_distribution.h +++ b/libcxx/include/__random/extreme_value_distribution.h @@ -9,10 +9,10 @@ #ifndef _LIBCPP___RANDOM_EXTREME_VALUE_DISTRIBUTION_H #define _LIBCPP___RANDOM_EXTREME_VALUE_DISTRIBUTION_H +#include <__cmath/arithmetic.h> #include <__config> #include <__random/is_valid.h> #include <__random/uniform_real_distribution.h> -#include #include #include diff --git a/libcxx/include/__random/gamma_distribution.h b/libcxx/include/__random/gamma_distribution.h --- a/libcxx/include/__random/gamma_distribution.h +++ b/libcxx/include/__random/gamma_distribution.h @@ -13,7 +13,6 @@ #include <__random/exponential_distribution.h> #include <__random/is_valid.h> #include <__random/uniform_real_distribution.h> -#include #include #include diff --git a/libcxx/include/__random/lognormal_distribution.h b/libcxx/include/__random/lognormal_distribution.h --- a/libcxx/include/__random/lognormal_distribution.h +++ b/libcxx/include/__random/lognormal_distribution.h @@ -11,7 +11,6 @@ #include <__config> #include <__random/normal_distribution.h> -#include #include #include diff --git a/libcxx/include/__random/normal_distribution.h b/libcxx/include/__random/normal_distribution.h --- a/libcxx/include/__random/normal_distribution.h +++ b/libcxx/include/__random/normal_distribution.h @@ -9,10 +9,10 @@ #ifndef _LIBCPP___RANDOM_NORMAL_DISTRIBUTION_H #define _LIBCPP___RANDOM_NORMAL_DISTRIBUTION_H +#include <__cmath/arithmetic.h> #include <__config> #include <__random/is_valid.h> #include <__random/uniform_real_distribution.h> -#include #include #include diff --git a/libcxx/include/__random/poisson_distribution.h b/libcxx/include/__random/poisson_distribution.h --- a/libcxx/include/__random/poisson_distribution.h +++ b/libcxx/include/__random/poisson_distribution.h @@ -15,7 +15,6 @@ #include <__random/is_valid.h> #include <__random/normal_distribution.h> #include <__random/uniform_real_distribution.h> -#include #include #include diff --git a/libcxx/include/__random/student_t_distribution.h b/libcxx/include/__random/student_t_distribution.h --- a/libcxx/include/__random/student_t_distribution.h +++ b/libcxx/include/__random/student_t_distribution.h @@ -13,7 +13,6 @@ #include <__random/gamma_distribution.h> #include <__random/is_valid.h> #include <__random/normal_distribution.h> -#include #include #include diff --git a/libcxx/include/__random/weibull_distribution.h b/libcxx/include/__random/weibull_distribution.h --- a/libcxx/include/__random/weibull_distribution.h +++ b/libcxx/include/__random/weibull_distribution.h @@ -11,7 +11,6 @@ #include <__config> #include <__random/exponential_distribution.h> -#include #include #include diff --git a/libcxx/include/charconv b/libcxx/include/charconv --- a/libcxx/include/charconv +++ b/libcxx/include/charconv @@ -85,12 +85,12 @@ #include <__charconv/tables.h> #include <__charconv/to_chars_base_10.h> #include <__charconv/to_chars_result.h> +#include <__cmath/logarithm.h> #include <__config> #include <__debug> #include <__errc> #include <__type_traits/make_32_64_or_128_bit.h> #include <__utility/unreachable.h> -#include // for log2f #include #include #include @@ -717,7 +717,7 @@ [](const char* __p, const char* __lastp, _Tp& __val, int __b) -> from_chars_result { using __tl = numeric_limits<_Tp>; - auto __digits = __tl::digits / log2f(float(__b)); + auto __digits = __tl::digits / std::log2(float(__b)); _Tp __x = __in_pattern(*__p++, __b).__val, __y = 0; for (int __i = 1; __p != __lastp; ++__i, ++__p) diff --git a/libcxx/include/cmath b/libcxx/include/cmath --- a/libcxx/include/cmath +++ b/libcxx/include/cmath @@ -328,12 +328,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD -using ::signbit _LIBCPP_USING_IF_EXISTS; using ::fpclassify _LIBCPP_USING_IF_EXISTS; using ::isfinite _LIBCPP_USING_IF_EXISTS; using ::isinf _LIBCPP_USING_IF_EXISTS; -using ::isnan _LIBCPP_USING_IF_EXISTS; -using ::isnormal _LIBCPP_USING_IF_EXISTS; using ::isgreater _LIBCPP_USING_IF_EXISTS; using ::isgreaterequal _LIBCPP_USING_IF_EXISTS; using ::isless _LIBCPP_USING_IF_EXISTS; @@ -406,7 +403,6 @@ using ::acoshf _LIBCPP_USING_IF_EXISTS; using ::asinh _LIBCPP_USING_IF_EXISTS; using ::asinhf _LIBCPP_USING_IF_EXISTS; -using ::atanh _LIBCPP_USING_IF_EXISTS; using ::atanhf _LIBCPP_USING_IF_EXISTS; using ::cbrt _LIBCPP_USING_IF_EXISTS; using ::cbrtf _LIBCPP_USING_IF_EXISTS; diff --git a/libcxx/include/complex b/libcxx/include/complex --- a/libcxx/include/complex +++ b/libcxx/include/complex @@ -1047,7 +1047,7 @@ return complex<_Tp>(__x.real(), __libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag())); return complex<_Tp>(__libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag())); } - return polar(sqrt(abs(__x)), arg(__x) / _Tp(2)); + return std::polar(std::sqrt(std::abs(__x)), std::arg(__x) / _Tp(2)); } // exp diff --git a/libcxx/include/math.h b/libcxx/include/math.h --- a/libcxx/include/math.h +++ b/libcxx/include/math.h @@ -299,485 +299,100 @@ #include_next -#ifdef __cplusplus - -// We support including .h headers inside 'extern "C"' contexts, so switch -// back to C++ linkage before including these C++ headers. -extern "C++" { - -#include <__type_traits/promote.h> -#include -#include -#include - -// signbit - -#ifdef signbit - -template -_LIBCPP_INLINE_VISIBILITY -bool -__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_signbit) - return __builtin_signbit(__lcpp_x); -#else - return signbit(__lcpp_x); -#endif -} - -#undef signbit - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -signbit(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if< - std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type -signbit(_A1 __lcpp_x) _NOEXCEPT -{ return __lcpp_x < 0; } - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if< - std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type -signbit(_A1) _NOEXCEPT -{ return false; } - -#elif defined(_LIBCPP_MSVCRT) - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -signbit(_A1 __lcpp_x) _NOEXCEPT -{ - return ::signbit(static_cast::type>(__lcpp_x)); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if< - std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type -signbit(_A1 __lcpp_x) _NOEXCEPT -{ return __lcpp_x < 0; } - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if< - std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type -signbit(_A1) _NOEXCEPT -{ return false; } - -#endif // signbit - -// fpclassify - #ifdef fpclassify - -template -_LIBCPP_INLINE_VISIBILITY -int -__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_fpclassify) - return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, - FP_ZERO, __lcpp_x); -#else - return fpclassify(__lcpp_x); +# undef fpclassify #endif -} - -#undef fpclassify -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, int>::type -fpclassify(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, int>::type -fpclassify(_A1 __lcpp_x) _NOEXCEPT -{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; } +#ifdef isless +# undef isless +#endif -#elif defined(_LIBCPP_MSVCRT) +#ifdef islessequal +# undef islessequal +#endif -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -fpclassify(_A1 __lcpp_x) _NOEXCEPT -{ - return ::fpclassify(static_cast::type>(__lcpp_x)); -} +#ifdef islessgreater +# undef islessgreater +#endif -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, int>::type -fpclassify(_A1 __lcpp_x) _NOEXCEPT -{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; } +#ifdef isgreaterequal +# undef isgreaterequal +#endif -#endif // fpclassify +#ifdef isgreater +# undef isgreater +#endif -// isfinite +#ifdef isunordered +# undef isunordered +#endif #ifdef isfinite - -template -_LIBCPP_INLINE_VISIBILITY -bool -__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_isfinite) - return __builtin_isfinite(__lcpp_x); -#else - return isfinite(__lcpp_x); +# undef isfinite #endif -} - -#undef isfinite - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if< - std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, - bool>::type -isfinite(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if< - std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, - bool>::type -isfinite(_A1) _NOEXCEPT -{ return true; } - -#endif // isfinite - -// isinf #ifdef isinf - -template -_LIBCPP_INLINE_VISIBILITY -bool -__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_isinf) - return __builtin_isinf(__lcpp_x); -#else - return isinf(__lcpp_x); -#endif -} - -#undef isinf - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if< - std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, - bool>::type -isinf(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if< - std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, - bool>::type -isinf(_A1) _NOEXCEPT -{ return false; } - -#ifdef _LIBCPP_PREFERRED_OVERLOAD -inline _LIBCPP_INLINE_VISIBILITY -bool -isinf(float __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); } - -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD -bool -isinf(double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); } - -inline _LIBCPP_INLINE_VISIBILITY -bool -isinf(long double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); } +# undef isinf #endif -#endif // isinf - -// isnan - #ifdef isnan - -template -_LIBCPP_INLINE_VISIBILITY -bool -__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_isnan) - return __builtin_isnan(__lcpp_x); -#else - return isnan(__lcpp_x); +# undef isnan #endif -} - -#undef isnan - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -isnan(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -isnan(_A1) _NOEXCEPT -{ return false; } - -#ifdef _LIBCPP_PREFERRED_OVERLOAD -inline _LIBCPP_INLINE_VISIBILITY -bool -isnan(float __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); } - -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD -bool -isnan(double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); } - -inline _LIBCPP_INLINE_VISIBILITY -bool -isnan(long double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); } -#endif - -#endif // isnan - -// isnormal #ifdef isnormal - -template -_LIBCPP_INLINE_VISIBILITY -bool -__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_isnormal) - return __builtin_isnormal(__lcpp_x); -#else - return isnormal(__lcpp_x); +# undef isnormal #endif -} - -#undef isnormal -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -isnormal(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -isnormal(_A1 __lcpp_x) _NOEXCEPT -{ return __lcpp_x != 0; } - -#endif // isnormal - -// isgreater - -#ifdef isgreater - -template -_LIBCPP_INLINE_VISIBILITY -bool -__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return isgreater(__lcpp_x, __lcpp_y); -} - -#undef isgreater - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y); -} - -#endif // isgreater - -// isgreaterequal - -#ifdef isgreaterequal - -template -_LIBCPP_INLINE_VISIBILITY -bool -__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return isgreaterequal(__lcpp_x, __lcpp_y); -} - -#undef isgreaterequal - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y); -} - -#endif // isgreaterequal - -// isless - -#ifdef isless - -template -_LIBCPP_INLINE_VISIBILITY -bool -__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return isless(__lcpp_x, __lcpp_y); -} - -#undef isless - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y); -} - -#endif // isless - -// islessequal - -#ifdef islessequal - -template -_LIBCPP_INLINE_VISIBILITY -bool -__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return islessequal(__lcpp_x, __lcpp_y); -} +#ifdef signbit +# undef signbit +#endif -#undef islessequal - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y); -} +#ifdef __cplusplus -#endif // islessequal +// We support including .h headers inside 'extern "C"' contexts, so switch +// back to C++ linkage before including these C++ headers. +extern "C++" { +#include <__cmath/angular_functions.h> +#include <__cmath/arithmetic.h> +#include <__cmath/compare.h> +#include <__cmath/copysign.h> +#include <__cmath/fabs.h> +#include <__cmath/fdim.h> +#include <__cmath/fminmax.h> +#include <__cmath/frexp.h> +#include <__cmath/logarithm.h> +#include <__cmath/modf.h> +#include <__cmath/nextafter.h> +#include <__cmath/nexttoward.h> +#include <__cmath/remainder.h> +#include <__cmath/remquo.h> +#include <__cmath/rounding.h> +#include <__cmath/signbit.h> +#include <__cmath/tgamma.h> +#include <__cmath/traits.h> -// islessgreater +#include <__type_traits/promote.h> +#include +#include +#include -#ifdef islessgreater +// fpclassify -template -_LIBCPP_INLINE_VISIBILITY -bool -__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return islessgreater(__lcpp_x, __lcpp_y); -} +_LIBCPP_BEGIN_NAMESPACE_STD -#undef islessgreater - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y); +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI int fpclassify(_Tp __x) _NOEXCEPT { + return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); } -#endif // islessgreater - -// isunordered - -#ifdef isunordered - -template -_LIBCPP_INLINE_VISIBILITY -bool -__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return isunordered(__lcpp_x, __lcpp_y); +template ::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI int fpclassify(_Tp __x) _NOEXCEPT { + return __x == 0 ? FP_ZERO : FP_NORMAL; } -#undef isunordered - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y); -} +_LIBCPP_END_NAMESPACE_STD -#endif // isunordered +using std::fpclassify; // abs // @@ -787,962 +402,8 @@ // // handled in stdlib.h -// acos - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return ::acosf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);} - -// asin - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return ::asinf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);} - -// atan - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return ::atanf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);} - -// atan2 - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x); -} - -// ceil - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ::ceilf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);} - -// cos - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return ::cosf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return ::cosl(__lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);} - -// cosh - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return ::coshf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return ::coshl(__lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);} - -// exp - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return ::expf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return ::expl(__lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);} - -// fabs - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);} - -// floor - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return ::floorf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return ::floorl(__lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);} - -// fmod - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmodf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmodl(__lcpp_x, __lcpp_y);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// frexp - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpf(__lcpp_x, __lcpp_e);} -inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpl(__lcpp_x, __lcpp_e);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, __lcpp_e);} - -// ldexp - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpf(__lcpp_x, __lcpp_e);} -inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpl(__lcpp_x, __lcpp_e);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __lcpp_e);} - -// log - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return ::logf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return ::logl(__lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);} - -// log10 - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return ::log10f(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return ::log10l(__lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);} - -// modf - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return ::modff(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return ::modfl(__lcpp_x, __lcpp_y);} -# endif - -// pow - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::powf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::powl(__lcpp_x, __lcpp_y);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::pow((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// sin - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return ::sinf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return ::sinl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);} - -// sinh - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return ::sinhf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return ::sinhl(__lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);} - -// sqrt - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return ::sqrtf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return ::sqrtl(__lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);} - -// tan - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return ::tanf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return ::tanl(__lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);} - -// tanh - -# if !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return ::tanhf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return ::tanhl(__lcpp_x);} -# endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -tanh(_A1 __lcpp_x) _NOEXCEPT {return ::tanh((double)__lcpp_x);} - -// acosh - -inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return ::acoshf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return ::acoshl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -acosh(_A1 __lcpp_x) _NOEXCEPT {return ::acosh((double)__lcpp_x);} - -// asinh - -inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return ::asinhf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return ::asinhl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -asinh(_A1 __lcpp_x) _NOEXCEPT {return ::asinh((double)__lcpp_x);} - -// atanh - -inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return ::atanhf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return ::atanhl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -atanh(_A1 __lcpp_x) _NOEXCEPT {return ::atanh((double)__lcpp_x);} - -// cbrt - -inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return ::cbrtf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return ::cbrtl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -cbrt(_A1 __lcpp_x) _NOEXCEPT {return ::cbrt((double)__lcpp_x);} - -// copysign - -#if __has_builtin(__builtin_copysignf) -_LIBCPP_CONSTEXPR -#endif -inline _LIBCPP_INLINE_VISIBILITY float __libcpp_copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT { -#if __has_builtin(__builtin_copysignf) - return __builtin_copysignf(__lcpp_x, __lcpp_y); -#else - return ::copysignf(__lcpp_x, __lcpp_y); -#endif -} - -#if __has_builtin(__builtin_copysign) -_LIBCPP_CONSTEXPR -#endif -inline _LIBCPP_INLINE_VISIBILITY double __libcpp_copysign(double __lcpp_x, double __lcpp_y) _NOEXCEPT { -#if __has_builtin(__builtin_copysign) - return __builtin_copysign(__lcpp_x, __lcpp_y); -#else - return ::copysign(__lcpp_x, __lcpp_y); -#endif -} - -#if __has_builtin(__builtin_copysignl) -_LIBCPP_CONSTEXPR -#endif -inline _LIBCPP_INLINE_VISIBILITY long double __libcpp_copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT { -#if __has_builtin(__builtin_copysignl) - return __builtin_copysignl(__lcpp_x, __lcpp_y); -#else - return ::copysignl(__lcpp_x, __lcpp_y); -#endif -} - -template -#if __has_builtin(__builtin_copysign) -_LIBCPP_CONSTEXPR -#endif -inline _LIBCPP_INLINE_VISIBILITY -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -__libcpp_copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); -#if __has_builtin(__builtin_copysign) - return __builtin_copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y); -#else - return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y); -#endif -} - -inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT { - return ::__libcpp_copysign(__lcpp_x, __lcpp_y); -} - -inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT { - return ::__libcpp_copysign(__lcpp_x, __lcpp_y); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type - copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT { - return ::__libcpp_copysign(__lcpp_x, __lcpp_y); -} - -// erf - -inline _LIBCPP_INLINE_VISIBILITY float erf(float __lcpp_x) _NOEXCEPT {return ::erff(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return ::erfl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -erf(_A1 __lcpp_x) _NOEXCEPT {return ::erf((double)__lcpp_x);} - -// erfc - -inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return ::erfcf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return ::erfcl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -erfc(_A1 __lcpp_x) _NOEXCEPT {return ::erfc((double)__lcpp_x);} - -// exp2 - -inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return ::exp2f(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return ::exp2l(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -exp2(_A1 __lcpp_x) _NOEXCEPT {return ::exp2((double)__lcpp_x);} - -// expm1 - -inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return ::expm1f(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return ::expm1l(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -expm1(_A1 __lcpp_x) _NOEXCEPT {return ::expm1((double)__lcpp_x);} - -// fdim - -inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fdimf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fdiml(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// fma - -inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT -{ -#if __has_builtin(__builtin_fmaf) - return __builtin_fmaf(__lcpp_x, __lcpp_y, __lcpp_z); -#else - return ::fmaf(__lcpp_x, __lcpp_y, __lcpp_z); -#endif -} -inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT -{ -#if __has_builtin(__builtin_fmal) - return __builtin_fmal(__lcpp_x, __lcpp_y, __lcpp_z); -#else - return ::fmal(__lcpp_x, __lcpp_y, __lcpp_z); -#endif -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value && - std::is_arithmetic<_A3>::value, - std::__promote<_A1, _A2, _A3> ->::type -fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2, _A3>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value && - std::_IsSame<_A3, __result_type>::value)), ""); -#if __has_builtin(__builtin_fma) - return __builtin_fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z); -#else - return ::fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z); -#endif -} - -// fmax - -inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmaxf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmaxl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// fmin - -inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fminf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fminl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// hypot - -inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::hypotf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::hypotl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// ilogb - -inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ::ilogbf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ::ilogbl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, int>::type -ilogb(_A1 __lcpp_x) _NOEXCEPT {return ::ilogb((double)__lcpp_x);} - -// lgamma - -inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return ::lgammaf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return ::lgammal(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -lgamma(_A1 __lcpp_x) _NOEXCEPT {return ::lgamma((double)__lcpp_x);} - -// llrint - -inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_llrintf) - return __builtin_llrintf(__lcpp_x); -#else - return ::llrintf(__lcpp_x); -#endif -} -inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_llrintl) - return __builtin_llrintl(__lcpp_x); -#else - return ::llrintl(__lcpp_x); -#endif -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, long long>::type -llrint(_A1 __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_llrint) - return __builtin_llrint((double)__lcpp_x); -#else - return ::llrint((double)__lcpp_x); -#endif -} - -// llround - -inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_llroundf) - return __builtin_llroundf(__lcpp_x); -#else - return ::llroundf(__lcpp_x); -#endif -} -inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_llroundl) - return __builtin_llroundl(__lcpp_x); -#else - return ::llroundl(__lcpp_x); -#endif -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, long long>::type -llround(_A1 __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_llround) - return __builtin_llround((double)__lcpp_x); -#else - return ::llround((double)__lcpp_x); -#endif -} - -// log1p - -inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return ::log1pf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return ::log1pl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -log1p(_A1 __lcpp_x) _NOEXCEPT {return ::log1p((double)__lcpp_x);} - -// log2 - -inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return ::log2f(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return ::log2l(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -log2(_A1 __lcpp_x) _NOEXCEPT {return ::log2((double)__lcpp_x);} - -// logb - -inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return ::logbf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return ::logbl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -logb(_A1 __lcpp_x) _NOEXCEPT {return ::logb((double)__lcpp_x);} - -// lrint - -inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_lrintf) - return __builtin_lrintf(__lcpp_x); -#else - return ::lrintf(__lcpp_x); -#endif -} -inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_lrintl) - return __builtin_lrintl(__lcpp_x); -#else - return ::lrintl(__lcpp_x); -#endif -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, long>::type -lrint(_A1 __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_lrint) - return __builtin_lrint((double)__lcpp_x); -#else - return ::lrint((double)__lcpp_x); -#endif -} - -// lround - -inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_lroundf) - return __builtin_lroundf(__lcpp_x); -#else - return ::lroundf(__lcpp_x); -#endif -} -inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_lroundl) - return __builtin_lroundl(__lcpp_x); -#else - return ::lroundl(__lcpp_x); -#endif -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, long>::type -lround(_A1 __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_lround) - return __builtin_lround((double)__lcpp_x); -#else - return ::lround((double)__lcpp_x); -#endif -} - -// nan - -// nearbyint - -inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return ::nearbyintf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return ::nearbyintl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -nearbyint(_A1 __lcpp_x) _NOEXCEPT {return ::nearbyint((double)__lcpp_x);} - -// nextafter - -inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::nextafterf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nextafterl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// nexttoward - -inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttoward((double)__lcpp_x, __lcpp_y);} - -// remainder - -inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::remainderf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::remainderl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// remquo - -inline _LIBCPP_INLINE_VISIBILITY float remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT {return ::remquof(__lcpp_x, __lcpp_y, __lcpp_z);} -inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long double __lcpp_y, int* __lcpp_z) _NOEXCEPT {return ::remquol(__lcpp_x, __lcpp_y, __lcpp_z);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z); -} - -// rint - -inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_rintf) - return __builtin_rintf(__lcpp_x); -#else - return ::rintf(__lcpp_x); -#endif -} -inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_rintl) - return __builtin_rintl(__lcpp_x); -#else - return ::rintl(__lcpp_x); -#endif -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -rint(_A1 __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_rint) - return __builtin_rint((double)__lcpp_x); -#else - return ::rint((double)__lcpp_x); -#endif -} - -// round - -inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_round) - return __builtin_round(__lcpp_x); -#else - return ::round(__lcpp_x); -#endif -} -inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_roundl) - return __builtin_roundl(__lcpp_x); -#else - return ::roundl(__lcpp_x); -#endif -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -round(_A1 __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_round) - return __builtin_round((double)__lcpp_x); -#else - return ::round((double)__lcpp_x); -#endif -} - -// scalbln - -inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalbln((double)__lcpp_x, __lcpp_y);} - -// scalbn - -inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbn((double)__lcpp_x, __lcpp_y);} - // tgamma -inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return ::tgammaf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return ::tgammal(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -tgamma(_A1 __lcpp_x) _NOEXCEPT {return ::tgamma((double)__lcpp_x);} - -// trunc - -inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_trunc) - return __builtin_trunc(__lcpp_x); -#else - return ::trunc(__lcpp_x); -#endif -} -inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_truncl) - return __builtin_truncl(__lcpp_x); -#else - return ::truncl(__lcpp_x); -#endif -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, double>::type -trunc(_A1 __lcpp_x) _NOEXCEPT -{ -#if __has_builtin(__builtin_trunc) - return __builtin_trunc((double)__lcpp_x); -#else - return ::trunc((double)__lcpp_x); -#endif -} - } // extern "C++" #endif // __cplusplus diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in --- a/libcxx/include/module.modulemap.in +++ b/libcxx/include/module.modulemap.in @@ -169,6 +169,27 @@ module cmath { header "cmath" export * + + module __cmath { + module angular_functions { private header "__cmath/angular_functions.h" } + module arithmetic { private header "__cmath/arithmetic.h" } + module compare { private header "__cmath/compare.h" } + module copysign { private header "__cmath/copysign.h" } + module fabs { private header "__cmath/fabs.h" } + module fdim { private header "__cmath/fdim.h" } + module fminmax { private header "__cmath/fminmax.h" } + module frexp { private header "__cmath/frexp.h" } + module logarithm { private header "__cmath/logarithm.h" } + module modf { private header "__cmath/modf.h" } + module nextafter { private header "__cmath/nextafter.h" } + module nexttoward { private header "__cmath/nexttoward.h" } + module remainder { private header "__cmath/remainder.h" } + module remquo { private header "__cmath/remquo.h" } + module rounding { private header "__cmath/rounding.h" } + module signbit { private header "__cmath/signbit.h" } + module tgamma { private header "__cmath/tgamma.h" } + module traits { private header "__cmath/traits.h" } + } } module csetjmp { header "csetjmp" diff --git a/libcxx/include/numeric b/libcxx/include/numeric --- a/libcxx/include/numeric +++ b/libcxx/include/numeric @@ -146,7 +146,6 @@ #include <__assert> // all public C++ headers provide the assertion handler #include <__config> -#include // for isnormal #include #include <__numeric/accumulate.h> diff --git a/libcxx/include/valarray b/libcxx/include/valarray --- a/libcxx/include/valarray +++ b/libcxx/include/valarray @@ -349,13 +349,15 @@ #include <__algorithm/min_element.h> #include <__algorithm/unwrap_iter.h> #include <__assert> // all public C++ headers provide the assertion handler +#include <__cmath/angular_functions.h> +#include <__cmath/arithmetic.h> +#include <__cmath/logarithm.h> #include <__config> #include <__functional/operations.h> #include <__memory/allocator.h> #include <__memory/uninitialized_algorithms.h> #include <__utility/move.h> #include <__utility/swap.h> -#include #include #include #include diff --git a/libcxx/src/include/to_chars_floating_point.h b/libcxx/src/include/to_chars_floating_point.h --- a/libcxx/src/include/to_chars_floating_point.h +++ b/libcxx/src/include/to_chars_floating_point.h @@ -519,7 +519,6 @@ #include #include #include -#include #include #include #include diff --git a/libcxx/test/libcxx/private_headers.verify.cpp b/libcxx/test/libcxx/private_headers.verify.cpp --- a/libcxx/test/libcxx/private_headers.verify.cpp +++ b/libcxx/test/libcxx/private_headers.verify.cpp @@ -260,6 +260,24 @@ #include <__chrono/year_month.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/year_month.h'}} #include <__chrono/year_month_day.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/year_month_day.h'}} #include <__chrono/year_month_weekday.h> // expected-error@*:* {{use of private header from outside its module: '__chrono/year_month_weekday.h'}} +#include <__cmath/angular_functions.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/angular_functions.h'}} +#include <__cmath/arithmetic.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/arithmetic.h'}} +#include <__cmath/compare.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/compare.h'}} +#include <__cmath/copysign.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/copysign.h'}} +#include <__cmath/fabs.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/fabs.h'}} +#include <__cmath/fdim.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/fdim.h'}} +#include <__cmath/fminmax.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/fminmax.h'}} +#include <__cmath/frexp.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/frexp.h'}} +#include <__cmath/logarithm.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/logarithm.h'}} +#include <__cmath/modf.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/modf.h'}} +#include <__cmath/nextafter.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/nextafter.h'}} +#include <__cmath/nexttoward.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/nexttoward.h'}} +#include <__cmath/remainder.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/remainder.h'}} +#include <__cmath/remquo.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/remquo.h'}} +#include <__cmath/rounding.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/rounding.h'}} +#include <__cmath/signbit.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/signbit.h'}} +#include <__cmath/tgamma.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/tgamma.h'}} +#include <__cmath/traits.h> // expected-error@*:* {{use of private header from outside its module: '__cmath/traits.h'}} #include <__compare/common_comparison_category.h> // expected-error@*:* {{use of private header from outside its module: '__compare/common_comparison_category.h'}} #include <__compare/compare_partial_order_fallback.h> // expected-error@*:* {{use of private header from outside its module: '__compare/compare_partial_order_fallback.h'}} #include <__compare/compare_strong_order_fallback.h> // expected-error@*:* {{use of private header from outside its module: '__compare/compare_strong_order_fallback.h'}} diff --git a/libcxx/test/libcxx/transitive_includes/cxx2b.csv b/libcxx/test/libcxx/transitive_includes/cxx2b.csv --- a/libcxx/test/libcxx/transitive_includes/cxx2b.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx2b.csv @@ -52,7 +52,6 @@ bitset string ccomplex complex charconv cerrno -charconv cmath charconv concepts charconv cstdlib charconv cstring @@ -85,7 +84,7 @@ codecvt stdexcept codecvt type_traits codecvt typeinfo -compare cmath +compare limits compare type_traits complex cmath complex iosfwd @@ -178,7 +177,6 @@ experimental/vector experimental/memory_resource experimental/vector vector ext/hash_map algorithm -ext/hash_map cmath ext/hash_map concepts ext/hash_map cstddef ext/hash_map cstring @@ -189,7 +187,6 @@ ext/hash_map string ext/hash_map type_traits ext/hash_set algorithm -ext/hash_set cmath ext/hash_set concepts ext/hash_set cstddef ext/hash_set cstring @@ -355,8 +352,10 @@ new cstdlib new exception numbers concepts -numeric cmath numeric concepts +numeric limits +numeric type_traits +numeric version optional compare optional cstddef optional cstring @@ -506,7 +505,6 @@ typeinfo cstddef typeinfo cstdint typeinfo exception -unordered_map cmath unordered_map concepts unordered_map cstdlib unordered_map cstring @@ -517,7 +515,6 @@ unordered_map stdexcept unordered_map tuple unordered_map type_traits -unordered_set cmath unordered_set concepts unordered_set cstdlib unordered_set cstring @@ -533,7 +530,6 @@ utility initializer_list utility limits utility type_traits -valarray cmath valarray concepts valarray cstdlib valarray cstring