aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog17
-rw-r--r--Makeconfig4
-rw-r--r--include/math.h15
-rw-r--r--math/w_sqrt_compat.c1
-rw-r--r--math/w_sqrt_template.c1
-rw-r--r--math/w_sqrtf_compat.c1
-rw-r--r--math/w_sqrtl_compat.c1
-rw-r--r--sysdeps/generic/math-type-macros-float128.h3
-rw-r--r--sysdeps/i386/fpu/w_sqrt.c1
-rw-r--r--sysdeps/i386/fpu/w_sqrt_compat.c1
10 files changed, 42 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 6c8c880..1a497ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,23 @@
2018-03-15 Wilco Dijkstra <wdijkstr@arm.com>
+ * include/math.h (sqrt): Declare with asm redirect.
+ (sqrtf): Likewise.
+ (sqrtl): Likewise.
+ (sqrtf128): Likewise.
+ * Makeconfig: Add -fno-math-errno for libc/libm, but build testsuite,
+ nonlib and libnldbl with -fmath-errno.
+ * math/w_sqrt_compat.c: Define NO_MATH_REDIRECT.
+ * math/w_sqrt_template.c: Likewise.
+ * math/w_sqrtf_compat.c: Likewise.
+ * math/w_sqrtl_compat.c: Likewise.
+ * sysdeps/i386/fpu/w_sqrt.c: Likewise.
+ * sysdeps/i386/fpu/w_sqrt_compat.c: Likewise.
+ * sysdeps/generic/math-type-macros-float128.h: Remove math.h and
+ complex.h.
+
+2018-03-15 Wilco Dijkstra <wdijkstr@arm.com>
+
* benchtests/Makefile: Define _ISOMAC.
* benchtests/bench-strcoll.c: Add missing sys/stat.h include.
* benchtests/bench-string.h: Define inhibit_loop_to_libcall macro.
diff --git a/Makeconfig b/Makeconfig
index 86a71e5..1afe864 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -831,6 +831,9 @@ endif
# disable any optimization that assume default rounding mode.
+math-flags = -frounding-math
+# Build libc/libm using -fno-math-errno, but run testsuite with -fmath-errno.
++extra-math-flags = $(if $(filter libnldbl nonlib testsuite,$(in-module)),-fmath-errno,-fno-math-errno)
+
# We might want to compile with some stack-protection flag.
ifneq ($(stack-protector),)
+stack-protector=$(stack-protector)
@@ -966,6 +969,7 @@ endif
override CFLAGS = -std=gnu11 -fgnu89-inline $(config-extra-cflags) \
$(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
+ $(+extra-math-flags) \
$(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
$(CFLAGS-$(@F)) $(tls-model) \
$(foreach lib,$(libof-$(basename $(@F))) \
diff --git a/include/math.h b/include/math.h
index 7ee291f..e21d34b 100644
--- a/include/math.h
+++ b/include/math.h
@@ -54,5 +54,20 @@ libm_hidden_proto (__expf128)
libm_hidden_proto (__expm1f128)
# endif
+# if !(defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0)
+# ifndef NO_MATH_REDIRECT
+/* Declare sqrt for use within GLIBC. Compilers typically inline sqrt as a
+ single instruction. Use an asm to avoid use of PLTs if it doesn't. */
+float (sqrtf) (float) asm ("__ieee754_sqrtf");
+double (sqrt) (double) asm ("__ieee754_sqrt");
+# ifndef __NO_LONG_DOUBLE_MATH
+long double (sqrtl) (long double) asm ("__ieee754_sqrtl");
+# endif
+# if __HAVE_DISTINCT_FLOAT128 > 0
+_Float128 (sqrtf128) (_Float128) asm ("__ieee754_sqrtf128");
+# endif
+# endif
+# endif
+
#endif
#endif
diff --git a/math/w_sqrt_compat.c b/math/w_sqrt_compat.c
index 7884d14..e76a807 100644
--- a/math/w_sqrt_compat.c
+++ b/math/w_sqrt_compat.c
@@ -16,6 +16,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#define NO_MATH_REDIRECT
#include <math.h>
#include <math_private.h>
#include <math-svid-compat.h>
diff --git a/math/w_sqrt_template.c b/math/w_sqrt_template.c
index 52a21c0..9c6ac75 100644
--- a/math/w_sqrt_template.c
+++ b/math/w_sqrt_template.c
@@ -21,6 +21,7 @@
for each floating-point type. */
#if __USE_WRAPPER_TEMPLATE
+# define NO_MATH_REDIRECT
# include <errno.h>
# include <fenv.h>
# include <math.h>
diff --git a/math/w_sqrtf_compat.c b/math/w_sqrtf_compat.c
index 824ce0e..cad9b4a 100644
--- a/math/w_sqrtf_compat.c
+++ b/math/w_sqrtf_compat.c
@@ -16,6 +16,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#define NO_MATH_REDIRECT
#include <math.h>
#include <math_private.h>
#include <math-svid-compat.h>
diff --git a/math/w_sqrtl_compat.c b/math/w_sqrtl_compat.c
index 56627a6..16dda40 100644
--- a/math/w_sqrtl_compat.c
+++ b/math/w_sqrtl_compat.c
@@ -16,6 +16,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#define NO_MATH_REDIRECT
#include <math.h>
#include <math_private.h>
#include <math-svid-compat.h>
diff --git a/sysdeps/generic/math-type-macros-float128.h b/sysdeps/generic/math-type-macros-float128.h
index 605996e..485c13b 100644
--- a/sysdeps/generic/math-type-macros-float128.h
+++ b/sysdeps/generic/math-type-macros-float128.h
@@ -19,9 +19,6 @@
#ifndef _MATH_TYPE_MACROS_FLOAT128
#define _MATH_TYPE_MACROS_FLOAT128
-#include <math.h>
-#include <complex.h>
-
#define M_LIT(c) __f128 (c)
#define M_PFX FLT128
#define M_SUF(c) c ## f128
diff --git a/sysdeps/i386/fpu/w_sqrt.c b/sysdeps/i386/fpu/w_sqrt.c
index d37a5d5..8bef04e 100644
--- a/sysdeps/i386/fpu/w_sqrt.c
+++ b/sysdeps/i386/fpu/w_sqrt.c
@@ -1,5 +1,6 @@
/* The inline __ieee754_sqrt is not correctly rounding; it's OK for
most internal uses in glibc, but not for sqrt itself. */
+#define NO_MATH_REDIRECT
#define __ieee754_sqrt __avoid_ieee754_sqrt
#include <math.h>
#include <math_private.h>
diff --git a/sysdeps/i386/fpu/w_sqrt_compat.c b/sysdeps/i386/fpu/w_sqrt_compat.c
index ddd36d0..dd485f4 100644
--- a/sysdeps/i386/fpu/w_sqrt_compat.c
+++ b/sysdeps/i386/fpu/w_sqrt_compat.c
@@ -1,5 +1,6 @@
/* The inline __ieee754_sqrt is not correctly rounding; it's OK for
most internal uses in glibc, but not for sqrt itself. */
+#define NO_MATH_REDIRECT
#define __ieee754_sqrt __avoid_ieee754_sqrt
#include <math.h>
#include <math_private.h>