diff options
author | Martin Liska <mliska@suse.cz> | 2022-10-19 15:25:12 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2022-10-19 15:25:12 +0200 |
commit | 4465e2a047c3b175bf6c4ca500547eb6b12df52f (patch) | |
tree | 3159c8256f9907538f186ce7c1087c83825b5519 /libstdc++-v3 | |
parent | 6c22519f33270a689fc8730ceff9212b376ed40d (diff) | |
parent | 09fed44cabd50f3d8e050f91cc2db02364ce9176 (diff) | |
download | gcc-4465e2a047c3b175bf6c4ca500547eb6b12df52f.zip gcc-4465e2a047c3b175bf6c4ca500547eb6b12df52f.tar.gz gcc-4465e2a047c3b175bf6c4ca500547eb6b12df52f.tar.bz2 |
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'libstdc++-v3')
27 files changed, 3496 insertions, 67 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 9ff3e3f..09988f6 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,71 @@ +2022-10-18 Patrick Palka <ppalka@redhat.com> + + * include/std/ranges (stride_view): Define. + (stride_view::_Iterator): Define. + (views::__detail::__can_stride_view): Define. + (views::_Stride, views::stride): Define. + * testsuite/std/ranges/adaptors/stride/1.cc: New test. + +2022-10-18 Jakub Jelinek <jakub@redhat.com> + + PR c++/106652 + * include/std/stdfloat: New file. + * include/std/numbers (__glibcxx_numbers): Define and use it + for __float128 explicit instantiations as well as + _Float{16,32,64,128} and __gnu_cxx::__bfloat16_t. + * include/std/atomic (atomic<_Float16>, atomic<_Float32>, + atomic<_Float64>, atomic<_Float128>, atomic<__gnu_cxx::__bfloat16_t>): + New explicit instantiations. + * include/std/type_traits (__is_floating_point_helper<_Float16>, + __is_floating_point_helper<_Float32>, + __is_floating_point_helper<_Float64>, + __is_floating_point_helper<_Float128>, + __is_floating_point_helper<__gnu_cxx::__bfloat16_t>): Likewise. + * include/std/limits (__glibcxx_concat3_, __glibcxx_concat3, + __glibcxx_float_n): Define. + (numeric_limits<_Float16>, numeric_limits<_Float32>, + numeric_limits<_Float64>, numeric_limits<_Float128>, + numeric_limits<__gnu_cxx::__bfloat16_t>): New explicit instantiations. + * include/bits/std_abs.h (abs): New overloads for + _Float{16,32,64,128} and __gnu_cxx::__bfloat16_t. + * include/bits/c++config (_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128): Define + if long double is IEEE quad. + (__gnu_cxx::__bfloat16_t): New using. + * include/c_global/cmath (acos, asin, atan, atan2, ceil, cos, cosh, + exp, fabs, floor, fmod, frexp, ldexp, log, log10, modf, pow, sin, + sinh, sqrt, tan, tanh, fpclassify, isfinite, isinf, isnan, isnormal, + signbit, isgreater, isgreaterequal, isless, islessequal, + islessgreater, isunordered, acosh, asinh, atanh, cbrt, copysign, erf, + erfc, exp2, expm1, fdim, fma, fmax, fmin, hypot, ilogb, lgamma, + llrint, llround, log1p, log2, logb, lrint, lround, nearbyint, + nextafter, remainder, rint, round, scalbln, scalbn, tgamma, trunc, + lerp): New overloads with _Float{16,32,64,128} or + __gnu_cxx::__bfloat16_t types. + * config/os/gnu-linux/os_defines.h (_GLIBCXX_HAVE_FLOAT128_MATH): + Prepare for definition if glibc 2.26 and later implements *f128 APIs + but comment out the actual definition for now. + * include/ext/type_traits.h (__promote<_Float16>, __promote<_Float32>, + __promote<_Float64>, __promote<_Float128>, + __promote<__gnu_cxx::__bfloat16_t>): New specializations. + * include/Makefile.am (std_headers): Add stdfloat. + * include/Makefile.in: Regenerated. + * include/precompiled/stdc++.h: Include stdfloat. + * testsuite/18_support/headers/stdfloat/types_std.cc: New test. + * testsuite/18_support/headers/limits/synopsis_cxx23.cc: New test. + * testsuite/26_numerics/headers/cmath/c99_classification_macros_c++23.cc: + New test. + * testsuite/26_numerics/headers/cmath/functions_std_c++23.cc: New test. + * testsuite/26_numerics/numbers/4.cc: New test. + * testsuite/29_atomics/atomic_float/requirements_cxx23.cc: New test. + +2022-10-17 Jonathan Wakely <jwakely@redhat.com> + + * include/std/charconv (__cpp_lib_constexpr_charconv): Define to + correct value. + * include/std/version (__cpp_lib_constexpr_charconv): Likewise. + * testsuite/20_util/to_chars/constexpr.cc: Check correct value. + * testsuite/20_util/to_chars/version.cc: Likewise. + 2022-10-15 Jonathan Wakely <jwakely@redhat.com> * src/c++11/debug.cc (print_raw): Move inside #if block. diff --git a/libstdc++-v3/config/os/gnu-linux/os_defines.h b/libstdc++-v3/config/os/gnu-linux/os_defines.h index c0caa21..e5b640a 100644 --- a/libstdc++-v3/config/os/gnu-linux/os_defines.h +++ b/libstdc++-v3/config/os/gnu-linux/os_defines.h @@ -49,6 +49,17 @@ // version dynamically in case it has changed since libstdc++ was configured. #define _GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC __GLIBC_PREREQ(2,23) +// Glibc 2.26 on i?86/x86-64/ia64/ppc64le added *f128 support. +// Glibc 2.27 added it also on many other arches but those have IEEE quad +// long double. +#if __GLIBC_PREREQ(2, 26) \ + && (defined(__i386__) || defined(__x86_64__) || defined (__ia64__) \ + || (defined(__powerpc__) && defined(_ARCH_PWR8) \ + && defined(__LITTLE_ENDIAN__) && (_CALL_ELF == 2) \ + && defined(__FLOAT128__))) +//# define _GLIBCXX_HAVE_FLOAT128_MATH 1 +#endif + #if __GLIBC_PREREQ(2, 27) // Since glibc 2.27 pthread_self() is usable without linking to libpthread. # define _GLIBCXX_NATIVE_THREAD_ID pthread_self() diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 9754252..96137a6 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -95,6 +95,7 @@ std_headers = \ ${std_srcdir}/stack \ ${std_srcdir}/stacktrace \ ${std_srcdir}/stdexcept \ + ${std_srcdir}/stdfloat \ ${std_srcdir}/stop_token \ ${std_srcdir}/streambuf \ ${std_srcdir}/string \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 0a3a1e3..dac7765 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -452,6 +452,7 @@ std_freestanding = \ @GLIBCXX_HOSTED_TRUE@ ${std_srcdir}/stack \ @GLIBCXX_HOSTED_TRUE@ ${std_srcdir}/stacktrace \ @GLIBCXX_HOSTED_TRUE@ ${std_srcdir}/stdexcept \ +@GLIBCXX_HOSTED_TRUE@ ${std_srcdir}/stdfloat \ @GLIBCXX_HOSTED_TRUE@ ${std_srcdir}/stop_token \ @GLIBCXX_HOSTED_TRUE@ ${std_srcdir}/streambuf \ @GLIBCXX_HOSTED_TRUE@ ${std_srcdir}/string \ diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index 191880f..5040606 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -796,6 +796,20 @@ namespace std # define _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 1 #endif +// Define if long double has the IEEE binary128 format. +#if __LDBL_MANT_DIG__ == 113 \ + && __LDBL_MIN_EXP__ == -16381 \ + && __LDBL_MAX_EXP__ == 16384 +# define _GLIBCXX_LDOUBLE_IS_IEEE_BINARY128 1 +#endif + +#ifdef __STDCPP_BFLOAT16_T__ +namespace __gnu_cxx +{ + using __bfloat16_t = decltype(0.0bf16); +} +#endif + #ifdef __has_builtin # ifdef __is_identifier // Intel and older Clang require !__is_identifier for some built-ins: diff --git a/libstdc++-v3/include/bits/std_abs.h b/libstdc++-v3/include/bits/std_abs.h index c8d589d..3363e71 100644 --- a/libstdc++-v3/include/bits/std_abs.h +++ b/libstdc++-v3/include/bits/std_abs.h @@ -97,6 +97,40 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION abs(__GLIBCXX_TYPE_INT_N_3 __x) { return __x >= 0 ? __x : -__x; } #endif +#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + constexpr _Float16 + abs(_Float16 __x) + { return _Float16(__builtin_fabsf(__x)); } +#endif + +#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + constexpr _Float32 + abs(_Float32 __x) + { return __builtin_fabsf(__x); } +#endif + +#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) + constexpr _Float64 + abs(_Float64 __x) + { return __builtin_fabs(__x); } +#endif + +#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) + constexpr _Float128 + abs(_Float128 __x) + { return __builtin_fabsl(__x); } +#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH) + constexpr _Float128 + abs(_Float128 __x) + { return __builtin_fabsf128(__x); } +#endif + +#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + constexpr __gnu_cxx::__bfloat16_t + abs(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_fabsf(__x)); } +#endif + #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) __extension__ inline _GLIBCXX_CONSTEXPR __float128 diff --git a/libstdc++-v3/include/c_global/cmath b/libstdc++-v3/include/c_global/cmath index cc14982..555d644 100644 --- a/libstdc++-v3/include/c_global/cmath +++ b/libstdc++-v3/include/c_global/cmath @@ -515,6 +515,564 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION tanh(_Tp __x) { return __builtin_tanh(__x); } +#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + constexpr _Float16 + acos(_Float16 __x) + { return _Float16(__builtin_acosf(__x)); } + + constexpr _Float16 + asin(_Float16 __x) + { return _Float16(__builtin_asinf(__x)); } + + constexpr _Float16 + atan(_Float16 __x) + { return _Float16(__builtin_atanf(__x)); } + + constexpr _Float16 + atan2(_Float16 __y, _Float16 __x) + { return _Float16(__builtin_atan2f(__y, __x)); } + + constexpr _Float16 + ceil(_Float16 __x) + { return _Float16(__builtin_ceilf(__x)); } + + constexpr _Float16 + cos(_Float16 __x) + { return _Float16(__builtin_cosf(__x)); } + + constexpr _Float16 + cosh(_Float16 __x) + { return _Float16(__builtin_coshf(__x)); } + + constexpr _Float16 + exp(_Float16 __x) + { return _Float16(__builtin_expf(__x)); } + + constexpr _Float16 + fabs(_Float16 __x) + { return _Float16(__builtin_fabsf(__x)); } + + constexpr _Float16 + floor(_Float16 __x) + { return _Float16(__builtin_floorf(__x)); } + + constexpr _Float16 + fmod(_Float16 __x, _Float16 __y) + { return _Float16(__builtin_fmodf(__x, __y)); } + + inline _Float16 + frexp(_Float16 __x, int* __exp) + { return _Float16(__builtin_frexpf(__x, __exp)); } + + constexpr _Float16 + ldexp(_Float16 __x, int __exp) + { return _Float16(__builtin_ldexpf(__x, __exp)); } + + constexpr _Float16 + log(_Float16 __x) + { return _Float16(__builtin_logf(__x)); } + + constexpr _Float16 + log10(_Float16 __x) + { return _Float16(__builtin_log10f(__x)); } + + inline _Float16 + modf(_Float16 __x, _Float16* __iptr) + { + float __i, __ret = __builtin_modff(__x, &__i); + *__iptr = _Float16(__i); + return _Float16(__ret); + } + + constexpr _Float16 + pow(_Float16 __x, _Float16 __y) + { return _Float16(__builtin_powf(__x, __y)); } + + constexpr _Float16 + sin(_Float16 __x) + { return _Float16(__builtin_sinf(__x)); } + + constexpr _Float16 + sinh(_Float16 __x) + { return _Float16(__builtin_sinhf(__x)); } + + constexpr _Float16 + sqrt(_Float16 __x) + { return _Float16(__builtin_sqrtf(__x)); } + + constexpr _Float16 + tan(_Float16 __x) + { return _Float16(__builtin_tanf(__x)); } + + constexpr _Float16 + tanh(_Float16 __x) + { return _Float16(__builtin_tanhf(__x)); } +#endif + +#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + constexpr _Float32 + acos(_Float32 __x) + { return __builtin_acosf(__x); } + + constexpr _Float32 + asin(_Float32 __x) + { return __builtin_asinf(__x); } + + constexpr _Float32 + atan(_Float32 __x) + { return __builtin_atanf(__x); } + + constexpr _Float32 + atan2(_Float32 __y, _Float32 __x) + { return __builtin_atan2f(__y, __x); } + + constexpr _Float32 + ceil(_Float32 __x) + { return __builtin_ceilf(__x); } + + constexpr _Float32 + cos(_Float32 __x) + { return __builtin_cosf(__x); } + + constexpr _Float32 + cosh(_Float32 __x) + { return __builtin_coshf(__x); } + + constexpr _Float32 + exp(_Float32 __x) + { return __builtin_expf(__x); } + + constexpr _Float32 + fabs(_Float32 __x) + { return __builtin_fabsf(__x); } + + constexpr _Float32 + floor(_Float32 __x) + { return __builtin_floorf(__x); } + + constexpr _Float32 + fmod(_Float32 __x, _Float32 __y) + { return __builtin_fmodf(__x, __y); } + + inline _Float32 + frexp(_Float32 __x, int* __exp) + { return __builtin_frexpf(__x, __exp); } + + constexpr _Float32 + ldexp(_Float32 __x, int __exp) + { return __builtin_ldexpf(__x, __exp); } + + constexpr _Float32 + log(_Float32 __x) + { return __builtin_logf(__x); } + + constexpr _Float32 + log10(_Float32 __x) + { return __builtin_log10f(__x); } + + inline _Float32 + modf(_Float32 __x, _Float32* __iptr) + { + float __i, __ret = __builtin_modff(__x, &__i); + *__iptr = __i; + return __ret; + } + + constexpr _Float32 + pow(_Float32 __x, _Float32 __y) + { return __builtin_powf(__x, __y); } + + constexpr _Float32 + sin(_Float32 __x) + { return __builtin_sinf(__x); } + + constexpr _Float32 + sinh(_Float32 __x) + { return __builtin_sinhf(__x); } + + constexpr _Float32 + sqrt(_Float32 __x) + { return __builtin_sqrtf(__x); } + + constexpr _Float32 + tan(_Float32 __x) + { return __builtin_tanf(__x); } + + constexpr _Float32 + tanh(_Float32 __x) + { return __builtin_tanhf(__x); } +#endif + +#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) + constexpr _Float64 + acos(_Float64 __x) + { return __builtin_acos(__x); } + + constexpr _Float64 + asin(_Float64 __x) + { return __builtin_asin(__x); } + + constexpr _Float64 + atan(_Float64 __x) + { return __builtin_atan(__x); } + + constexpr _Float64 + atan2(_Float64 __y, _Float64 __x) + { return __builtin_atan2(__y, __x); } + + constexpr _Float64 + ceil(_Float64 __x) + { return __builtin_ceil(__x); } + + constexpr _Float64 + cos(_Float64 __x) + { return __builtin_cos(__x); } + + constexpr _Float64 + cosh(_Float64 __x) + { return __builtin_cosh(__x); } + + constexpr _Float64 + exp(_Float64 __x) + { return __builtin_exp(__x); } + + constexpr _Float64 + fabs(_Float64 __x) + { return __builtin_fabs(__x); } + + constexpr _Float64 + floor(_Float64 __x) + { return __builtin_floor(__x); } + + constexpr _Float64 + fmod(_Float64 __x, _Float64 __y) + { return __builtin_fmod(__x, __y); } + + inline _Float64 + frexp(_Float64 __x, int* __exp) + { return __builtin_frexp(__x, __exp); } + + constexpr _Float64 + ldexp(_Float64 __x, int __exp) + { return __builtin_ldexp(__x, __exp); } + + constexpr _Float64 + log(_Float64 __x) + { return __builtin_log(__x); } + + constexpr _Float64 + log10(_Float64 __x) + { return __builtin_log10(__x); } + + inline _Float64 + modf(_Float64 __x, _Float64* __iptr) + { + double __i, __ret = __builtin_modf(__x, &__i); + *__iptr = __i; + return __ret; + } + + constexpr _Float64 + pow(_Float64 __x, _Float64 __y) + { return __builtin_pow(__x, __y); } + + constexpr _Float64 + sin(_Float64 __x) + { return __builtin_sin(__x); } + + constexpr _Float64 + sinh(_Float64 __x) + { return __builtin_sinh(__x); } + + constexpr _Float64 + sqrt(_Float64 __x) + { return __builtin_sqrt(__x); } + + constexpr _Float64 + tan(_Float64 __x) + { return __builtin_tan(__x); } + + constexpr _Float64 + tanh(_Float64 __x) + { return __builtin_tanh(__x); } +#endif + +#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) + constexpr _Float128 + acos(_Float128 __x) + { return __builtin_acosl(__x); } + + constexpr _Float128 + asin(_Float128 __x) + { return __builtin_asinl(__x); } + + constexpr _Float128 + atan(_Float128 __x) + { return __builtin_atanl(__x); } + + constexpr _Float128 + atan2(_Float128 __y, _Float128 __x) + { return __builtin_atan2l(__y, __x); } + + constexpr _Float128 + ceil(_Float128 __x) + { return __builtin_ceill(__x); } + + constexpr _Float128 + cos(_Float128 __x) + { return __builtin_cosl(__x); } + + constexpr _Float128 + cosh(_Float128 __x) + { return __builtin_coshl(__x); } + + constexpr _Float128 + exp(_Float128 __x) + { return __builtin_expl(__x); } + + constexpr _Float128 + fabs(_Float128 __x) + { return __builtin_fabsl(__x); } + + constexpr _Float128 + floor(_Float128 __x) + { return __builtin_floorl(__x); } + + constexpr _Float128 + fmod(_Float128 __x, _Float128 __y) + { return __builtin_fmodl(__x, __y); } + + inline _Float128 + frexp(_Float128 __x, int* __exp) + { return __builtin_frexpl(__x, __exp); } + + constexpr _Float128 + ldexp(_Float128 __x, int __exp) + { return __builtin_ldexpl(__x, __exp); } + + constexpr _Float128 + log(_Float128 __x) + { return __builtin_logl(__x); } + + constexpr _Float128 + log10(_Float128 __x) + { return __builtin_log10l(__x); } + + inline _Float128 + modf(_Float128 __x, _Float128* __iptr) + { + long double __i, __ret = __builtin_modfl(__x, &__i); + *__iptr = __i; + return __ret; + } + + constexpr _Float128 + pow(_Float128 __x, _Float128 __y) + { return __builtin_powl(__x, __y); } + + constexpr _Float128 + sin(_Float128 __x) + { return __builtin_sinl(__x); } + + constexpr _Float128 + sinh(_Float128 __x) + { return __builtin_sinhl(__x); } + + constexpr _Float128 + sqrt(_Float128 __x) + { return __builtin_sqrtl(__x); } + + constexpr _Float128 + tan(_Float128 __x) + { return __builtin_tanl(__x); } + + constexpr _Float128 + tanh(_Float128 __x) + { return __builtin_tanhl(__x); } +#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH) + constexpr _Float128 + acos(_Float128 __x) + { return __builtin_acosf128(__x); } + + constexpr _Float128 + asin(_Float128 __x) + { return __builtin_asinf128(__x); } + + constexpr _Float128 + atan(_Float128 __x) + { return __builtin_atanf128(__x); } + + constexpr _Float128 + atan2(_Float128 __y, _Float128 __x) + { return __builtin_atan2f128(__y, __x); } + + constexpr _Float128 + ceil(_Float128 __x) + { return __builtin_ceilf128(__x); } + + constexpr _Float128 + cos(_Float128 __x) + { return __builtin_cosf128(__x); } + + constexpr _Float128 + cosh(_Float128 __x) + { return __builtin_coshf128(__x); } + + constexpr _Float128 + exp(_Float128 __x) + { return __builtin_expf128(__x); } + + constexpr _Float128 + fabs(_Float128 __x) + { return __builtin_fabsf128(__x); } + + constexpr _Float128 + floor(_Float128 __x) + { return __builtin_floorf128(__x); } + + constexpr _Float128 + fmod(_Float128 __x, _Float128 __y) + { return __builtin_fmodf128(__x, __y); } + + inline _Float128 + frexp(_Float128 __x, int* __exp) + { return __builtin_frexpf128(__x, __exp); } + + constexpr _Float128 + ldexp(_Float128 __x, int __exp) + { return __builtin_ldexpf128(__x, __exp); } + + constexpr _Float128 + log(_Float128 __x) + { return __builtin_logf128(__x); } + + constexpr _Float128 + log10(_Float128 __x) + { return __builtin_log10f128(__x); } + + inline _Float128 + modf(_Float128 __x, _Float128* __iptr) + { return __builtin_modff128(__x, __iptr); } + + constexpr _Float128 + pow(_Float128 __x, _Float128 __y) + { return __builtin_powf128(__x, __y); } + + constexpr _Float128 + sin(_Float128 __x) + { return __builtin_sinf128(__x); } + + constexpr _Float128 + sinh(_Float128 __x) + { return __builtin_sinhf128(__x); } + + constexpr _Float128 + sqrt(_Float128 __x) + { return __builtin_sqrtf128(__x); } + + constexpr _Float128 + tan(_Float128 __x) + { return __builtin_tanf128(__x); } + + constexpr _Float128 + tanh(_Float128 __x) + { return __builtin_tanhf128(__x); } +#endif + +#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + constexpr __gnu_cxx::__bfloat16_t + acos(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_acosf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + asin(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_asinf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + atan(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_atanf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + atan2(__gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_atan2f(__y, __x)); } + + constexpr __gnu_cxx::__bfloat16_t + ceil(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_ceilf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + cos(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_cosf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + cosh(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_coshf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + exp(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_expf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + fabs(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_fabsf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + floor(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_floorf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + fmod(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) + { return __gnu_cxx::__bfloat16_t(__builtin_fmodf(__x, __y)); } + + inline __gnu_cxx::__bfloat16_t + frexp(__gnu_cxx::__bfloat16_t __x, int* __exp) + { return __gnu_cxx::__bfloat16_t(__builtin_frexpf(__x, __exp)); } + + constexpr __gnu_cxx::__bfloat16_t + ldexp(__gnu_cxx::__bfloat16_t __x, int __exp) + { return __gnu_cxx::__bfloat16_t(__builtin_ldexpf(__x, __exp)); } + + constexpr __gnu_cxx::__bfloat16_t + log(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_logf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + log10(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_log10f(__x)); } + + inline __gnu_cxx::__bfloat16_t + modf(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t* __iptr) + { + float __i, __ret = __builtin_modff(__x, &__i); + *__iptr = __gnu_cxx::__bfloat16_t(__i); + return __gnu_cxx::__bfloat16_t(__ret); + } + + constexpr __gnu_cxx::__bfloat16_t + pow(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) + { return __gnu_cxx::__bfloat16_t(__builtin_powf(__x, __y)); } + + constexpr __gnu_cxx::__bfloat16_t + sin(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_sinf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + sinh(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_sinhf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + sqrt(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_sqrtf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + tan(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_tanf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + tanh(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_tanhf(__x)); } +#endif + #if _GLIBCXX_USE_C99_MATH #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC @@ -948,6 +1506,262 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #endif // C++11 + +#ifdef __STDCPP_FLOAT16_T__ + constexpr int + fpclassify(_Float16 __x) + { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, + FP_SUBNORMAL, FP_ZERO, __x); } + + constexpr bool + isfinite(_Float16 __x) + { return __builtin_isfinite(__x); } + + constexpr bool + isinf(_Float16 __x) + { return __builtin_isinf(__x); } + + constexpr bool + isnan(_Float16 __x) + { return __builtin_isnan(__x); } + + constexpr bool + isnormal(_Float16 __x) + { return __builtin_isnormal(__x); } + + constexpr bool + signbit(_Float16 __x) + { return __builtin_signbit(__x); } + + constexpr bool + isgreater(_Float16 __x, _Float16 __y) + { return __builtin_isgreater(__x, __y); } + + constexpr bool + isgreaterequal(_Float16 __x, _Float16 __y) + { return __builtin_isgreaterequal(__x, __y); } + + constexpr bool + isless(_Float16 __x, _Float16 __y) + { return __builtin_isless(__x, __y); } + + constexpr bool + islessequal(_Float16 __x, _Float16 __y) + { return __builtin_islessequal(__x, __y); } + + constexpr bool + islessgreater(_Float16 __x, _Float16 __y) + { return __builtin_islessgreater(__x, __y); } + + constexpr bool + isunordered(_Float16 __x, _Float16 __y) + { return __builtin_isunordered(__x, __y); } +#endif + +#ifdef __STDCPP_FLOAT32_T__ + constexpr int + fpclassify(_Float32 __x) + { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, + FP_SUBNORMAL, FP_ZERO, __x); } + + constexpr bool + isfinite(_Float32 __x) + { return __builtin_isfinite(__x); } + + constexpr bool + isinf(_Float32 __x) + { return __builtin_isinf(__x); } + + constexpr bool + isnan(_Float32 __x) + { return __builtin_isnan(__x); } + + constexpr bool + isnormal(_Float32 __x) + { return __builtin_isnormal(__x); } + + constexpr bool + signbit(_Float32 __x) + { return __builtin_signbit(__x); } + + constexpr bool + isgreater(_Float32 __x, _Float32 __y) + { return __builtin_isgreater(__x, __y); } + + constexpr bool + isgreaterequal(_Float32 __x, _Float32 __y) + { return __builtin_isgreaterequal(__x, __y); } + + constexpr bool + isless(_Float32 __x, _Float32 __y) + { return __builtin_isless(__x, __y); } + + constexpr bool + islessequal(_Float32 __x, _Float32 __y) + { return __builtin_islessequal(__x, __y); } + + constexpr bool + islessgreater(_Float32 __x, _Float32 __y) + { return __builtin_islessgreater(__x, __y); } + + constexpr bool + isunordered(_Float32 __x, _Float32 __y) + { return __builtin_isunordered(__x, __y); } +#endif + +#ifdef __STDCPP_FLOAT64_T__ + constexpr int + fpclassify(_Float64 __x) + { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, + FP_SUBNORMAL, FP_ZERO, __x); } + + constexpr bool + isfinite(_Float64 __x) + { return __builtin_isfinite(__x); } + + constexpr bool + isinf(_Float64 __x) + { return __builtin_isinf(__x); } + + constexpr bool + isnan(_Float64 __x) + { return __builtin_isnan(__x); } + + constexpr bool + isnormal(_Float64 __x) + { return __builtin_isnormal(__x); } + + constexpr bool + signbit(_Float64 __x) + { return __builtin_signbit(__x); } + + constexpr bool + isgreater(_Float64 __x, _Float64 __y) + { return __builtin_isgreater(__x, __y); } + + constexpr bool + isgreaterequal(_Float64 __x, _Float64 __y) + { return __builtin_isgreaterequal(__x, __y); } + + constexpr bool + isless(_Float64 __x, _Float64 __y) + { return __builtin_isless(__x, __y); } + + constexpr bool + islessequal(_Float64 __x, _Float64 __y) + { return __builtin_islessequal(__x, __y); } + + constexpr bool + islessgreater(_Float64 __x, _Float64 __y) + { return __builtin_islessgreater(__x, __y); } + + constexpr bool + isunordered(_Float64 __x, _Float64 __y) + { return __builtin_isunordered(__x, __y); } +#endif + +#ifdef __STDCPP_FLOAT128_T__ + constexpr int + fpclassify(_Float128 __x) + { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, + FP_SUBNORMAL, FP_ZERO, __x); } + + constexpr bool + isfinite(_Float128 __x) + { return __builtin_isfinite(__x); } + + constexpr bool + isinf(_Float128 __x) + { return __builtin_isinf(__x); } + + constexpr bool + isnan(_Float128 __x) + { return __builtin_isnan(__x); } + + constexpr bool + isnormal(_Float128 __x) + { return __builtin_isnormal(__x); } + + constexpr bool + signbit(_Float128 __x) + { return __builtin_signbit(__x); } + + constexpr bool + isgreater(_Float128 __x, _Float128 __y) + { return __builtin_isgreater(__x, __y); } + + constexpr bool + isgreaterequal(_Float128 __x, _Float128 __y) + { return __builtin_isgreaterequal(__x, __y); } + + constexpr bool + isless(_Float128 __x, _Float128 __y) + { return __builtin_isless(__x, __y); } + + constexpr bool + islessequal(_Float128 __x, _Float128 __y) + { return __builtin_islessequal(__x, __y); } + + constexpr bool + islessgreater(_Float128 __x, _Float128 __y) + { return __builtin_islessgreater(__x, __y); } + + constexpr bool + isunordered(_Float128 __x, _Float128 __y) + { return __builtin_isunordered(__x, __y); } +#endif + +#ifdef __STDCPP_BFLOAT16_T__ + constexpr int + fpclassify(__gnu_cxx::__bfloat16_t __x) + { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, + FP_SUBNORMAL, FP_ZERO, __x); } + + constexpr bool + isfinite(__gnu_cxx::__bfloat16_t __x) + { return __builtin_isfinite(__x); } + + constexpr bool + isinf(__gnu_cxx::__bfloat16_t __x) + { return __builtin_isinf(__x); } + + constexpr bool + isnan(__gnu_cxx::__bfloat16_t __x) + { return __builtin_isnan(__x); } + + constexpr bool + isnormal(__gnu_cxx::__bfloat16_t __x) + { return __builtin_isnormal(__x); } + + constexpr bool + signbit(__gnu_cxx::__bfloat16_t __x) + { return __builtin_signbit(__x); } + + constexpr bool + isgreater(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) + { return __builtin_isgreater(__x, __y); } + + constexpr bool + isgreaterequal(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) + { return __builtin_isgreaterequal(__x, __y); } + + constexpr bool + isless(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) + { return __builtin_isless(__x, __y); } + + constexpr bool + islessequal(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) + { return __builtin_islessequal(__x, __y); } + + constexpr bool + islessgreater(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) + { return __builtin_islessgreater(__x, __y); } + + constexpr bool + isunordered(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) + { return __builtin_isunordered(__x, __y); } +#endif + #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */ #endif /* _GLIBCXX_USE_C99_MATH */ @@ -1843,6 +2657,901 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __builtin_trunc(__x); } #endif +#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + constexpr _Float16 + acosh(_Float16 __x) + { return _Float16(__builtin_acoshf(__x)); } + + constexpr _Float16 + asinh(_Float16 __x) + { return _Float16(__builtin_asinhf(__x)); } + + constexpr _Float16 + atanh(_Float16 __x) + { return _Float16(__builtin_atanhf(__x)); } + + constexpr _Float16 + cbrt(_Float16 __x) + { return _Float16(__builtin_cbrtf(__x)); } + + constexpr _Float16 + copysign(_Float16 __x, _Float16 __y) + { return __builtin_copysignf16(__x, __y); } + + constexpr _Float16 + erf(_Float16 __x) + { return _Float16(__builtin_erff(__x)); } + + constexpr _Float16 + erfc(_Float16 __x) + { return _Float16(__builtin_erfcf(__x)); } + + constexpr _Float16 + exp2(_Float16 __x) + { return _Float16(__builtin_exp2f(__x)); } + + constexpr _Float16 + expm1(_Float16 __x) + { return _Float16(__builtin_expm1f(__x)); } + + constexpr _Float16 + fdim(_Float16 __x, _Float16 __y) + { return _Float16(__builtin_fdimf(__x, __y)); } + + constexpr _Float16 + fma(_Float16 __x, _Float16 __y, _Float16 __z) + { return _Float16(__builtin_fmaf(__x, __y, __z)); } + + constexpr _Float16 + fmax(_Float16 __x, _Float16 __y) + { return _Float16(__builtin_fmaxf(__x, __y)); } + + constexpr _Float16 + fmin(_Float16 __x, _Float16 __y) + { return _Float16(__builtin_fminf(__x, __y)); } + + constexpr _Float16 + hypot(_Float16 __x, _Float16 __y) + { return _Float16(__builtin_hypotf(__x, __y)); } + + constexpr int + ilogb(_Float16 __x) + { return _Float16(__builtin_ilogbf(__x)); } + + constexpr _Float16 + lgamma(_Float16 __x) + { return _Float16(__builtin_lgammaf(__x)); } + + constexpr long long + llrint(_Float16 __x) + { return _Float16(__builtin_llrintf(__x)); } + + constexpr long long + llround(_Float16 __x) + { return _Float16(__builtin_llroundf(__x)); } + + constexpr _Float16 + log1p(_Float16 __x) + { return _Float16(__builtin_log1pf(__x)); } + + // DR 568. + constexpr _Float16 + log2(_Float16 __x) + { return _Float16(__builtin_log2f(__x)); } + + constexpr _Float16 + logb(_Float16 __x) + { return _Float16(__builtin_logbf(__x)); } + + constexpr long + lrint(_Float16 __x) + { return _Float16(__builtin_lrintf(__x)); } + + constexpr long + lround(_Float16 __x) + { return _Float16(__builtin_lroundf(__x)); } + + constexpr _Float16 + nearbyint(_Float16 __x) + { return _Float16(__builtin_nearbyintf(__x)); } + + inline _Float16 + nextafter(_Float16 __x, _Float16 __y) + { +#ifdef __INT16_TYPE__ + using __float16_int_type = __INT16_TYPE__; +#else + using __float16_int_type = short int; +#endif + __float16_int_type __hx, __hy, __ix, __iy; + __builtin_memcpy(&__hx, &__x, sizeof(__x)); + __builtin_memcpy(&__hy, &__y, sizeof(__x)); + __ix = __hx & 0x7fff; // |x| + __iy = __hy & 0x7fff; // |y| + if (__ix > 0x7c00 || __iy > 0x7c00) // x or y is NaN + return __x + __y; + if (__x == __y) + return __y; // x == y, return y + if (__ix == 0) // x == 0 + { + __hy = (__hy & 0x8000) | 1; // return +-__FLT16_DENORM_MIN__ + __builtin_memcpy(&__x, &__hy, sizeof(__x)); + __builtin_nextafterf(0.0f, 1.0f); // raise underflow + return __x; + } + if (__hx >= 0) // x > 0 + { + if (__hx > __hy) // x > y, x -= ulp + --__hx; + else // x < y, x += ulp + ++__hx; + } + else // x < 0 + { + if (__hy >= 0 || __hx > __hy) // x < y, x -= ulp + --__hx; + else // x > y, x += ulp + ++__hx; + } + __hy = __hx & 0x7c00; + if (__hy >= 0x7c00) + __builtin_nextafterf(__FLT_MAX__, __builtin_inff()); // overflow + else if (__hy < 0x0400) + __builtin_nextafterf(__FLT_MIN__, 0.0f); // underflow + __builtin_memcpy(&__x, &__hx, sizeof(__x)); + return __x; + } + + constexpr _Float16 + remainder(_Float16 __x, _Float16 __y) + { return _Float16(__builtin_remainderf(__x, __y)); } + + inline _Float16 + remquo(_Float16 __x, _Float16 __y, int* __pquo) + { return _Float16(__builtin_remquof(__x, __y, __pquo)); } + + constexpr _Float16 + rint(_Float16 __x) + { return _Float16(__builtin_rintf(__x)); } + + constexpr _Float16 + round(_Float16 __x) + { return _Float16(__builtin_roundf(__x)); } + + constexpr _Float16 + scalbln(_Float16 __x, long __ex) + { return _Float16(__builtin_scalblnf(__x, __ex)); } + + constexpr _Float16 + scalbn(_Float16 __x, int __ex) + { return _Float16(__builtin_scalbnf(__x, __ex)); } + + constexpr _Float16 + tgamma(_Float16 __x) + { return _Float16(__builtin_tgammaf(__x)); } + + constexpr _Float16 + trunc(_Float16 __x) + { return _Float16(__builtin_truncf(__x)); } +#endif + +#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + constexpr _Float32 + acosh(_Float32 __x) + { return __builtin_acoshf(__x); } + + constexpr _Float32 + asinh(_Float32 __x) + { return __builtin_asinhf(__x); } + + constexpr _Float32 + atanh(_Float32 __x) + { return __builtin_atanhf(__x); } + + constexpr _Float32 + cbrt(_Float32 __x) + { return __builtin_cbrtf(__x); } + + constexpr _Float32 + copysign(_Float32 __x, _Float32 __y) + { return __builtin_copysignf(__x, __y); } + + constexpr _Float32 + erf(_Float32 __x) + { return __builtin_erff(__x); } + + constexpr _Float32 + erfc(_Float32 __x) + { return __builtin_erfcf(__x); } + + constexpr _Float32 + exp2(_Float32 __x) + { return __builtin_exp2f(__x); } + + constexpr _Float32 + expm1(_Float32 __x) + { return __builtin_expm1f(__x); } + + constexpr _Float32 + fdim(_Float32 __x, _Float32 __y) + { return __builtin_fdimf(__x, __y); } + + constexpr _Float32 + fma(_Float32 __x, _Float32 __y, _Float32 __z) + { return __builtin_fmaf(__x, __y, __z); } + + constexpr _Float32 + fmax(_Float32 __x, _Float32 __y) + { return __builtin_fmaxf(__x, __y); } + + constexpr _Float32 + fmin(_Float32 __x, _Float32 __y) + { return __builtin_fminf(__x, __y); } + + constexpr _Float32 + hypot(_Float32 __x, _Float32 __y) + { return __builtin_hypotf(__x, __y); } + + constexpr int + ilogb(_Float32 __x) + { return __builtin_ilogbf(__x); } + + constexpr _Float32 + lgamma(_Float32 __x) + { return __builtin_lgammaf(__x); } + + constexpr long long + llrint(_Float32 __x) + { return __builtin_llrintf(__x); } + + constexpr long long + llround(_Float32 __x) + { return __builtin_llroundf(__x); } + + constexpr _Float32 + log1p(_Float32 __x) + { return __builtin_log1pf(__x); } + + // DR 568. + constexpr _Float32 + log2(_Float32 __x) + { return __builtin_log2f(__x); } + + constexpr _Float32 + logb(_Float32 __x) + { return __builtin_logbf(__x); } + + constexpr long + lrint(_Float32 __x) + { return __builtin_lrintf(__x); } + + constexpr long + lround(_Float32 __x) + { return __builtin_lroundf(__x); } + + constexpr _Float32 + nearbyint(_Float32 __x) + { return __builtin_nearbyintf(__x); } + + constexpr _Float32 + nextafter(_Float32 __x, _Float32 __y) + { return __builtin_nextafterf(__x, __y); } + + constexpr _Float32 + remainder(_Float32 __x, _Float32 __y) + { return __builtin_remainderf(__x, __y); } + + inline _Float32 + remquo(_Float32 __x, _Float32 __y, int* __pquo) + { return __builtin_remquof(__x, __y, __pquo); } + + constexpr _Float32 + rint(_Float32 __x) + { return __builtin_rintf(__x); } + + constexpr _Float32 + round(_Float32 __x) + { return __builtin_roundf(__x); } + + constexpr _Float32 + scalbln(_Float32 __x, long __ex) + { return __builtin_scalblnf(__x, __ex); } + + constexpr _Float32 + scalbn(_Float32 __x, int __ex) + { return __builtin_scalbnf(__x, __ex); } + + constexpr _Float32 + tgamma(_Float32 __x) + { return __builtin_tgammaf(__x); } + + constexpr _Float32 + trunc(_Float32 __x) + { return __builtin_truncf(__x); } +#endif + +#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) + constexpr _Float64 + acosh(_Float64 __x) + { return __builtin_acosh(__x); } + + constexpr _Float64 + asinh(_Float64 __x) + { return __builtin_asinh(__x); } + + constexpr _Float64 + atanh(_Float64 __x) + { return __builtin_atanh(__x); } + + constexpr _Float64 + cbrt(_Float64 __x) + { return __builtin_cbrt(__x); } + + constexpr _Float64 + copysign(_Float64 __x, _Float64 __y) + { return __builtin_copysign(__x, __y); } + + constexpr _Float64 + erf(_Float64 __x) + { return __builtin_erf(__x); } + + constexpr _Float64 + erfc(_Float64 __x) + { return __builtin_erfc(__x); } + + constexpr _Float64 + exp2(_Float64 __x) + { return __builtin_exp2(__x); } + + constexpr _Float64 + expm1(_Float64 __x) + { return __builtin_expm1(__x); } + + constexpr _Float64 + fdim(_Float64 __x, _Float64 __y) + { return __builtin_fdim(__x, __y); } + + constexpr _Float64 + fma(_Float64 __x, _Float64 __y, _Float64 __z) + { return __builtin_fma(__x, __y, __z); } + + constexpr _Float64 + fmax(_Float64 __x, _Float64 __y) + { return __builtin_fmax(__x, __y); } + + constexpr _Float64 + fmin(_Float64 __x, _Float64 __y) + { return __builtin_fmin(__x, __y); } + + constexpr _Float64 + hypot(_Float64 __x, _Float64 __y) + { return __builtin_hypot(__x, __y); } + + constexpr int + ilogb(_Float64 __x) + { return __builtin_ilogb(__x); } + + constexpr _Float64 + lgamma(_Float64 __x) + { return __builtin_lgamma(__x); } + + constexpr long long + llrint(_Float64 __x) + { return __builtin_llrint(__x); } + + constexpr long long + llround(_Float64 __x) + { return __builtin_llround(__x); } + + constexpr _Float64 + log1p(_Float64 __x) + { return __builtin_log1p(__x); } + + // DR 568. + constexpr _Float64 + log2(_Float64 __x) + { return __builtin_log2(__x); } + + constexpr _Float64 + logb(_Float64 __x) + { return __builtin_logb(__x); } + + constexpr long + lrint(_Float64 __x) + { return __builtin_lrint(__x); } + + constexpr long + lround(_Float64 __x) + { return __builtin_lround(__x); } + + constexpr _Float64 + nearbyint(_Float64 __x) + { return __builtin_nearbyint(__x); } + + constexpr _Float64 + nextafter(_Float64 __x, _Float64 __y) + { return __builtin_nextafter(__x, __y); } + + constexpr _Float64 + remainder(_Float64 __x, _Float64 __y) + { return __builtin_remainder(__x, __y); } + + inline _Float64 + remquo(_Float64 __x, _Float64 __y, int* __pquo) + { return __builtin_remquo(__x, __y, __pquo); } + + constexpr _Float64 + rint(_Float64 __x) + { return __builtin_rint(__x); } + + constexpr _Float64 + round(_Float64 __x) + { return __builtin_round(__x); } + + constexpr _Float64 + scalbln(_Float64 __x, long __ex) + { return __builtin_scalbln(__x, __ex); } + + constexpr _Float64 + scalbn(_Float64 __x, int __ex) + { return __builtin_scalbn(__x, __ex); } + + constexpr _Float64 + tgamma(_Float64 __x) + { return __builtin_tgamma(__x); } + + constexpr _Float64 + trunc(_Float64 __x) + { return __builtin_trunc(__x); } +#endif + +#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) + constexpr _Float128 + acosh(_Float128 __x) + { return __builtin_acoshl(__x); } + + constexpr _Float128 + asinh(_Float128 __x) + { return __builtin_asinhl(__x); } + + constexpr _Float128 + atanh(_Float128 __x) + { return __builtin_atanhl(__x); } + + constexpr _Float128 + cbrt(_Float128 __x) + { return __builtin_cbrtl(__x); } + + constexpr _Float128 + copysign(_Float128 __x, _Float128 __y) + { return __builtin_copysignl(__x, __y); } + + constexpr _Float128 + erf(_Float128 __x) + { return __builtin_erfl(__x); } + + constexpr _Float128 + erfc(_Float128 __x) + { return __builtin_erfcl(__x); } + + constexpr _Float128 + exp2(_Float128 __x) + { return __builtin_exp2l(__x); } + + constexpr _Float128 + expm1(_Float128 __x) + { return __builtin_expm1l(__x); } + + constexpr _Float128 + fdim(_Float128 __x, _Float128 __y) + { return __builtin_fdiml(__x, __y); } + + constexpr _Float128 + fma(_Float128 __x, _Float128 __y, _Float128 __z) + { return __builtin_fmal(__x, __y, __z); } + + constexpr _Float128 + fmax(_Float128 __x, _Float128 __y) + { return __builtin_fmaxl(__x, __y); } + + constexpr _Float128 + fmin(_Float128 __x, _Float128 __y) + { return __builtin_fminl(__x, __y); } + + constexpr _Float128 + hypot(_Float128 __x, _Float128 __y) + { return __builtin_hypotl(__x, __y); } + + constexpr int + ilogb(_Float128 __x) + { return __builtin_ilogbl(__x); } + + constexpr _Float128 + lgamma(_Float128 __x) + { return __builtin_lgammal(__x); } + + constexpr long long + llrint(_Float128 __x) + { return __builtin_llrintl(__x); } + + constexpr long long + llround(_Float128 __x) + { return __builtin_llroundl(__x); } + + constexpr _Float128 + log1p(_Float128 __x) + { return __builtin_log1pl(__x); } + + // DR 568. + constexpr _Float128 + log2(_Float128 __x) + { return __builtin_log2l(__x); } + + constexpr _Float128 + logb(_Float128 __x) + { return __builtin_logbl(__x); } + + constexpr long + lrint(_Float128 __x) + { return __builtin_lrintl(__x); } + + constexpr long + lround(_Float128 __x) + { return __builtin_lroundl(__x); } + + constexpr _Float128 + nearbyint(_Float128 __x) + { return __builtin_nearbyintl(__x); } + + constexpr _Float128 + nextafter(_Float128 __x, _Float128 __y) + { return __builtin_nextafterl(__x, __y); } + + constexpr _Float128 + remainder(_Float128 __x, _Float128 __y) + { return __builtin_remainderl(__x, __y); } + + inline _Float128 + remquo(_Float128 __x, _Float128 __y, int* __pquo) + { return __builtin_remquol(__x, __y, __pquo); } + + constexpr _Float128 + rint(_Float128 __x) + { return __builtin_rintl(__x); } + + constexpr _Float128 + round(_Float128 __x) + { return __builtin_roundl(__x); } + + constexpr _Float128 + scalbln(_Float128 __x, long __ex) + { return __builtin_scalblnl(__x, __ex); } + + constexpr _Float128 + scalbn(_Float128 __x, int __ex) + { return __builtin_scalbnl(__x, __ex); } + + constexpr _Float128 + tgamma(_Float128 __x) + { return __builtin_tgammal(__x); } + + constexpr _Float128 + trunc(_Float128 __x) + { return __builtin_truncl(__x); } +#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH) + constexpr _Float128 + acosh(_Float128 __x) + { return __builtin_acoshf128(__x); } + + constexpr _Float128 + asinh(_Float128 __x) + { return __builtin_asinhf128(__x); } + + constexpr _Float128 + atanh(_Float128 __x) + { return __builtin_atanhf128(__x); } + + constexpr _Float128 + cbrt(_Float128 __x) + { return __builtin_cbrtf128(__x); } + + constexpr _Float128 + copysign(_Float128 __x, _Float128 __y) + { return __builtin_copysignf128(__x, __y); } + + constexpr _Float128 + erf(_Float128 __x) + { return __builtin_erff128(__x); } + + constexpr _Float128 + erfc(_Float128 __x) + { return __builtin_erfcf128(__x); } + + constexpr _Float128 + exp2(_Float128 __x) + { return __builtin_exp2f128(__x); } + + constexpr _Float128 + expm1(_Float128 __x) + { return __builtin_expm1f128(__x); } + + constexpr _Float128 + fdim(_Float128 __x, _Float128 __y) + { return __builtin_fdimf128(__x, __y); } + + constexpr _Float128 + fma(_Float128 __x, _Float128 __y, _Float128 __z) + { return __builtin_fmaf128(__x, __y, __z); } + + constexpr _Float128 + fmax(_Float128 __x, _Float128 __y) + { return __builtin_fmaxf128(__x, __y); } + + constexpr _Float128 + fmin(_Float128 __x, _Float128 __y) + { return __builtin_fminf128(__x, __y); } + + constexpr _Float128 + hypot(_Float128 __x, _Float128 __y) + { return __builtin_hypotf128(__x, __y); } + + constexpr int + ilogb(_Float128 __x) + { return __builtin_ilogbf128(__x); } + + constexpr _Float128 + lgamma(_Float128 __x) + { return __builtin_lgammaf128(__x); } + + constexpr long long + llrint(_Float128 __x) + { return __builtin_llrintf128(__x); } + + constexpr long long + llround(_Float128 __x) + { return __builtin_llroundf128(__x); } + + constexpr _Float128 + log1p(_Float128 __x) + { return __builtin_log1pf128(__x); } + + // DR 568. + constexpr _Float128 + log2(_Float128 __x) + { return __builtin_log2f128(__x); } + + constexpr _Float128 + logb(_Float128 __x) + { return __builtin_logbf128(__x); } + + constexpr long + lrint(_Float128 __x) + { return __builtin_lrintf128(__x); } + + constexpr long + lround(_Float128 __x) + { return __builtin_lroundf128(__x); } + + constexpr _Float128 + nearbyint(_Float128 __x) + { return __builtin_nearbyintf128(__x); } + + constexpr _Float128 + nextafter(_Float128 __x, _Float128 __y) + { return __builtin_nextafterf128(__x, __y); } + + constexpr _Float128 + remainder(_Float128 __x, _Float128 __y) + { return __builtin_remainderf128(__x, __y); } + + inline _Float128 + remquo(_Float128 __x, _Float128 __y, int* __pquo) + { return __builtin_remquof128(__x, __y, __pquo); } + + constexpr _Float128 + rint(_Float128 __x) + { return __builtin_rintf128(__x); } + + constexpr _Float128 + round(_Float128 __x) + { return __builtin_roundf128(__x); } + + constexpr _Float128 + scalbln(_Float128 __x, long __ex) + { return __builtin_scalblnf128(__x, __ex); } + + constexpr _Float128 + scalbn(_Float128 __x, int __ex) + { return __builtin_scalbnf128(__x, __ex); } + + constexpr _Float128 + tgamma(_Float128 __x) + { return __builtin_tgammaf128(__x); } + + constexpr _Float128 + trunc(_Float128 __x) + { return __builtin_truncf128(__x); } +#endif + +#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + constexpr __gnu_cxx::__bfloat16_t + acosh(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_acoshf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + asinh(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_asinhf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + atanh(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_atanhf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + cbrt(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_cbrtf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + copysign(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) + { return __gnu_cxx::__bfloat16_t(__builtin_copysignf(__x, __y)); } + + constexpr __gnu_cxx::__bfloat16_t + erf(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_erff(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + erfc(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_erfcf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + exp2(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_exp2f(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + expm1(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_expm1f(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + fdim(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) + { return __gnu_cxx::__bfloat16_t(__builtin_fdimf(__x, __y)); } + + constexpr __gnu_cxx::__bfloat16_t + fma(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __z) + { return __gnu_cxx::__bfloat16_t(__builtin_fmaf(__x, __y, __z)); } + + constexpr __gnu_cxx::__bfloat16_t + fmax(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) + { return __gnu_cxx::__bfloat16_t(__builtin_fmaxf(__x, __y)); } + + constexpr __gnu_cxx::__bfloat16_t + fmin(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) + { return __gnu_cxx::__bfloat16_t(__builtin_fminf(__x, __y)); } + + constexpr __gnu_cxx::__bfloat16_t + hypot(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) + { return __gnu_cxx::__bfloat16_t(__builtin_hypotf(__x, __y)); } + + constexpr int + ilogb(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_ilogbf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + lgamma(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_lgammaf(__x)); } + + constexpr long long + llrint(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_llrintf(__x)); } + + constexpr long long + llround(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_llroundf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + log1p(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_log1pf(__x)); } + + // DR 568. + constexpr __gnu_cxx::__bfloat16_t + log2(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_log2f(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + logb(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_logbf(__x)); } + + constexpr long + lrint(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_lrintf(__x)); } + + constexpr long + lround(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_lroundf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + nearbyint(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_nearbyintf(__x)); } + + inline __gnu_cxx::__bfloat16_t + nextafter(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) + { +#ifdef __INT16_TYPE__ + using __bfloat16_int_type = __INT16_TYPE__; +#else + using __bfloat16_int_type = short int; +#endif + __bfloat16_int_type __hx, __hy, __ix, __iy; + __builtin_memcpy(&__hx, &__x, sizeof(__x)); + __builtin_memcpy(&__hy, &__y, sizeof(__x)); + __ix = __hx & 0x7fff; // |x| + __iy = __hy & 0x7fff; // |y| + if (__ix > 0x7f80 || __iy > 0x7f80) // x or y is NaN + return __x + __y; + if (__x == __y) + return __y; // x == y, return y + if (__ix == 0) // x == 0 + { + __hy = (__hy & 0x8000) | 1; // return +-__BFLT16_DENORM_MIN__ + __builtin_memcpy(&__x, &__hy, sizeof(__x)); + __builtin_nextafterf(0.0f, 1.0f); // raise underflow + return __x; + } + if (__hx >= 0) // x > 0 + { + if (__hx > __hy) // x > y, x -= ulp + --__hx; + else // x < y, x += ulp + ++__hx; + } + else // x < 0 + { + if (__hy >= 0 || __hx > __hy) // x < y, x -= ulp + --__hx; + else // x > y, x += ulp + ++__hx; + } + __hy = __hx & 0x7f80; + if (__hy >= 0x7f80) + __builtin_nextafterf(__FLT_MAX__, __builtin_inff()); // overflow + else if (__hy < 0x0080) + __builtin_nextafterf(__FLT_MIN__, 0.0f); // underflow + __builtin_memcpy(&__x, &__hx, sizeof(__x)); + return __x; + } + + constexpr __gnu_cxx::__bfloat16_t + remainder(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) + { return __gnu_cxx::__bfloat16_t(__builtin_remainderf(__x, __y)); } + + inline __gnu_cxx::__bfloat16_t + remquo(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, int* __pquo) + { return __gnu_cxx::__bfloat16_t(__builtin_remquof(__x, __y, __pquo)); } + + constexpr __gnu_cxx::__bfloat16_t + rint(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_rintf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + round(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_roundf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + scalbln(__gnu_cxx::__bfloat16_t __x, long __ex) + { return __gnu_cxx::__bfloat16_t(__builtin_scalblnf(__x, __ex)); } + + constexpr __gnu_cxx::__bfloat16_t + scalbn(__gnu_cxx::__bfloat16_t __x, int __ex) + { return __gnu_cxx::__bfloat16_t(__builtin_scalbnf(__x, __ex)); } + + constexpr __gnu_cxx::__bfloat16_t + tgamma(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_tgammaf(__x)); } + + constexpr __gnu_cxx::__bfloat16_t + trunc(__gnu_cxx::__bfloat16_t __x) + { return __gnu_cxx::__bfloat16_t(__builtin_truncf(__x)); } +#endif + + #endif // _GLIBCXX_USE_C99_MATH_TR1 #endif // C++11 @@ -1885,6 +3594,39 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using __type = __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>; return std::__hypot3<__type>(__x, __y, __z); } + +#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline _Float16 + hypot(_Float16 __x, _Float16 __y, _Float16 __z) + { return std::__hypot3<_Float16>(__x, __y, __z); } +#endif + +#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline _Float32 + hypot(_Float32 __x, _Float32 __y, _Float32 __z) + { return std::__hypot3<_Float32>(__x, __y, __z); } +#endif + +#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) + inline _Float64 + hypot(_Float64 __x, _Float64 __y, _Float64 __z) + { return std::__hypot3<_Float64>(__x, __y, __z); } +#endif + +#if defined(__STDCPP_FLOAT128_T__) \ + && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \ + || defined(_GLIBCXX_HAVE_FLOAT128_MATH)) + inline _Float128 + hypot(_Float128 __x, _Float128 __y, _Float128 __z) + { return std::__hypot3<_Float128>(__x, __y, __z); } +#endif + +#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline __gnu_cxx::__bfloat16_t + hypot(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __z) + { return std::__hypot3<__gnu_cxx::__bfloat16_t>(__x, __y, __z); } +#endif + #endif // C++17 #if __cplusplus >= 202002L @@ -1928,6 +3670,39 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using __type = __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>; return std::__lerp<__type>(__x, __y, __z); } + +#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline _Float16 + lerp(_Float16 __x, _Float16 __y, _Float16 __z) noexcept + { return std::__lerp<_Float16>(__x, __y, __z); } +#endif + +#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline _Float32 + lerp(_Float32 __x, _Float32 __y, _Float32 __z) noexcept + { return std::__lerp<_Float32>(__x, __y, __z); } +#endif + +#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) + inline _Float64 + lerp(_Float64 __x, _Float64 __y, _Float64 __z) noexcept + { return std::__lerp<_Float64>(__x, __y, __z); } +#endif + +#if defined(__STDCPP_FLOAT128_T__) \ + && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \ + || defined(_GLIBCXX_HAVE_FLOAT128_MATH)) + inline _Float128 + lerp(_Float128 __x, _Float128 __y, _Float128 __z) noexcept + { return std::__lerp<_Float128>(__x, __y, __z); } +#endif + +#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + inline __gnu_cxx::__bfloat16_t + lerp(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __z) noexcept + { return std::__lerp<__gnu_cxx::__bfloat16_t>(__x, __y, __z); } +#endif + #endif // C++20 _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/ext/type_traits.h b/libstdc++-v3/include/ext/type_traits.h index 27fae82..a6321df 100644 --- a/libstdc++-v3/include/ext/type_traits.h +++ b/libstdc++-v3/include/ext/type_traits.h @@ -190,6 +190,36 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __promote<float> { typedef float __type; }; +#ifdef __STDCPP_FLOAT16_T__ + template<> + struct __promote<_Float16> + { typedef _Float16 __type; }; +#endif + +#ifdef __STDCPP_FLOAT32_T__ + template<> + struct __promote<_Float32> + { typedef _Float32 __type; }; +#endif + +#ifdef __STDCPP_FLOAT64_T__ + template<> + struct __promote<_Float64> + { typedef _Float64 __type; }; +#endif + +#ifdef __STDCPP_FLOAT128_T__ + template<> + struct __promote<_Float128> + { typedef _Float128 __type; }; +#endif + +#ifdef __STDCPP_BFLOAT16_T__ + template<> + struct __promote<__gnu_cxx::__bfloat16_t> + { typedef __gnu_cxx::__bfloat16_t __type; }; +#endif + #if __cpp_fold_expressions template<typename... _Tp> diff --git a/libstdc++-v3/include/precompiled/stdc++.h b/libstdc++-v3/include/precompiled/stdc++.h index bfbb165..8157689 100644 --- a/libstdc++-v3/include/precompiled/stdc++.h +++ b/libstdc++-v3/include/precompiled/stdc++.h @@ -228,6 +228,7 @@ # include <stacktrace> #endif #include <stdatomic.h> +#include <stdfloat> #endif #endif // HOSTED diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic index b913960..356f145 100644 --- a/libstdc++-v3/include/std/atomic +++ b/libstdc++-v3/include/std/atomic @@ -1625,6 +1625,91 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using __atomic_float<long double>::operator=; }; +#ifdef __STDCPP_FLOAT16_T__ + template<> + struct atomic<_Float16> : __atomic_float<_Float16> + { + atomic() noexcept = default; + + constexpr + atomic(_Float16 __fp) noexcept : __atomic_float<_Float16>(__fp) + { } + + atomic& operator=(const atomic&) volatile = delete; + atomic& operator=(const atomic&) = delete; + + using __atomic_float<_Float16>::operator=; + }; +#endif + +#ifdef __STDCPP_FLOAT32_T__ + template<> + struct atomic<_Float32> : __atomic_float<_Float32> + { + atomic() noexcept = default; + + constexpr + atomic(_Float32 __fp) noexcept : __atomic_float<_Float32>(__fp) + { } + + atomic& operator=(const atomic&) volatile = delete; + atomic& operator=(const atomic&) = delete; + + using __atomic_float<_Float32>::operator=; + }; +#endif + +#ifdef __STDCPP_FLOAT64_T__ + template<> + struct atomic<_Float64> : __atomic_float<_Float64> + { + atomic() noexcept = default; + + constexpr + atomic(_Float64 __fp) noexcept : __atomic_float<_Float64>(__fp) + { } + + atomic& operator=(const atomic&) volatile = delete; + atomic& operator=(const atomic&) = delete; + + using __atomic_float<_Float64>::operator=; + }; +#endif + +#ifdef __STDCPP_FLOAT128_T__ + template<> + struct atomic<_Float128> : __atomic_float<_Float128> + { + atomic() noexcept = default; + + constexpr + atomic(_Float128 __fp) noexcept : __atomic_float<_Float128>(__fp) + { } + + atomic& operator=(const atomic&) volatile = delete; + atomic& operator=(const atomic&) = delete; + + using __atomic_float<_Float128>::operator=; + }; +#endif + +#ifdef __STDCPP_BFLOAT16_T__ + template<> + struct atomic<__gnu_cxx::__bfloat16_t> : __atomic_float<__gnu_cxx::__bfloat16_t> + { + atomic() noexcept = default; + + constexpr + atomic(__gnu_cxx::__bfloat16_t __fp) noexcept : __atomic_float<__gnu_cxx::__bfloat16_t>(__fp) + { } + + atomic& operator=(const atomic&) volatile = delete; + atomic& operator=(const atomic&) = delete; + + using __atomic_float<__gnu_cxx::__bfloat16_t>::operator=; + }; +#endif + #define __cpp_lib_atomic_ref 201806L /// Class template to provide atomic operations on a non-atomic variable. diff --git a/libstdc++-v3/include/std/charconv b/libstdc++-v3/include/std/charconv index 4b6cc83..7aefdd3 100644 --- a/libstdc++-v3/include/std/charconv +++ b/libstdc++-v3/include/std/charconv @@ -51,7 +51,7 @@ #endif #if __cplusplus > 202002L -# define __cpp_lib_constexpr_charconv 202202L +# define __cpp_lib_constexpr_charconv 202207L #endif namespace std _GLIBCXX_VISIBILITY(default) diff --git a/libstdc++-v3/include/std/limits b/libstdc++-v3/include/std/limits index a60611b..9dde9f3 100644 --- a/libstdc++-v3/include/std/limits +++ b/libstdc++-v3/include/std/limits @@ -1890,6 +1890,189 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #undef __glibcxx_long_double_traps #undef __glibcxx_long_double_tinyness_before +#if __cplusplus > 202002L + +#define __glibcxx_concat3_(P,M,S) P ## M ## S +#define __glibcxx_concat3(P,M,S) __glibcxx_concat3_ (P,M,S) + +#define __glibcxx_float_n(BITSIZE) \ + __extension__ \ + template<> \ + struct numeric_limits<_Float##BITSIZE> \ + { \ + static constexpr bool is_specialized = true; \ + \ + static constexpr _Float##BITSIZE \ + min() noexcept \ + { return __glibcxx_concat3 (__FLT, BITSIZE, _MIN__); } \ + \ + static constexpr _Float##BITSIZE \ + max() noexcept \ + { return __glibcxx_concat3 (__FLT, BITSIZE, _MAX__); } \ + \ + static constexpr _Float##BITSIZE \ + lowest() noexcept \ + { return -__glibcxx_concat3 (__FLT, BITSIZE, _MAX__); } \ + \ + static constexpr int digits \ + = __glibcxx_concat3 (__FLT, BITSIZE, _MANT_DIG__); \ + static constexpr int digits10 \ + = __glibcxx_concat3 (__FLT, BITSIZE, _DIG__); \ + static constexpr int max_digits10 \ + = __glibcxx_max_digits10 (__glibcxx_concat3 (__FLT, BITSIZE, \ + _MANT_DIG__)); \ + static constexpr bool is_signed = true; \ + static constexpr bool is_integer = false; \ + static constexpr bool is_exact = false; \ + static constexpr int radix = __FLT_RADIX__; \ + \ + static constexpr _Float##BITSIZE \ + epsilon() noexcept \ + { return __glibcxx_concat3 (__FLT, BITSIZE, _EPSILON__); } \ + \ + static constexpr _Float##BITSIZE \ + round_error() noexcept { return 0.5F##BITSIZE; } \ + \ + static constexpr int min_exponent \ + = __glibcxx_concat3 (__FLT, BITSIZE, _MIN_EXP__); \ + static constexpr int min_exponent10 \ + = __glibcxx_concat3 (__FLT, BITSIZE, _MIN_10_EXP__); \ + static constexpr int max_exponent \ + = __glibcxx_concat3 (__FLT, BITSIZE, _MAX_EXP__); \ + static constexpr int max_exponent10 \ + = __glibcxx_concat3 (__FLT, BITSIZE, _MAX_10_EXP__); \ + \ + static constexpr bool has_infinity \ + = __glibcxx_concat3 (__FLT, BITSIZE, _HAS_INFINITY__); \ + static constexpr bool has_quiet_NaN \ + = __glibcxx_concat3 (__FLT, BITSIZE, _HAS_QUIET_NAN__); \ + static constexpr bool has_signaling_NaN \ + = has_quiet_NaN; \ + static constexpr float_denorm_style has_denorm \ + = bool(__glibcxx_concat3 (__FLT, BITSIZE, _HAS_DENORM__)) \ + ? denorm_present : denorm_absent; \ + static constexpr bool has_denorm_loss = false; \ + \ + static constexpr _Float##BITSIZE \ + infinity() noexcept \ + { return __builtin_huge_valf##BITSIZE(); } \ + \ + static constexpr _Float##BITSIZE \ + quiet_NaN() noexcept \ + { return __builtin_nanf##BITSIZE(""); } \ + \ + static constexpr _Float##BITSIZE \ + signaling_NaN() noexcept \ + { return __builtin_nansf##BITSIZE(""); } \ + \ + static constexpr _Float##BITSIZE \ + denorm_min() noexcept \ + { return __glibcxx_concat3 (__FLT, BITSIZE, _DENORM_MIN__); } \ + \ + static constexpr bool is_iec559 \ + = has_infinity && has_quiet_NaN && has_denorm == denorm_present;\ + static constexpr bool is_bounded = true; \ + static constexpr bool is_modulo = false; \ + \ + static constexpr bool traps = false; \ + static constexpr bool tinyness_before = false; \ + static constexpr float_round_style round_style \ + = round_to_nearest; \ + }; \ + +#ifdef __STDCPP_FLOAT16_T__ +__glibcxx_float_n(16) +#endif +#ifdef __STDCPP_FLOAT32_T__ +__glibcxx_float_n(32) +#endif +#ifdef __STDCPP_FLOAT64_T__ +__glibcxx_float_n(64) +#endif +#ifdef __STDCPP_FLOAT128_T__ +__glibcxx_float_n(128) +#endif +#undef __glibcxx_float_n +#undef __glibcxx_concat3 +#undef __glibcxx_concat3_ + +#ifdef __STDCPP_BFLOAT16_T__ + __extension__ + template<> + struct numeric_limits<__gnu_cxx::__bfloat16_t> + { + static constexpr bool is_specialized = true; + + static constexpr __gnu_cxx::__bfloat16_t + min() noexcept + { return __BFLT16_MIN__; } + + static constexpr __gnu_cxx::__bfloat16_t + max() noexcept + { return __BFLT16_MAX__; } + + static constexpr __gnu_cxx::__bfloat16_t + lowest() noexcept + { return -__BFLT16_MAX__; } + + static constexpr int digits = __BFLT16_MANT_DIG__; + static constexpr int digits10 = __BFLT16_DIG__; + static constexpr int max_digits10 + = __glibcxx_max_digits10 (__BFLT16_MANT_DIG__); + static constexpr bool is_signed = true; + static constexpr bool is_integer = false; + static constexpr bool is_exact = false; + static constexpr int radix = __FLT_RADIX__; + + static constexpr __gnu_cxx::__bfloat16_t + epsilon() noexcept + { return __BFLT16_EPSILON__; } + + static constexpr __gnu_cxx::__bfloat16_t + round_error() noexcept { return 0.5BF16; } + + static constexpr int min_exponent = __BFLT16_MIN_EXP__; + static constexpr int min_exponent10 = __BFLT16_MIN_10_EXP__; + static constexpr int max_exponent = __BFLT16_MAX_EXP__; + static constexpr int max_exponent10 = __BFLT16_MAX_10_EXP__; + + static constexpr bool has_infinity = __BFLT16_HAS_INFINITY__; + static constexpr bool has_quiet_NaN = __BFLT16_HAS_QUIET_NAN__; + static constexpr bool has_signaling_NaN = has_quiet_NaN; + static constexpr float_denorm_style has_denorm + = bool(__BFLT16_HAS_DENORM__) + ? denorm_present : denorm_absent; + static constexpr bool has_denorm_loss = false; + + static constexpr __gnu_cxx::__bfloat16_t + infinity() noexcept + { return __gnu_cxx::__bfloat16_t(__builtin_huge_valf()); } + + static constexpr __gnu_cxx::__bfloat16_t + quiet_NaN() noexcept + { return __gnu_cxx::__bfloat16_t(__builtin_nanf("")); } + + static constexpr __gnu_cxx::__bfloat16_t + signaling_NaN() noexcept + { return __builtin_nansf16b(""); } + + static constexpr __gnu_cxx::__bfloat16_t + denorm_min() noexcept + { return __BFLT16_DENORM_MIN__; } + + static constexpr bool is_iec559 + = has_infinity && has_quiet_NaN && has_denorm == denorm_present; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = false; + + static constexpr bool traps = false; + static constexpr bool tinyness_before = false; + static constexpr float_round_style round_style = round_to_nearest; + }; +#endif + +#endif + _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/std/numbers b/libstdc++-v3/include/std/numbers index 5187665..6d33228 100644 --- a/libstdc++-v3/include/std/numbers +++ b/libstdc++-v3/include/std/numbers @@ -133,72 +133,98 @@ namespace numbers inline constexpr double egamma = egamma_v<double>; inline constexpr double phi = phi_v<double>; -#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) - template<> - inline constexpr __float128 e_v<__float128> - = 2.718281828459045235360287471352662498Q; - - /// log_2 e - template<> - inline constexpr __float128 log2e_v<__float128> - = 1.442695040888963407359924681001892137Q; - - /// log_10 e - template<> - inline constexpr __float128 log10e_v<__float128> - = 0.434294481903251827651128918916605082Q; - - /// pi - template<> - inline constexpr __float128 pi_v<__float128> - = 3.141592653589793238462643383279502884Q; - - /// 1/pi - template<> - inline constexpr __float128 inv_pi_v<__float128> - = 0.318309886183790671537767526745028724Q; - - /// 1/sqrt(pi) - template<> - inline constexpr __float128 inv_sqrtpi_v<__float128> - = 0.564189583547756286948079451560772586Q; - - /// log_e 2 - template<> - inline constexpr __float128 ln2_v<__float128> - = 0.693147180559945309417232121458176568Q; +#define __glibcxx_numbers(TYPE, SUFFIX) \ + /* e */ \ + template<> \ + inline constexpr TYPE e_v<TYPE> \ + = 2.718281828459045235360287471352662498##SUFFIX; \ + \ + /* log_2 e */ \ + template<> \ + inline constexpr TYPE log2e_v<TYPE> \ + = 1.442695040888963407359924681001892137##SUFFIX; \ + \ + /* log_10 e */ \ + template<> \ + inline constexpr TYPE log10e_v<TYPE> \ + = 0.434294481903251827651128918916605082##SUFFIX; \ + \ + /* pi */ \ + template<> \ + inline constexpr TYPE pi_v<TYPE> \ + = 3.141592653589793238462643383279502884##SUFFIX; \ + \ + /* 1/pi */ \ + template<> \ + inline constexpr TYPE inv_pi_v<TYPE> \ + = 0.318309886183790671537767526745028724##SUFFIX; \ + \ + /* 1/sqrt(pi) */ \ + template<> \ + inline constexpr TYPE inv_sqrtpi_v<TYPE> \ + = 0.564189583547756286948079451560772586##SUFFIX; \ + \ + /* log_e 2 */ \ + template<> \ + inline constexpr TYPE ln2_v<TYPE> \ + = 0.693147180559945309417232121458176568##SUFFIX; \ + \ + /* log_e 10 */ \ + template<> \ + inline constexpr TYPE ln10_v<TYPE> \ + = 2.302585092994045684017991454684364208##SUFFIX; \ + \ + /* sqrt(2) */ \ + template<> \ + inline constexpr TYPE sqrt2_v<TYPE> \ + = 1.414213562373095048801688724209698079##SUFFIX; \ + \ + /* sqrt(3) */ \ + template<> \ + inline constexpr TYPE sqrt3_v<TYPE> \ + = 1.732050807568877293527446341505872367##SUFFIX; \ + \ + /* 1/sqrt(3) */ \ + template<> \ + inline constexpr TYPE inv_sqrt3_v<TYPE> \ + = 0.577350269189625764509148780501957456##SUFFIX; \ + \ + /* The Euler-Mascheroni constant */ \ + template<> \ + inline constexpr TYPE egamma_v<TYPE> \ + = 0.577215664901532860606512090082402431##SUFFIX; \ + \ + /* The golden ratio, (1+sqrt(5))/2 */ \ + template<> \ + inline constexpr TYPE phi_v<TYPE> \ + = 1.618033988749894848204586834365638118##SUFFIX + +#ifdef __STDCPP_FLOAT16_T__ +__glibcxx_numbers (_Float16, F16); +#endif + +#ifdef __STDCPP_FLOAT32_T__ +__glibcxx_numbers (_Float32, F32); +#endif + +#ifdef __STDCPP_FLOAT64_T__ +__glibcxx_numbers (_Float64, F64); +#endif + +#ifdef __STDCPP_FLOAT128_T__ +__glibcxx_numbers (_Float128, F128); +#endif + +#ifdef __STDCPP_BFLOAT128_T__ +__glibcxx_numbers (__gnu_cxx::__bfloat16_t, BF16); +#endif - /// log_e 10 - template<> - inline constexpr __float128 ln10_v<__float128> - = 2.302585092994045684017991454684364208Q; - - /// sqrt(2) - template<> - inline constexpr __float128 sqrt2_v<__float128> - = 1.414213562373095048801688724209698079Q; - - /// sqrt(3) - template<> - inline constexpr __float128 sqrt3_v<__float128> - = 1.732050807568877293527446341505872367Q; - - /// 1/sqrt(3) - template<> - inline constexpr __float128 inv_sqrt3_v<__float128> - = 0.577350269189625764509148780501957456Q; - - /// The Euler-Mascheroni constant - template<> - inline constexpr __float128 egamma_v<__float128> - = 0.577215664901532860606512090082402431Q; - - /// The golden ratio, (1+sqrt(5))/2 - template<> - inline constexpr __float128 phi_v<__float128> - = 1.618033988749894848204586834365638118Q; +#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) +__glibcxx_numbers (__float128, Q); #endif // USE_FLOAT128 +#undef __glibcxx_numbers + } // namespace numbers /// @} _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 5857d42..d113cf1 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -7566,6 +7566,357 @@ namespace views::__adaptor inline constexpr _Repeat repeat; } + + template<input_range _Vp> + requires view<_Vp> + class stride_view : public view_interface<stride_view<_Vp>> + { + _Vp _M_base; + range_difference_t<_Vp> _M_stride; + + template<bool _Const> using _Base = __detail::__maybe_const_t<_Const, _Vp>; + + template<bool _Const> + struct __iter_cat + { }; + + template<bool _Const> + requires forward_range<_Base<_Const>> + struct __iter_cat<_Const> + { + private: + static auto + _S_iter_cat() + { + using _Cat = typename iterator_traits<iterator_t<_Base<_Const>>>::iterator_category; + if constexpr (derived_from<_Cat, random_access_iterator_tag>) + return random_access_iterator_tag{}; + else + return _Cat{}; + } + public: + using iterator_category = decltype(_S_iter_cat()); + }; + + template<bool> class _Iterator; + + public: + constexpr explicit + stride_view(_Vp __base, range_difference_t<_Vp> __stride) + : _M_base(std::move(__base)), _M_stride(__stride) + { __glibcxx_assert(__stride > 0); } + + constexpr _Vp + base() const& requires copy_constructible<_Vp> + { return _M_base; } + + constexpr _Vp + base() && + { return std::move(_M_base); } + + constexpr range_difference_t<_Vp> + stride() const noexcept + { return _M_stride; } + + constexpr auto + begin() requires (!__detail::__simple_view<_Vp>) + { return _Iterator<false>(this, ranges::begin(_M_base)); } + + constexpr auto + begin() const requires range<const _Vp> + { return _Iterator<true>(this, ranges::begin(_M_base)); } + + constexpr auto + end() requires (!__detail::__simple_view<_Vp>) + { + if constexpr (common_range<_Vp> && sized_range<_Vp> && forward_range<_Vp>) + { + auto __missing = (_M_stride - ranges::distance(_M_base) % _M_stride) % _M_stride; + return _Iterator<false>(this, ranges::end(_M_base), __missing); + } + else if constexpr (common_range<_Vp> && !bidirectional_range<_Vp>) + return _Iterator<false>(this, ranges::end(_M_base)); + else + return default_sentinel; + } + + constexpr auto + end() const requires range<const _Vp> + { + if constexpr (common_range<const _Vp> && sized_range<const _Vp> + && forward_range<const _Vp>) + { + auto __missing = (_M_stride - ranges::distance(_M_base) % _M_stride) % _M_stride; + return _Iterator<true>(this, ranges::end(_M_base), __missing); + } + else if constexpr (common_range<const _Vp> && !bidirectional_range<const _Vp>) + return _Iterator<true>(this, ranges::end(_M_base)); + else + return default_sentinel; + } + + constexpr auto + size() requires sized_range<_Vp> + { + return __detail::__to_unsigned_like + (__detail::__div_ceil(ranges::distance(_M_base), _M_stride)); + } + + constexpr auto + size() const requires sized_range<const _Vp> + { + return __detail::__to_unsigned_like + (__detail::__div_ceil(ranges::distance(_M_base), _M_stride)); + } + }; + + template<typename _Range> + stride_view(_Range&&, range_difference_t<_Range>) -> stride_view<views::all_t<_Range>>; + + template<typename _Vp> + inline constexpr bool enable_borrowed_range<stride_view<_Vp>> + = enable_borrowed_range<_Vp>; + + template<input_range _Vp> + requires view<_Vp> + template<bool _Const> + class stride_view<_Vp>::_Iterator : public __iter_cat<_Const> + { + using _Parent = __detail::__maybe_const_t<_Const, stride_view>; + using _Base = stride_view::_Base<_Const>; + + iterator_t<_Base> _M_current = iterator_t<_Base>(); + sentinel_t<_Base> _M_end = sentinel_t<_Base>(); + range_difference_t<_Base> _M_stride = 0; + range_difference_t<_Base> _M_missing = 0; + + constexpr + _Iterator(_Parent* __parent, iterator_t<_Base> __current, + range_difference_t<_Base> __missing = 0) + : _M_current(std::move(__current)), _M_end(ranges::end(__parent->_M_base)), + _M_stride(__parent->_M_stride), _M_missing(__missing) + { } + + static auto + _S_iter_concept() + { + if constexpr (random_access_range<_Base>) + return random_access_iterator_tag{}; + else if constexpr (bidirectional_range<_Base>) + return bidirectional_iterator_tag{}; + else if constexpr (forward_range<_Base>) + return forward_iterator_tag{}; + else + return input_iterator_tag{}; + } + + friend stride_view; + + public: + using difference_type = range_difference_t<_Base>; + using value_type = range_value_t<_Base>; + using iterator_concept = decltype(_S_iter_concept()); + // iterator_category defined in stride_view::__iter_cat + + _Iterator() requires default_initializable<iterator_t<_Base>> = default; + + constexpr + _Iterator(_Iterator<!_Const> __other) + requires _Const + && convertible_to<iterator_t<_Vp>, iterator_t<_Base>> + && convertible_to<sentinel_t<_Vp>, sentinel_t<_Base>> + : _M_current(std::move(__other._M_current)), _M_end(std::move(__other._M_end)), + _M_stride(__other._M_stride), _M_missing(__other._M_missing) + { } + + constexpr iterator_t<_Base> + base() && + { return std::move(_M_current); } + + constexpr const iterator_t<_Base>& + base() const & noexcept + { return _M_current; } + + constexpr decltype(auto) + operator*() const + { return *_M_current; } + + constexpr _Iterator& + operator++() + { + __glibcxx_assert(_M_current != _M_end); + _M_missing = ranges::advance(_M_current, _M_stride, _M_end); + return *this; + } + + constexpr void + operator++(int) + { ++*this; } + + constexpr _Iterator + operator++(int) requires forward_range<_Base> + { + auto __tmp = *this; + ++*this; + return __tmp; + } + + constexpr _Iterator& + operator--() requires bidirectional_range<_Base> + { + ranges::advance(_M_current, _M_missing - _M_stride); + _M_missing = 0; + return *this; + } + + constexpr _Iterator + operator--(int) requires bidirectional_range<_Base> + { + auto __tmp = *this; + --*this; + return __tmp; + } + + constexpr _Iterator& + operator+=(difference_type __n) requires random_access_range<_Base> + { + if (__n > 0) + { + __glibcxx_assert(ranges::distance(_M_current, _M_end) > _M_stride * (__n - 1)); + _M_missing = ranges::advance(_M_current, _M_stride * __n, _M_end); + } + else if (__n < 0) + { + ranges::advance(_M_current, _M_stride * __n + _M_missing); + _M_missing = 0; + } + return *this; + } + + constexpr _Iterator& + operator-=(difference_type __n) requires random_access_range<_Base> + { return *this += -__n; } + + constexpr decltype(auto) operator[](difference_type __n) const + requires random_access_range<_Base> + { return *(*this + __n); } + + friend constexpr bool + operator==(const _Iterator& __x, default_sentinel_t) + { return __x._M_current == __x._M_end; } + + friend constexpr bool + operator==(const _Iterator& __x, const _Iterator& __y) + requires equality_comparable<iterator_t<_Base>> + { return __x._M_current == __y._M_current; } + + friend constexpr bool + operator<(const _Iterator& __x, const _Iterator& __y) + requires random_access_range<_Base> + { return __x._M_current < __y._M_current; } + + friend constexpr bool + operator>(const _Iterator& __x, const _Iterator& __y) + requires random_access_range<_Base> + { return __y._M_current < __x._M_current; } + + friend constexpr bool + operator<=(const _Iterator& __x, const _Iterator& __y) + requires random_access_range<_Base> + { return !(__y._M_current < __x._M_current); } + + friend constexpr bool + operator>=(const _Iterator& __x, const _Iterator& __y) + requires random_access_range<_Base> + { return !(__x._M_current < __y._M_current); } + + friend constexpr auto + operator<=>(const _Iterator& __x, const _Iterator& __y) + requires random_access_range<_Base> && three_way_comparable<iterator_t<_Base>> + { return __x._M_current <=> __y._M_current; } + + friend constexpr _Iterator + operator+(const _Iterator& __i, difference_type __n) + requires random_access_range<_Base> + { + auto __r = __i; + __r += __n; + return __r; + } + + friend constexpr _Iterator + operator+(difference_type __n, const _Iterator& __i) + requires random_access_range<_Base> + { return __i + __n; } + + friend constexpr _Iterator + operator-(const _Iterator& __i, difference_type __n) + requires random_access_range<_Base> + { + auto __r = __i; + __r -= __n; + return __r; + } + + friend constexpr difference_type + operator-(const _Iterator& __x, const _Iterator& __y) + requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>> + { + auto __n = __x._M_current - __y._M_current; + if constexpr (forward_range<_Base>) + return (__n + __x._M_missing - __y._M_missing) / __x._M_stride; + else if (__n < 0) + return -__detail::__div_ceil(-__n, __x._M_stride); + else + return __detail::__div_ceil(__n, __x._M_stride); + } + + friend constexpr difference_type + operator-(default_sentinel_t __y, const _Iterator& __x) + requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<_Base>> + { return __detail::__div_ceil(__x._M_end, __x._M_current, __x._M_stride); } + + friend constexpr difference_type + operator-(const _Iterator& __x, default_sentinel_t __y) + requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<_Base>> + { return -(__y - __x); } + + friend constexpr range_rvalue_reference_t<_Base> + iter_move(const _Iterator& __i) + noexcept(noexcept(ranges::iter_move(__i._M_current))) + { return ranges::iter_move(__i._M_current); } + + friend constexpr void + iter_swap(const _Iterator& __x, const _Iterator& __y) + noexcept(noexcept(ranges::iter_swap(__x._M_current, __y._M_current))) + requires indirectly_swappable<iterator_t<_Base>> + { ranges::iter_swap(__x._M_current, __y._M_current); } + }; + + namespace views + { + namespace __detail + { + template<typename _Range, typename _Dp> + concept __can_stride_view + = requires { stride_view(std::declval<_Range>(), std::declval<_Dp>()); }; + } + + struct _Stride : __adaptor::_RangeAdaptor<_Stride> + { + template<viewable_range _Range, typename _Dp = range_difference_t<_Range>> + requires __detail::__can_stride_view<_Range, _Dp> + constexpr auto + operator() [[nodiscard]] (_Range&& __r, type_identity_t<_Dp> __n) const + { return stride_view(std::forward<_Range>(__r), __n); } + + using __adaptor::_RangeAdaptor<_Stride>::operator(); + static constexpr int _S_arity = 2; + static constexpr bool _S_has_simple_extra_args = true; + }; + + inline constexpr _Stride stride; + } #endif // C++23 } // namespace ranges diff --git a/libstdc++-v3/include/std/stdfloat b/libstdc++-v3/include/std/stdfloat new file mode 100644 index 0000000..5ab1fa0 --- /dev/null +++ b/libstdc++-v3/include/std/stdfloat @@ -0,0 +1,62 @@ +// <stdfloat> -*- C++ -*- + +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file include/stdfloat + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_STDFLOAT +#define _GLIBCXX_STDFLOAT 1 + +#if __cplusplus > 202002L +#include <bits/c++config.h> + +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + #ifdef __STDCPP_FLOAT16_T__ + using float16_t = _Float16; + #endif + + #ifdef __STDCPP_FLOAT32_T__ + using float32_t = _Float32; + #endif + + #ifdef __STDCPP_FLOAT64_T__ + using float64_t = _Float64; + #endif + + #ifdef __STDCPP_FLOAT128_T__ + using float128_t = _Float128; + #endif + + #ifdef __STDCPP_BFLOAT16_T__ + using bfloat16_t = __gnu_cxx::__bfloat16_t; + #endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++23 +#endif // _GLIBCXX_STDFLOAT diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 1d7c3b0..5dc9e1b 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -459,6 +459,36 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __is_floating_point_helper<long double> : public true_type { }; +#ifdef __STDCPP_FLOAT16_T__ + template<> + struct __is_floating_point_helper<_Float16> + : public true_type { }; +#endif + +#ifdef __STDCPP_FLOAT32_T__ + template<> + struct __is_floating_point_helper<_Float32> + : public true_type { }; +#endif + +#ifdef __STDCPP_FLOAT64_T__ + template<> + struct __is_floating_point_helper<_Float64> + : public true_type { }; +#endif + +#ifdef __STDCPP_FLOAT128_T__ + template<> + struct __is_floating_point_helper<_Float128> + : public true_type { }; +#endif + +#ifdef __STDCPP_BFLOAT16_T__ + template<> + struct __is_floating_point_helper<__gnu_cxx::__bfloat16_t> + : public true_type { }; +#endif + #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) template<> struct __is_floating_point_helper<__float128> diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index bec9e7a..3c7c440 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -302,7 +302,7 @@ #if __cplusplus > 202002L // c++23 #define __cpp_lib_byteswap 202110L -#define __cpp_lib_constexpr_charconv 202202L +#define __cpp_lib_constexpr_charconv 202207L #define __cpp_lib_constexpr_typeinfo 202106L #if __cpp_concepts >= 202002L # define __cpp_lib_expected 202202L diff --git a/libstdc++-v3/testsuite/18_support/headers/limits/synopsis_cxx23.cc b/libstdc++-v3/testsuite/18_support/headers/limits/synopsis_cxx23.cc new file mode 100644 index 0000000..c551005 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/headers/limits/synopsis_cxx23.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++2b" } +// { dg-do compile { target c++23 } } +// { dg-require-normal-namespace "" } + +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <limits> +#include <stdfloat> + +namespace std { + template<class T> class numeric_limits; + +#if defined(__STDCPP_FLOAT16_T__) + template<> class numeric_limits<float16_t>; +#endif +#if defined(__STDCPP_FLOAT32_T__) + template<> class numeric_limits<float32_t>; +#endif +#if defined(__STDCPP_FLOAT64_T__) + template<> class numeric_limits<float64_t>; +#endif +#if defined(__STDCPP_FLOAT128_T__) + template<> class numeric_limits<float128_t>; +#endif +#if defined(__STDCPP_BFLOAT16_T__) + template<> class numeric_limits<bfloat16_t>; +#endif +} diff --git a/libstdc++-v3/testsuite/18_support/headers/stdfloat/types_std.cc b/libstdc++-v3/testsuite/18_support/headers/stdfloat/types_std.cc new file mode 100644 index 0000000..d852801 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/headers/stdfloat/types_std.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++2b" } +// { dg-do compile { target c++23 } } + +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <stdfloat> + +namespace gnu +{ +#if defined(__STDCPP_FLOAT16_T__) + typedef std::float16_t t1; +#endif +#if defined(__STDCPP_FLOAT32_T__) + typedef std::float32_t t2; +#endif +#if defined(__STDCPP_FLOAT64_T__) + typedef std::float64_t t3; +#endif +#if defined(__STDCPP_FLOAT128_T__) + typedef std::float128_t t4; +#endif +#if defined(__STDCPP_BFLOAT16_T__) + typedef std::bfloat16_t t5; +#endif +} diff --git a/libstdc++-v3/testsuite/20_util/to_chars/constexpr.cc b/libstdc++-v3/testsuite/20_util/to_chars/constexpr.cc index 30c5916..10855b7 100644 --- a/libstdc++-v3/testsuite/20_util/to_chars/constexpr.cc +++ b/libstdc++-v3/testsuite/20_util/to_chars/constexpr.cc @@ -5,7 +5,7 @@ #ifndef __cpp_lib_constexpr_charconv # error "Feature-test macro for constexpr charconv missing in <charconv>" -#elif __cpp_lib_constexpr_charconv != 202202L +#elif __cpp_lib_constexpr_charconv != 202207L # error "Feature-test macro for constexpr charconv has wrong value in <charconv>" #endif diff --git a/libstdc++-v3/testsuite/20_util/to_chars/version.cc b/libstdc++-v3/testsuite/20_util/to_chars/version.cc index af06e1b..25b1e00 100644 --- a/libstdc++-v3/testsuite/20_util/to_chars/version.cc +++ b/libstdc++-v3/testsuite/20_util/to_chars/version.cc @@ -11,6 +11,6 @@ #ifndef __cpp_lib_constexpr_charconv # error "Feature-test macro for constexpr charconv missing in <version>" -#elif __cpp_lib_constexpr_charconv != 202202L +#elif __cpp_lib_constexpr_charconv != 202207L # error "Feature-test macro for constexpr charconv has wrong value in <version>" #endif diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++23.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++23.cc new file mode 100644 index 0000000..0fda6a7 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++23.cc @@ -0,0 +1,96 @@ +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do link { target c++23 } } +// { dg-excess-errors "" { target uclibc } } + +#include <cmath> +#include <stdfloat> + +void fpclassify() { } + +void isfinite() { } + +void isinf() { } + +void isnan() { } + +void isnormal() { } + +void signbit() { } + +void isgreater() { } + +void isgreaterequal() { } + +void isless() { } + +void islessequal() { } + +void islessgreater() { } + +void isunordered() { } + +#if _GLIBCXX_USE_C99_MATH +template <typename _Tp, typename _Up = _Tp> + void test_c99_classify() + { + typedef _Tp fp_type_one; + typedef _Up fp_type_two; + fp_type_one f1 = _Tp(1.0); + fp_type_two f2 = _Up(3.0); + int resi; + volatile bool res; + + resi = std::fpclassify(f1); + res = std::isfinite(f2); + res = std::isinf(f1); + res = std::isnan(f2); + res = std::isnormal(f1); + res = std::signbit(f2); + res = std::isgreater(f1, f2); + res = std::isgreaterequal(f1, f2); + res = std::isless(f1, f2); + res = std::islessequal(f1,f2); + res = std::islessgreater(f1, f2); + res = std::isunordered(f1, f2); + resi = resi; // Suppress unused warning. + res = res; + } +#endif + +int main() +{ +#if _GLIBCXX_USE_C99_MATH +#ifdef __STDCPP_FLOAT16_T__ + test_c99_classify<std::float16_t>(); +#endif +#ifdef __STDCPP_FLOAT32_T__ + test_c99_classify<std::float32_t>(); +#endif +#ifdef __STDCPP_FLOAT64_T__ + test_c99_classify<std::float64_t>(); +#endif +#ifdef __STDCPP_FLOAT128_T__ + test_c99_classify<std::float128_t>(); +#endif +#ifdef __STDCPP_BFLOAT16_T__ + test_c99_classify<std::bfloat16_t>(); +#endif +#endif + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc new file mode 100644 index 0000000..190f8d1 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc @@ -0,0 +1,146 @@ +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do link { target c++23 } } + +#include <stdfloat> +#include <cmath> + +template <typename T> +__attribute__((__noipa__)) void +test_functions (T *p, int *q, long int *r, long long int *s) +{ + p[0] = std::acos (p[0]); + p[1] = std::asin (p[1]); + p[2] = std::atan (p[2]); + p[3] = std::cos (p[3]); + p[4] = std::sin (p[4]); + p[5] = std::tan (p[5]); + p[6] = std::acosh (p[6]); + p[7] = std::asinh (p[7]); + p[8] = std::atanh (p[8]); + p[9] = std::cosh (p[9]); + p[10] = std::sinh (p[10]); + p[11] = std::tanh (p[11]); + p[12] = std::exp (p[12]); + p[13] = std::exp2 (p[13]); + p[14] = std::expm1 (p[14]); + p[15] = std::log (p[15]); + p[16] = std::log10 (p[16]); + p[17] = std::log1p (p[17]); + p[18] = std::log2 (p[18]); + p[19] = std::logb (p[19]); + p[20] = std::cbrt (p[20]); + p[21] = std::fabs (p[21]); + p[22] = std::sqrt (p[22]); + p[23] = std::erf (p[23]); + p[24] = std::erfc (p[24]); + p[25] = std::lgamma (p[25]); + p[26] = std::tgamma (p[26]); + p[27] = std::ceil (p[27]); + p[28] = std::floor (p[28]); + p[29] = std::nearbyint (p[29]); + p[30] = std::rint (p[30]); + p[31] = std::round (p[31]); + p[32] = std::trunc (p[32]); + p[33] = std::atan2 (p[33], p[100]); + p[34] = std::hypot (p[34], p[101]); + p[35] = std::pow (p[35], p[102]); + p[36] = std::fmod (p[36], p[103]); + p[37] = std::remainder (p[37], p[104]); + p[38] = std::copysign (p[38], p[105]); + p[39] = std::nextafter (p[39], p[106]); + p[40] = std::fdim (p[40], p[107]); + p[41] = std::fmax (p[41], p[108]); + p[42] = std::fmin (p[42], p[109]); + p[43] = std::atan2 (p[43], p[110]); + p[44] = std::frexp (p[44], q + 0); + q[1] = std::ilogb (p[45]); + p[46] = std::ldexp (p[46], q[2]); + p[47] = std::modf (p[47], p + 111); + p[48] = std::scalbn (p[48], q[3]); + p[49] = std::scalbln (p[49], r[0]); + p[50] = std::hypot (p[50], p[111], p[112]); + r[1] = std::lrint (p[51]); + s[0] = std::llrint (p[52]); + r[2] = std::lround (p[53]); + s[1] = std::llround (p[54]); + p[55] = std::remquo (p[55], p[113], q + 4); + p[56] = std::fma (p[56], p[114], p[115]); + p[57] = std::lerp (p[57], p[116], p[117]); + p[58] = std::assoc_laguerre (q[5], q[6], p[58]); + p[59] = std::assoc_legendre (q[7], q[8], p[59]); + p[60] = std::beta (p[60], p[118]); + p[61] = std::comp_ellint_1 (p[61]); + p[62] = std::comp_ellint_2 (p[62]); + p[63] = std::comp_ellint_3 (p[63], p[119]); + p[64] = std::cyl_bessel_i (p[64], p[120]); + p[65] = std::cyl_bessel_j (p[65], p[121]); + p[66] = std::cyl_bessel_k (p[66], p[122]); + p[67] = std::cyl_neumann (p[67], p[123]); + p[68] = std::ellint_1 (p[68], p[124]); + p[69] = std::ellint_2 (p[69], p[125]); + p[70] = std::ellint_3 (p[70], p[126], p[127]); + p[71] = std::expint (p[71]); + p[72] = std::hermite (q[9], p[72]); + p[73] = std::laguerre (q[10], p[73]); + p[74] = std::legendre (q[11], p[72]); + p[75] = std::riemann_zeta (p[75]); + p[76] = std::sph_bessel (q[12], p[76]); + p[77] = std::sph_legendre (q[13], q[14], p[77]); + p[78] = std::sph_neumann (q[15], p[78]); +} + +int +main () +{ + int q[16] = {}; + long int r[16] = {}; + long long int s[16] = {}; +#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + { + std::float16_t p[128] = {}; + test_functions (p, q, r, s); + } +#endif +#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + { + std::float32_t p[128] = {}; + test_functions (p, q, r, s); + } +#endif +#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) + { + std::float64_t p[128] = {}; + test_functions (p, q, r, s); + } +#endif +#if defined(__STDCPP_FLOAT128_T__) \ + && (defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY128) \ + || defined(_GLIBCXX_HAVE_FLOAT128_MATH)) + { + std::float128_t p[128] = {}; + test_functions (p, q, r, s); + } +#endif +#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + { + std::bfloat16_t p[128] = {}; + test_functions (p, q, r, s); + } +#endif +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc new file mode 100644 index 0000000..45aa3b7 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc @@ -0,0 +1,125 @@ +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++2b" } +// { dg-do run { target c++23 } } + +#include <stdfloat> +#include <cmath> +#include <limits> +#include <testsuite_hooks.h> + +template <typename T> +void +test () +{ + using lim = std::numeric_limits<T>; + T t0 = std::nextafter(T(-0.0), T(2.0)); + VERIFY(t0 == lim::denorm_min()); + T t1 = std::nextafter(T(), T(1.0)); + VERIFY(t1 == lim::denorm_min()); + T t2 = std::nextafter(T(), T()); + VERIFY(t2 == T() && !std::signbit(t2)); + T t3 = std::nextafter(lim::denorm_min(), T(-2.0)); + VERIFY(t3 == T() && !std::signbit(t3)); + T t4 = std::nextafter(lim::min(), T(-0.0)); + VERIFY(std::fpclassify(t4) == FP_SUBNORMAL && t4 > T()); + T t5 = std::nextafter(t4, T(1.0)); + VERIFY(t5 == lim::min()); + T t6 = std::nextafter(lim::min(), lim::infinity()); + VERIFY(std::fpclassify(t6) == FP_NORMAL && t6 > lim::min()); + T t7 = std::nextafter(t6, -lim::infinity()); + VERIFY(t7 == lim::min()); + T t8 = std::nextafter(T(16.0), T(16.5)); + VERIFY(t8 > t7); + T t9 = std::nextafter(t8, T(15.5)); + VERIFY(t9 == T(16.0)); + T t10 = std::nextafter(lim::max(), T(-0.5)); + VERIFY(std::fpclassify(t10) == FP_NORMAL && t10 < lim::max()); + T t11 = std::nextafter(t10, lim::infinity()); + VERIFY(t11 == lim::max()); + T t12 = std::nextafter(t11, lim::infinity()); + VERIFY(std::fpclassify(t12) == FP_INFINITE && !std::signbit(t12)); + T t13 = std::nextafter(lim::infinity(), t12); + VERIFY(t13 == t12); + T t14 = std::nextafter(t13, T(1.0)); + VERIFY(t14 == lim::max()); + T t15 = std::nextafter(lim::quiet_NaN(), T()); + VERIFY(std::fpclassify(t15) == FP_NAN); + T t16 = std::nextafter(T(17.0), lim::quiet_NaN()); + VERIFY(std::fpclassify(t16) == FP_NAN); + T t17 = std::nextafter(T(), T(-0.0)); + VERIFY(t17 == T() && std::signbit(t17)); + T t20 = std::nextafter(T(-0.0), T(-2.0)); + VERIFY(t20 == -lim::denorm_min()); + T t21 = std::nextafter(T(), T(-1.0)); + VERIFY(t21 == -lim::denorm_min()); + T t22 = std::nextafter(T(-0.0), T(-0.0)); + VERIFY(t22 == T() && std::signbit(t22)); + T t23 = std::nextafter(-lim::denorm_min(), T(2.0)); + VERIFY(t23 == T() && std::signbit(t23)); + T t24 = std::nextafter(-lim::min(), T()); + VERIFY(std::fpclassify(t24) == FP_SUBNORMAL && t24 < T()); + T t25 = std::nextafter(t24, T(-1.0)); + VERIFY(t25 == -lim::min()); + T t26 = std::nextafter(-lim::min(), -lim::infinity()); + VERIFY(std::fpclassify(t26) == FP_NORMAL && t26 < -lim::min()); + T t27 = std::nextafter(t26, lim::infinity()); + VERIFY(t27 == -lim::min()); + T t28 = std::nextafter(T(-16.0), T(-16.5)); + VERIFY(t28 < t27); + T t29 = std::nextafter(t28, T(-15.5)); + VERIFY(t29 == T(-16.0)); + T t30 = std::nextafter(-lim::max(), T(0.5)); + VERIFY(std::fpclassify(t30) == FP_NORMAL && t30 > -lim::max()); + T t31 = std::nextafter(t30, -lim::infinity()); + VERIFY(t31 == -lim::max()); + T t32 = std::nextafter(t31, -lim::infinity()); + VERIFY(std::fpclassify(t32) == FP_INFINITE && std::signbit(t32)); + T t33 = std::nextafter(-lim::infinity(), t32); + VERIFY(t33 == t32); + T t34 = std::nextafter(t33, T(-1.0)); + VERIFY(t34 == -lim::max()); + T t35 = std::nextafter(-lim::quiet_NaN(), T()); + VERIFY(std::fpclassify(t35) == FP_NAN); + T t36 = std::nextafter(T(-17.0), lim::quiet_NaN()); + VERIFY(std::fpclassify(t36) == FP_NAN); + T t37 = std::nextafter(T(-0.0), T()); + VERIFY(t37 == T() && !std::signbit(t37)); +} + +int +main () +{ +#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + test <std::float16_t>(); +#endif +#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + test <std::float32_t>(); +#endif +#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) + test <std::float64_t>(); +#endif +#if defined(__STDCPP_FLOAT128_T__) \ + && (defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY128) \ + || defined(_GLIBCXX_HAVE_FLOAT128_MATH)) + test <std::float128_t>(); +#endif +#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) + test <std::bfloat16_t>(); +#endif +} diff --git a/libstdc++-v3/testsuite/26_numerics/numbers/4.cc b/libstdc++-v3/testsuite/26_numerics/numbers/4.cc new file mode 100644 index 0000000..4a59988 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/numbers/4.cc @@ -0,0 +1,122 @@ +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++2b" } +// { dg-do compile { target c++23 } } + +#include <numbers> +#include <stdfloat> + +#if defined(__STDCPP_FLOAT16_T__) +void +test01() +{ + const std::float16_t* d1 = &std::numbers::e_v<std::float16_t>; + const std::float16_t* d2 = &std::numbers::log2e_v<std::float16_t>; + const std::float16_t* d3 = &std::numbers::log10e_v<std::float16_t>; + const std::float16_t* d4 = &std::numbers::pi_v<std::float16_t>; + const std::float16_t* d5 = &std::numbers::inv_pi_v<std::float16_t>; + const std::float16_t* d6 = &std::numbers::inv_sqrtpi_v<std::float16_t>; + const std::float16_t* d7 = &std::numbers::ln2_v<std::float16_t>; + const std::float16_t* d8 = &std::numbers::ln10_v<std::float16_t>; + const std::float16_t* d9 = &std::numbers::sqrt2_v<std::float16_t>; + const std::float16_t* d10 = &std::numbers::sqrt3_v<std::float16_t>; + const std::float16_t* d11 = &std::numbers::inv_sqrt3_v<std::float16_t>; + const std::float16_t* d12 = &std::numbers::egamma_v<std::float16_t>; + const std::float16_t* d13 = &std::numbers::phi_v<std::float16_t>; +} +#endif + +#if defined(__STDCPP_FLOAT32_T__) +void +test02() +{ + const std::float32_t* d1 = &std::numbers::e_v<std::float32_t>; + const std::float32_t* d2 = &std::numbers::log2e_v<std::float32_t>; + const std::float32_t* d3 = &std::numbers::log10e_v<std::float32_t>; + const std::float32_t* d4 = &std::numbers::pi_v<std::float32_t>; + const std::float32_t* d5 = &std::numbers::inv_pi_v<std::float32_t>; + const std::float32_t* d6 = &std::numbers::inv_sqrtpi_v<std::float32_t>; + const std::float32_t* d7 = &std::numbers::ln2_v<std::float32_t>; + const std::float32_t* d8 = &std::numbers::ln10_v<std::float32_t>; + const std::float32_t* d9 = &std::numbers::sqrt2_v<std::float32_t>; + const std::float32_t* d10 = &std::numbers::sqrt3_v<std::float32_t>; + const std::float32_t* d11 = &std::numbers::inv_sqrt3_v<std::float32_t>; + const std::float32_t* d12 = &std::numbers::egamma_v<std::float32_t>; + const std::float32_t* d13 = &std::numbers::phi_v<std::float32_t>; +} +#endif + +#if defined(__STDCPP_FLOAT64_T__) +void +test03() +{ + const std::float64_t* d1 = &std::numbers::e_v<std::float64_t>; + const std::float64_t* d2 = &std::numbers::log2e_v<std::float64_t>; + const std::float64_t* d3 = &std::numbers::log10e_v<std::float64_t>; + const std::float64_t* d4 = &std::numbers::pi_v<std::float64_t>; + const std::float64_t* d5 = &std::numbers::inv_pi_v<std::float64_t>; + const std::float64_t* d6 = &std::numbers::inv_sqrtpi_v<std::float64_t>; + const std::float64_t* d7 = &std::numbers::ln2_v<std::float64_t>; + const std::float64_t* d8 = &std::numbers::ln10_v<std::float64_t>; + const std::float64_t* d9 = &std::numbers::sqrt2_v<std::float64_t>; + const std::float64_t* d10 = &std::numbers::sqrt3_v<std::float64_t>; + const std::float64_t* d11 = &std::numbers::inv_sqrt3_v<std::float64_t>; + const std::float64_t* d12 = &std::numbers::egamma_v<std::float64_t>; + const std::float64_t* d13 = &std::numbers::phi_v<std::float64_t>; +} +#endif + +#if defined(__STDCPP_FLOAT128_T__) +void +test04() +{ + const std::float128_t* d1 = &std::numbers::e_v<std::float128_t>; + const std::float128_t* d2 = &std::numbers::log2e_v<std::float128_t>; + const std::float128_t* d3 = &std::numbers::log10e_v<std::float128_t>; + const std::float128_t* d4 = &std::numbers::pi_v<std::float128_t>; + const std::float128_t* d5 = &std::numbers::inv_pi_v<std::float128_t>; + const std::float128_t* d6 = &std::numbers::inv_sqrtpi_v<std::float128_t>; + const std::float128_t* d7 = &std::numbers::ln2_v<std::float128_t>; + const std::float128_t* d8 = &std::numbers::ln10_v<std::float128_t>; + const std::float128_t* d9 = &std::numbers::sqrt2_v<std::float128_t>; + const std::float128_t* d10 = &std::numbers::sqrt3_v<std::float128_t>; + const std::float128_t* d11 = &std::numbers::inv_sqrt3_v<std::float128_t>; + const std::float128_t* d12 = &std::numbers::egamma_v<std::float128_t>; + const std::float128_t* d13 = &std::numbers::phi_v<std::float128_t>; +} +#endif + +#if defined(__STDCPP_BFLOAT16_T__) +void +test05() +{ + const std::bfloat16_t* d1 = &std::numbers::e_v<std::bfloat16_t>; + const std::bfloat16_t* d2 = &std::numbers::log2e_v<std::bfloat16_t>; + const std::bfloat16_t* d3 = &std::numbers::log10e_v<std::bfloat16_t>; + const std::bfloat16_t* d4 = &std::numbers::pi_v<std::bfloat16_t>; + const std::bfloat16_t* d5 = &std::numbers::inv_pi_v<std::bfloat16_t>; + const std::bfloat16_t* d6 = &std::numbers::inv_sqrtpi_v<std::bfloat16_t>; + const std::bfloat16_t* d7 = &std::numbers::ln2_v<std::bfloat16_t>; + const std::bfloat16_t* d8 = &std::numbers::ln10_v<std::bfloat16_t>; + const std::bfloat16_t* d9 = &std::numbers::sqrt2_v<std::bfloat16_t>; + const std::bfloat16_t* d10 = &std::numbers::sqrt3_v<std::bfloat16_t>; + const std::bfloat16_t* d11 = &std::numbers::inv_sqrt3_v<std::bfloat16_t>; + const std::bfloat16_t* d12 = &std::numbers::egamma_v<std::bfloat16_t>; + const std::bfloat16_t* d13 = &std::numbers::phi_v<std::bfloat16_t>; +} +#endif diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_float/requirements_cxx23.cc b/libstdc++-v3/testsuite/29_atomics/atomic_float/requirements_cxx23.cc new file mode 100644 index 0000000..9c33b25 --- /dev/null +++ b/libstdc++-v3/testsuite/29_atomics/atomic_float/requirements_cxx23.cc @@ -0,0 +1,112 @@ +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++2b" } +// { dg-do compile { target c++23 } } + +#include <atomic> +#include <stdfloat> + +#if defined(__STDCPP_FLOAT16_T__) +void +test01() +{ + using A = std::atomic<std::float16_t>; + static_assert( std::is_standard_layout_v<A> ); + static_assert( !std::is_trivially_default_constructible_v<A> ); + static_assert( std::is_trivially_destructible_v<A> ); + static_assert( std::is_same_v<A::value_type, std::float16_t> ); + static_assert( std::is_same_v<A::difference_type, A::value_type> ); + static_assert( !std::is_copy_constructible_v<A> ); + static_assert( !std::is_move_constructible_v<A> ); + static_assert( !std::is_copy_assignable_v<A> ); + static_assert( !std::is_move_assignable_v<A> ); + static_assert( !std::is_assignable_v<volatile A&, const A&> ); +} +#endif + +#if defined(__STDCPP_FLOAT32_T__) +void +test02() +{ + using A = std::atomic<std::float32_t>; + static_assert( std::is_standard_layout_v<A> ); + static_assert( !std::is_trivially_default_constructible_v<A> ); + static_assert( std::is_trivially_destructible_v<A> ); + static_assert( std::is_same_v<A::value_type, std::float32_t> ); + static_assert( std::is_same_v<A::difference_type, A::value_type> ); + static_assert( !std::is_copy_constructible_v<A> ); + static_assert( !std::is_move_constructible_v<A> ); + static_assert( !std::is_copy_assignable_v<A> ); + static_assert( !std::is_move_assignable_v<A> ); + static_assert( !std::is_assignable_v<volatile A&, const A&> ); +} +#endif + +#if defined(__STDCPP_FLOAT64_T__) +void +test03() +{ + using A = std::atomic<std::float64_t>; + static_assert( std::is_standard_layout_v<A> ); + static_assert( !std::is_trivially_default_constructible_v<A> ); + static_assert( std::is_trivially_destructible_v<A> ); + static_assert( std::is_same_v<A::value_type, std::float64_t> ); + static_assert( std::is_same_v<A::difference_type, A::value_type> ); + static_assert( !std::is_copy_constructible_v<A> ); + static_assert( !std::is_move_constructible_v<A> ); + static_assert( !std::is_copy_assignable_v<A> ); + static_assert( !std::is_move_assignable_v<A> ); + static_assert( !std::is_assignable_v<volatile A&, const A&> ); +} +#endif + +#if defined(__STDCPP_FLOAT128_T__) +void +test04() +{ + using A = std::atomic<std::float128_t>; + static_assert( std::is_standard_layout_v<A> ); + static_assert( !std::is_trivially_default_constructible_v<A> ); + static_assert( std::is_trivially_destructible_v<A> ); + static_assert( std::is_same_v<A::value_type, std::float128_t> ); + static_assert( std::is_same_v<A::difference_type, A::value_type> ); + static_assert( !std::is_copy_constructible_v<A> ); + static_assert( !std::is_move_constructible_v<A> ); + static_assert( !std::is_copy_assignable_v<A> ); + static_assert( !std::is_move_assignable_v<A> ); + static_assert( !std::is_assignable_v<volatile A&, const A&> ); +} +#endif + +#if defined(__STDCPP_BFLOAT16_T__) +void +test05() +{ + using A = std::atomic<std::bfloat16_t>; + static_assert( std::is_standard_layout_v<A> ); + static_assert( !std::is_trivially_default_constructible_v<A> ); + static_assert( std::is_trivially_destructible_v<A> ); + static_assert( std::is_same_v<A::value_type, std::bfloat16_t> ); + static_assert( std::is_same_v<A::difference_type, A::value_type> ); + static_assert( !std::is_copy_constructible_v<A> ); + static_assert( !std::is_move_constructible_v<A> ); + static_assert( !std::is_copy_assignable_v<A> ); + static_assert( !std::is_move_assignable_v<A> ); + static_assert( !std::is_assignable_v<volatile A&, const A&> ); +} +#endif diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc new file mode 100644 index 0000000..745d1a6 --- /dev/null +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc @@ -0,0 +1,73 @@ +// { dg-options "-std=gnu++23" } +// { dg-do run { target c++23 } } + +#include <ranges> +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +namespace ranges = std::ranges; +namespace views = std::views; + +constexpr bool +test01() +{ + int x[] = {1, 2, 3, 4, 5, 6, 7}; + + auto v2 = x | views::stride(2); + const auto i0 = v2.begin(), i1 = v2.begin() + 1; + VERIFY( i0 + 1 - 1 == i0 ); + VERIFY( i0 != i1 ); + VERIFY( i0 < i1 ); + VERIFY( i0 <= i0 ); + VERIFY( i0 >= i0 ); + VERIFY( v2.end() > i1 ); + VERIFY( i1 - i0 == 1 ); + VERIFY( i0 - i1 == -1 ); + VERIFY( v2.end() - i1 == 3 ); + VERIFY( i1 - v2.end() == -3 ); + auto i2 = v2.begin(); + i2 += 2; + i2 -= -2; + VERIFY( i2 == v2.end() ); + VERIFY( ranges::size(v2) == 4 ); + VERIFY( ranges::equal(v2, (int[]){1, 3, 5, 7}) ); + VERIFY( ranges::equal(v2 | views::reverse, (int[]){7, 5, 3, 1}) ); + VERIFY( v2.stride() == 2 ); + + auto v1 = x | views::stride(1); + VERIFY( ranges::size(v1) == ranges::size(x) ); + VERIFY( ranges::equal(v1, x) ); + VERIFY( ranges::equal(v1 | views::reverse, x | views::reverse) ); + VERIFY( v1.stride() == 1 ); + + auto v5 = x | views::stride(5); + VERIFY( ranges::equal(v5, (int[]){1, 6}) ); + VERIFY( ranges::equal(v5 | views::reverse, (int[]){6, 1}) ); + VERIFY( v5.stride() == 5 ); + + auto v10 = x | views::stride(10); + VERIFY( ranges::equal(v10, (int[]){1}) ); + VERIFY( ranges::equal(v10 | views::reverse, (int[]){1}) ); + VERIFY( v10.stride() == 10 ); + + return true; +} + +template<class container> +void +test02() +{ + int x[] = {1, 2, 3, 4, 5, 6, 7, 8}; + container rx(x); + auto v = rx | views::stride(3); + VERIFY( ranges::equal(v, (int[]){1, 4, 7}) ); +} + +int +main() +{ + static_assert(test01()); + test02<__gnu_test::test_input_range<int>>(); + test02<__gnu_test::test_forward_range<int>>(); +} |