From fb7f07e3bd48e770c419d75e30831716d948fc25 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Fri, 13 May 2011 21:52:40 +0000 Subject: [PATCH] http://llvm.org/bugs/show_bug.cgi?id=9854. Also created an emulated hexfloat literal for use in some of the tests. And cleaned up some harmless but irritating warnings in the tests. llvm-svn: 131318 --- libcxx/include/cmath | 898 +++++++++--------- libcxx/include/iosfwd | 1 + .../test/depr/depr.c.headers/math_h.pass.cpp | 144 +-- .../test/depr/depr.c.headers/stdio_h.pass.cpp | 16 +- libcxx/test/hexfloat.h | 37 + .../facet.num.get.members/get_double.pass.cpp | 3 +- .../facet.num.get.members/get_float.pass.cpp | 3 +- .../get_long_double.pass.cpp | 3 +- libcxx/test/numerics/c.math/cmath.pass.cpp | 6 +- 9 files changed, 573 insertions(+), 538 deletions(-) create mode 100644 libcxx/test/hexfloat.h diff --git a/libcxx/include/cmath b/libcxx/include/cmath index ae507775d6c7..f8bc0dfc66a7 100644 --- a/libcxx/include/cmath +++ b/libcxx/include/cmath @@ -303,673 +303,663 @@ long double truncl(long double x); #pragma GCC system_header -_LIBCPP_BEGIN_NAMESPACE_STD - -using ::float_t; -using ::double_t; +// signbit -// abs +#ifdef signbit template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, _A1>::type -abs(_A1 __x) {return fabs(__x);} - -// acos - -using ::acos; -using ::acosf; +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_signbit(_A1 __x) +{ + return signbit(__x); +} -inline _LIBCPP_INLINE_VISIBILITY float acos(float __x) {return acosf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __x) {return acosl(__x);} +#undef signbit template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -acos(_A1 __x) {return acos((double)__x);} +typename std::enable_if::value, bool>::type +signbit(_A1 __x) +{ + return __libcpp_signbit(__x); +} -// asin +#endif // signbit -using ::asin; -using ::asinf; +// fpclassify -inline _LIBCPP_INLINE_VISIBILITY float asin(float __x) {return asinf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __x) {return asinl(__x);} +#ifdef fpclassify template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -asin(_A1 __x) {return asin((double)__x);} - -// atan - -using ::atan; -using ::atanf; +_LIBCPP_ALWAYS_INLINE +int +__libcpp_fpclassify(_A1 __x) +{ + return fpclassify(__x); +} -inline _LIBCPP_INLINE_VISIBILITY float atan(float __x) {return atanf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __x) {return atanl(__x);} +#undef fpclassify template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -atan(_A1 __x) {return atan((double)__x);} +typename std::enable_if::value, int>::type +fpclassify(_A1 __x) +{ + return __libcpp_fpclassify(__x); +} -// atan2 +#endif // fpclassify -using ::atan2; -using ::atan2f; +// isfinite -inline _LIBCPP_INLINE_VISIBILITY float atan2(float __y, float __x) {return atan2f(__y, __x);} -inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __y, long double __x) {return atan2l(__y, __x);} +#ifdef isfinite -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - typename __promote<_A1, _A2>::type ->::type -atan2(_A1 __y, _A2 __x) +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isfinite(_A1 __x) { - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return atan2((__result_type)__y, (__result_type)__x); + return isfinite(__x); } -// ceil - -using ::ceil; -using ::ceilf; - -inline _LIBCPP_INLINE_VISIBILITY float ceil(float __x) {return ceilf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __x) {return ceill(__x);} +#undef isfinite template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -ceil(_A1 __x) {return ceil((double)__x);} +typename std::enable_if::value, bool>::type +isfinite(_A1 __x) +{ + return __libcpp_isfinite(__x); +} -// cos +#endif // isfinite -using ::cos; -using ::cosf; +// isinf -inline _LIBCPP_INLINE_VISIBILITY float cos(float __x) {return cosf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __x) {return cosl(__x);} +#ifdef isinf template -inline _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -cos(_A1 __x) {return cos((double)__x);} - -// cosh - -using ::cosh; -using ::coshf; +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isinf(_A1 __x) +{ + return isinf(__x); +} -inline _LIBCPP_INLINE_VISIBILITY float cosh(float __x) {return coshf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __x) {return coshl(__x);} +#undef isinf template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -cosh(_A1 __x) {return cosh((double)__x);} +typename std::enable_if::value, bool>::type +isinf(_A1 __x) +{ + return __libcpp_isinf(__x); +} -// exp +#endif // isinf -using ::exp; -using ::expf; +// isnan -inline _LIBCPP_INLINE_VISIBILITY float exp(float __x) {return expf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __x) {return expl(__x);} +#ifdef isnan template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -exp(_A1 __x) {return exp((double)__x);} - -// fabs - -using ::fabs; -using ::fabsf; +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isnan(_A1 __x) +{ + return isnan(__x); +} -inline _LIBCPP_INLINE_VISIBILITY float fabs(float __x) {return fabsf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __x) {return fabsl(__x);} +#undef isnan template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -fabs(_A1 __x) {return fabs((double)__x);} +typename std::enable_if::value, bool>::type +isnan(_A1 __x) +{ + return __libcpp_isnan(__x); +} -// floor +#endif // isnan -using ::floor; -using ::floorf; +// isnormal -inline _LIBCPP_INLINE_VISIBILITY float floor(float __x) {return floorf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __x) {return floorl(__x);} +#ifdef isnormal + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isnormal(_A1 __x) +{ + return isnormal(__x); +} + +#undef isnormal template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -floor(_A1 __x) {return floor((double)__x);} +typename std::enable_if::value, bool>::type +isnormal(_A1 __x) +{ + return __libcpp_isnormal(__x); +} -// fmod +#endif // isnormal -using ::fmod; -using ::fmodf; +// isgreater -inline _LIBCPP_INLINE_VISIBILITY float fmod(float __x, float __y) {return fmodf(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __x, long double __y) {return fmodl(__x, __y);} +#ifdef isgreater + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isgreater(_A1 __x, _A2 __y) +{ + return isgreater(__x, __y); +} + +#undef isgreater template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if +typename std::enable_if < - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - typename __promote<_A1, _A2>::type + std::is_floating_point<_A1>::value && + std::is_floating_point<_A2>::value, + bool >::type -fmod(_A1 __x, _A2 __y) +isgreater(_A1 __x, _A2 __y) { - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return fmod((__result_type)__x, (__result_type)__y); + return __libcpp_isgreater(__x, __y); } -// frexp - -using ::frexp; -using ::frexpf; - -inline _LIBCPP_INLINE_VISIBILITY float frexp(float __x, int* __e) {return frexpf(__x, __e);} -inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __x, int* __e) {return frexpl(__x, __e);} +#endif // isgreater -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -frexp(_A1 __x, int* __e) {return frexp((double)__x, __e);} +// isgreaterequal -// ldexp +#ifdef isgreaterequal -using ::ldexp; -using ::ldexpf; +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isgreaterequal(_A1 __x, _A2 __y) +{ + return isgreaterequal(__x, __y); +} -inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __x, int __e) {return ldexpf(__x, __e);} -inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __x, int __e) {return ldexpl(__x, __e);} +#undef isgreaterequal -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -ldexp(_A1 __x, int __e) {return ldexp((double)__x, __e);} +typename std::enable_if +< + std::is_floating_point<_A1>::value && + std::is_floating_point<_A2>::value, + bool +>::type +isgreaterequal(_A1 __x, _A2 __y) +{ + return __libcpp_isgreaterequal(__x, __y); +} -// log +#endif // isgreaterequal -using ::log; -using ::logf; +// isless -inline _LIBCPP_INLINE_VISIBILITY float log(float __x) {return logf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double log(long double __x) {return logl(__x);} +#ifdef isless -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -log(_A1 __x) {return log((double)__x);} +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isless(_A1 __x, _A2 __y) +{ + return isless(__x, __y); +} -// log10 +#undef isless -using ::log10; -using ::log10f; +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if +< + std::is_floating_point<_A1>::value && + std::is_floating_point<_A2>::value, + bool +>::type +isless(_A1 __x, _A2 __y) +{ + return __libcpp_isless(__x, __y); +} -inline _LIBCPP_INLINE_VISIBILITY float log10(float __x) {return log10f(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __x) {return log10l(__x);} +#endif // isless -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -log10(_A1 __x) {return log10((double)__x);} +// islessequal -// modf +#ifdef islessequal -using ::modf; -using ::modff; +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_islessequal(_A1 __x, _A2 __y) +{ + return islessequal(__x, __y); +} -inline _LIBCPP_INLINE_VISIBILITY float modf(float __x, float* __y) {return modff(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __x, long double* __y) {return modfl(__x, __y);} +#undef islessequal -// pow +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if +< + std::is_floating_point<_A1>::value && + std::is_floating_point<_A2>::value, + bool +>::type +islessequal(_A1 __x, _A2 __y) +{ + return __libcpp_islessequal(__x, __y); +} -using ::pow; -using ::powf; +#endif // islessequal -inline _LIBCPP_INLINE_VISIBILITY float pow(float __x, float __y) {return powf(__x, __y);} -inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __x, long double __y) {return powl(__x, __y);} +// islessgreater + +#ifdef islessgreater + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_islessgreater(_A1 __x, _A2 __y) +{ + return islessgreater(__x, __y); +} + +#undef islessgreater template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if +typename std::enable_if < - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - typename __promote<_A1, _A2>::type + std::is_floating_point<_A1>::value && + std::is_floating_point<_A2>::value, + bool >::type -pow(_A1 __x, _A2 __y) +islessgreater(_A1 __x, _A2 __y) { - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return pow((__result_type)__x, (__result_type)__y); + return __libcpp_islessgreater(__x, __y); } -// sin +#endif // islessgreater -using ::sin; -using ::sinf; +// isunordered -inline _LIBCPP_INLINE_VISIBILITY float sin(float __x) {return sinf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __x) {return sinl(__x);} +#ifdef isunordered -template +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isunordered(_A1 __x, _A2 __y) +{ + return isunordered(__x, __y); +} + +#undef isunordered + +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -sin(_A1 __x) {return sin((double)__x);} +typename std::enable_if +< + std::is_floating_point<_A1>::value && + std::is_floating_point<_A2>::value, + bool +>::type +isunordered(_A1 __x, _A2 __y) +{ + return __libcpp_isunordered(__x, __y); +} -// sinh +#endif // isunordered -using ::sinh; -using ::sinhf; +_LIBCPP_BEGIN_NAMESPACE_STD -inline _LIBCPP_INLINE_VISIBILITY float sinh(float __x) {return sinhf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __x) {return sinhl(__x);} +using ::signbit; +using ::fpclassify; +using ::isfinite; +using ::isinf; +using ::isnan; +using ::isnormal; +using ::isgreater; +using ::isgreaterequal; +using ::isless; +using ::islessequal; +using ::islessgreater; +using ::isunordered; +using ::isunordered; + +using ::float_t; +using ::double_t; + +// abs template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -sinh(_A1 __x) {return sinh((double)__x);} +typename enable_if::value, _A1>::type +abs(_A1 __x) {return fabs(__x);} -// sqrt +// acos -using ::sqrt; -using ::sqrtf; +using ::acos; +using ::acosf; -inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __x) {return sqrtf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __x) {return sqrtl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float acos(float __x) {return acosf(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __x) {return acosl(__x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -sqrt(_A1 __x) {return sqrt((double)__x);} +acos(_A1 __x) {return acos((double)__x);} -// tan +// asin -using ::tan; -using ::tanf; +using ::asin; +using ::asinf; -inline _LIBCPP_INLINE_VISIBILITY float tan(float __x) {return tanf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __x) {return tanl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float asin(float __x) {return asinf(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __x) {return asinl(__x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -tan(_A1 __x) {return tan((double)__x);} +asin(_A1 __x) {return asin((double)__x);} -// tanh +// atan -using ::tanh; -using ::tanhf; +using ::atan; +using ::atanf; -inline _LIBCPP_INLINE_VISIBILITY float tanh(float __x) {return tanhf(__x);} -inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __x) {return tanhl(__x);} +inline _LIBCPP_INLINE_VISIBILITY float atan(float __x) {return atanf(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __x) {return atanl(__x);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if::value, double>::type -tanh(_A1 __x) {return tanh((double)__x);} - -// signbit +atan(_A1 __x) {return atan((double)__x);} -#ifndef signbit -#error Implementation error: signbit not defined -#else +// atan2 -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_signbit(_A1 __x) -{ - return signbit(__x); -} +using ::atan2; +using ::atan2f; -#undef signbit +inline _LIBCPP_INLINE_VISIBILITY float atan2(float __y, float __x) {return atan2f(__y, __x);} +inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __y, long double __x) {return atan2l(__y, __x);} -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, bool>::type -signbit(_A1 __x) +typename enable_if +< + is_arithmetic<_A1>::value && + is_arithmetic<_A2>::value, + typename __promote<_A1, _A2>::type +>::type +atan2(_A1 __y, _A2 __x) { - return __libcpp_signbit(__x); + typedef typename __promote<_A1, _A2>::type __result_type; + static_assert((!(is_same<_A1, __result_type>::value && + is_same<_A2, __result_type>::value)), ""); + return atan2((__result_type)__y, (__result_type)__x); } -#endif // signbit - -// fpclassify - -#ifndef fpclassify -#error Implementation error: fpclassify not defined -#else +// ceil -template -_LIBCPP_ALWAYS_INLINE -int -__libcpp_fpclassify(_A1 __x) -{ - return fpclassify(__x); -} +using ::ceil; +using ::ceilf; -#undef fpclassify +inline _LIBCPP_INLINE_VISIBILITY float ceil(float __x) {return ceilf(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __x) {return ceill(__x);} template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, int>::type -fpclassify(_A1 __x) -{ - return __libcpp_fpclassify(__x); -} +typename enable_if::value, double>::type +ceil(_A1 __x) {return ceil((double)__x);} -#endif // fpclassify +// cos -// isfinite +using ::cos; +using ::cosf; -#ifndef isfinite -#error Implementation error: isfinite not defined -#else +inline _LIBCPP_INLINE_VISIBILITY float cos(float __x) {return cosf(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __x) {return cosl(__x);} template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isfinite(_A1 __x) -{ - return isfinite(__x); -} +inline _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY +typename enable_if::value, double>::type +cos(_A1 __x) {return cos((double)__x);} -#undef isfinite +// cosh + +using ::cosh; +using ::coshf; + +inline _LIBCPP_INLINE_VISIBILITY float cosh(float __x) {return coshf(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __x) {return coshl(__x);} template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, bool>::type -isfinite(_A1 __x) -{ - return __libcpp_isfinite(__x); -} +typename enable_if::value, double>::type +cosh(_A1 __x) {return cosh((double)__x);} -#endif // isfinite +// exp -// isinf +using ::exp; +using ::expf; -#ifndef isinf -#error Implementation error: isinf not defined -#else - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isinf(_A1 __x) -{ - return isinf(__x); -} - -#undef isinf +inline _LIBCPP_INLINE_VISIBILITY float exp(float __x) {return expf(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __x) {return expl(__x);} template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, bool>::type -isinf(_A1 __x) -{ - return __libcpp_isinf(__x); -} - -#endif // isinf - -// isnan +typename enable_if::value, double>::type +exp(_A1 __x) {return exp((double)__x);} -#ifndef isnan -#error Implementation error: isnan not defined -#else +// fabs -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isnan(_A1 __x) -{ - return isnan(__x); -} +using ::fabs; +using ::fabsf; -#undef isnan +inline _LIBCPP_INLINE_VISIBILITY float fabs(float __x) {return fabsf(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __x) {return fabsl(__x);} template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, bool>::type -isnan(_A1 __x) -{ - return __libcpp_isnan(__x); -} - -#endif // isnan - -// isnormal +typename enable_if::value, double>::type +fabs(_A1 __x) {return fabs((double)__x);} -#ifndef isnormal -#error Implementation error: isnormal not defined -#else +// floor -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isnormal(_A1 __x) -{ - return isnormal(__x); -} +using ::floor; +using ::floorf; -#undef isnormal +inline _LIBCPP_INLINE_VISIBILITY float floor(float __x) {return floorf(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __x) {return floorl(__x);} template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, bool>::type -isnormal(_A1 __x) -{ - return __libcpp_isnormal(__x); -} - -#endif // isnormal - -// isgreater +typename enable_if::value, double>::type +floor(_A1 __x) {return floor((double)__x);} -#ifndef isgreater -#error Implementation error: isgreater not defined -#else +// fmod -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isgreater(_A1 __x, _A2 __y) -{ - return isgreater(__x, __y); -} +using ::fmod; +using ::fmodf; -#undef isgreater +inline _LIBCPP_INLINE_VISIBILITY float fmod(float __x, float __y) {return fmodf(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __x, long double __y) {return fmodl(__x, __y);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < - is_floating_point<_A1>::value && - is_floating_point<_A2>::value, - bool + is_arithmetic<_A1>::value && + is_arithmetic<_A2>::value, + typename __promote<_A1, _A2>::type >::type -isgreater(_A1 __x, _A2 __y) +fmod(_A1 __x, _A2 __y) { - return __libcpp_isgreater(__x, __y); + typedef typename __promote<_A1, _A2>::type __result_type; + static_assert((!(is_same<_A1, __result_type>::value && + is_same<_A2, __result_type>::value)), ""); + return fmod((__result_type)__x, (__result_type)__y); } -#endif // isgreater +// frexp -// isgreaterequal +using ::frexp; +using ::frexpf; -#ifndef isgreaterequal -#error Implementation error: isgreaterequal not defined -#else +inline _LIBCPP_INLINE_VISIBILITY float frexp(float __x, int* __e) {return frexpf(__x, __e);} +inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __x, int* __e) {return frexpl(__x, __e);} -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isgreaterequal(_A1 __x, _A2 __y) -{ - return isgreaterequal(__x, __y); -} +template +inline _LIBCPP_INLINE_VISIBILITY +typename enable_if::value, double>::type +frexp(_A1 __x, int* __e) {return frexp((double)__x, __e);} -#undef isgreaterequal +// ldexp -template +using ::ldexp; +using ::ldexpf; + +inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __x, int __e) {return ldexpf(__x, __e);} +inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __x, int __e) {return ldexpl(__x, __e);} + +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_floating_point<_A1>::value && - is_floating_point<_A2>::value, - bool ->::type -isgreaterequal(_A1 __x, _A2 __y) -{ - return __libcpp_isgreaterequal(__x, __y); -} +typename enable_if::value, double>::type +ldexp(_A1 __x, int __e) {return ldexp((double)__x, __e);} -#endif // isgreaterequal +// log -// isless +using ::log; +using ::logf; -#ifndef isless -#error Implementation error: isless not defined -#else +inline _LIBCPP_INLINE_VISIBILITY float log(float __x) {return logf(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double log(long double __x) {return logl(__x);} -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isless(_A1 __x, _A2 __y) -{ - return isless(__x, __y); -} +template +inline _LIBCPP_INLINE_VISIBILITY +typename enable_if::value, double>::type +log(_A1 __x) {return log((double)__x);} -#undef isless +// log10 -template +using ::log10; +using ::log10f; + +inline _LIBCPP_INLINE_VISIBILITY float log10(float __x) {return log10f(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __x) {return log10l(__x);} + +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_floating_point<_A1>::value && - is_floating_point<_A2>::value, - bool ->::type -isless(_A1 __x, _A2 __y) -{ - return __libcpp_isless(__x, __y); -} +typename enable_if::value, double>::type +log10(_A1 __x) {return log10((double)__x);} -#endif // isless +// modf -// islessequal +using ::modf; +using ::modff; -#ifndef islessequal -#error Implementation error: islessequal not defined -#else +inline _LIBCPP_INLINE_VISIBILITY float modf(float __x, float* __y) {return modff(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __x, long double* __y) {return modfl(__x, __y);} -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_islessequal(_A1 __x, _A2 __y) -{ - return islessequal(__x, __y); -} +// pow -#undef islessequal +using ::pow; +using ::powf; + +inline _LIBCPP_INLINE_VISIBILITY float pow(float __x, float __y) {return powf(__x, __y);} +inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __x, long double __y) {return powl(__x, __y);} template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < - is_floating_point<_A1>::value && - is_floating_point<_A2>::value, - bool + is_arithmetic<_A1>::value && + is_arithmetic<_A2>::value, + typename __promote<_A1, _A2>::type >::type -islessequal(_A1 __x, _A2 __y) +pow(_A1 __x, _A2 __y) { - return __libcpp_islessequal(__x, __y); + typedef typename __promote<_A1, _A2>::type __result_type; + static_assert((!(is_same<_A1, __result_type>::value && + is_same<_A2, __result_type>::value)), ""); + return pow((__result_type)__x, (__result_type)__y); } -#endif // islessequal +// sin -// islessgreater +using ::sin; +using ::sinf; -#ifndef islessgreater -#error Implementation error: islessgreater not defined -#else +inline _LIBCPP_INLINE_VISIBILITY float sin(float __x) {return sinf(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __x) {return sinl(__x);} -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_islessgreater(_A1 __x, _A2 __y) -{ - return islessgreater(__x, __y); -} +template +inline _LIBCPP_INLINE_VISIBILITY +typename enable_if::value, double>::type +sin(_A1 __x) {return sin((double)__x);} -#undef islessgreater +// sinh -template +using ::sinh; +using ::sinhf; + +inline _LIBCPP_INLINE_VISIBILITY float sinh(float __x) {return sinhf(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __x) {return sinhl(__x);} + +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_floating_point<_A1>::value && - is_floating_point<_A2>::value, - bool ->::type -islessgreater(_A1 __x, _A2 __y) -{ - return __libcpp_islessgreater(__x, __y); -} +typename enable_if::value, double>::type +sinh(_A1 __x) {return sinh((double)__x);} -#endif // islessgreater +// sqrt -// isunordered +using ::sqrt; +using ::sqrtf; -#ifndef isunordered -#error Implementation error: isunordered not defined -#else +inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __x) {return sqrtf(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __x) {return sqrtl(__x);} -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isunordered(_A1 __x, _A2 __y) -{ - return isunordered(__x, __y); -} +template +inline _LIBCPP_INLINE_VISIBILITY +typename enable_if::value, double>::type +sqrt(_A1 __x) {return sqrt((double)__x);} -#undef isunordered +// tan -template +using ::tan; +using ::tanf; + +inline _LIBCPP_INLINE_VISIBILITY float tan(float __x) {return tanf(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __x) {return tanl(__x);} + +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_floating_point<_A1>::value && - is_floating_point<_A2>::value, - bool ->::type -isunordered(_A1 __x, _A2 __y) -{ - return __libcpp_isunordered(__x, __y); -} +typename enable_if::value, double>::type +tan(_A1 __x) {return tan((double)__x);} -#endif // isunordered +// tanh + +using ::tanh; +using ::tanhf; + +inline _LIBCPP_INLINE_VISIBILITY float tanh(float __x) {return tanhf(__x);} +inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __x) {return tanhl(__x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename enable_if::value, double>::type +tanh(_A1 __x) {return tanh((double)__x);} // acosh diff --git a/libcxx/include/iosfwd b/libcxx/include/iosfwd index 0e5c683ac0b7..852d9e5f3e8b 100644 --- a/libcxx/include/iosfwd +++ b/libcxx/include/iosfwd @@ -20,6 +20,7 @@ namespace std template struct char_traits; template class allocator; +class ios_base; template > class basic_ios; template > class basic_streambuf; diff --git a/libcxx/test/depr/depr.c.headers/math_h.pass.cpp b/libcxx/test/depr/depr.c.headers/math_h.pass.cpp index 3ba34196f860..9bc3116eb457 100644 --- a/libcxx/test/depr/depr.c.headers/math_h.pass.cpp +++ b/libcxx/test/depr/depr.c.headers/math_h.pass.cpp @@ -13,6 +13,8 @@ #include #include +#include "../../hexfloat.h" + void test_acos() { static_assert((std::is_same::value), ""); @@ -194,9 +196,9 @@ void test_tanh() void test_signbit() { - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(signbit(-1.0) == true); } @@ -210,117 +212,117 @@ void test_fpclassify() void test_isfinite() { - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(isfinite(-1.0) == true); } void test_isinf() { - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(isinf(-1.0) == false); } void test_isnan() { - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(isnan(-1.0) == false); } void test_isnormal() { - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(isnormal(-1.0) == true); } void test_isgreater() { - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(isgreater(-1.0, 0.F) == false); } void test_isgreaterequal() { - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(isgreaterequal(-1.0, 0.F) == false); } void test_isless() { - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(isless(-1.0, 0.F) == true); } void test_islessequal() { - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(islessequal(-1.0, 0.F) == true); } void test_islessgreater() { - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(islessgreater(-1.0, 0.F) == true); } void test_isunordered() { - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(isunordered(-1.0, 0.F) == false); } @@ -528,7 +530,7 @@ void test_nextafter() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - assert(nextafter(0,1) == 0x1p-1074); + assert(nextafter(0,1) == hexfloat(0x1, 0, -1074)); } void test_nexttoward() @@ -536,7 +538,7 @@ void test_nexttoward() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - assert(nexttoward(0, 1) == 0x1p-1074); + assert(nexttoward(0, 1) == hexfloat(0x1, 0, -1074)); } void test_remainder() diff --git a/libcxx/test/depr/depr.c.headers/stdio_h.pass.cpp b/libcxx/test/depr/depr.c.headers/stdio_h.pass.cpp index 850200d755a0..50e1c80d4249 100644 --- a/libcxx/test/depr/depr.c.headers/stdio_h.pass.cpp +++ b/libcxx/test/depr/depr.c.headers/stdio_h.pass.cpp @@ -95,19 +95,19 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); diff --git a/libcxx/test/hexfloat.h b/libcxx/test/hexfloat.h new file mode 100644 index 000000000000..907de02c584f --- /dev/null +++ b/libcxx/test/hexfloat.h @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Define a hexfloat literal emulator since we can't depend on being able to +// for hexfloat literals + +// 0x10.F5p-10 == hexfloat(0x10, 0xF5, -10) + +#ifndef HEXFLOAT_H +#define HEXFLOAT_H + +#include +#include +#include + +template +class hexfloat +{ + T value_; +public: + hexfloat(unsigned long long m1, unsigned long long m0, int exp) + { + const std::size_t n = sizeof(unsigned long long) * CHAR_BIT; + value_ = std::ldexp(m1 + std::ldexp(T(m0), -static_cast(n - + std::__clz(m0))), exp); + } + + operator T() const {return value_;} +}; + +#endif diff --git a/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp b/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp index cf30ea34676e..4fa9b0a877f0 100644 --- a/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp +++ b/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp @@ -20,6 +20,7 @@ #include #include #include "iterators.h" +#include "../../../../../hexfloat.h" typedef std::num_get > F; @@ -105,7 +106,7 @@ int main() ios, err, v); assert(iter.base() == str+sizeof(str)-1); assert(err == ios.goodbit); - assert(v == 0x125p-1); + assert(v == hexfloat(0x125, 0, -1)); } { const char str[] = "inf"; diff --git a/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp b/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp index 00f9400e7014..c61dcdaf846b 100644 --- a/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp +++ b/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp @@ -20,6 +20,7 @@ #include #include #include "iterators.h" +#include "../../../../../hexfloat.h" typedef std::num_get > F; @@ -93,7 +94,7 @@ int main() ios, err, v); assert(iter.base() == str+sizeof(str)-1); assert(err == ios.goodbit); - assert(v == 0x125p-1); + assert(v == hexfloat(0x125, 0, -1)); } { const char str[] = "inf"; diff --git a/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp b/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp index 89019fe2b393..d39ba0acee29 100644 --- a/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp +++ b/libcxx/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp @@ -20,6 +20,7 @@ #include #include #include "iterators.h" +#include "../../../../../hexfloat.h" typedef std::num_get > F; @@ -93,7 +94,7 @@ int main() ios, err, v); assert(iter.base() == str+sizeof(str)-1); assert(err == ios.goodbit); - assert(v == 0x125p-1); + assert(v == hexfloat(0x125, 0, -1)); } { const char str[] = "inf"; diff --git a/libcxx/test/numerics/c.math/cmath.pass.cpp b/libcxx/test/numerics/c.math/cmath.pass.cpp index 84d695e21d94..7fa763b66bbc 100644 --- a/libcxx/test/numerics/c.math/cmath.pass.cpp +++ b/libcxx/test/numerics/c.math/cmath.pass.cpp @@ -13,6 +13,8 @@ #include #include +#include "../../hexfloat.h" + void test_abs() { static_assert((std::is_same::value), ""); @@ -1089,7 +1091,7 @@ void test_nextafter() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - assert(std::nextafter(0,1) == 0x1p-1074); + assert(std::nextafter(0,1) == hexfloat(0x1, 0, -1074)); } void test_nexttoward() @@ -1107,7 +1109,7 @@ void test_nexttoward() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - assert(std::nexttoward(0, 1) == 0x1p-1074); + assert(std::nexttoward(0, 1) == hexfloat(0x1, 0, -1074)); } void test_remainder() -- GitLab