aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std/limits
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-10-19 11:25:03 +0200
committerJakub Jelinek <jakub@redhat.com>2022-10-19 11:26:17 +0200
commitba281da28d34f9a78a07f6ee56ad2c754447966e (patch)
tree138b87b22ce59fc64ded5d445160605eda5c22fd /libstdc++-v3/include/std/limits
parent8f7df3338c16471a38784983531e57aa2dba1d03 (diff)
downloadgcc-ba281da28d34f9a78a07f6ee56ad2c754447966e.zip
gcc-ba281da28d34f9a78a07f6ee56ad2c754447966e.tar.gz
gcc-ba281da28d34f9a78a07f6ee56ad2c754447966e.tar.bz2
libstdc++-v3: Implement {,b}float16_t nextafter and some fixes [PR106652]
The following patch implements nextafter for std::{,b}float16_t, though right now only without constexpr support, and adds a testcase for it. The testcase unfortunately relevealed I've screwed up testing of my last patch. I've tested earlier version of the patch with --target_board=unix/-std=c++23 but didn't test the final version with that RUNTESTFLAGS, so missed an invalid call to std::sph_neumann (too many arguments) in the test. And, I've made a typo in the guard for numeric_limits (the reason for the guard is I wanted to avoid defining a large macro that nothing will then use because the std::{,b}float*_t types are C++23 only) and so numeric_limits wasn't specialized for the types at all but testsuite/18_support/headers/limits/synopsis_cxx23.cc test didn't detect that. In the nextafter implementation I'm calling __builtin_nextafterf to get various required side-effects for nextafter from 0/-0, or from max to inf or from min to largest subnormal to avoid needing to set errno inline, or use inline asm specific for each processor to force math evaluation barriers. Dunno if #ifdef __INT16_TYPE__ using __float16_int_type = __INT16_TYPE__; #else using __float16_int_type = short int; #endif isn't too ugly, perhaps we could just blindly use short int and hope or even assert it has the same size as _Float16 or __gnu_cxx::__bfloat16_t? Only aarch64, arm, csky, gcn, x86, nvptx and riscv support these types and all of them have 16-bit short (I think the only target with some other short size is avr with certain command line switches where both short and int are 8-bit, but such mode isn't compatible with C and C++ requirements). 2022-10-19 Jakub Jelinek <jakub@redhat.com> PR c++/106652 * include/std/limits: Fix a typo, 202202L -> 202002L. (numeric_limits::<_Float16>::radix, numeric_limits::<_Float32>::radix, numeric_limits::<_Float64>::radix, numeric_limits::<_Float128>::radix, numeric_limits::<__gnu_cxx::__bfloat16_t>::radix): Use __FLT_RADIX__ macro instead of type specific macros. * include/c_global/cmath (nextafter(_Float16, _Float16)): New overload. (nextafter(__gnu_cxx::__bfloat16_t, __gnu_cxx::__bfloat16_t)): Likewise. * testsuite/26_numerics/headers/cmath/functions_std_c++23.cc (test_functions): Uncomment nextafter test. Fix up sph_neumann call. * testsuite/26_numerics/headers/cmath/nextafter_c++23.cc: New test.
Diffstat (limited to 'libstdc++-v3/include/std/limits')
-rw-r--r--libstdc++-v3/include/std/limits7
1 files changed, 3 insertions, 4 deletions
diff --git a/libstdc++-v3/include/std/limits b/libstdc++-v3/include/std/limits
index 61b6c3b..9dde9f3 100644
--- a/libstdc++-v3/include/std/limits
+++ b/libstdc++-v3/include/std/limits
@@ -1890,7 +1890,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#undef __glibcxx_long_double_traps
#undef __glibcxx_long_double_tinyness_before
-#if __cplusplus > 202202L
+#if __cplusplus > 202002L
#define __glibcxx_concat3_(P,M,S) P ## M ## S
#define __glibcxx_concat3(P,M,S) __glibcxx_concat3_ (P,M,S)
@@ -1924,8 +1924,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static constexpr bool is_signed = true; \
static constexpr bool is_integer = false; \
static constexpr bool is_exact = false; \
- static constexpr int radix \
- = __glibcxx_concat3 (__FLT, BITSIZE, _RADIX__); \
+ static constexpr int radix = __FLT_RADIX__; \
\
static constexpr _Float##BITSIZE \
epsilon() noexcept \
@@ -2023,7 +2022,7 @@ __glibcxx_float_n(128)
static constexpr bool is_signed = true;
static constexpr bool is_integer = false;
static constexpr bool is_exact = false;
- static constexpr int radix = __BFLT16_RADIX__;
+ static constexpr int radix = __FLT_RADIX__;
static constexpr __gnu_cxx::__bfloat16_t
epsilon() noexcept