eglibc: add upstream patches

Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
Stephan Raue 2012-07-17 20:05:18 +02:00
parent 71b598d54d
commit 93ba969498
10 changed files with 2379 additions and 0 deletions

View File

@ -0,0 +1,56 @@
From d0cd7d02120a1700a9b9f2b5601c35142f1be44b Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@linux-m68k.org>
Date: Mon, 16 Jul 2012 16:51:13 +0200
Subject: [PATCH] Fix bug-getcontext test
---
ChangeLog | 5 +++++
stdlib/bug-getcontext.c | 25 ++++++++++++++++++++-----
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/stdlib/bug-getcontext.c b/stdlib/bug-getcontext.c
index 7db49c8..133ee91 100644
--- a/stdlib/bug-getcontext.c
+++ b/stdlib/bug-getcontext.c
@@ -9,10 +9,25 @@
static int
do_test (void)
{
-#if FE_ALL_EXCEPT == 0
- printf("Skipping test; no support for FP exceptions.\n");
-#else
- int except_mask = FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW;
+ if (FE_ALL_EXCEPT == 0)
+ {
+ printf("Skipping test; no support for FP exceptions.\n");
+ return 0;
+ }
+
+ int except_mask = 0;
+#ifdef FE_DIVBYZERO
+ except_mask |= FE_DIVBYZERO;
+#endif
+#ifdef FE_INVALID
+ except_mask |= FE_INVALID;
+#endif
+#ifdef FE_OVERFLOW
+ except_mask |= FE_OVERFLOW;
+#endif
+#ifdef FE_UNDERFLOW
+ except_mask |= FE_UNDERFLOW;
+#endif
int status = feenableexcept (except_mask);
except_mask = fegetexcept ();
@@ -44,7 +59,7 @@ do_test (void)
printf("\nAt end fegetexcept() returned %d, expected: %d.\n",
mask, except_mask);
-#endif
+
return 0;
}
--
1.7.3.4

View File

@ -0,0 +1,136 @@
From 9ad63c23eabdec1b625b1217b6635f34268ca342 Mon Sep 17 00:00:00 2001
From: Joseph Myers <joseph@codesourcery.com>
Date: Fri, 6 Jul 2012 21:19:38 +0000
Subject: [PATCH] Fix tanf underflow close to pi/4 (bug 14154).
---
ChangeLog | 8 +++++++
NEWS | 2 +-
math/libm-test.inc | 41 +++++++++++++++++++++++++++++++++++++-
sysdeps/i386/fpu/libm-test-ulps | 36 ++++++++++++++++++++++++++++++++++
sysdeps/ieee754/flt-32/k_tanf.c | 2 +
5 files changed, 86 insertions(+), 3 deletions(-)
diff --git a/math/libm-test.inc b/math/libm-test.inc
index b87a40d..27c53a1 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -8405,13 +8405,50 @@ tan_test (void)
TEST_f_f (tan, nan_value, nan_value);
check_int ("errno for tan(NaN) == 0", errno, 0, 0, 0, 0);
- /* Bug 14154: spurious exception may occur. */
- TEST_f_f (tan, M_PI_4l, 1, UNDERFLOW_EXCEPTION_OK_FLOAT);
+ TEST_f_f (tan, M_PI_4l, 1);
TEST_f_f (tan, 0.75L, 0.931596459944072461165202756573936428L);
TEST_f_f (tan, 0x1p65, -0.0472364872359047946798414219288370688827L);
TEST_f_f (tan, -0x1p65, 0.0472364872359047946798414219288370688827L);
+ TEST_f_f (tan, 0xc.9p-4, 0.9995162902115457818029468900654150261381L);
+ TEST_f_f (tan, 0xc.908p-4, 0.9997603425502441410973077452249560802034L);
+ TEST_f_f (tan, 0xc.90cp-4, 0.9998823910588060302788513970802357770031L);
+ TEST_f_f (tan, 0xc.90ep-4, 0.9999434208994808753305784795924711152508L);
+ TEST_f_f (tan, 0xc.90fp-4, 0.9999739372166156702433266059635165160515L);
+ TEST_f_f (tan, 0xc.90f8p-4, 0.9999891957244072765118898375645469865764L);
+ TEST_f_f (tan, 0xc.90fcp-4, 0.9999968250656122402859679132395522927393L);
+ TEST_f_f (tan, 0xc.90fdp-4, 0.9999987324100083358016192309006353329444L);
+ TEST_f_f (tan, 0xc.90fd8p-4, 0.9999996860835706212861509874451585282616L);
+ TEST_f_f (tan, 0xc.90fdap-4, 0.9999999245021033010474530133665235922808L);
+ TEST_f_f (tan, 0xc.ap-4, 1.0073556597407272165371804539701396631519L);
+ TEST_f_f (tan, 0xc.98p-4, 1.0034282930863044654045449407466962736255L);
+ TEST_f_f (tan, 0xc.94p-4, 1.0014703786820082237342656561856877993328L);
+ TEST_f_f (tan, 0xc.92p-4, 1.0004928571392300571266638743539017593717L);
+ TEST_f_f (tan, 0xc.91p-4, 1.0000044544650244953647966900221905361131L);
+ TEST_f_f (tan, 0xc.90fep-4, 1.0000006397580424009014454926842136804016L);
+ TEST_f_f (tan, 0xc.90fdcp-4, 1.0000001629206928242190327320047489394217L);
+ TEST_f_f (tan, 0xc.90fdbp-4, 1.0000000437113909572052640953950483705005L);
+
+ TEST_f_f (tan, -0xc.9p-4, -0.9995162902115457818029468900654150261381L);
+ TEST_f_f (tan, -0xc.908p-4, -0.9997603425502441410973077452249560802034L);
+ TEST_f_f (tan, -0xc.90cp-4, -0.9998823910588060302788513970802357770031L);
+ TEST_f_f (tan, -0xc.90ep-4, -0.9999434208994808753305784795924711152508L);
+ TEST_f_f (tan, -0xc.90fp-4, -0.9999739372166156702433266059635165160515L);
+ TEST_f_f (tan, -0xc.90f8p-4, -0.9999891957244072765118898375645469865764L);
+ TEST_f_f (tan, -0xc.90fcp-4, -0.9999968250656122402859679132395522927393L);
+ TEST_f_f (tan, -0xc.90fdp-4, -0.9999987324100083358016192309006353329444L);
+ TEST_f_f (tan, -0xc.90fd8p-4, -0.9999996860835706212861509874451585282616L);
+ TEST_f_f (tan, -0xc.90fdap-4, -0.9999999245021033010474530133665235922808L);
+ TEST_f_f (tan, -0xc.ap-4, -1.0073556597407272165371804539701396631519L);
+ TEST_f_f (tan, -0xc.98p-4, -1.0034282930863044654045449407466962736255L);
+ TEST_f_f (tan, -0xc.94p-4, -1.0014703786820082237342656561856877993328L);
+ TEST_f_f (tan, -0xc.92p-4, -1.0004928571392300571266638743539017593717L);
+ TEST_f_f (tan, -0xc.91p-4, -1.0000044544650244953647966900221905361131L);
+ TEST_f_f (tan, -0xc.90fep-4, -1.0000006397580424009014454926842136804016L);
+ TEST_f_f (tan, -0xc.90fdcp-4, -1.0000001629206928242190327320047489394217L);
+ TEST_f_f (tan, -0xc.90fdbp-4, -1.0000000437113909572052640953950483705005L);
+
#ifndef TEST_FLOAT
TEST_f_f (tan, 1e22, -1.628778225606898878549375936939548513545L);
TEST_f_f (tan, 0x1p1023, -0.6814476476066215012854144040167365190368L);
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index ab02bde..9ea5ed6 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -2353,9 +2353,45 @@ double: 1
idouble: 1
# tan
+Test "tan (-0xc.90fdbp-4) == -1.0000000437113909572052640953950483705005":
+float: 1
+ifloat: 1
+Test "tan (-0xc.90fdcp-4) == -1.0000001629206928242190327320047489394217":
+float: 1
+ifloat: 1
+Test "tan (-0xc.90fep-4) == -1.0000006397580424009014454926842136804016":
+float: 1
+ifloat: 1
+Test "tan (-0xc.91p-4) == -1.0000044544650244953647966900221905361131":
+float: 1
+ifloat: 1
+Test "tan (-0xc.92p-4) == -1.0004928571392300571266638743539017593717":
+float: 1
+ifloat: 1
+Test "tan (-0xc.94p-4) == -1.0014703786820082237342656561856877993328":
+float: 1
+ifloat: 1
Test "tan (0x1p16383) == 0.422722393732022337800504160054440141575":
ildouble: 1
ldouble: 1
+Test "tan (0xc.90fdbp-4) == 1.0000000437113909572052640953950483705005":
+float: 1
+ifloat: 1
+Test "tan (0xc.90fdcp-4) == 1.0000001629206928242190327320047489394217":
+float: 1
+ifloat: 1
+Test "tan (0xc.90fep-4) == 1.0000006397580424009014454926842136804016":
+float: 1
+ifloat: 1
+Test "tan (0xc.91p-4) == 1.0000044544650244953647966900221905361131":
+float: 1
+ifloat: 1
+Test "tan (0xc.92p-4) == 1.0004928571392300571266638743539017593717":
+float: 1
+ifloat: 1
+Test "tan (0xc.94p-4) == 1.0014703786820082237342656561856877993328":
+float: 1
+ifloat: 1
Test "tan (1e22) == -1.628778225606898878549375936939548513545":
ildouble: 1
ldouble: 1
diff --git a/sysdeps/ieee754/flt-32/k_tanf.c b/sysdeps/ieee754/flt-32/k_tanf.c
index 9220606..be9a5d0 100644
--- a/sysdeps/ieee754/flt-32/k_tanf.c
+++ b/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;
--
1.7.3.4

