+2023-10-12 Bruno Haible <bruno@clisp.org>
+
+ nan, snan tests: Avoid test failures.
+ * tests/test-nan-1.c (main): Special handling of arm CPUs with software
+ floating-point emulation.
+ * tests/test-snan-1.c (main): Likewise. Disable tests that are known to
+ fail.
+ * tests/test-snan-2.c (main): Skip tests that are known to fail.
+ * modules/snan-tests (Files): Add m4/math_h.m4.
+ (configure.ac): Require gl_LONG_DOUBLE_VS_DOUBLE.
+ * m4/math_h.m4 (gl_LONG_DOUBLE_VS_DOUBLE): Mention also NetBSD/sparc32.
+
2023-10-12 Bruno Haible <bruno@clisp.org>
snan: Add tests.
# Sets variable HAVE_SAME_LONG_DOUBLE_AS_DOUBLE to 0 or 1, and defines
# HAVE_SAME_LONG_DOUBLE_AS_DOUBLE accordingly.
# The currently known platforms where this is the case are:
-# Linux/HPPA, Minix 3.1.8, AIX 5, AIX 6 and 7 with xlc, MSVC 9.
+# Linux/HPPA, NetBSD/sparc32, Minix 3.1.8, AIX 5, AIX 6 and 7 with xlc, MSVC 9.
AC_DEFUN([gl_LONG_DOUBLE_VS_DOUBLE],
[
AC_CACHE_CHECK([whether long double and double are the same],
tests/test-snan-2.sh
tests/test-snan-2.c
tests/macros.h
+m4/math_h.m4
Depends-on:
fpe-tracking
fpe-trapping
configure.ac:
+AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
Makefile.am:
TESTS += test-snan-1 test-snan-2.sh
/* Specification. */
#include "nan.h"
+#include <stdio.h>
+
#if HAVE_FE_INVALID
-# include <fenv.h>
+# if defined __GLIBC__ && defined __arm__ && defined __SOFTFP__
+
+/* The arm software floating-point emulation (used e.g. on armv5) does not set
+ the floating-point exception bits. */
+
+int
+main ()
+{
+ fputs ("Skipping test: software floating-point emulation\n", stderr);
+ return 77;
+}
+
+# else
+
+# include <fenv.h>
-# include "macros.h"
+# include "macros.h"
float volatile resultf;
double volatile resultd;
return 0;
}
+# endif
+
#else
/* No <fenv.h> available.
We could use the various alternative approaches from
libgfortran/config/fpu-*.h, but that's not worth it. */
-#include <stdio.h>
-
int
main ()
{
/* Specification. */
#include "snan.h"
+#include <stdio.h>
+
#if HAVE_FE_INVALID
-# include <fenv.h>
+# if defined __GLIBC__ && defined __arm__ && defined __SOFTFP__
+
+/* The arm software floating-point emulation (used e.g. on armv5) does not set
+ the floating-point exception bits. */
+
+int
+main ()
+{
+ fputs ("Skipping test: software floating-point emulation\n", stderr);
+ return 77;
+}
+
+# else
+
+# include <fenv.h>
-# include "macros.h"
+# include "macros.h"
float volatile resultf;
double volatile resultd;
long double volatile nanl = SNaNl ();
/* Check that the values are really signalling. */
+ /* These tests do not work on 32-bit x86 processors, although the
+ "Intel 64 and IA-32 Architectures Software Developer's Manual" and
+ "IA-32 Intel Architecture Software Developer's Manual", each in
+ sections
+ 4.8.3.4 NaNs
+ 4.8.3.5 Operating on SNaNs and QNaNs
+ 4.8.3.6 Using SNaNs and QNaNs in Applications
+ claim that it should work. */
+ #if !(defined __i386 || defined _M_IX86)
+ /* This test does not work on AIX 7.1 with the xlc compiler, even with
+ the compiler options -qfloat=fenv -qfloat=nans -qfloat=spnans. */
+ #if !(defined _AIX && defined __xlC__)
{
feclearexcept (FE_INVALID);
resultf = nanf + 42.0f;
ASSERT (fetestexcept (FE_INVALID));
}
+ #endif
{
feclearexcept (FE_INVALID);
resultd = nand + 42.0;
ASSERT (fetestexcept (FE_INVALID));
}
+ #endif
+ /* This test does not work on eglibc 2.13/mips64
+ (bug in libc function __addtf3).
+ This test does not work on FreeBSD/arm64
+ (bug in libc function __addtf3).
+ This test does not work on FreeBSD/sparc64 and NetBSD/sparc64
+ (bug in libc function _Qp_add).
+ This test does not work on MSVC/i386, because of the general IA-32
+ problem (see above) and 'long double' == 'double'. */
+ #if !((((__GLIBC__ == 2 && __GLIBC_MINOR__ < 19 && defined __mips64) \
+ || ((defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__) && (defined __aarch64__ || defined __sparc__))) \
+ && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE) \
+ || ((defined __i386 || defined _M_IX86) && HAVE_SAME_LONG_DOUBLE_AS_DOUBLE))
{
feclearexcept (FE_INVALID);
resultl = nanl + 42.0L;
ASSERT (fetestexcept (FE_INVALID));
}
+ #endif
return 0;
}
+# endif
+
#else
/* No <fenv.h> available.
We could use the various alternative approaches from
libgfortran/config/fpu-*.h, but that's not worth it. */
-#include <stdio.h>
-
int
main ()
{
switch (argv[1][0])
{
case 'f':
+ /* This test does not work on 32-bit x86 processors, although the
+ "Intel 64 and IA-32 Architectures Software Developer's Manual" and
+ "IA-32 Intel Architecture Software Developer's Manual", each in
+ sections
+ 4.8.3.4 NaNs
+ 4.8.3.5 Operating on SNaNs and QNaNs
+ 4.8.3.6 Using SNaNs and QNaNs in Applications
+ claim that it should work. */
+ #if !(defined __i386 || defined _M_IX86)
+ /* This test does not work on AIX 7.1 with the xlc compiler, even with
+ the compiler options -qfloat=fenv -qfloat=nans -qfloat=spnans. */
+ #if !(defined _AIX && defined __xlC__)
resultf = nanf + 42.0f;
+ #else
+ fputs ("Skipping test: known failure on this platform with this compiler\n", stderr);
+ return 77;
+ #endif
+ #else
+ fputs ("Skipping test: known failure on this platform\n", stderr);
+ return 77;
+ #endif
break;
+
case 'd':
+ /* This test does not work on 32-bit x86 processors, although the
+ "Intel 64 and IA-32 Architectures Software Developer's Manual" and
+ "IA-32 Intel Architecture Software Developer's Manual", each in
+ sections
+ 4.8.3.4 NaNs
+ 4.8.3.5 Operating on SNaNs and QNaNs
+ 4.8.3.6 Using SNaNs and QNaNs in Applications
+ claim that it should work. */
+ #if !(defined __i386 || defined _M_IX86)
resultd = nand + 42.0;
+ #else
+ fputs ("Skipping test: known failure on this platform\n", stderr);
+ return 77;
+ #endif
break;
+
case 'l':
+ /* This test does not work on Linux/alpha with glibc 2.7. But it
+ works with glibc 2.36. Cause unknown.
+ This test does not work on Linux/loongarch64 with glibc 2.37.
+ Cause unknown.
+ This test does not work on eglibc 2.13/mips64
+ (bug in libc function __addtf3).
+ This test does not work on FreeBSD/arm64
+ (bug in libc function __addtf3).
+ This test does not work on FreeBSD/sparc64 and NetBSD/sparc64
+ (bug in libc function _Qp_add).
+ This test does not work on Cygwin 2.9.0/i386. Cause unknown.
+ This test does not work on MSVC/i386, because of the general IA-32
+ problem (see above) and 'long double' == 'double'. */
+ #if !((__GLIBC__ == 2 && __GLIBC_MINOR__ < 36 && defined __alpha__) \
+ || (__GLIBC__ >= 2 && defined __loongarch__) \
+ || (((__GLIBC__ == 2 && __GLIBC_MINOR__ < 19 && defined __mips64) \
+ || ((defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__) && (defined __aarch64__ || defined __sparc__))) \
+ && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE) \
+ || (defined __CYGWIN__ && defined __i386) \
+ || ((defined __i386 || defined _M_IX86) && HAVE_SAME_LONG_DOUBLE_AS_DOUBLE))
resultl = nanl + 42.0L;
+ #else
+ fputs ("Skipping test: known failure on this platform\n", stderr);
+ return 77;
+ #endif
break;
+
default:
break;
}