fenv-*: Fix for FreeBSD/powerpc64 and NetBSD/powerpc

2024-01-19 Thread Bruno Haible
On FreeBSD 14.0/powerpc64 and NetBSD 9.3/powerpc I'm seeing many test failures
of the fenv-* modules:

* FreeBSD 14.0/powerpc64 and FreeBSD 14.0/powerpc64le:

FAIL: test-fenv-env-2
FAIL: test-fenv-env-3
FAIL: test-fenv-env-4
FAIL: test-fenv-env-5
FAIL: test-fenv-except-state-2
FAIL: test-fenv-except-tracking-4
FAIL: test-fenv-except-tracking-1
FAIL: test-fenv-except-trapping-2.sh

* NetBSD 9.3/powerpc:

FAIL: test-fenv-env-2
FAIL: test-fenv-env-3
FAIL: test-fenv-env-4
FAIL: test-fenv-env-5
FAIL: test-fenv-env-6.sh
FAIL: test-fenv-except-state-2
FAIL: test-fenv-except-tracking-4
FAIL: test-fenv-except-tracking-1
FAIL: test-fenv-except-trapping-2.sh

This series of patches fixes them.


2024-01-19  Bruno Haible  

fenv-environment: Fix for NetBSD/powerpc.
* m4/fenv-environment.m4 (gl_FENV_ENVIRONMENT): For feupdateenv, use
the same configure test on NetBSD/powerpc as on glibc/hppa.
* doc/posix-functions/feupdateenv.texi: Mention the NetBSD/powerpc bug.

fenv-exceptions-trapping: Avoid a test failure on *BSD/powerpc*.
* tests/test-fenv-except-trapping-2.c (main): Skip the '4' tests also on
FreeBSD/powerpc* and NetBSD/powerpc*.

fenv-exceptions-state-c99: Fix for FreeBSD/powerpc64 and NetBSD/powerpc.
* m4/fenv-exceptions-state.m4 (gl_FENV_EXCEPTIONS_STATE): On
FreeBSD/powerpc64 and NetBSD/powerpc, set REPLACE_FESETEXCEPTFLAG.
* doc/posix-functions/fesetexceptflag.texi: Mention the FreeBSD and
NetBSD bug.

fenv-*: Avoid test failures on FreeBSD/powerpc64 and NetBSD/powerpc.
On these platforms, FE_ALL_EXCEPT contains additional bits.
* tests/test-fenv-except-tracking-1.c (FE_VXSOFT, FE_VXZDZ): Define
fallbacks.
(main): Allow fetestexcept(FE_ALL_EXCEPT) to contain FE_VXSOFT or
FE_VXZDZ in addition to FE_INVALID.
* tests/test-fenv-except-tracking-4.c (FE_VXSOFT): Define fallback.
(main): Allow fetestexcept(FE_ALL_EXCEPT) to contain FE_VXSOFT in
addition to FE_INVALID.
* tests/test-fenv-env-2.c: Likewise.
* tests/test-fenv-env-3.c: Likewise.
* tests/test-fenv-env-4.c: Likewise.
* tests/test-fenv-env-5.c: Likewise.

>From 48a7fb40d822bb96d89bf2a1be61b3497b89a267 Mon Sep 17 00:00:00 2001
From: Bruno Haible 
Date: Fri, 19 Jan 2024 22:04:33 +0100
Subject: [PATCH 1/4] fenv-*: Avoid test failures on FreeBSD/powerpc64 and
 NetBSD/powerpc.

On these platforms, FE_ALL_EXCEPT contains additional bits.

* tests/test-fenv-except-tracking-1.c (FE_VXSOFT, FE_VXZDZ): Define
fallbacks.
(main): Allow fetestexcept(FE_ALL_EXCEPT) to contain FE_VXSOFT or
FE_VXZDZ in addition to FE_INVALID.
* tests/test-fenv-except-tracking-4.c (FE_VXSOFT): Define fallback.
(main): Allow fetestexcept(FE_ALL_EXCEPT) to contain FE_VXSOFT in
addition to FE_INVALID.
* tests/test-fenv-env-2.c: Likewise.
* tests/test-fenv-env-3.c: Likewise.
* tests/test-fenv-env-4.c: Likewise.
* tests/test-fenv-env-5.c: Likewise.
---
 ChangeLog   | 16 
 tests/test-fenv-env-2.c | 15 +--
 tests/test-fenv-env-3.c | 25 +
 tests/test-fenv-env-4.c | 10 +-
 tests/test-fenv-env-5.c | 15 +--
 tests/test-fenv-except-tracking-1.c | 22 +++---
 tests/test-fenv-except-tracking-4.c |  7 ++-
 7 files changed, 93 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 71516a86b8..6901b278f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2024-01-19  Bruno Haible  
