]> sourceware.org Git - newlib-cygwin.git/commitdiff
libm: Set math_errhandling to match library and hardware [v2]
authorKeith Packard via Newlib <newlib@sourceware.org>
Tue, 4 Aug 2020 15:04:39 +0000 (08:04 -0700)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 4 Aug 2020 17:30:45 +0000 (19:30 +0200)
math_errhandling is specified to contain two bits of information:

 1. MATH_ERRNO     -- Set when the library sets errno
 2. MATH_ERREXCEPT -- Set when math operations report exceptions

MATH_ERRNO should match whether the original math code is compiled in
_IEEE_LIBM mode and the new math code has WANT_ERRNO == 1.

MATH_ERREXCEPT should match whether the underlying hardware has
exception support. This patch adds configurations of this value for
RISC-V, ARM, Aarch64, x86 and x86_64 when using HW float.

Signed-off-by: Keith Packard <keithp@keithp.com>
newlib/libc/include/machine/ieeefp.h
newlib/libc/include/math.h

index aa8a1903b8d6f3deb1d733674ea975077b38e127..b0042bbf66aa88adc4f69a31ce201878d947daae 100644 (file)
@@ -87,6 +87,9 @@
 #  define __IEEE_BYTES_LITTLE_ENDIAN
 # endif
 #endif
+#ifndef __SOFTFP__
+# define _SUPPORTS_ERREXCEPT
+#endif
 #endif
 
 #if defined (__aarch64__)
@@ -96,6 +99,9 @@
 #define __IEEE_BIG_ENDIAN
 #endif
 #define __OBSOLETE_MATH_DEFAULT 0
+#ifdef __ARM_FP
+# define _SUPPORTS_ERREXCEPT
+#endif
 #endif
 
 #ifdef __epiphany__
 
 #ifdef __i386__
 #define __IEEE_LITTLE_ENDIAN
+# define _SUPPORTS_ERREXCEPT
 #endif
 
 #ifdef __riscv
 #define __IEEE_LITTLE_ENDIAN
+#ifdef __riscv_flen
+# define _SUPPORTS_ERREXCEPT
+#endif
 #endif
 
 #ifdef __i960__
 
 #ifdef __x86_64__
 #define __IEEE_LITTLE_ENDIAN
+# define _SUPPORTS_ERREXCEPT
 #endif
 
 #ifdef __mep__
index 1efc5b92c709ea90b9df0db5fc575a95aacd74e5..9fd82d9faabdd780656c8e83ba5296ed1354e797 100644 (file)
@@ -188,7 +188,17 @@ extern int isnan (double);
 # define MATH_ERREXCEPT 2
 #endif
 #ifndef math_errhandling
-# define math_errhandling MATH_ERRNO
+# ifdef _IEEE_LIBM
+#  define _MATH_ERRHANDLING_ERRNO 0
+# else
+#  define _MATH_ERRHANDLING_ERRNO MATH_ERRNO
+# endif
+# ifdef _SUPPORTS_ERREXCEPT
+#  define _MATH_ERRHANDLING_ERREXCEPT MATH_ERREXCEPT
+# else
+#  define _MATH_ERRHANDLING_ERREXCEPT 0
+# endif
+# define math_errhandling (_MATH_ERRHANDLING_ERRNO | _MATH_ERRHANDLING_ERREXCEPT)
 #endif
 
 extern int __isinff (float x);
This page took 0.031615 seconds and 5 git commands to generate.