about summary refs log tree commit diff
path: root/math
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2013-04-26 19:25:19 +0000
committerJoseph Myers <joseph@codesourcery.com>2013-04-26 19:25:19 +0000
commitf0302940e7c2acb587971e3c99dfbd00aa4e2134 (patch)
tree14ca5247684a4ca2ef2ea2f46c4d375cde6aa6b9 /math
parentaa630f590c9c7d070a7cdf3a2a88069ad6b63de9 (diff)
downloadglibc-f0302940e7c2acb587971e3c99dfbd00aa4e2134.tar.gz
glibc-f0302940e7c2acb587971e3c99dfbd00aa4e2134.tar.xz
glibc-f0302940e7c2acb587971e3c99dfbd00aa4e2134.zip
Fix csin, csinh, ccos, ccosh missing underflows (bug 15405).
Diffstat (limited to 'math')
-rw-r--r--math/libm-test.inc12
-rw-r--r--math/s_ccosh.c13
-rw-r--r--math/s_ccoshf.c13
-rw-r--r--math/s_ccoshl.c13
-rw-r--r--math/s_csin.c13
-rw-r--r--math/s_csinf.c13
-rw-r--r--math/s_csinh.c13
-rw-r--r--math/s_csinhf.c13
-rw-r--r--math/s_csinhl.c13
-rw-r--r--math/s_csinl.c13
10 files changed, 129 insertions, 0 deletions
diff --git a/math/libm-test.inc b/math/libm-test.inc
index eb9fa710cd..a3d7731531 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -4570,6 +4570,9 @@ ccos_test (void)
   TEST_c_c (ccos, 0x1p-16434L, 22730, plus_infty, -1.217853148905605987081057582351152052687e4924L, OVERFLOW_EXCEPTION);
 #endif
 
+  TEST_c_c (ccos, min_subnorm_value * 0x1p120, 0x1p-120, 1.0, -min_subnorm_value, UNDERFLOW_EXCEPTION);
+  TEST_c_c (ccos, 0x1p-120, min_subnorm_value * 0x1p120, 1.0, -min_subnorm_value, UNDERFLOW_EXCEPTION);
+
   END (ccos, complex);
 }
 
@@ -4670,6 +4673,9 @@ ccosh_test (void)
   TEST_c_c (ccosh, 22730, 0x1p-16434L, plus_infty, 1.217853148905605987081057582351152052687e4924L, OVERFLOW_EXCEPTION);
 #endif
 
+  TEST_c_c (ccosh, min_subnorm_value * 0x1p120, 0x1p-120, 1.0, min_subnorm_value, UNDERFLOW_EXCEPTION);
+  TEST_c_c (ccosh, 0x1p-120, min_subnorm_value * 0x1p120, 1.0, min_subnorm_value, UNDERFLOW_EXCEPTION);
+
   END (ccosh, complex);
 }
 
@@ -5898,6 +5904,9 @@ csin_test (void)
   TEST_c_c (csin, 0x1p-16434L, 22730, 1.217853148905605987081057582351152052687e4924L, plus_infty, OVERFLOW_EXCEPTION);
 #endif
 
+  TEST_c_c (csin, min_subnorm_value, min_value, min_subnorm_value, min_value, UNDERFLOW_EXCEPTION);
+  TEST_c_c (csin, min_value, min_subnorm_value, min_value, min_subnorm_value, UNDERFLOW_EXCEPTION);
+
   END (csin, complex);
 }
 
@@ -5997,6 +6006,9 @@ csinh_test (void)
   TEST_c_c (csinh, 22730, 0x1p-16434L, plus_infty, 1.217853148905605987081057582351152052687e4924L, OVERFLOW_EXCEPTION);
 #endif
 
+  TEST_c_c (csinh, min_subnorm_value, min_value, min_subnorm_value, min_value, UNDERFLOW_EXCEPTION);
+  TEST_c_c (csinh, min_value, min_subnorm_value, min_value, min_subnorm_value, UNDERFLOW_EXCEPTION);
+
   END (csinh, complex);
 }
 
diff --git a/math/s_ccosh.c b/math/s_ccosh.c
index 2c05b63de4..05b146ecbf 100644
--- a/math/s_ccosh.c
+++ b/math/s_ccosh.c
@@ -82,6 +82,19 @@ __ccosh (__complex__ double x)
 	      __real__ retval = __ieee754_cosh (__real__ x) * cosix;
 	      __imag__ retval = __ieee754_sinh (__real__ x) * sinix;
 	    }
+
+	  if (fabs (__real__ retval) < DBL_MIN)
+	    {
+	      volatile double force_underflow
+		= __real__ retval * __real__ retval;
+	      (void) force_underflow;
+	    }
+	  if (fabs (__imag__ retval) < DBL_MIN)
+	    {
+	      volatile double force_underflow
+		= __imag__ retval * __imag__ retval;
+	      (void) force_underflow;
+	    }
 	}
       else
 	{
diff --git a/math/s_ccoshf.c b/math/s_ccoshf.c
index de7e7d302a..62bf83c05b 100644
--- a/math/s_ccoshf.c
+++ b/math/s_ccoshf.c
@@ -82,6 +82,19 @@ __ccoshf (__complex__ float x)
 	      __real__ retval = __ieee754_coshf (__real__ x) * cosix;
 	      __imag__ retval = __ieee754_sinhf (__real__ x) * sinix;
 	    }
