This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Improve math_errhandling
- From: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- To: "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Cc: nd <nd at arm dot com>
- Date: Wed, 8 Nov 2017 14:41:55 +0000
- Subject: [PATCH] Improve math_errhandling
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco dot Dijkstra at arm dot com;
- Nodisclaimer: True
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
This is based on discussion in https://gcc.gnu.org/ml/gcc-patches/2017-10/msg02096.html.
Currently math_errhandling is always set to MATH_ERRNO | MATH_ERREXCEPT
even if -fno-math-errno is used. It is not defined at all when fast-math
is used, eventhough the GLIBC implementation always supports exceptions
(on hardware floating point implementations). Improve this to take
__NO_MATH_ERRNO__ into account and update comment.
OK for commit?
ChangeLog:
2017-11-08 Wilco Dijkstra <wdijkstr@arm.com>
* math/math.h (math_errhandling): Add __NO_MATH_ERRNO__ check.
--
diff --git a/math/math.h b/math/math.h
index 5ad8156555daf583514e214c2de0aca782871788..d46c26533eff01dfbcee8f59d022febdbdb8d769 100644
--- a/math/math.h
+++ b/math/math.h
@@ -506,10 +506,15 @@ enum
# define MATH_ERRNO 1 /* errno set by math functions. */
# define MATH_ERREXCEPT 2 /* Exceptions raised by math functions. */
-/* By default all functions support both errno and exception handling.
- In gcc's fast math mode and if inline functions are defined this
- might not be true. */
-# ifndef __FAST_MATH__
+/* By default all math functions support both errno and exception handling
+ (except for soft floating point implementations which may only support
+ errno handling). If errno handling is disabled, exceptions are still
+ supported by GLIBC. If a target adds inlines which do not support
+ exceptions, math_errhandling must be undefined (since setting it to 0
+ is not standard compliant). */
+# ifdef __NO_MATH_ERRNO__
+# define math_errhandling (MATH_ERREXCEPT)
+# else
# define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT)
# endif