View File

@ -0,0 +1,355 @@
From cdfe2c5eb3703ed964cbfdb6906b21ace2956385 Mon Sep 17 00:00:00 2001
From: Joseph Myers <joseph@codesourcery.com>
Date: Thu, 5 Jul 2012 11:02:13 +0000
Subject: [PATCH] Fix csqrt underflow (bugs 14157, 14331).
---
ChangeLog | 14 +++++++++++++
NEWS | 2 +-
math/libm-test.inc | 39 ++++++++++++++++++++++++++++++++++--
math/s_csqrt.c | 26 ++++++++++++++++++------
math/s_csqrtf.c | 26 ++++++++++++++++++------
math/s_csqrtl.c | 26 ++++++++++++++++++------
sysdeps/i386/fpu/libm-test-ulps | 28 ++++++++++++++++++++++++++
sysdeps/x86_64/fpu/libm-test-ulps | 30 ++++++++++++++++++++++++++++
8 files changed, 166 insertions(+), 25 deletions(-)
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 514ad06..6adbb61 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -3213,18 +3213,51 @@ csqrt_test (void)
TEST_c_c (csqrt, 0x1p-149L, 0x1p-149L, 4.112805464342778798097003462770175200803e-23L, 1.703579802732953750368659735601389709551e-23L);
TEST_c_c (csqrt, 0x1p-147L, 0x1p-147L, 8.225610928685557596194006925540350401606e-23L, 3.407159605465907500737319471202779419102e-23L);
+ TEST_c_c (csqrt, plus_zero, 0x1p-149L, 2.646977960169688559588507814623881131411e-23L, 2.646977960169688559588507814623881131411e-23L);
+ TEST_c_c (csqrt, 0x1p-50L, 0x1p-149L, 2.980232238769531250000000000000000000000e-8L, 2.350988701644575015937473074444491355637e-38L);
+#ifdef TEST_FLOAT
+ TEST_c_c (csqrt, 0x1p+127L, 0x1p-149L, 1.304381782533278221234957180625250836888e19L, plus_zero, UNDERFLOW_EXCEPTION);
+#endif
+ TEST_c_c (csqrt, 0x1p-149L, 0x1p+127L, 9.223372036854775808000000000000000000000e18L, 9.223372036854775808000000000000000000000e18L);
+ TEST_c_c (csqrt, 0x1.000002p-126L, 0x1.000002p-126L, 1.191195773697904627170323731331667740087e-19L, 4.934094449071842328766868579214125217132e-20L);
+ TEST_c_c (csqrt, -0x1.000002p-126L, -0x1.000002p-126L, 4.934094449071842328766868579214125217132e-20L, -1.191195773697904627170323731331667740087e-19L);
+
#ifndef TEST_FLOAT
TEST_c_c (csqrt, 0x1.fffffffffffffp+1023L, 0x1.fffffffffffffp+1023L, 1.473094556905565378990473658199034571917e+154L, 6.101757441282702188537080005372547713595e+153L);
TEST_c_c (csqrt, 0x1.fffffffffffffp+1023L, 0x1p+1023L, 1.379778091031440685006200821918878702861e+154L, 3.257214233483129514781233066898042490248e+153L);
- /* Bug 14157: spurious exception may occur. */
- TEST_c_c (csqrt, 0x1p-1074L, 0x1p-1074L, 2.442109726130830256743814843868934877597e-162L, 1.011554969366634726113090867589031782487e-162L, UNDERFLOW_EXCEPTION_OK);
- TEST_c_c (csqrt, 0x1p-1073L, 0x1p-1073L, 3.453664695497464982856905711457966660085e-162L, 1.430554756764195530630723976279903095110e-162L, UNDERFLOW_EXCEPTION_OK);
+ TEST_c_c (csqrt, 0x1p-1074L, 0x1p-1074L, 2.442109726130830256743814843868934877597e-162L, 1.011554969366634726113090867589031782487e-162L);
+ TEST_c_c (csqrt, 0x1p-1073L, 0x1p-1073L, 3.453664695497464982856905711457966660085e-162L, 1.430554756764195530630723976279903095110e-162L);
+
+ TEST_c_c (csqrt, plus_zero, 0x1p-1074L, 1.571727784702628688909515672805082228285e-162L, 1.571727784702628688909515672805082228285e-162L);
+ TEST_c_c (csqrt, 0x1p-500L, 0x1p-1074L, 5.527147875260444560247265192192255725514e-76L, 4.469444793151709302716387622440056066334e-249L);
+#if defined TEST_DOUBLE || (defined TEST_LDOUBLE && LDBL_MAX_EXP == 1024)
+ TEST_c_c (csqrt, 0x1p+1023L, 0x1p-1074L, 9.480751908109176726832526455652159260085e153L, plus_zero, UNDERFLOW_EXCEPTION);
+#endif
+ TEST_c_c (csqrt, 0x1p-1074L, 0x1p+1023L, 6.703903964971298549787012499102923063740e153L, 6.703903964971298549787012499102923063740e153L);
+ TEST_c_c (csqrt, 0x1.0000000000001p-1022L, 0x1.0000000000001p-1022L, 1.638872094839911521020410942677082920935e-154L, 6.788430486774966350907249113759995429568e-155L);
+ TEST_c_c (csqrt, -0x1.0000000000001p-1022L, -0x1.0000000000001p-1022L, 6.788430486774966350907249113759995429568e-155L, -1.638872094839911521020410942677082920935e-154L);
#endif
#if defined TEST_LDOUBLE && LDBL_MAX_EXP >= 16384
TEST_c_c (csqrt, 0x1.fp+16383L, 0x1.fp+16383L, 1.179514222452201722651836720466795901016e+2466L, 4.885707879516577666702435054303191575148e+2465L);
TEST_c_c (csqrt, 0x1.fp+16383L, 0x1p+16383L, 1.106698967236475180613254276996359485630e+2466L, 2.687568007603946993388538156299100955642e+2465L);
TEST_c_c (csqrt, 0x1p-16440L, 0x1p-16441L, 3.514690655930285351254618340783294558136e-2475L, 8.297059146828716918029689466551384219370e-2476L);
+
+ TEST_c_c (csqrt, plus_zero, 0x1p-16445L, 4.269191686890197837775136325621239761720e-2476L, 4.269191686890197837775136325621239761720e-2476L);
+ TEST_c_c (csqrt, 0x1p-5000L, 0x1p-16445L, 2.660791472672778409283210520357607795518e-753L, 6.849840675828785164910701384823702064234e-4199L);
+ TEST_c_c (csqrt, 0x1p+16383L, 0x1p-16445L, 7.712754032630730034273323365543179095045e2465L, plus_zero, UNDERFLOW_EXCEPTION);
+ TEST_c_c (csqrt, 0x1p-16445L, 0x1p+16383L, 5.453740678097079647314921223668914312241e2465L, 5.453740678097079647314921223668914312241e2465L);
+ TEST_c_c (csqrt, 0x1.0000000000000002p-16382L, 0x1.0000000000000002p-16382L, 2.014551439675644900131815801350165472778e-2466L, 8.344545284118961664300307045791497724440e-2467L);
+ TEST_c_c (csqrt, -0x1.0000000000000002p-16382L, -0x1.0000000000000002p-16382L, 8.344545284118961664300307045791497724440e-2467L, -2.014551439675644900131815801350165472778e-2466L);
+
+# if LDBL_MANT_DIG >= 113
+ TEST_c_c (csqrt, plus_zero, 0x1p-16494L, 1.799329752913293143453817328207572571442e-2483L, 1.799329752913293143453817328207572571442e-2483L);
+ TEST_c_c (csqrt, 0x1p-5000L, 0x1p-16494L, 2.660791472672778409283210520357607795518e-753L, 1.216776133331049643422030716668249905907e-4213L);
+ TEST_c_c (csqrt, 0x1p+16383L, 0x1p-16494L, 7.712754032630730034273323365543179095045e2465L, plus_zero, UNDERFLOW_EXCEPTION);
+ TEST_c_c (csqrt, 0x1p-16494L, 0x1p+16383L, 5.453740678097079647314921223668914312241e2465L, 5.453740678097079647314921223668914312241e2465L);
+ TEST_c_c (csqrt, 0x1.0000000000000000000000000001p-16382L, 0x1.0000000000000000000000000001p-16382L, 2.014551439675644900022606748976158925145e-2466L, 8.344545284118961663847948339519226074126e-2467L);
+ TEST_c_c (csqrt, -0x1.0000000000000000000000000001p-16382L, -0x1.0000000000000000000000000001p-16382L, 8.344545284118961663847948339519226074126e-2467L, -2.014551439675644900022606748976158925145e-2466L);
+# endif
#endif
END (csqrt, complex);
diff --git a/math/s_csqrt.c b/math/s_csqrt.c
index 002ea5f..f4d0f99 100644
--- a/math/s_csqrt.c
+++ b/math/s_csqrt.c
@@ -75,7 +75,11 @@ __csqrt (__complex__ double x)
}
else if (__builtin_expect (rcls == FP_ZERO, 0))
{
- double r = __ieee754_sqrt (0.5 * fabs (__imag__ x));
+ double r;
+ if (fabs (__imag__ x) >= 2.0 * DBL_MIN)
+ r = __ieee754_sqrt (0.5 * fabs (__imag__ x));
+ else
+ r = 0.5 * __ieee754_sqrt (2.0 * fabs (__imag__ x));
__real__ res = r;
__imag__ res = __copysign (r, __imag__ x);
@@ -85,13 +89,21 @@ __csqrt (__complex__ double x)
double d, r, s;
int scale = 0;
- if (fabs (__real__ x) > DBL_MAX / 2.0
- || fabs (__imag__ x) > DBL_MAX / 2.0)
+ if (fabs (__real__ x) > DBL_MAX / 4.0)
{
scale = 1;
__real__ x = __scalbn (__real__ x, -2 * scale);
__imag__ x = __scalbn (__imag__ x, -2 * scale);
}
+ else if (fabs (__imag__ x) > DBL_MAX / 4.0)
+ {
+ scale = 1;
+ if (fabs (__real__ x) >= 4.0 * DBL_MIN)
+ __real__ x = __scalbn (__real__ x, -2 * scale);
+ else
+ __real__ x = 0.0;
+ __imag__ x = __scalbn (__imag__ x, -2 * scale);
+ }
else if (fabs (__real__ x) < DBL_MIN
&& fabs (__imag__ x) < DBL_MIN)
{
@@ -105,13 +117,13 @@ __csqrt (__complex__ double x)
to avoid cancellation error in d +/- Re x. */
if (__real__ x > 0)
{
- r = __ieee754_sqrt (0.5 * d + 0.5 * __real__ x);
- s = (0.5 * __imag__ x) / r;
+ r = __ieee754_sqrt (0.5 * (d + __real__ x));
+ s = 0.5 * (__imag__ x / r);
}
else
{
- s = __ieee754_sqrt (0.5 * d - 0.5 * __real__ x);
- r = fabs ((0.5 * __imag__ x) / s);
+ s = __ieee754_sqrt (0.5 * (d - __real__ x));
+ r = fabs (0.5 * (__imag__ x / s));
}
if (scale)
diff --git a/math/s_csqrtf.c b/math/s_csqrtf.c
index 6539ba2..5a274fd 100644
--- a/math/s_csqrtf.c
+++ b/math/s_csqrtf.c
@@ -75,7 +75,11 @@ __csqrtf (__complex__ float x)
}
else if (__builtin_expect (rcls == FP_ZERO, 0))
{
- float r = __ieee754_sqrtf (0.5 * fabsf (__imag__ x));
+ float r;
+ if (fabsf (__imag__ x) >= 2.0f * FLT_MIN)
+ r = __ieee754_sqrtf (0.5f * fabsf (__imag__ x));
+ else
+ r = 0.5f * __ieee754_sqrtf (2.0f * fabsf (__imag__ x));
__real__ res = r;
__imag__ res = __copysignf (r, __imag__ x);
@@ -85,13 +89,21 @@ __csqrtf (__complex__ float x)
float d, r, s;
int scale = 0;
- if (fabsf (__real__ x) > FLT_MAX / 2.0f
- || fabsf (__imag__ x) > FLT_MAX / 2.0f)
+ if (fabsf (__real__ x) > FLT_MAX / 4.0f)
{
scale = 1;
__real__ x = __scalbnf (__real__ x, -2 * scale);
__imag__ x = __scalbnf (__imag__ x, -2 * scale);
}
+ else if (fabsf (__imag__ x) > FLT_MAX / 4.0f)
+ {
+ scale = 1;
+ if (fabsf (__real__ x) >= 4.0f * FLT_MIN)
+ __real__ x = __scalbnf (__real__ x, -2 * scale);
+ else
+ __real__ x = 0.0f;
+ __imag__ x = __scalbnf (__imag__ x, -2 * scale);
+ }
else if (fabsf (__real__ x) < FLT_MIN
&& fabsf (__imag__ x) < FLT_MIN)
{
@@ -105,13 +117,13 @@ __csqrtf (__complex__ float x)
to avoid cancellation error in d +/- Re x. */
if (__real__ x > 0)
{
- r = __ieee754_sqrtf (0.5f * d + 0.5f * __real__ x);
- s = (0.5f * __imag__ x) / r;
+ r = __ieee754_sqrtf (0.5f * (d + __real__ x));
+ s = 0.5f * (__imag__ x / r);
}
else
{
- s = __ieee754_sqrtf (0.5f * d - 0.5f * __real__ x);
- r = fabsf ((0.5f * __imag__ x) / s);
+ s = __ieee754_sqrtf (0.5f * (d - __real__ x));
+ r = fabsf (0.5f * (__imag__ x / s));
}
if (scale)
diff --git a/math/s_csqrtl.c b/math/s_csqrtl.c
index 64332f6..579d976 100644
--- a/math/s_csqrtl.c
+++ b/math/s_csqrtl.c
@@ -75,7 +75,11 @@ __csqrtl (__complex__ long double x)
}
else if (__builtin_expect (rcls == FP_ZERO, 0))
{
- long double r = __ieee754_sqrtl (0.5 * fabsl (__imag__ x));
+ long double r;
+ if (fabsl (__imag__ x) >= 2.0L * LDBL_MIN)
+ r = __ieee754_sqrtl (0.5L * fabsl (__imag__ x));
+ else
+ r = 0.5L * __ieee754_sqrtl (2.0L * fabsl (__imag__ x));
__real__ res = r;
__imag__ res = __copysignl (r, __imag__ x);
@@ -85,13 +89,21 @@ __csqrtl (__complex__ long double x)
long double d, r, s;
int scale = 0;
- if (fabsl (__real__ x) > LDBL_MAX / 2.0L
- || fabsl (__imag__ x) > LDBL_MAX / 2.0L)
+ if (fabsl (__real__ x) > LDBL_MAX / 4.0L)
{
scale = 1;
__real__ x = __scalbnl (__real__ x, -2 * scale);
__imag__ x = __scalbnl (__imag__ x, -2 * scale);
}
+ else if (fabsl (__imag__ x) > LDBL_MAX / 4.0L)
+ {
+ scale = 1;
+ if (fabsl (__real__ x) >= 4.0L * LDBL_MIN)
+ __real__ x = __scalbnl (__real__ x, -2 * scale);
+ else
+ __real__ x = 0.0L;
+ __imag__ x = __scalbnl (__imag__ x, -2 * scale);
+ }
else if (fabsl (__real__ x) < LDBL_MIN
&& fabsl (__imag__ x) < LDBL_MIN)
{
@@ -105,13 +117,13 @@ __csqrtl (__complex__ long double x)
to avoid cancellation error in d +/- Re x. */
if (__real__ x > 0)
{
- r = __ieee754_sqrtl (0.5L * d + 0.5L * __real__ x);
- s = (0.5L * __imag__ x) / r;
+ r = __ieee754_sqrtl (0.5L * (d + __real__ x));
+ s = 0.5L * (__imag__ x / r);
}
else
{
- s = __ieee754_sqrtl (0.5L * d - 0.5L * __real__ x);
- r = fabsl ((0.5L * __imag__ x) / s);
+ s = __ieee754_sqrtl (0.5L * (d - __real__ x));
+ r = fabsl (0.5L * (__imag__ x / s));
}
if (scale)
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index 6f41f02..9724919 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -1374,6 +1374,30 @@ float: 1
ifloat: 1
# csqrt
+Test "Real part of: csqrt (-0x1.0000000000000002p-16382 - 0x1.0000000000000002p-16382 i) == 8.344545284118961664300307045791497724440e-2467 - 2.014551439675644900131815801350165472778e-2466 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (-0x1.0000000000000002p-16382 - 0x1.0000000000000002p-16382 i) == 8.344545284118961664300307045791497724440e-2467 - 2.014551439675644900131815801350165472778e-2466 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (-0x1.0000000000001p-1022 - 0x1.0000000000001p-1022 i) == 6.788430486774966350907249113759995429568e-155 - 1.638872094839911521020410942677082920935e-154 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (-0x1.000002p-126 - 0x1.000002p-126 i) == 4.934094449071842328766868579214125217132e-20 - 1.191195773697904627170323731331667740087e-19 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (0x1.0000000000000002p-16382 + 0x1.0000000000000002p-16382 i) == 2.014551439675644900131815801350165472778e-2466 + 8.344545284118961664300307045791497724440e-2467 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0x1.0000000000000002p-16382 + 0x1.0000000000000002p-16382 i) == 2.014551439675644900131815801350165472778e-2466 + 8.344545284118961664300307045791497724440e-2467 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0x1.0000000000001p-1022 + 0x1.0000000000001p-1022 i) == 1.638872094839911521020410942677082920935e-154 + 6.788430486774966350907249113759995429568e-155 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0x1.000002p-126 + 0x1.000002p-126 i) == 1.191195773697904627170323731331667740087e-19 + 4.934094449071842328766868579214125217132e-20 i":
+ildouble: 1
+ldouble: 1
Test "Imaginary part of: csqrt (0x1.fffffffffffffp+1023 + 0x1p+1023 i) == 1.379778091031440685006200821918878702861e+154 + 3.257214233483129514781233066898042490248e+153 i":
ildouble: 1
ldouble: 1
@@ -3032,6 +3056,10 @@ ifloat: 1
ildouble: 2
ldouble: 2
+Function: Real part of "csqrt":
+ildouble: 1
+ldouble: 1
+
Function: Imaginary part of "csqrt":
ildouble: 1
ldouble: 1
diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps
index 765c7a0..b64e52d 100644
--- a/sysdeps/x86_64/fpu/libm-test-ulps
+++ b/sysdeps/x86_64/fpu/libm-test-ulps
@@ -1222,12 +1222,40 @@ float: 1
ifloat: 1
# csqrt
+Test "Real part of: csqrt (-0x1.0000000000000002p-16382 - 0x1.0000000000000002p-16382 i) == 8.344545284118961664300307045791497724440e-2467 - 2.014551439675644900131815801350165472778e-2466 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (-0x1.0000000000000002p-16382 - 0x1.0000000000000002p-16382 i) == 8.344545284118961664300307045791497724440e-2467 - 2.014551439675644900131815801350165472778e-2466 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (-0x1.0000000000001p-1022 - 0x1.0000000000001p-1022 i) == 6.788430486774966350907249113759995429568e-155 - 1.638872094839911521020410942677082920935e-154 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (-0x1.000002p-126 - 0x1.000002p-126 i) == 4.934094449071842328766868579214125217132e-20 - 1.191195773697904627170323731331667740087e-19 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
float: 1
ifloat: 1
Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
float: 1
ifloat: 1
+Test "Real part of: csqrt (0x1.0000000000000002p-16382 + 0x1.0000000000000002p-16382 i) == 2.014551439675644900131815801350165472778e-2466 + 8.344545284118961664300307045791497724440e-2467 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0x1.0000000000000002p-16382 + 0x1.0000000000000002p-16382 i) == 2.014551439675644900131815801350165472778e-2466 + 8.344545284118961664300307045791497724440e-2467 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0x1.0000000000001p-1022 + 0x1.0000000000001p-1022 i) == 1.638872094839911521020410942677082920935e-154 + 6.788430486774966350907249113759995429568e-155 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0x1.000002p-126 + 0x1.000002p-126 i) == 1.191195773697904627170323731331667740087e-19 + 4.934094449071842328766868579214125217132e-20 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
Test "Imaginary part of: csqrt (0x1.fffffep+127 + 1.0 i) == 1.844674352395372953599975585936590505260e+19 + 2.710505511993121390769065968615872097053e-20 i":
float: 1
ifloat: 1
@@ -2818,6 +2846,8 @@ double: 1
float: 1
idouble: 1
ifloat: 1
+ildouble: 1
+ldouble: 1
Function: Imaginary part of "csqrt":
double: 1
--
1.7.3.4

View File

@ -0,0 +1,46 @@
From 541428fecf21cdde271acbd280c53bfe5beaafe2 Mon Sep 17 00:00:00 2001
From: Marek Polacek <polacek@redhat.com>
Date: Thu, 12 Jul 2012 16:34:47 +0200
Subject: [PATCH] Fix ynl return value with LDBL_MIN.
---
ChangeLog | 7 +++++++
NEWS | 3 ++-
math/libm-test.inc | 5 ++++-
sysdeps/ieee754/ldbl-96/e_jnl.c | 3 ++-
4 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/math/libm-test.inc b/math/libm-test.inc
index a9cc2bd..25a8f41 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -9015,8 +9015,11 @@ yn_test (void)
TEST_ff_f (yn, 10, 2.0, -129184.542208039282635913145923304214L);
TEST_ff_f (yn, 10, 10.0, -0.359814152183402722051986577343560609L);
- END (yn);
+ /* Check whether yn returns correct value for LDBL_MIN, DBL_MIN,
+ and FLT_MIN. See Bug 14173. */
+ TEST_ff_f (yn, 10, min_value, minus_infty, OVERFLOW_EXCEPTION);
+ END (yn);
}
diff --git a/sysdeps/ieee754/ldbl-96/e_jnl.c b/sysdeps/ieee754/ldbl-96/e_jnl.c
index 2e206e7..36b0d8b 100644
--- a/sysdeps/ieee754/ldbl-96/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-96/e_jnl.c
@@ -360,7 +360,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;
--
1.7.3.4

View File

@ -0,0 +1,148 @@
From 7a845b2c237434d4aad790aaba3a973e24ea802f Mon Sep 17 00:00:00 2001
From: Joseph Myers <joseph@codesourcery.com>
Date: Tue, 3 Jul 2012 17:10:42 +0000
Subject: [PATCH] Fix float range reduction problems (bug 14283).
---
ChangeLog | 9 ++++++++
NEWS | 2 +
math/libm-test.inc | 4 +++
sysdeps/i386/fpu/libm-test-ulps | 16 +++++++-------
sysdeps/ieee754/flt-32/k_rem_pio2f.c | 37 +++++++++++++++++++++------------
5 files changed, 46 insertions(+), 22 deletions(-)
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 48b05a6..3e33348 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -2589,6 +2589,8 @@ cos_test (void)
TEST_f_f (cos, 0.80190127184058835, 0.69534156199418473);
#endif
+ TEST_f_f (cos, 0x1.442f74p+15, 2.4407839902314016628485779006274989801517e-06L);
+
#ifndef TEST_FLOAT
TEST_f_f (cos, 1e22, 0.5232147853951389454975944733847094921409L);
TEST_f_f (cos, 0x1p1023, -0.826369834614147994500785680811743734805L);
@@ -7692,6 +7694,8 @@ sin_test (void)
TEST_f_f (sin, 0x1p65, -0.047183876212354673805106149805700013943218L);
TEST_f_f (sin, -0x1p65, 0.047183876212354673805106149805700013943218L);
+ TEST_f_f (sin, 0x1.7f4134p+103, -6.6703229329788657073304190650534846045235e-08L);
+
#ifdef TEST_DOUBLE
TEST_f_f (sin, 0.80190127184058835, 0.71867942238767868);
TEST_f_f (sin, 2.522464e-1, 2.4957989804940911e-1);
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index 38a69e6..4661aea 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -1656,8 +1656,8 @@ Test "j1 (0.75) == 0.349243602174862192523281016426251335":
double: 1
idouble: 1
Test "j1 (0x1.3ffp+74) == 1.818984347516051243459364437186082741567e-12":
-float: 1
-ifloat: 1
+float: 2
+ifloat: 2
ildouble: 1
ldouble: 1
Test "j1 (0x1.ff00000000002p+840) == 1.846591691699331493194965158699937660696e-127":
@@ -2359,8 +2359,8 @@ float: 1
idouble: 1
ifloat: 1
Test "y0 (0x1.3ffp+74) == 1.818984347516051243459467456433028748678e-12":
-float: 1
-ifloat: 1
+float: 2
+ifloat: 2
ildouble: 1
ldouble: 1
Test "y0 (0x1.ff00000000002p+840) == 1.846591691699331493194965158699937660696e-127":
@@ -2956,9 +2956,9 @@ ldouble: 2
Function: "j1":
double: 2
-float: 1
+float: 2
idouble: 2
-ifloat: 1
+ifloat: 2
ildouble: 1
ldouble: 1
@@ -3128,9 +3128,9 @@ ldouble: 1
Function: "y0":
double: 2
-float: 1
+float: 2
idouble: 2
-ifloat: 1
+ifloat: 2
ildouble: 1
ldouble: 1
diff --git a/sysdeps/ieee754/flt-32/k_rem_pio2f.c b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
index 06c2f37..e54a067 100644
--- a/sysdeps/ieee754/flt-32/k_rem_pio2f.c
+++ b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
@@ -88,7 +88,7 @@ recompute:
iq[jz-1] -= i<<(8-q0);
ih = iq[jz-1]>>(7-q0);
}
- else if(q0==0) ih = iq[jz-1]>>8;
+ else if(q0==0) ih = iq[jz-1]>>7;
else if(z>=(float)0.5) ih=2;
if(ih>0) { /* q > 0.5 */
@@ -166,24 +166,33 @@ recompute:
y[0] = (ih==0)? fw: -fw;
break;
case 1:
- case 2:
- fw = 0.0;
- for (i=jz;i>=0;i--) fw += fq[i];
- y[0] = (ih==0)? fw: -fw;
- fw = fq[0]-fw;
- for (i=1;i<=jz;i++) fw += fq[i];
- y[1] = (ih==0)? fw: -fw;
+ case 2:;
+#if __FLT_EVAL_METHOD__ != 0
+ volatile
+#endif
+ float fv = 0.0;
+ for (i=jz;i>=0;i--) fv += fq[i];
+ y[0] = (ih==0)? fv: -fv;
+ fv = fq[0]-fv;
+ for (i=1;i<=jz;i++) fv += fq[i];
+ y[1] = (ih==0)? fv: -fv;
break;
case 3: /* painful */
for (i=jz;i>0;i--) {
- fw = fq[i-1]+fq[i];
- fq[i] += fq[i-1]-fw;
- fq[i-1] = fw;
+#if __FLT_EVAL_METHOD__ != 0
+ volatile
+#endif
+ float fv = fq[i-1]+fq[i];
+ fq[i] += fq[i-1]-fv;
+ fq[i-1] = fv;
}
for (i=jz;i>1;i--) {
- fw = fq[i-1]+fq[i];
- fq[i] += fq[i-1]-fw;
- fq[i-1] = fw;
+#if __FLT_EVAL_METHOD__ != 0
+ volatile
+#endif
+ float fv = fq[i-1]+fq[i];
+ fq[i] += fq[i-1]-fv;
+ fq[i-1] = fv;
}
for (fw=0.0,i=jz;i>=2;i--) fw += fq[i];
if(ih==0) {
--
1.7.3.4

View File

@ -0,0 +1,97 @@
From 7b6e99be77c24a79cb07416d81796b45176923c6 Mon Sep 17 00:00:00 2001
From: Jeroen van Bemmel <jvb127@gmail.com>
Date: Thu, 12 Jul 2012 11:23:28 +0530
Subject: [PATCH] Avoid duplicate DNS requests if answer is longer than a implementation
limit
[BZ #14307]
* sysdeps/posix/getaddrinfo.c (gaih_inet): Increase the size of
the temporary buffer used to invoke __gethostbyname2_r,
__gethostbyaddr_r and gethostbyname4_r to make room for struct
host_data / struct gaih_addrtuple.
* resolv/nss_dns/dns-host.c (global scope): Move definition of
implementation constants MAX_NR_ALIASES and MAX_NR_ADDRS to
header file nss/nsswitch.h.
* nss/nsswitch.h (global scope): Add definition of implementation
constants MAX_NR_ALIASES and MAX_NR_ADDRS (moved from
resolv/nss_dns/dns-host.c).
---
ChangeLog | 14 ++++++++++++++
nss/nsswitch.h | 7 +++++--
resolv/nss_dns/dns-host.c | 4 ----
sysdeps/posix/getaddrinfo.c | 10 +++++++---
4 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/nss/nsswitch.h b/nss/nsswitch.h
index 90e208b..047a9e5 100644
--- a/nss/nsswitch.h
+++ b/nss/nsswitch.h
@@ -1,5 +1,4 @@
-/* Copyright (C) 1996-1999,2001,2002,2003,2004,2007,2010,2011
- Free Software Foundation, Inc.
+/* Copyright (C) 1996-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -198,4 +197,8 @@ extern int __nss_hostname_digits_dots (const char *name,
int *h_errnop);
libc_hidden_proto (__nss_hostname_digits_dots)
+/* Maximum number of aliases we allow. */
+#define MAX_NR_ALIASES 48
+#define MAX_NR_ADDRS 48
+
#endif /* nsswitch.h */
diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index a924d40..6b62c05 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -88,10 +88,6 @@
#define RESOLVSORT
-/* Maximum number of aliases we allow. */
-#define MAX_NR_ALIASES 48
-#define MAX_NR_ADDRS 48
-
#if PACKETSZ > 65536
# define MAXPACKET PACKETSZ
#else
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 2eca2ae..78a2474 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -568,7 +568,9 @@ gaih_inet (const char *name, const struct gaih_service *service,
IPv6 scope ids. */
if (req->ai_family == AF_INET)
{
- size_t tmpbuflen = 512;
+ /* Allocate additional room for struct host_data. */
+ size_t tmpbuflen = (512 + MAX_NR_ALIASES * sizeof(char*)
+ + 16 * sizeof(char));
assert (tmpbuf == NULL);
tmpbuf = alloca_account (tmpbuflen, alloca_used);
int rc;
@@ -811,7 +813,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
old_res_options = _res.options;
_res.options &= ~RES_USE_INET6;
- size_t tmpbuflen = 1024;
+ size_t tmpbuflen = 1024 + sizeof(struct gaih_addrtuple);
malloc_tmpbuf = !__libc_use_alloca (alloca_used + tmpbuflen);
assert (tmpbuf == NULL);
if (!malloc_tmpbuf)
@@ -1113,7 +1115,9 @@ gaih_inet (const char *name, const struct gaih_service *service,
struct hostent *h = NULL;
int herrno;
struct hostent th;
- size_t tmpbuf2len = 512;
+ /* Add room for struct host_data. */
+ size_t tmpbuf2len = (512 + (MAX_NR_ALIASES+MAX_NR_ADDRS+1)
+ * sizeof(char*) + 16 * sizeof(char));
do
{
--
1.7.3.4

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,357 @@
From f17ac40d7cb8e8c462476b6ab703262f6b8f6da8 Mon Sep 17 00:00:00 2001
From: Joseph Myers <joseph@codesourcery.com>
Date: Fri, 6 Jul 2012 11:17:41 +0000
Subject: [PATCH] Fix expm1 spurious underflow exceptions (bug 6778).
---
ChangeLog | 21 ++++++++++++++++++
NEWS | 2 +-
math/libm-test.inc | 24 +++++++++++++++++++-
sysdeps/i386/fpu/e_expl.S | 42 ++++++++++++++++++++++++------------
sysdeps/i386/fpu/libm-test-ulps | 3 ++
sysdeps/i386/fpu/s_expm1.S | 24 +++++++++++++++------
sysdeps/i386/fpu/s_expm1f.S | 24 +++++++++++++++------
sysdeps/x86_64/fpu/e_expl.S | 42 ++++++++++++++++++++++++------------
sysdeps/x86_64/fpu/libm-test-ulps | 3 ++
9 files changed, 140 insertions(+), 45 deletions(-)
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 6adbb61..b87a40d 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -4039,12 +4039,32 @@ expm1_test (void)
TEST_f_f (expm1, 11356.25L, 9.05128237311923300051376115753226014206e+4931L);
#endif
+ TEST_f_f (expm1, -10.0, -0.9999546000702375151484644084844394493898L);
+ TEST_f_f (expm1, -16.0, -0.9999998874648252807408854862248209398728L);
+ TEST_f_f (expm1, -17.0, -0.9999999586006228121483334034897228104472L);
+ TEST_f_f (expm1, -18.0, -0.9999999847700202552873715638633707664826L);
+ TEST_f_f (expm1, -36.0, -0.9999999999999997680477169756430611687736L);
+ TEST_f_f (expm1, -37.0, -0.9999999999999999146695237425593420572195L);
+ TEST_f_f (expm1, -38.0, -0.9999999999999999686086720795197037129104L);
+ TEST_f_f (expm1, -44.0, -0.9999999999999999999221886775886620348429L);
+ TEST_f_f (expm1, -45.0, -0.9999999999999999999713748141945060635553L);
+ TEST_f_f (expm1, -46.0, -0.9999999999999999999894693826424461876212L);
+ TEST_f_f (expm1, -73.0, -0.9999999999999999999999999999999802074012L);
+ TEST_f_f (expm1, -74.0, -0.9999999999999999999999999999999927187098L);
+ TEST_f_f (expm1, -75.0, -0.9999999999999999999999999999999973213630L);
+ TEST_f_f (expm1, -78.0, -0.9999999999999999999999999999999998666385L);
+ TEST_f_f (expm1, -79.0, -0.9999999999999999999999999999999999509391L);
+ TEST_f_f (expm1, -80.0, -0.9999999999999999999999999999999999819515L);
+ TEST_f_f (expm1, -100.0, -1.0);
+ TEST_f_f (expm1, -1000.0, -1.0);
+ TEST_f_f (expm1, -10000.0, -1.0);
+ TEST_f_f (expm1, -100000.0, -1.0);
+
errno = 0;
TEST_f_f (expm1, 100000.0, plus_infty, OVERFLOW_EXCEPTION);
check_int ("errno for expm1(large) == ERANGE", errno, ERANGE, 0, 0, 0);
TEST_f_f (expm1, max_value, plus_infty, OVERFLOW_EXCEPTION);
- /* Bug 6778: spurious underflow exception. */
- TEST_f_f (expm1, -max_value, -1, UNDERFLOW_EXCEPTION_OK);
+ TEST_f_f (expm1, -max_value, -1);
END (expm1);
}
diff --git a/sysdeps/i386/fpu/e_expl.S b/sysdeps/i386/fpu/e_expl.S
index bab0a08..e42c9a1 100644
--- a/sysdeps/i386/fpu/e_expl.S
+++ b/sysdeps/i386/fpu/e_expl.S
@@ -60,10 +60,12 @@ c1: .byte 0x20, 0xfa, 0xee, 0xc2, 0x5f, 0x70, 0xa5, 0xec, 0xed, 0x3f
.byte 0, 0, 0, 0, 0, 0
ASM_SIZE_DIRECTIVE(c1)
#endif
+#ifndef USE_AS_EXPM1L
ASM_TYPE_DIRECTIVE(csat,@object)
csat: .byte 0, 0, 0, 0, 0, 0, 0, 0x80, 0x0e, 0x40
.byte 0, 0, 0, 0, 0, 0
ASM_SIZE_DIRECTIVE(csat)
+#endif
#ifdef PIC
# define MO(op) op##@GOTOFF(%ecx)
@@ -88,9 +90,26 @@ ENTRY(IEEE754_EXPL)
#ifdef PIC
LOAD_PIC_REG (cx)
#endif
-#ifndef USE_AS_EXPM1L
+#ifdef USE_AS_EXPM1L
+ xorb $0x80, %ah
+ cmpl $0xc006, %eax
+ fstsw %ax
+ movb $0x45, %dh
+ jb 4f
+
+ /* Below -64.0 (may be -NaN or -Inf). */
+ andb %ah, %dh
+ cmpb $0x01, %dh
+ je 2f /* Is +-NaN, jump. */
+ jmp 1f /* -large, possibly -Inf. */
+
+4: /* In range -64.0 to 64.0 (may be +-0 but not NaN or +-Inf). */
+ /* Test for +-0 as argument. */
+ andb %ah, %dh
+ cmpb $0x40, %dh
+ je 2f
+#else
movzwl 4+8(%esp), %eax
-#endif
andl $0x7fff, %eax
cmpl $0x400d, %eax
jle 3f
@@ -108,16 +127,8 @@ ENTRY(IEEE754_EXPL)
andb $2, %ah
jz 3f
fchs
-3:
-#ifdef USE_AS_EXPM1L
- /* Test for +-0 as argument. */
- fstsw %ax
- movb $0x45, %dh
- andb %ah, %dh
- cmpb $0x40, %dh
- je 2f
#endif
- FLDLOG /* 1 log2(base) */
+3: FLDLOG /* 1 log2(base) */
fmul %st(1), %st /* 1 x log2(base) */
frndint /* 1 i */
fld %st(1) /* 2 x */
@@ -154,13 +165,16 @@ ENTRY(IEEE754_EXPL)
#endif
fstp %st(1) /* 0 */
jmp 2f
-1: testl $0x200, %eax /* Test sign. */
- jz 2f /* If positive, jump. */
- fstp %st
+1:
#ifdef USE_AS_EXPM1L
+ /* For expm1l, only negative sign gets here. */
+ fstp %st
fld1
fchs
#else
+ testl $0x200, %eax /* Test sign. */
+ jz 2f /* If positive, jump. */
+ fstp %st
fldz /* Set result to 0. */
#endif
2: ret
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index 9724919..ab02bde 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -1779,6 +1779,9 @@ idouble: 1
ifloat: 1
# expm1
+Test "expm1 (-45.0) == -0.9999999999999999999713748141945060635553":
+ildouble: 1
+ldouble: 1
Test "expm1 (1) == M_El - 1.0":
ildouble: 1
Test "expm1 (11356.25) == 9.05128237311923300051376115753226014206e+4931":
diff --git a/sysdeps/i386/fpu/s_expm1.S b/sysdeps/i386/fpu/s_expm1.S
index 9883f9b..d2754de 100644
--- a/sysdeps/i386/fpu/s_expm1.S
+++ b/sysdeps/i386/fpu/s_expm1.S
@@ -51,19 +51,31 @@ ENTRY(__expm1)
jae HIDDEN_JUMPTARGET (__exp)
fldl 4(%esp) // x
- fxam // Is NaN or +-Inf?
+ fxam // Is NaN, +-Inf or +-0?
+ xorb $0x80, %ah
+ cmpl $0xc043, %eax // is num <= -38.0?
fstsw %ax
movb $0x45, %ch
+ jb 4f
+
+ // Below -38.0 (may be -NaN or -Inf).
+ andb %ah, %ch
+#ifdef PIC
+ LOAD_PIC_REG (dx)
+#endif
+ cmpb $0x01, %ch
+ je 5f // If -NaN, jump.
+ jmp 2f // -large, possibly -Inf.
+
+4: // In range -38.0 to 704.0 (may be +-0 but not NaN or +-Inf).
andb %ah, %ch
cmpb $0x40, %ch
je 3f // If +-0, jump.
#ifdef PIC
LOAD_PIC_REG (dx)
#endif
- cmpb $0x05, %ch
- je 2f // If +-Inf, jump.
- fldt MO(l2e) // log2(e) : x
+5: fldt MO(l2e) // log2(e) : x
fmulp // log2(e)*x
fld %st // log2(e)*x : log2(e)*x
frndint // int(log2(e)*x) : log2(e)*x
@@ -79,9 +91,7 @@ ENTRY(__expm1)
fsubrp %st, %st(1) // 2^(log2(e)*x)
ret
-2: testl $0x200, %eax // Test sign.
- jz 3f // If positive, jump.
- fstp %st
+2: fstp %st
fldl MO(minus1) // Set result to -1.0.
3: ret
END(__expm1)
diff --git a/sysdeps/i386/fpu/s_expm1f.S b/sysdeps/i386/fpu/s_expm1f.S
index 45257d7..fc82b92 100644
--- a/sysdeps/i386/fpu/s_expm1f.S
+++ b/sysdeps/i386/fpu/s_expm1f.S
@@ -51,19 +51,31 @@ ENTRY(__expm1f)
jae HIDDEN_JUMPTARGET (__expf)
flds 4(%esp) // x
- fxam // Is NaN or +-Inf?
+ fxam // Is NaN, +-Inf or +-0?
+ xorb $0x80, %ah
+ cmpl $0xc190, %eax // is num <= -18.0?
fstsw %ax
movb $0x45, %ch
+ jb 4f
+
+ // Below -18.0 (may be -NaN or -Inf).
+ andb %ah, %ch
+#ifdef PIC
+ LOAD_PIC_REG (dx)
+#endif
+ cmpb $0x01, %ch
+ je 5f // If -NaN, jump.
+ jmp 2f // -large, possibly -Inf.
+
+4: // In range -18.0 to 88.5 (may be +-0 but not NaN or +-Inf).
andb %ah, %ch
cmpb $0x40, %ch
je 3f // If +-0, jump.
#ifdef PIC
LOAD_PIC_REG (dx)
#endif
- cmpb $0x05, %ch
- je 2f // If +-Inf, jump.
- fldt MO(l2e) // log2(e) : x
+5: fldt MO(l2e) // log2(e) : x
fmulp // log2(e)*x
fld %st // log2(e)*x : log2(e)*x
frndint // int(log2(e)*x) : log2(e)*x
@@ -79,9 +91,7 @@ ENTRY(__expm1f)
fsubrp %st, %st(1) // 2^(log2(e)*x)
ret
-2: testl $0x200, %eax // Test sign.
- jz 3f // If positive, jump.
- fstp %st
+2: fstp %st
fldl MO(minus1) // Set result to -1.0.
3: ret
END(__expm1f)
diff --git a/sysdeps/x86_64/fpu/e_expl.S b/sysdeps/x86_64/fpu/e_expl.S
index e6b842b..1c37c86 100644
--- a/sysdeps/x86_64/fpu/e_expl.S
+++ b/sysdeps/x86_64/fpu/e_expl.S
@@ -60,10 +60,12 @@ c1: .byte 0x20, 0xfa, 0xee, 0xc2, 0x5f, 0x70, 0xa5, 0xec, 0xed, 0x3f
.byte 0, 0, 0, 0, 0, 0
ASM_SIZE_DIRECTIVE(c1)
#endif
+#ifndef USE_AS_EXPM1L
ASM_TYPE_DIRECTIVE(csat,@object)
csat: .byte 0, 0, 0, 0, 0, 0, 0, 0x80, 0x0e, 0x40
.byte 0, 0, 0, 0, 0, 0
ASM_SIZE_DIRECTIVE(csat)
+#endif
#ifdef PIC
# define MO(op) op##(%rip)
@@ -85,9 +87,26 @@ ENTRY(IEEE754_EXPL)
For the i686 the code can be written better.
-- drepper@cygnus.com. */
fxam /* Is NaN or +-Inf? */
-#ifndef USE_AS_EXPM1L
+#ifdef USE_AS_EXPM1L
+ xorb $0x80, %ah
+ cmpl $0xc006, %eax
+ fstsw %ax
+ movb $0x45, %dh
+ jb 4f
+
+ /* Below -64.0 (may be -NaN or -Inf). */
+ andb %ah, %dh
+ cmpb $0x01, %dh
+ je 2f /* Is +-NaN, jump. */
+ jmp 1f /* -large, possibly -Inf. */
+
+4: /* In range -64.0 to 64.0 (may be +-0 but not NaN or +-Inf). */
+ /* Test for +-0 as argument. */
+ andb %ah, %dh
+ cmpb $0x40, %dh
+ je 2f
+#else
movzwl 8+8(%rsp), %eax
-#endif
andl $0x7fff, %eax
cmpl $0x400d, %eax
jle 3f
@@ -105,16 +124,8 @@ ENTRY(IEEE754_EXPL)
andb $2, %ah
jz 3f
fchs
-3:
-#ifdef USE_AS_EXPM1L
- /* Test for +-0 as argument. */
- fstsw %ax
- movb $0x45, %dh
- andb %ah, %dh
- cmpb $0x40, %dh
- je 2f
#endif
- FLDLOG /* 1 log2(base) */
+3: FLDLOG /* 1 log2(base) */
fmul %st(1), %st /* 1 x log2(base) */
frndint /* 1 i */
fld %st(1) /* 2 x */
@@ -151,13 +162,16 @@ ENTRY(IEEE754_EXPL)
#endif
fstp %st(1) /* 0 */
jmp 2f
-1: testl $0x200, %eax /* Test sign. */
- jz 2f /* If positive, jump. */
- fstp %st
+1:
#ifdef USE_AS_EXPM1L
+ /* For expm1l, only negative sign gets here. */
+ fstp %st
fld1
fchs
#else
+ testl $0x200, %eax /* Test sign. */
+ jz 2f /* If positive, jump. */
+ fstp %st
fldz /* Set result to 0. */
#endif
2: ret
diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps
index b64e52d..be28024 100644
--- a/sysdeps/x86_64/fpu/libm-test-ulps
+++ b/sysdeps/x86_64/fpu/libm-test-ulps
@@ -1657,6 +1657,9 @@ float: 1
ifloat: 1
# expm1
+Test "expm1 (-45.0) == -0.9999999999999999999713748141945060635553":
+ildouble: 1
+ldouble: 1
Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
double: 1
idouble: 1
--
1.7.3.4

View File

@ -0,0 +1,41 @@
From fb21f89b75d0152aa42efb6b620843799a4cd76b Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Tue, 3 Jul 2012 15:22:05 -0400
Subject: [PATCH] sunrpc: fix rpc bootstrap builds
If you build & install glibc w/rpc disabled, you no longer have headers in
/usr/include/rpc/ (this is expected). But if you try to build glibc w/rpc
enabled, this gets into a bad state due to the new rpc helpers that get
cross-compiled:
$ make
...
x86_64-pc-linux-gnu-gcc -m32 -D_RPC_THREAD_SAFE_ -D_GNU_SOURCE -DIS_IN_build \
-include $objdir/config.h rpc_clntout.c -o $objdir/sunrpc/cross-rpc_clntout.o \
-MMD -MP -MF $objdir/sunrpc/cross-rpc_clntout.o.dt -MT $objdir/sunrpc/cross-rpc_clntout.o -c
rpc_clntout.c:34:23: fatal error: rpc/types.h: No such file or directory
compilation terminated.
make: *** [$objdir/sunrpc/cross-rpc_clntout.o] Error 1
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
ChangeLog | 4 ++++
sunrpc/rpc_clntout.c | 2 +-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/sunrpc/rpc_clntout.c b/sunrpc/rpc_clntout.c
index ec040c7..ce4d2a4 100644
--- a/sunrpc/rpc_clntout.c
+++ b/sunrpc/rpc_clntout.c
@@ -31,7 +31,7 @@
*/
#include <stdio.h>
#include <string.h>
-#include <rpc/types.h>
+#include "rpc/types.h"
#include "rpc_parse.h"
#include "rpc_util.h"
#include "proto.h"
--
1.7.3.4

View File

@ -0,0 +1,27 @@
From c57a67e03368687fc0d2ae8354cd1b347a61ea44 Mon Sep 17 00:00:00 2001
From: Joseph Myers <joseph@codesourcery.com>
Date: Thu, 5 Jul 2012 22:16:03 +0000
Subject: [PATCH] Add ARM-specific static-stubs.c.
---
ports/ChangeLog.arm | 4 ++++
ports/sysdeps/arm/static-stubs.c | 7 +++++++
2 files changed, 11 insertions(+), 0 deletions(-)
create mode 100644 ports/sysdeps/arm/static-stubs.c
diff --git a/ports/sysdeps/arm/static-stubs.c b/ports/sysdeps/arm/static-stubs.c
new file mode 100644
index 0000000..d90d603
--- /dev/null
+++ b/ports/sysdeps/arm/static-stubs.c
@@ -0,0 +1,7 @@
+/* When building with GCC with static-only libgcc, the dummy
+ _Unwind_Resume from static-stubs.c needs to be used together with
+ the dummy __aeabi_unwind_cpp_pr* from aeabi_unwind_cpp_pr1.c
+ instead of the copies from libgcc. */
+
+#include <elf/static-stubs.c>
+#include <aeabi_unwind_cpp_pr1.c>
--
1.7.3.4