+
+	fenv-*: Avoid test failures on FreeBSD/powerpc64 and NetBSD/powerpc.
+	On these platforms, FE_ALL_EXCEPT contains additional bits.
+	* tests/test-fenv-except-tracking-1.c (FE_VXSOFT, FE_VXZDZ): Define
+	fallbacks.
+	(main): Allow fetestexcept(FE_ALL_EXCEPT) to contain FE_VXSOFT or
+	FE_VXZDZ in addition to FE_INVALID.
+	* tests/test-fenv-except-tracking-4.c (FE_VXSOFT): Define fallback.
+	(main): Allow fetestexcept(FE_ALL_EXCEPT) to contain FE_VXSOFT in
+	addition to FE_INVALID.
+	* tests/test-fenv-env-2.c: Likewise.
+	* tests/test-fenv-env-3.c: Likewise.
+	* tests/test-fenv-env-4.c: Likewise.
+	* tests/test-fenv-env-5.c: Likewise.
+
 2024-01-19  Bruno Haible  
 
 	fenv-*: Fix test failures on NetBSD 9.3/arm64.
diff --git a/tests/test-fenv-env-2.c b/tests/test-fenv-env-2.c
index 9ea5b096bb..f1cc482608 100644
--- a/tests/test-fenv-env-2.c
+++ b/tests/test-fenv-env-2.c
@@ -25,6 +25,11 @@
 
 /* Test the combination of fegetenv() with fesetenv().  */
 
+/* On *BSD/powerpc systems, raising FE_INVALID also sets FE_VXSOFT.  */
+#ifndef FE_VXSOFT
+# define FE_VXSOFT 0
+#endif
+
 int
 main ()
 {
@@ -49,7 +54,10 @@ main ()
   ASSERT (fegetenv () == 0);
 
   /* Check that the exception flags are unmodified.  */
-  ASSERT (fetestexcept (FE_ALL_EXCEPT) == (supports_tracking ? FE_INVALID | FE_OVERFLOW | FE_INEXACT : 0));
+  if (supports_tracking)
+ASSERT 

fenv-*: Fix test failures on NetBSD 9.3/arm64

2024-01-19 Thread Bruno Haible
On NetBSD 9.3/arm64, I see the attached test failures of fenv* tests.

This patch fixes them all.


2024-01-19  Bruno Haible  

fenv-*: Fix test failures on NetBSD 9.3/arm64.
* m4/fenv-exceptions-trapping.m4 (gl_FENV_EXCEPTIONS_TRAPPING): Override
feenableexcept() also on NetBSD/arm64.
* doc/glibc-functions/feenableexcept.texi: Update platforms list.

diff --git a/doc/glibc-functions/feenableexcept.texi 
b/doc/glibc-functions/feenableexcept.texi
index 0c98c5c844..a306a904e5 100644
--- a/doc/glibc-functions/feenableexcept.texi
+++ b/doc/glibc-functions/feenableexcept.texi
@@ -26,7 +26,7 @@
 macOS 11.1, musl libc, FreeBSD 5.2.1, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, 
AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 11.4, Cygwin 1.7.7, mingw, MSVC 14, 
Android 4.4.
 @item
 This function does not detect failures on
-glibc 2.19/aarch64, FreeBSD 12.2/arm, FreeBSD 12.2/arm64.
+glibc 2.19/aarch64, FreeBSD 12.2/arm, FreeBSD 12.2/arm64, NetBSD 9.3/arm64.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/m4/fenv-exceptions-trapping.m4 b/m4/fenv-exceptions-trapping.m4
index 784bed1697..cd9c96674f 100644
--- a/m4/fenv-exceptions-trapping.m4
+++ b/m4/fenv-exceptions-trapping.m4
@@ -1,4 +1,4 @@
-# fenv-exceptions-trapping.m4 serial 1
+# fenv-exceptions-trapping.m4 serial 2
 dnl Copyright (C) 2023-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,7 +17,7 @@ AC_DEFUN_ONCE([gl_FENV_EXCEPTIONS_TRAPPING]
 dnl On glibc 2.19/aarch64, feenableexcept does not detect failures.
 dnl Fixed through
 dnl 
.
-dnl Similarly on FreeBSD 12.2/arm and FreeBSD 12.2/arm64.
+dnl Similarly on FreeBSD 12.2/arm, FreeBSD 12.2/arm64, NetBSD 9.3/arm64.
 case "$host" in
   aarch64*-*-linux*)
 AC_CACHE_CHECK([whether feenableexcept works],
@@ -41,7 +41,7 @@ AC_DEFUN_ONCE([gl_FENV_EXCEPTIONS_TRAPPING]
   *) REPLACE_FEENABLEEXCEPT=1 ;;
 esac
 ;;
-  arm*-*-freebsd* | aarch64*-*-freebsd*)
+  arm*-*-freebsd* | aarch64*-*-freebsd* | aarch64*-*-netbsd*)
 REPLACE_FEENABLEEXCEPT=1
 ;;
 esac
=
   dummy 0: gltests/test-suite.log
=

# TOTAL: 22
# PASS:  13
# SKIP:  0
# XFAIL: 0
# FAIL:  9
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: test-fenv-env-2
=

