On 2025-07-06 14:08, C. Neidahl wrote:
The test is now failing on the equality check of LDBL_NORM_MAX and LDBL_MAX.

Thanks for reporting that too. I installed the attached further patch; please give it a try on your platform.
From 65ed9d3b24ad09fd61d326c83e7f1b05f6e9d65f Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 6 Jul 2025 16:22:05 -0700
Subject: [PATCH] float-h: port to C23 PowerPC GCC

* lib/float.in.h (LDBL_MAX) [__LDBL_NORM_MAX__]: Do not override, as
GCC versions defining __LDBL_NORM_MAX__ surely have LDBL_MAX right.
(LDBL_NORM_MAX): Prefer __LDBL_NORM_MAX__ if defined.
Otherwise, hardcode PowerPC value if applicable.
* tests/test-float-h.c (normalize_long_double):
Fix typo that broke this function when given large numbers.
(test_long_double): Normalize LDBL_MAX before comparing it
to LDBL_NORM_MAX.
---
 ChangeLog            | 10 ++++++++--
 lib/float.in.h       | 10 ++++++++--
 tests/test-float-h.c |  4 ++--
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index df445d4b76..998838c98f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,14 @@
 2025-07-06  Paul Eggert  <egg...@cs.ucla.edu>
 
 	float-h-tests: port to C23 PowerPC GCC
-	Problem reported by C. Neidhal
-	<https://lists.gnu.org/r/bug-gnulib/2025-07/msg00021.html>.
+	Problems reported by C. Neidhal in:
+	https://lists.gnu.org/r/bug-gnulib/2025-07/msg00021.html
+	https://lists.gnu.org/r/bug-gnulib/2025-07/msg00027.html
+	* lib/float.in.h (LDBL_MAX): Do not override on PowerPC
+	if __LDBL_NORM_MAX__ is defined, as GCC versions defining that
+	symbol surely have LDBL_MAX right.
+	(LDBL_NORM_MAX): Prefer __LDBL_NORM_MAX__ if defined.
+	Otherwise, hardcode PowerPC value if applicable.
 	* modules/float-h-tests (Depends-on): Add floorl, frexpl, ldexpl.
 	(test_float_h_LDADD): Link the resulting libms too.
 	* tests/test-float-h.c: Include math.h.
diff --git a/lib/float.in.h b/lib/float.in.h
index 54093f6e7e..86af55ad1b 100644
--- a/lib/float.in.h
+++ b/lib/float.in.h
@@ -124,7 +124,7 @@ extern const union gl_long_double_union gl_LDBL_MAX;
 # undef LDBL_MIN
 # define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
 #endif
-#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
+#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__ && !defined __LDBL_NORM_MAX__
 # undef LDBL_MAX
 /* LDBL_MAX is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xFFFFFFFF }.
    It is not easy to define:
@@ -309,7 +309,13 @@ extern gl_DBL_SNAN_t gl_DBL_SNAN;
 # endif
 #endif
 #ifndef LDBL_NORM_MAX
-# define LDBL_NORM_MAX LDBL_MAX
+# ifdef __LDBL_NORM_MAX__
+#  define LDBL_NORM_MAX __LDBL_NORM_MAX__
+# elif FLT_RADIX == 2 && LDBL_MAX_EXP == 1024 && LDBL_MANT_DIG == 106
+#  define LDBL_NORM_MAX 8.98846567431157953864652595394501E+307L
+# else
+#  define LDBL_NORM_MAX LDBL_MAX
+# endif
 #endif
 #ifndef LDBL_SNAN
 /* For sh, beware of <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111814>.  */
diff --git a/tests/test-float-h.c b/tests/test-float-h.c
index c0440bc3f0..1e294c87e0 100644
--- a/tests/test-float-h.c
+++ b/tests/test-float-h.c
@@ -412,7 +412,7 @@ normalize_long_double (long double volatile x)
     {
       int xexp;
       long double volatile xfrac = frexpl (x, &xexp);
-      x = ldexpl (floorl (ldexpl (xfrac, LDBL_MANT_DIG - xexp)),
+      x = ldexpl (floorl (ldexpl (xfrac, LDBL_MANT_DIG)),
                   xexp - LDBL_MANT_DIG);
     }
   else
@@ -510,7 +510,7 @@ test_long_double (void)
 #endif
 
   /* Check the value of LDBL_NORM_MAX.  */
-  ASSERT (LDBL_NORM_MAX == LDBL_MAX);
+  ASSERT (LDBL_NORM_MAX == normalize_long_double (LDBL_MAX));
 
   /* Check the value of LDBL_SNAN.  */
   ASSERT (isnanl (LDBL_SNAN));
-- 
2.48.1

Reply via email to