summary refs log tree commit diff
path: root/sysdeps/i386/fpu/__math.h
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/i386/fpu/__math.h')
-rw-r--r--sysdeps/i386/fpu/__math.h69
1 files changed, 50 insertions, 19 deletions
diff --git a/sysdeps/i386/fpu/__math.h b/sysdeps/i386/fpu/__math.h
index 86793babe5..080d0ec220 100644
--- a/sysdeps/i386/fpu/__math.h
+++ b/sysdeps/i386/fpu/__math.h
@@ -96,6 +96,7 @@ fabs (double __x)
   return __value;
 }
 
+/* The argument range of this inline version is limited.  */
 __MATH_INLINE double sin (double __x);
 __MATH_INLINE double
 sin (double __x)
@@ -108,6 +109,7 @@ sin (double __x)
   return __value;
 }
 
+/* The argument range of this inline version is limited.  */
 __MATH_INLINE double cos (double __x);
 __MATH_INLINE double
 cos (double __x)
@@ -371,7 +373,7 @@ ceil (double __x)
 
 
 /* Optimized versions for some non-standardized functions.  */
-#ifdef __USE_MISC
+#if defined __USE_ISOC9X || defined __USE_MISC
 
 __MATH_INLINE double hypot (double __x, double __y);
 __MATH_INLINE double
@@ -424,22 +426,6 @@ atanh (double __x)
   return -0.5 * __log1p (-(__y + __y) / (1.0 + __y)) * __sgn1 (__x);
 }
 
-__MATH_INLINE double coshm1 (double __x);
-__MATH_INLINE double
-coshm1 (double __x)
-{
-  register double __exm1 = __expm1 (fabs (__x));
-
-  return 0.5 * (__exm1 / (__exm1 + 1.0)) * __exm1;
-}
-
-__MATH_INLINE double acosh1p (double __x);
-__MATH_INLINE double
-acosh1p (double __x)
-{
-  return __log1p (__x + sqrt (__x) * sqrt (__x + 2.0));
-}
-
 __MATH_INLINE double logb (double __x);
 __MATH_INLINE double
 logb (double __x)
@@ -467,13 +453,58 @@ drem (double __x, double __y)
   return __value;
 }
 
+/* This function is used in the `isfinite' macro.  */
+__MATH_INLINE int __finite (double __x);
+__MATH_INLINE int
+__finite (double __x)
+{
+  register int __result;
+  __asm__ __volatile__
+    ("orl	$x0x800fffff, %0\n\t"
+     "incl	%0\n\t"
+     "shrl	$31, %0"
+     : "=q" (__result) : "0" (((int *) &__x)[1]));
+  return __result;
+}
+#endif
+
+#ifdef __USE_MISC
+__MATH_INLINE double coshm1 (double __x);
+__MATH_INLINE double
+coshm1 (double __x)
+{
+  register double __exm1 = __expm1 (fabs (__x));
+
+  return 0.5 * (__exm1 / (__exm1 + 1.0)) * __exm1;
+}
+
+__MATH_INLINE double acosh1p (double __x);
+__MATH_INLINE double
+acosh1p (double __x)
+{
+  return __log1p (__x + sqrt (__x) * sqrt (__x + 2.0));
+}
+
 __MATH_INLINE void sincos (double __x, double *__sinx, double *__cosx);
 __MATH_INLINE void
 sincos (double __x, double *__sinx, double *__cosx)
 {
   register double __cosr, __sinr;
   __asm __volatile__
-    ("fsincos"
+    ("fsincos\n\t"
+     "fnstsw	%%ax\n\t"
+     "testl	$0x400, %%eax\n\t"
+     "jz	1f\n\t"
+     "fldpi\n\t"
+     "fadd	%%st(0)\n\t"
+     "fxch	%%st(1)\n\t"
+     "2: fprem1\n\t"
+     "fnstsw	%%ax\n\t"
+     "testl	$0x400, %%eax\n\t"
+     "jnz	2b\n\t"
+     "fstp	%%st(1)\n\t"
+     "fsincos\n\t"
+     "1:"
      : "=t" (__cosr), "=u" (__sinr) : "0" (__x));
 
   *__sinx = __sinr;
@@ -484,7 +515,7 @@ __MATH_INLINE double sgn (double __x);
 __MATH_INLINE double
 sgn (double __x)
 {
-  return (__x == 0.0 ? 0.0 : (__x > 0.0 ? 1.0 : -1.0));
+  return __x == 0.0 ? 0.0 : (__x > 0.0 ? 1.0 : -1.0);
 }
 
 __MATH_INLINE double pow2 (double __x);