From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 97AEF3840C0A; Tue, 4 Aug 2020 17:31:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97AEF3840C0A Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] libm: Set math_errhandling to match library and hardware [v2] X-Act-Checkin: newlib-cygwin X-Git-Author: Keith Packard via Newlib X-Git-Refname: refs/heads/master X-Git-Oldrev: bb166cfc3e45ceb712fb867c116b7cae4834209d X-Git-Newrev: 45efe659b836f7e48b0671c4318c5d4ba7210504 Message-Id: <20200804173108.97AEF3840C0A@sourceware.org> Date: Tue, 4 Aug 2020 17:31:08 +0000 (GMT) X-BeenThere: newlib-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib GIT logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Aug 2020 17:31:08 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=45efe659b836f7e48b0671c4318c5d4ba7210504 commit 45efe659b836f7e48b0671c4318c5d4ba7210504 Author: Keith Packard via Newlib Date: Tue Aug 4 08:04:39 2020 -0700 libm: Set math_errhandling to match library and hardware [v2] 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 Diff: --- newlib/libc/include/machine/ieeefp.h | 11 +++++++++++ newlib/libc/include/math.h | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/newlib/libc/include/machine/ieeefp.h b/newlib/libc/include/machine/ieeefp.h index aa8a1903b..b0042bbf6 100644 --- a/newlib/libc/include/machine/ieeefp.h +++ b/newlib/libc/include/machine/ieeefp.h @@ -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__ @@ -189,10 +195,14 @@ #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__ @@ -386,6 +396,7 @@ #ifdef __x86_64__ #define __IEEE_LITTLE_ENDIAN +# define _SUPPORTS_ERREXCEPT #endif #ifdef __mep__ diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h index 1efc5b92c..9fd82d9fa 100644 --- a/newlib/libc/include/math.h +++ b/newlib/libc/include/math.h @@ -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);