diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2012-07-31 15:30:38 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2012-07-31 15:30:38 +0000 |
commit | dd3105b347f432016fcdc1abd472c3717f557c9e (patch) | |
tree | cbaaecdaa1d3ad240177c9040f7f46c1387716ce /libc/sysdeps/ieee754 | |
parent | 20f73aac36c2b2c240dcc379d5117488fe44960c (diff) | |
download | eglibc2-dd3105b347f432016fcdc1abd472c3717f557c9e.tar.gz |
Merge changes between r19464 and r19920 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@19921 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/sysdeps/ieee754')
-rw-r--r-- | libc/sysdeps/ieee754/dbl-64/e_jn.c | 4 | ||||
-rw-r--r-- | libc/sysdeps/ieee754/flt-32/e_jnf.c | 4 | ||||
-rw-r--r-- | libc/sysdeps/ieee754/flt-32/k_tanf.c | 2 | ||||
-rw-r--r-- | libc/sysdeps/ieee754/k_standard.c | 2 | ||||
-rw-r--r-- | libc/sysdeps/ieee754/ldbl-128/e_jnl.c | 4 | ||||
-rw-r--r-- | libc/sysdeps/ieee754/ldbl-128ibm/e_jnl.c | 4 | ||||
-rw-r--r-- | libc/sysdeps/ieee754/ldbl-128ibm/s_ctanhl.c | 38 | ||||
-rw-r--r-- | libc/sysdeps/ieee754/ldbl-128ibm/s_ctanl.c | 34 | ||||
-rw-r--r-- | libc/sysdeps/ieee754/ldbl-96/e_jnl.c | 7 |
9 files changed, 76 insertions, 23 deletions
diff --git a/libc/sysdeps/ieee754/dbl-64/e_jn.c b/libc/sysdeps/ieee754/dbl-64/e_jn.c index 63788c5a2..0d2a24c93 100644 --- a/libc/sysdeps/ieee754/dbl-64/e_jn.c +++ b/libc/sysdeps/ieee754/dbl-64/e_jn.c @@ -36,6 +36,7 @@ * */ +#include <errno.h> #include <math.h> #include <math_private.h> @@ -276,6 +277,9 @@ __ieee754_yn(int n, double x) GET_HIGH_WORD(high,b); a = temp; } + /* If B is +-Inf, set up errno accordingly. */ + if (! __finite (b)) + __set_errno (ERANGE); } if(sign>0) return b; else return -b; } diff --git a/libc/sysdeps/ieee754/flt-32/e_jnf.c b/libc/sysdeps/ieee754/flt-32/e_jnf.c index bed9cee7a..ad26d7e8a 100644 --- a/libc/sysdeps/ieee754/flt-32/e_jnf.c +++ b/libc/sysdeps/ieee754/flt-32/e_jnf.c @@ -13,6 +13,7 @@ * ==================================================== */ +#include <errno.h> #include <math.h> #include <math_private.h> @@ -199,6 +200,9 @@ __ieee754_ynf(int n, float x) GET_FLOAT_WORD(ib,b); a = temp; } + /* If B is +-Inf, set up errno accordingly. */ + if (! __finitef (b)) + __set_errno (ERANGE); if(sign>0) return b; else return -b; } strong_alias (__ieee754_ynf, __ynf_finite) diff --git a/libc/sysdeps/ieee754/flt-32/k_tanf.c b/libc/sysdeps/ieee754/flt-32/k_tanf.c index 92206069c..be9a5d0f0 100644 --- a/libc/sysdeps/ieee754/flt-32/k_tanf.c +++ b/libc/sysdeps/ieee754/flt-32/k_tanf.c @@ -56,6 +56,8 @@ float __kernel_tanf(float x, float y, int iy) z = pio4-x; w = pio4lo-y; x = z+w; y = 0.0; + if (fabsf (x) < 0x1p-13f) + return (1 - ((hx >> 30) & 2)) * iy * (1.0f - 2 * iy * x); } z = x*x; w = z*z; diff --git a/libc/sysdeps/ieee754/k_standard.c b/libc/sysdeps/ieee754/k_standard.c index 4e65bb16c..cd3123046 100644 --- a/libc/sysdeps/ieee754/k_standard.c +++ b/libc/sysdeps/ieee754/k_standard.c @@ -1003,6 +1003,7 @@ __kernel_standard_f(float x, float y, int type) return __kernel_standard(x, y, type); } +#ifndef __NO_LONG_DOUBLE_MATH long double __kernel_standard_l (long double x, long double y, int type) { @@ -1082,3 +1083,4 @@ __kernel_standard_l (long double x, long double y, int type) return __kernel_standard (dx, dy, type); } } +#endif diff --git a/libc/sysdeps/ieee754/ldbl-128/e_jnl.c b/libc/sysdeps/ieee754/ldbl-128/e_jnl.c index e320d994b..70d5672fd 100644 --- a/libc/sysdeps/ieee754/ldbl-128/e_jnl.c +++ b/libc/sysdeps/ieee754/ldbl-128/e_jnl.c @@ -56,6 +56,7 @@ * */ +#include <errno.h> #include <math.h> #include <math_private.h> @@ -385,6 +386,9 @@ __ieee754_ynl (int n, long double x) a = temp; } } + /* If B is +-Inf, set up errno accordingly. */ + if (! __finitel (b)) + __set_errno (ERANGE); if (sign > 0) return b; else diff --git a/libc/sysdeps/ieee754/ldbl-128ibm/e_jnl.c b/libc/sysdeps/ieee754/ldbl-128ibm/e_jnl.c index 930a2bcbd..40012e41e 100644 --- a/libc/sysdeps/ieee754/ldbl-128ibm/e_jnl.c +++ b/libc/sysdeps/ieee754/ldbl-128ibm/e_jnl.c @@ -56,6 +56,7 @@ * */ +#include <errno.h> #include <math.h> #include <math_private.h> @@ -387,6 +388,9 @@ __ieee754_ynl (int n, long double x) a = temp; } } + /* If B is +-Inf, set up errno accordingly. */ + if (! __finitel (b)) + __set_errno (ERANGE); if (sign > 0) return b; else diff --git a/libc/sysdeps/ieee754/ldbl-128ibm/s_ctanhl.c b/libc/sysdeps/ieee754/ldbl-128ibm/s_ctanhl.c index 2ab80a224..e11ce5678 100644 --- a/libc/sysdeps/ieee754/ldbl-128ibm/s_ctanhl.c +++ b/libc/sysdeps/ieee754/ldbl-128ibm/s_ctanhl.c @@ -25,6 +25,8 @@ #include <math_private.h> +/* IBM long double GCC builtin sets LDBL_EPSILON == LDBL_DENORM_MIN */ +static const long double ldbl_eps = 0x1p-106L; __complex__ long double __ctanhl (__complex__ long double x) @@ -35,8 +37,8 @@ __ctanhl (__complex__ long double x) { if (__isinfl (__real__ x)) { - __real__ res = __copysignl (1.0, __real__ x); - __imag__ res = __copysignl (0.0, __imag__ x); + __real__ res = __copysignl (1.0L, __real__ x); + __imag__ res = __copysignl (0.0L, __imag__ x); } else if (__imag__ x == 0.0) { @@ -57,7 +59,7 @@ __ctanhl (__complex__ long double x) { long double sinix, cosix; long double den; - const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l / 2); + const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l / 2.0L); /* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y)) = (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2). */ @@ -71,7 +73,7 @@ __ctanhl (__complex__ long double x) the real part is +/- 1, the imaginary part is sin(y)*cos(y)/sinh(x)^2 = 4*sin(y)*cos(y)/exp(2x). */ long double exp_2t = __ieee754_expl (2 * t); - __real__ res = __copysignl (1.0, __real__ x); + __real__ res = __copysignl (1.0L, __real__ x); __imag__ res = 4 * sinix * cosix; __real__ x = fabsl (__real__ x); __real__ x -= t; @@ -83,22 +85,34 @@ __ctanhl (__complex__ long double x) __imag__ res /= exp_2t; } else - __imag__ res /= __ieee754_expl (2 * __real__ x); + __imag__ res /= __ieee754_expl (2.0L * __real__ x); } else { - long double sinhrx = __ieee754_sinhl (__real__ x); - long double coshrx = __ieee754_coshl (__real__ x); + long double sinhrx, coshrx; + if (fabs (__real__ x) > LDBL_MIN) + { + sinhrx = __ieee754_sinhl (__real__ x); + coshrx = __ieee754_coshl (__real__ x); + } + else + { + sinhrx = __real__ x; + coshrx = 1.0L; + } - den = sinhrx * sinhrx + cosix * cosix; - __real__ res = sinhrx * coshrx / den; - __imag__ res = sinix * cosix / den; + if (fabsl (sinhrx) > fabsl (cosix) * ldbl_eps) + den = sinhrx * sinhrx + cosix * cosix; + else + den = cosix * cosix; + __real__ res = sinhrx * (coshrx / den); + __imag__ res = sinix * (cosix / den); } /* __gcc_qmul does not respect -0.0 so we need the following fixup. */ - if ((__real__ res == 0.0) && (__real__ x == 0.0)) + if ((__real__ res == 0.0L) && (__real__ x == 0.0L)) __real__ res = __real__ x; - if ((__real__ res == 0.0) && (__imag__ x == 0.0)) + if ((__real__ res == 0.0L) && (__imag__ x == 0.0L)) __imag__ res = __imag__ x; } diff --git a/libc/sysdeps/ieee754/ldbl-128ibm/s_ctanl.c b/libc/sysdeps/ieee754/ldbl-128ibm/s_ctanl.c index 9d89bbe31..34a370a30 100644 --- a/libc/sysdeps/ieee754/ldbl-128ibm/s_ctanl.c +++ b/libc/sysdeps/ieee754/ldbl-128ibm/s_ctanl.c @@ -25,6 +25,8 @@ #include <math_private.h> +/* IBM long double GCC builtin sets LDBL_EPSILON == LDBL_DENORM_MIN */ +static const long double ldbl_eps = 0x1p-106L; __complex__ long double __ctanl (__complex__ long double x) @@ -55,7 +57,7 @@ __ctanl (__complex__ long double x) { long double sinrx, cosrx; long double den; - const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l / 2); + const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l / 2.0L); /* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y)) = (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */ @@ -70,7 +72,7 @@ __ctanl (__complex__ long double x) sin(x)*cos(x)/sinh(y)^2 = 4*sin(x)*cos(x)/exp(2y). */ long double exp_2t = __ieee754_expl (2 * t); - __imag__ res = __copysignl (1.0, __imag__ x); + __imag__ res = __copysignl (1.0L, __imag__ x); __real__ res = 4 * sinrx * cosrx; __imag__ x = fabsl (__imag__ x); __imag__ x -= t; @@ -82,23 +84,35 @@ __ctanl (__complex__ long double x) __real__ res /= exp_2t; } else - __real__ res /= __ieee754_expl (2 * __imag__ x); + __real__ res /= __ieee754_expl (2.0L * __imag__ x); } else { - long double sinhix = __ieee754_sinhl (__imag__ x); - long double coshix = __ieee754_coshl (__imag__ x); + long double sinhix, coshix; + if (fabsl (__imag__ x) > LDBL_MIN) + { + sinhix = __ieee754_sinhl (__imag__ x); + coshix = __ieee754_coshl (__imag__ x); + } + else + { + sinhix = __imag__ x; + coshix = 1.0L; + } - den = cosrx * cosrx + sinhix * sinhix; - __real__ res = sinrx * cosrx / den; - __imag__ res = sinhix * coshix / den; + if (fabsl (sinhix) > fabsl (cosrx) * ldbl_eps) + den = cosrx * cosrx + sinhix * sinhix; + else + den = cosrx * cosrx; + __real__ res = sinrx * (cosrx / den); + __imag__ res = sinhix * (coshix / den); } /* __gcc_qmul does not respect -0.0 so we need the following fixup. */ - if ((__real__ res == 0.0) && (__real__ x == 0.0)) + if ((__real__ res == 0.0L) && (__real__ x == 0.0L)) __real__ res = __real__ x; - if ((__real__ res == 0.0) && (__imag__ x == 0.0)) + if ((__real__ res == 0.0L) && (__imag__ x == 0.0L)) __imag__ res = __imag__ x; } diff --git a/libc/sysdeps/ieee754/ldbl-96/e_jnl.c b/libc/sysdeps/ieee754/ldbl-96/e_jnl.c index 2e206e7e2..58a9107f7 100644 --- a/libc/sysdeps/ieee754/ldbl-96/e_jnl.c +++ b/libc/sysdeps/ieee754/ldbl-96/e_jnl.c @@ -56,6 +56,7 @@ * */ +#include <errno.h> #include <math.h> #include <math_private.h> @@ -360,7 +361,8 @@ __ieee754_ynl (int n, long double x) b = __ieee754_y1l (x); /* quit if b is -inf */ GET_LDOUBLE_WORDS (se, i0, i1, b); - for (i = 1; i < n && se != 0xffff; i++) + /* Use 0xffffffff since GET_LDOUBLE_WORDS sign-extends SE. */ + for (i = 1; i < n && se != 0xffffffff; i++) { temp = b; b = ((long double) (i + i) / x) * b - a; @@ -368,6 +370,9 @@ __ieee754_ynl (int n, long double x) a = temp; } } + /* If B is +-Inf, set up errno accordingly. */ + if (! __finitel (b)) + __set_errno (ERANGE); if (sign > 0) return b; else |