Module Name:    src
Committed By:   kre
Date:           Thu May  2 03:30:07 UTC 2024

Modified Files:
        src/tests/lib/libm: t_fe_round.c

Log Message:
Use intmax_t instead of long int when trying to represent very large
integers (10^50 or so), so we don't exceed the capacity of systems where
long int is only 32 bits.

Hopefully will unbreak the i386 build, perhaps others.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libm/t_fe_round.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libm/t_fe_round.c
diff -u src/tests/lib/libm/t_fe_round.c:1.11 src/tests/lib/libm/t_fe_round.c:1.12
--- src/tests/lib/libm/t_fe_round.c:1.11	Thu May  2 00:01:48 2024
+++ src/tests/lib/libm/t_fe_round.c	Thu May  2 03:30:07 2024
@@ -9,6 +9,7 @@
 #include <fenv.h>
 #ifdef __HAVE_FENV
 #include <math.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -145,24 +146,28 @@ ATF_TC_BODY(fe_nearbyint, tc)
 
 #ifdef __HAVE_LONG_DOUBLE
 
+#define IM intmax_t
+
 /*
  * Use one bit more than fits in IEEE 754 binary64.
  */
 static const struct {
 	int round_mode;
 	long double input;
-	long int expected;
+	IM expected;
 } valuesl[] = {
-	{ FE_TOWARDZERO,	0x2.00000000000008p+52L, 0x20000000000000 },
-	{ FE_DOWNWARD,		0x2.00000000000008p+52L, 0x20000000000000 },
-	{ FE_UPWARD,		0x2.00000000000008p+52L, 0x20000000000001 },
-	{ FE_TONEAREST,		0x2.00000000000008p+52L, 0x20000000000000 },
-	{ FE_TOWARDZERO,	0x2.00000000000018p+52L, 0x20000000000001 },
-	{ FE_DOWNWARD,		0x2.00000000000018p+52L, 0x20000000000001 },
-	{ FE_UPWARD,		0x2.00000000000018p+52L, 0x20000000000002 },
-	{ FE_TONEAREST,		0x2.00000000000018p+52L, 0x20000000000002 },
+	{ FE_TOWARDZERO,	0x2.00000000000008p+52L, (IM)0x20000000000000 },
+	{ FE_DOWNWARD,		0x2.00000000000008p+52L, (IM)0x20000000000000 },
+	{ FE_UPWARD,		0x2.00000000000008p+52L, (IM)0x20000000000001 },
+	{ FE_TONEAREST,		0x2.00000000000008p+52L, (IM)0x20000000000000 },
+	{ FE_TOWARDZERO,	0x2.00000000000018p+52L, (IM)0x20000000000001 },
+	{ FE_DOWNWARD,		0x2.00000000000018p+52L, (IM)0x20000000000001 },
+	{ FE_UPWARD,		0x2.00000000000018p+52L, (IM)0x20000000000002 },
+	{ FE_TONEAREST,		0x2.00000000000018p+52L, (IM)0x20000000000002 },
 };
 
+#undef IM
+
 ATF_TC(fe_nearbyintl);
 ATF_TC_HEAD(fe_nearbyintl, tc)
 {
@@ -183,7 +188,7 @@ ATF_TC_BODY(fe_nearbyintl, tc)
 		    "%s nearbyintl(%Lf) has fractional part %Lf",
 		    rmname(values[i].round_mode), valuesl[i].input, fpart);
 		ATF_CHECK_MSG((long int)received == valuesl[i].expected,
-		    "%s [%u] nearbyint(%Lf): got %Lf, expected %ld",
+		    "%s [%u] nearbyint(%Lf): got %Lf, expected %jd",
 		    rmname(values[i].round_mode), i,
 		    valuesl[i].input, received, valuesl[i].expected);
 

Reply via email to