+
+	  if (fabsf (__real__ retval) < FLT_MIN)
+	    {
+	      volatile float force_underflow
+		= __real__ retval * __real__ retval;
+	      (void) force_underflow;
+	    }
+	  if (fabsf (__imag__ retval) < FLT_MIN)
+	    {
+	      volatile float force_underflow
+		= __imag__ retval * __imag__ retval;
+	      (void) force_underflow;
+	    }
 	}
       else
 	{
diff --git a/math/s_ccoshl.c b/math/s_ccoshl.c
index 4bbd31148f..18d3df0430 100644
--- a/math/s_ccoshl.c
+++ b/math/s_ccoshl.c
@@ -82,6 +82,19 @@ __ccoshl (__complex__ long double x)
 	      __real__ retval = __ieee754_coshl (__real__ x) * cosix;
 	      __imag__ retval = __ieee754_sinhl (__real__ x) * sinix;
 	    }
+
+	  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
 	{
diff --git a/math/s_csin.c b/math/s_csin.c
index cc1c9cd7ab..6d28e4c1b9 100644
--- a/math/s_csin.c
+++ b/math/s_csin.c
@@ -88,6 +88,19 @@ __csin (__complex__ double x)
 
 	  if (negate)
 	    __real__ retval = -__real__ retval;
+
+	  if (fabs (__real__ retval) < DBL_MIN)
+	    {
+	      volatile double force_underflow
+		= __real__ retval * __real__ retval;
+	      (void) force_underflow;
+	    }
+	  if (fabs (__imag__ retval) < DBL_MIN)
+	    {
+	      volatile double force_underflow
+		= __imag__ retval * __imag__ retval;
+	      (void) force_underflow;
+	    }
 	}
       else
 	{
diff --git a/math/s_csinf.c b/math/s_csinf.c
index 92b858ae6a..a3dcf9d3aa 100644
--- a/math/s_csinf.c
+++ b/math/s_csinf.c
@@ -88,6 +88,19 @@ __csinf (__complex__ float x)
 
 	  if (negate)
 	    __real__ retval = -__real__ retval;
+
+	  if (fabsf (__real__ retval) < FLT_MIN)
+	    {
+	      volatile float force_underflow
+		= __real__ retval * __real__ retval;
+	      (void) force_underflow;
+	    }
+	  if (fabsf (__imag__ retval) < FLT_MIN)
+	    {
+	      volatile float force_underflow
+		= __imag__ retval * __imag__ retval;
+	      (void) force_underflow;
+	    }
 	}
       else
 	{
diff --git a/math/s_csinh.c b/math/s_csinh.c
index be3c6bbb87..5a98f67851 100644
--- a/math/s_csinh.c
+++ b/math/s_csinh.c
@@ -88,6 +88,19 @@ __csinh (__complex__ double x)
 
 	  if (negate)
 	    __real__ retval = -__real__ retval;
+
+	  if (fabs (__real__ retval) < DBL_MIN)
+	    {
+	      volatile double force_underflow
+		= __real__ retval * __real__ retval;
+	      (void) force_underflow;
+	    }
+	  if (fabs (__imag__ retval) < DBL_MIN)
+	    {
+	      volatile double force_underflow
+		= __imag__ retval * __imag__ retval;
+	      (void) force_underflow;
+	    }
 	}
       else
 	{
diff --git a/math/s_csinhf.c b/math/s_csinhf.c
index 6c58c1d0d2..3658805fcb 100644
--- a/math/s_csinhf.c
+++ b/math/s_csinhf.c
@@ -88,6 +88,19 @@ __csinhf (__complex__ float x)
 
 	  if (negate)
 	    __real__ retval = -__real__ retval;
+
+	  if (fabsf (__real__ retval) < FLT_MIN)
+	    {
+	      volatile float force_underflow
+		= __real__ retval * __real__ retval;
+	      (void) force_underflow;
+	    }
+	  if (fabsf (__imag__ retval) < FLT_MIN)
+	    {
+	      volatile float force_underflow
+		= __imag__ retval * __imag__ retval;
+	      (void) force_underflow;
+	    }
 	}
       else
 	{
diff --git a/math/s_csinhl.c b/math/s_csinhl.c
index 8acf6dec52..54a13fdda2 100644
--- a/math/s_csinhl.c
+++ b/math/s_csinhl.c
@@ -88,6 +88,19 @@ __csinhl (__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
 	{
diff --git a/math/s_csinl.c b/math/s_csinl.c
index 6b3c1ea2f1..4d6ce3db35 100644
--- a/math/s_csinl.c
+++ b/math/s_csinl.c
@@ -88,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
 	{