about summary refs log tree commit diff
path: root/math/math.h
diff options
context:
space:
mode:
authorWilco Dijkstra <wdijkstr@arm.com>2018-01-03 13:14:10 +0000
committerWilco Dijkstra <wdijkstr@arm.com>2018-01-03 13:14:10 +0000
commit3c7d03129498e7426855b5d4cdd5b7109ecc2172 (patch)
treeec66bfb4d0b21311d263b2a1c4643d50d51975b3 /math/math.h
parent7eff095459d5720642e0a8e6766852fe2fa65310 (diff)
downloadglibc-3c7d03129498e7426855b5d4cdd5b7109ecc2172.tar.gz
glibc-3c7d03129498e7426855b5d4cdd5b7109ecc2172.tar.xz
glibc-3c7d03129498e7426855b5d4cdd5b7109ecc2172.zip
Improve math_errhandling
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.  Set it to 0 with fast-math - this is noncomforming but more
useful than not define math_errhandling at all. Also take __NO_MATH_ERRNO__
into account and update comment.

	* math/math.h (math_errhandling): Set to 0 with __FAST_MATH__.
	Add __NO_MATH_ERRNO__ check.
Diffstat (limited to 'math/math.h')
-rw-r--r--math/math.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/math/math.h b/math/math.h
index 633681ec8b..3c515f817f 100644
--- a/math/math.h
+++ b/math/math.h
@@ -665,10 +665,16 @@ 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.  Set math_errhandling to 0 with -ffast-math (this is
+   nonconforming but it is more useful than leaving it undefined).  */
+# ifdef __FAST_MATH__
+#  define math_errhandling	0
+# elif defined __NO_MATH_ERRNO__
+#  define math_errhandling	(MATH_ERREXCEPT)
+# else
 #  define math_errhandling	(MATH_ERRNO | MATH_ERREXCEPT)
 # endif