../../gltests/test-fenv-env-2.c:54: assertion 'fegetexcept () == (supports_trapping ? FE_DIVBYZERO : 0)' failed
FAIL test-fenv-env-2 (exit status: 134)

FAIL: test-fenv-env-3
=

../../gltests/test-fenv-env-3.c:54: assertion 'fegetexcept () == (supports_trapping ? FE_DIVBYZERO : 0)' failed
FAIL test-fenv-env-3 (exit status: 134)

FAIL: test-fenv-env-4
=

../../gltests/test-fenv-env-4.c:74: assertion 'fegetexcept () == (supports_trapping ? FE_INVALID : 0)' failed
FAIL test-fenv-env-4 (exit status: 134)

FAIL: test-fenv-env-5
=

../../gltests/test-fenv-env-5.c:76: assertion 'fegetexcept () == (supports_trapping ? FE_INVALID : 0)' failed
FAIL test-fenv-env-5 (exit status: 134)

FAIL: test-fenv-env-6.sh


Failed: ./test-fenv-env-6
FAIL test-fenv-env-6.sh (exit status: 1)

FAIL: test-fenv-except-tracking-2.sh


Failed: ./test-fenv-except-tracking-2 f
FAIL test-fenv-except-tracking-2.sh (exit status: 1)

FAIL: test-fenv-except-tracking-3.sh


Failed: ./test-fenv-except-tracking-3 FE_INVALID
FAIL test-fenv-except-tracking-3.sh (exit status: 1)

FAIL: test-fenv-except-trapping-1
=

../../gltests/test-fenv-except-trapping-1.c:64: assertion 'fedisableexcept (uint_to_exceptions (b)) == uint_to_exceptions (a)' failed
FAIL test-fenv-except-trapping-1 (exit status: 134)

FAIL: test-fenv-except-trapping-2.sh


Failed (got no trap): ./test-fenv-except-trapping-2 1 p f
Failed (got no trap): ./test-fenv-except-trapping-2 1 p d
Failed (got no trap): ./test-fenv-except-trapping-2 1 p l
Failed (got no trap): ./test-fenv-except-trapping-2 1 q f
Failed (got no trap): ./test-fenv-except-trapping-2 1 q d
Failed (got no trap): ./test-fenv-except-trapping-2 1 q l
../../gltests/test-fenv-except-trapping-2.c:417: assertion 'fedisableexcept (FE_ALL_EXCEPT & ~expected_exceptions) == FE_ALL_EXCEPT' failed
[1]   Abort trap (core dumped) ${CHECKER} ./test-fenv-except-trapping-2${EXEE...
../../gltests/test-fenv-except-trapping-2.c:417: assertion 'fedisableexcept (FE_ALL_EXCEPT & ~expected_exceptions) == FE_ALL_EXCEPT' failed
[1]   Abort trap (core dumped) ${CHECKER} ./test-fenv-except-trapping-2${EXEE...
../../gltests/test-fenv-except-trapping-2.c:417: assertion 'fedisableexcept (FE_ALL_EXCEPT 

fenv-*: Avoid test failures on OpenBSD/sparc64

2024-01-19 Thread Bruno Haible
On OpenBSD 7.2/sparc64 I see these two test failures:

FAIL: test-fenv-except-tracking-2.sh


Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed: ./test-fenv-except-tracking-2 l
FAIL test-fenv-except-tracking-2.sh (exit status: 1)

FAIL: test-fenv-except-trapping-2.sh


Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 1 p l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 1 q l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 1 r l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 2 p l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 2 q l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 2 r l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 3 p l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 3 q l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 3 r l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 4 p l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 4 q l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 4 r l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 5 p l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 5 q l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 5 r l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 6 p l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 6 q l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 6 r l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 7 p l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 7 q l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 7 r l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 8 p l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 8 q l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 8 r l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 9 p l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 9 q l
Floating point exception (core dumped) 
Floating point exception (core dumped) 
Failed (got no trap): ./test-fenv-except-trapping-2 9 r l
FAIL test-fenv-except-trapping-2.sh (exit status: 1)

This patch acknowledges the problem and avoids the test failures.


2024-01-19  Bruno Haible  

fenv-*: Avoid test failures on OpenBSD/sparc64.
* tests/test-fenv-except-tracking-2.c (main): On OpenBSD/sparc64, skip
the 'long double' test.
* tests/test-fenv-except-trapping-2.c (main): Skip the 'long double'
tests also on OpenBSD/sparc64.

diff --git a/tests/test-fenv-except-tracking-2.c 
b/tests/test-fenv-except-tracking-2.c
index 9a76c8afda..2db4949882 100644
--- a/tests/test-fenv-except-tracking-2.c
+++ b/tests/test-fenv-except-tracking-2.c
@@ -66,12 +66,12 @@ main (int argc, char *argv[])
   case 'l':
 /* This test does not work on Linux/loongarch64 with glibc 2.37.
Likewise on Linux/alpha with glibc 2.7 on Linux 2.6.26.
-   Likewise on FreeBSD 12.2/sparc