diff options
author | Joseph Myers <joseph@codesourcery.com> | 2015-02-26 17:18:54 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2015-02-26 17:18:54 +0000 |
commit | ec0ce0d3be4ae21add09139c705852ed8bb114c7 (patch) | |
tree | 5f1fdab17731cca01fd46bcb264a6805a0e9d3fc /sysdeps/ieee754 | |
parent | 380bd0fd2418f8988217de950f8b8ff18af0cb2b (diff) | |
download | glibc-ec0ce0d3be4ae21add09139c705852ed8bb114c7.zip glibc-ec0ce0d3be4ae21add09139c705852ed8bb114c7.tar.gz glibc-ec0ce0d3be4ae21add09139c705852ed8bb114c7.tar.bz2 |
Fix asin missing underflows (bug 16351).
Similar to various other bugs in this area, some asin implementations
do not raise the underflow exception for subnormal arguments, when the
result is tiny and inexact. This patch forces the exception in a
similar way to previous fixes.
Tested for x86_64, x86, powerpc and mips64.
[BZ #16351]
* sysdeps/i386/fpu/e_asin.S (dbl_min): New object.
(MO): New macro.
(__ieee754_asin): Force underflow exception for results with small
absolute value.
* sysdeps/i386/fpu/e_asinf.S (flt_min): New object.
(MO): New macro.
(__ieee754_asinf): Force underflow exception for results with
small absolute value.
* sysdeps/ieee754/dbl-64/e_asin.c: Include <float.h> and <math.h>.
(__ieee754_asin): Force underflow exception for results with small
absolute value.
* sysdeps/ieee754/flt-32/e_asinf.c: Include <float.h>.
(__ieee754_asinf): Force underflow exception for results with
small absolute value.
* sysdeps/ieee754/ldbl-128/e_asinl.c: Include <float.h>.
(__ieee754_asinl): Force underflow exception for results with
small absolute value.
* sysdeps/ieee754/ldbl-128ibm/e_asinl.c: Include <float.h>.
(__ieee754_asinl): Force underflow exception for results with
small absolute value.
* sysdeps/ieee754/ldbl-96/e_asinl.c: Include <float.h>.
(__ieee754_asinl): Force underflow exception for results with
small absolute value.
* sysdeps/x86_64/fpu/multiarch/e_asin.c [HAVE_FMA4_SUPPORT]:
Include <math.h>.
* math/auto-libm-test-in: Do not mark underflow exceptions as
possibly missing for bug 16351.
* math/auto-libm-test-out: Regenerated.
Diffstat (limited to 'sysdeps/ieee754')
-rw-r--r-- | sysdeps/ieee754/dbl-64/e_asin.c | 12 | ||||
-rw-r--r-- | sysdeps/ieee754/flt-32/e_asinf.c | 6 | ||||
-rw-r--r-- | sysdeps/ieee754/ldbl-128/e_asinl.c | 6 | ||||
-rw-r--r-- | sysdeps/ieee754/ldbl-128ibm/e_asinl.c | 6 | ||||
-rw-r--r-- | sysdeps/ieee754/ldbl-96/e_asinl.c | 6 |
5 files changed, 35 insertions, 1 deletions
diff --git a/sysdeps/ieee754/dbl-64/e_asin.c b/sysdeps/ieee754/dbl-64/e_asin.c index e90f47c..b87e557 100644 --- a/sysdeps/ieee754/dbl-64/e_asin.c +++ b/sysdeps/ieee754/dbl-64/e_asin.c @@ -39,6 +39,8 @@ #include "powtwo.tbl" #include "MathLib.h" #include "uasncs.h" +#include <float.h> +#include <math.h> #include <math_private.h> #ifndef SECTION @@ -67,7 +69,15 @@ __ieee754_asin(double x){ m = u.i[HIGH_HALF]; k = 0x7fffffff&m; /* no sign */ - if (k < 0x3e500000) return x; /* for x->0 => sin(x)=x */ + if (k < 0x3e500000) + { + if (fabs (x) < DBL_MIN) + { + double force_underflow = x * x; + math_force_eval (force_underflow); + } + return x; /* for x->0 => sin(x)=x */ + } /*----------------------2^-26 <= |x| < 2^ -3 -----------------*/ else if (k < 0x3fc00000) { diff --git a/sysdeps/ieee754/flt-32/e_asinf.c b/sysdeps/ieee754/flt-32/e_asinf.c index 91ca9af..00bad42 100644 --- a/sysdeps/ieee754/flt-32/e_asinf.c +++ b/sysdeps/ieee754/flt-32/e_asinf.c @@ -39,6 +39,7 @@ static char rcsid[] = "$NetBSD: e_asinf.c,v 1.5 1995/05/12 04:57:25 jtc Exp $"; #endif +#include <float.h> #include <math.h> #include <math_private.h> @@ -72,6 +73,11 @@ float __ieee754_asinf(float x) return (x-x)/(x-x); /* asin(|x|>1) is NaN */ } else if (ix<0x3f000000) { /* |x|<0.5 */ if(ix<0x32000000) { /* if |x| < 2**-27 */ + if (fabsf (x) < FLT_MIN) + { + float force_underflow = x * x; + math_force_eval (force_underflow); + } if(huge+x>one) return x;/* return x with inexact if x!=0*/ } else { t = x*x; diff --git a/sysdeps/ieee754/ldbl-128/e_asinl.c b/sysdeps/ieee754/ldbl-128/e_asinl.c index cd1a8da..353603d 100644 --- a/sysdeps/ieee754/ldbl-128/e_asinl.c +++ b/sysdeps/ieee754/ldbl-128/e_asinl.c @@ -59,6 +59,7 @@ */ +#include <float.h> #include <math.h> #include <math_private.h> long double sqrtl (long double); @@ -152,6 +153,11 @@ __ieee754_asinl (long double x) { if (ix < 0x3fc60000) /* |x| < 2**-57 */ { + if (fabsl (x) < LDBL_MIN) + { + long double force_underflow = x * x; + math_force_eval (force_underflow); + } if (huge + x > one) return x; /* return x with inexact if x!=0 */ } diff --git a/sysdeps/ieee754/ldbl-128ibm/e_asinl.c b/sysdeps/ieee754/ldbl-128ibm/e_asinl.c index dece118..00386db 100644 --- a/sysdeps/ieee754/ldbl-128ibm/e_asinl.c +++ b/sysdeps/ieee754/ldbl-128ibm/e_asinl.c @@ -59,6 +59,7 @@ */ +#include <float.h> #include <math.h> #include <math_private.h> long double sqrtl (long double); @@ -146,6 +147,11 @@ __ieee754_asinl (long double x) { if (a < 6.938893903907228e-18L) /* |x| < 2**-57 */ { + if (fabsl (x) < LDBL_MIN) + { + long double force_underflow = x * x; + math_force_eval (force_underflow); + } if (huge + x > one) return x; /* return x with inexact if x!=0 */ } diff --git a/sysdeps/ieee754/ldbl-96/e_asinl.c b/sysdeps/ieee754/ldbl-96/e_asinl.c index c1ffa3e..2973bf0 100644 --- a/sysdeps/ieee754/ldbl-96/e_asinl.c +++ b/sysdeps/ieee754/ldbl-96/e_asinl.c @@ -58,6 +58,7 @@ */ +#include <float.h> #include <math.h> #include <math_private.h> @@ -111,6 +112,11 @@ __ieee754_asinl (long double x) { /* |x|<0.5 */ if (ix < 0x3fde8000) { /* if |x| < 2**-33 */ + if (fabsl (x) < LDBL_MIN) + { + long double force_underflow = x * x; + math_force_eval (force_underflow); + } if (huge + x > one) return x; /* return x with inexact if x!=0 */ } |