NPTL is no longer an add-on!
[platform/upstream/glibc.git] / math / s_csinl.c
index ff43256..a3316d3 100644 (file)
@@ -1,5 +1,5 @@
 /* Complex sine function for long double.
-   Copyright (C) 1997-2012 Free Software Foundation, Inc.
+   Copyright (C) 1997-2014 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -33,16 +33,24 @@ __csinl (__complex__ long double x)
 
   __real__ x = fabsl (__real__ x);
 
-  if (__builtin_expect (icls >= FP_ZERO, 1))
+  if (__glibc_likely (icls >= FP_ZERO))
     {
       /* Imaginary part is finite.  */
-      if (__builtin_expect (rcls >= FP_ZERO, 1))
+      if (__glibc_likely (rcls >= FP_ZERO))
        {
          /* Real part is finite.  */
          const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l);
          long double sinix, cosix;
 
-         __sincosl (__real__ x, &sinix, &cosix);
+         if (__glibc_likely (rcls != FP_SUBNORMAL))
+           {
+             __sincosl (__real__ x, &sinix, &cosix);
+           }
+         else
+           {
+             sinix = __real__ x;
+             cosix = 1.0;
+           }
 
          if (fabsl (__imag__ x) > t)
            {
@@ -80,6 +88,19 @@ __csinl (__complex__ long double x)
 
          if (negate)
            __real__ retval = -__real__ retval;
+
+         if (fabsl (__real__ retval) < LDBL_MIN)
+           {
+             volatile long double force_underflow
+               = __real__ retval * __real__ retval;
+             (void) force_underflow;
+           }
+         if (fabsl (__imag__ retval) < LDBL_MIN)
+           {
+             volatile long double force_underflow
+               = __imag__ retval * __imag__ retval;
+             (void) force_underflow;
+           }
        }
       else
        {
@@ -115,7 +136,15 @@ __csinl (__complex__ long double x)
          /* Real part is finite.  */
          long double sinix, cosix;
 
-         __sincosl (__real__ x, &sinix, &cosix);
+         if (__glibc_likely (rcls != FP_SUBNORMAL))
+           {
+             __sincosl (__real__ x, &sinix, &cosix);
+           }
+         else
+           {
+             sinix = __real__ x;
+             cosix = 1.0;
+           }
 
          __real__ retval = __copysignl (HUGE_VALL, sinix);
          __imag__ retval = __copysignl (HUGE_VALL, cosix);