about summary refs log tree commit diff
path: root/include/math.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/math.h')
-rw-r--r--include/math.h29
1 files changed, 21 insertions, 8 deletions
diff --git a/include/math.h b/include/math.h
index 9ab7aa4403..eed953072b 100644
--- a/include/math.h
+++ b/include/math.h
@@ -79,16 +79,29 @@ fabsf128 (_Float128 x)
 
 # 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");
+/* Declare some functions for use within GLIBC.  Compilers typically
+   inline those functions as a single instruction.  Use an asm to
+   avoid use of PLTs if it doesn't.  */
+#   define MATH_REDIRECT(FUNC, PREFIX, ARGS)			\
+  float (FUNC ## f) (ARGS (float)) asm (PREFIX #FUNC "f");	\
+  double (FUNC) (ARGS (double)) asm (PREFIX #FUNC );		\
+  MATH_REDIRECT_LDBL (FUNC, PREFIX, ARGS)			\
+  MATH_REDIRECT_F128 (FUNC, PREFIX, ARGS)
+#   ifdef __NO_LONG_DOUBLE_MATH
+#    define MATH_REDIRECT_LDBL(FUNC, PREFIX, ARGS)
+#   else
+#    define MATH_REDIRECT_LDBL(FUNC, PREFIX, ARGS)			\
+  long double (FUNC ## l) (ARGS (long double)) asm (PREFIX #FUNC "l");
 #   endif
-#   if __HAVE_DISTINCT_FLOAT128 > 0
-_Float128 (sqrtf128) (_Float128) asm ("__ieee754_sqrtf128");
+#   if __HAVE_DISTINCT_FLOAT128
+#    define MATH_REDIRECT_F128(FUNC, PREFIX, ARGS)			\
+  _Float128 (FUNC ## f128) (ARGS (_Float128)) asm (PREFIX #FUNC "f128");
+#   else
+#    define MATH_REDIRECT_F128(FUNC, PREFIX, ARGS)
 #   endif
+#   define MATH_REDIRECT_UNARY_ARGS(TYPE) TYPE
+MATH_REDIRECT (sqrt, "__ieee754_", MATH_REDIRECT_UNARY_ARGS)
+MATH_REDIRECT (floor, "__", MATH_REDIRECT_UNARY_ARGS)
 #  endif
 # endif