]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - math/s_ccosh.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / math / s_ccosh.c
index 44c9944466f7588ec18c4e911c0956d7ebe135f1..4c2f3008a3255c57af3cce741fea0b45338636da 100644 (file)
@@ -1,5 +1,5 @@
 /* Complex cosine hyperbole function for double.
-   Copyright (C) 1997-2012 Free Software Foundation, Inc.
+   Copyright (C) 1997-2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -30,16 +30,24 @@ __ccosh (__complex__ double x)
   int rcls = fpclassify (__real__ x);
   int icls = fpclassify (__imag__ x);
 
-  if (__builtin_expect (rcls >= FP_ZERO, 1))
+  if (__glibc_likely (rcls >= FP_ZERO))
     {
       /* Real part is finite.  */
-      if (__builtin_expect (icls >= FP_ZERO, 1))
+      if (__glibc_likely (icls >= FP_ZERO))
        {
          /* Imaginary part is finite.  */
          const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2);
          double sinix, cosix;
 
-         __sincos (__imag__ x, &sinix, &cosix);
+         if (__glibc_likely (fabs (__imag__ x) > DBL_MIN))
+           {
+             __sincos (__imag__ x, &sinix, &cosix);
+           }
+         else
+           {
+             sinix = __imag__ x;
+             cosix = 1.0;
+           }
 
          if (fabs (__real__ x) > t)
            {
@@ -74,6 +82,8 @@ __ccosh (__complex__ double x)
              __real__ retval = __ieee754_cosh (__real__ x) * cosix;
              __imag__ retval = __ieee754_sinh (__real__ x) * sinix;
            }
+
+         math_check_force_underflow_complex (retval);
        }
       else
        {
@@ -87,12 +97,20 @@ __ccosh (__complex__ double x)
   else if (rcls == FP_INFINITE)
     {
       /* Real part is infinite.  */
-      if (__builtin_expect (icls > FP_ZERO, 1))
+      if (__glibc_likely (icls > FP_ZERO))
        {
          /* Imaginary part is finite.  */
          double sinix, cosix;
 
-         __sincos (__imag__ x, &sinix, &cosix);
+         if (__glibc_likely (fabs (__imag__ x) > DBL_MIN))
+           {
+             __sincos (__imag__ x, &sinix, &cosix);
+           }
+         else
+           {
+             sinix = __imag__ x;
+             cosix = 1.0;
+           }
 
          __real__ retval = __copysign (HUGE_VAL, cosix);
          __imag__ retval = (__copysign (HUGE_VAL, sinix)