From 006d01ca2c255c98ca2d67760d94c3f8bcebab7c2196d470754e9271dde182f5 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Thu, 3 Apr 2014 09:25:20 +0000 Subject: [PATCH] Accepting request 228849 from home:Andreas_Schwab:Factory - nextafterl-ibm-ldouble.patch: Correct IBM long double nextafterl (bnc#871637, BZ #16739) OBS-URL: https://build.opensuse.org/request/show/228849 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=357 --- glibc-testsuite.changes | 6 ++ glibc-testsuite.spec | 3 + glibc-utils.changes | 6 ++ glibc-utils.spec | 3 + glibc.changes | 6 ++ glibc.spec | 3 + nextafterl-ibm-ldouble.patch | 116 +++++++++++++++++++++++++++++++++++ 7 files changed, 143 insertions(+) create mode 100644 nextafterl-ibm-ldouble.patch diff --git a/glibc-testsuite.changes b/glibc-testsuite.changes index 56a90b3..f346b76 100644 --- a/glibc-testsuite.changes +++ b/glibc-testsuite.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Apr 3 07:32:24 UTC 2014 - schwab@suse.de + +- nextafterl-ibm-ldouble.patch: Correct IBM long double nextafterl + (bnc#871637, BZ #16739) + ------------------------------------------------------------------- Tue Apr 1 13:33:24 UTC 2014 - schwab@suse.de diff --git a/glibc-testsuite.spec b/glibc-testsuite.spec index 8c00dbb..ca9740b 100644 --- a/glibc-testsuite.spec +++ b/glibc-testsuite.spec @@ -246,6 +246,8 @@ Patch1005: check-pf-alloca.patch Patch1006: getaddrinfo-uninit-result.patch # PATCH-FIX-UPSTREAM Fix ppc64le copysign overwriting parent stack frame (BZ #16786) Patch1007: ppc64-copysign.patch +# PATCH-FIX-UPSTREAM Correct IBM long double nextafterl (BZ #16739) +Patch1008: nextafterl-ibm-ldouble.patch ### # Patches awaiting upstream approval @@ -470,6 +472,7 @@ rm nscd/s-stamp %patch1005 -p1 %patch1006 -p1 %patch1007 -p1 +%patch1008 -p1 %patch2000 -p1 %patch2001 -p1 diff --git a/glibc-utils.changes b/glibc-utils.changes index 56a90b3..f346b76 100644 --- a/glibc-utils.changes +++ b/glibc-utils.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Apr 3 07:32:24 UTC 2014 - schwab@suse.de + +- nextafterl-ibm-ldouble.patch: Correct IBM long double nextafterl + (bnc#871637, BZ #16739) + ------------------------------------------------------------------- Tue Apr 1 13:33:24 UTC 2014 - schwab@suse.de diff --git a/glibc-utils.spec b/glibc-utils.spec index 012da23..92ce4d9 100644 --- a/glibc-utils.spec +++ b/glibc-utils.spec @@ -245,6 +245,8 @@ Patch1005: check-pf-alloca.patch Patch1006: getaddrinfo-uninit-result.patch # PATCH-FIX-UPSTREAM Fix ppc64le copysign overwriting parent stack frame (BZ #16786) Patch1007: ppc64-copysign.patch +# PATCH-FIX-UPSTREAM Correct IBM long double nextafterl (BZ #16739) +Patch1008: nextafterl-ibm-ldouble.patch ### # Patches awaiting upstream approval @@ -470,6 +472,7 @@ rm nscd/s-stamp %patch1005 -p1 %patch1006 -p1 %patch1007 -p1 +%patch1008 -p1 %patch2000 -p1 %patch2001 -p1 diff --git a/glibc.changes b/glibc.changes index 56a90b3..f346b76 100644 --- a/glibc.changes +++ b/glibc.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Apr 3 07:32:24 UTC 2014 - schwab@suse.de + +- nextafterl-ibm-ldouble.patch: Correct IBM long double nextafterl + (bnc#871637, BZ #16739) + ------------------------------------------------------------------- Tue Apr 1 13:33:24 UTC 2014 - schwab@suse.de diff --git a/glibc.spec b/glibc.spec index d74e8d3..720f07a 100644 --- a/glibc.spec +++ b/glibc.spec @@ -246,6 +246,8 @@ Patch1005: check-pf-alloca.patch Patch1006: getaddrinfo-uninit-result.patch # PATCH-FIX-UPSTREAM Fix ppc64le copysign overwriting parent stack frame (BZ #16786) Patch1007: ppc64-copysign.patch +# PATCH-FIX-UPSTREAM Correct IBM long double nextafterl (BZ #16739) +Patch1008: nextafterl-ibm-ldouble.patch ### # Patches awaiting upstream approval @@ -470,6 +472,7 @@ rm nscd/s-stamp %patch1005 -p1 %patch1006 -p1 %patch1007 -p1 +%patch1008 -p1 %patch2000 -p1 %patch2001 -p1 diff --git a/nextafterl-ibm-ldouble.patch b/nextafterl-ibm-ldouble.patch new file mode 100644 index 0000000..c5d107f --- /dev/null +++ b/nextafterl-ibm-ldouble.patch @@ -0,0 +1,116 @@ +2014-04-02 Alan Modra + + [BZ #16739] + * sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c (__nextafterl): Correct + output when value is near a power of two. Use int64_t for lx and + remove casts. Use decimal rather than hex exponent constants. + Don't use long double multiplication when double will suffice. + * math/libm-test.inc (nextafter_test_data): Add tests. + +Index: glibc-2.19/math/libm-test.inc +=================================================================== +--- glibc-2.19.orig/math/libm-test.inc ++++ glibc-2.19/math/libm-test.inc +@@ -10528,6 +10528,14 @@ static const struct test_ff_f_data nexta + // XXX Enable once gcc is fixed. + //TEST_ff_f (nextafter, 0x0.00000040000000000000p-16385L, -0.1L, 0x0.0000003ffffffff00000p-16385L), + #endif ++#if defined TEST_LDOUBLE && LDBL_MANT_DIG == 106 ++ TEST_ff_f (nextafter, 1.0L, -10.0L, 1.0L-0x1p-106L, NO_EXCEPTION), ++ TEST_ff_f (nextafter, 1.0L, 10.0L, 1.0L+0x1p-105L, NO_EXCEPTION), ++ TEST_ff_f (nextafter, 1.0L-0x1p-106L, 10.0L, 1.0L, NO_EXCEPTION), ++ TEST_ff_f (nextafter, -1.0L, -10.0L, -1.0L-0x1p-105L, NO_EXCEPTION), ++ TEST_ff_f (nextafter, -1.0L, 10.0L, -1.0L+0x1p-106L, NO_EXCEPTION), ++ TEST_ff_f (nextafter, -1.0L+0x1p-106L, -10.0L, -1.0L, NO_EXCEPTION), ++#endif + + /* XXX We need the hexadecimal FP number representation here for further + tests. */ +Index: glibc-2.19/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c +=================================================================== +--- glibc-2.19.orig/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c ++++ glibc-2.19/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c +@@ -30,8 +30,7 @@ static char rcsid[] = "$NetBSD: $"; + + long double __nextafterl(long double x, long double y) + { +- int64_t hx,hy,ihx,ihy; +- uint64_t lx; ++ int64_t hx, hy, ihx, ihy, lx; + double xhi, xlo, yhi; + + ldbl_unpack (x, &xhi, &xlo); +@@ -76,19 +75,28 @@ long double __nextafterl(long double x, + u = math_opt_barrier (x); + x -= __LDBL_DENORM_MIN__; + if (ihx < 0x0360000000000000LL +- || (hx > 0 && (int64_t) lx <= 0) +- || (hx < 0 && (int64_t) lx > 1)) { ++ || (hx > 0 && lx <= 0) ++ || (hx < 0 && lx > 1)) { + u = u * u; + math_force_eval (u); /* raise underflow flag */ + } + return x; + } +- if (ihx < 0x06a0000000000000LL) { /* ulp will denormal */ +- INSERT_WORDS64 (yhi, hx & (0x7ffLL<<52)); +- u = yhi; +- u *= 0x1.0000000000000p-105L; ++ /* If the high double is an exact power of two and the low ++ double is the opposite sign, then 1ulp is one less than ++ what we might determine from the high double. Similarly ++ if X is an exact power of two, and positive, because ++ making it a little smaller will result in the exponent ++ decreasing by one and normalisation of the mantissa. */ ++ if ((hx & 0x000fffffffffffffLL) == 0 ++ && ((lx != 0 && (hx ^ lx) < 0) ++ || (lx == 0 && hx >= 0))) ++ ihx -= 1LL << 52; ++ if (ihx < (106LL << 52)) { /* ulp will denormal */ ++ INSERT_WORDS64 (yhi, ihx & (0x7ffLL<<52)); ++ u = yhi * 0x1p-105; + } else { +- INSERT_WORDS64 (yhi, (hx & (0x7ffLL<<52))-(0x069LL<<52)); ++ INSERT_WORDS64 (yhi, (ihx & (0x7ffLL<<52))-(105LL<<52)); + u = yhi; + } + return x - u; +@@ -103,8 +111,8 @@ long double __nextafterl(long double x, + u = math_opt_barrier (x); + x += __LDBL_DENORM_MIN__; + if (ihx < 0x0360000000000000LL +- || (hx > 0 && (int64_t) lx < 0 && lx != 0x8000000000000001LL) +- || (hx < 0 && (int64_t) lx >= 0)) { ++ || (hx > 0 && lx < 0 && lx != 0x8000000000000001LL) ++ || (hx < 0 && lx >= 0)) { + u = u * u; + math_force_eval (u); /* raise underflow flag */ + } +@@ -112,12 +120,21 @@ long double __nextafterl(long double x, + x = -0.0L; + return x; + } +- if (ihx < 0x06a0000000000000LL) { /* ulp will denormal */ +- INSERT_WORDS64 (yhi, hx & (0x7ffLL<<52)); +- u = yhi; +- u *= 0x1.0000000000000p-105L; ++ /* If the high double is an exact power of two and the low ++ double is the opposite sign, then 1ulp is one less than ++ what we might determine from the high double. Similarly ++ if X is an exact power of two, and negative, because ++ making it a little larger will result in the exponent ++ decreasing by one and normalisation of the mantissa. */ ++ if ((hx & 0x000fffffffffffffLL) == 0 ++ && ((lx != 0 && (hx ^ lx) < 0) ++ || (lx == 0 && hx < 0))) ++ ihx -= 1LL << 52; ++ if (ihx < (106LL << 52)) { /* ulp will denormal */ ++ INSERT_WORDS64 (yhi, ihx & (0x7ffLL<<52)); ++ u = yhi * 0x1p-105; + } else { +- INSERT_WORDS64 (yhi, (hx & (0x7ffLL<<52))-(0x069LL<<52)); ++ INSERT_WORDS64 (yhi, (ihx & (0x7ffLL<<52))-(105LL<<52)); + u = yhi; + } + return x + u;