aboutsummaryrefslogtreecommitdiff
path: root/math/math.h
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2022-09-30 19:36:41 +0000
committerJoseph Myers <joseph@codesourcery.com>2022-09-30 19:36:41 +0000
commitba70f6959876b6daba180afbe427710e4383e357 (patch)
tree51503b85a9b486a15eedbdd0ded7b6ba3ed60f9f /math/math.h
parent609c9d0951da387cd523b5db42a82d38dabc37c4 (diff)
downloadglibc-ba70f6959876b6daba180afbe427710e4383e357.zip
glibc-ba70f6959876b6daba180afbe427710e4383e357.tar.gz
glibc-ba70f6959876b6daba180afbe427710e4383e357.tar.bz2
Fix iseqsig for _FloatN and _FloatNx in C++ with GCC 13
With GCC 13, _FloatN and _FloatNx types, when they exist, are distinct types like they are in C with GCC 7 and later, rather than typedefs for types such as float, double or long double. This breaks the templated iseqsig implementation for C++ in <math.h>, when used with types that were previously implemented as aliases. Add the necessary definitions for _Float32, _Float64, _Float128 (when the same format as long double), _Float32x and _Float64x in this case, so that iseqsig can be used with such types in C++ with GCC 13 as it could with previous GCC versions. Also add tests for calling iseqsig in C++ with arguments of such types (more minimal than existing tests, so that they can work with older GCC versions and without relying on any C++ library support for the types or on hardcoding details of their formats). The LDBL_MANT_DIG != 106 conditionals on some tests are because the type-generic comparison macros have undefined behavior when neither argument has a type whose set of values is a subset of those for the type of the other argument, which applies when one argument is IBM long double and the other is an IEEE format wider than binary64. Tested with build-many-glibcs.py glibcs build for aarch64-linux-gnu i686-linux-gnu mips-linux-gnu mips64-linux-gnu-n32 powerpc-linux-gnu powerpc64le-linux-gnu x86_64-linux-gnu.
Diffstat (limited to 'math/math.h')
-rw-r--r--math/math.h50
1 files changed, 49 insertions, 1 deletions
diff --git a/math/math.h b/math/math.h
index 27963ef..cf980c3 100644
--- a/math/math.h
+++ b/math/math.h
@@ -1391,14 +1391,62 @@ template<> struct __iseqsig_type<long double>
}
};
-# if __HAVE_FLOAT128_UNLIKE_LDBL
+# if __HAVE_FLOAT32 && __GNUC_PREREQ (13, 0)
+template<> struct __iseqsig_type<_Float32>
+{
+ static int __call (_Float32 __x, _Float32 __y) throw ()
+ {
+ return __iseqsigf (__x, __y);
+ }
+};
+# endif
+
+# if __HAVE_FLOAT64 && __GNUC_PREREQ (13, 0)
+template<> struct __iseqsig_type<_Float64>
+{
+ static int __call (_Float64 __x, _Float64 __y) throw ()
+ {
+ return __iseqsig (__x, __y);
+ }
+};
+# endif
+
+# if __HAVE_FLOAT128_UNLIKE_LDBL || (__HAVE_FLOAT128 && __GNUC_PREREQ (13, 0))
/* When using an IEEE 128-bit long double, _Float128 is defined as long double
in C++. */
template<> struct __iseqsig_type<_Float128>
{
static int __call (_Float128 __x, _Float128 __y) throw ()
{
+# if __HAVE_FLOAT128_UNLIKE_LDBL
return __iseqsigf128 (__x, __y);
+# else
+ return __iseqsigl (__x, __y);
+# endif
+ }
+};
+# endif
+
+# if __HAVE_FLOAT32X && __GNUC_PREREQ (13, 0)
+template<> struct __iseqsig_type<_Float32x>
+{
+ static int __call (_Float32x __x, _Float32x __y) throw ()
+ {
+ return __iseqsig (__x, __y);
+ }
+};
+# endif
+
+# if __HAVE_FLOAT64X && __GNUC_PREREQ (13, 0)
+template<> struct __iseqsig_type<_Float64x>
+{
+ static int __call (_Float64x __x, _Float64x __y) throw ()
+ {
+# if __HAVE_FLOAT64X_LONG_DOUBLE
+ return __iseqsigl (__x, __y);
+# else
+ return __iseqsigf128 (__x, __y);
+# endif
}
};
# endif