1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/patches/glibc/2.9/180-math-tests.patch Sun May 08 14:14:40 2011 +0200
1.3 @@ -0,0 +1,72 @@
1.4 +Original patch from: gentoo/src/patchsets/glibc/2.9/0090_all_glibc-math-tests.patch
1.5 +
1.6 +-= BEGIN original header =-
1.7 +From: "Joseph S. Myers" <joseph at codesourcery dot com>
1.8 +To: libc-alpha at sourceware dot org
1.9 +Date: Tue, 15 Jul 2008 14:43:04 +0000 (UTC)
1.10 +Subject: expm1 ulps
1.11 +
1.12 +If you test glibc on i686 with GCC 4.3, you get a test-ildoubl failure:
1.13 +
1.14 +Failure: Test: expm1 (1) == M_El - 1.0
1.15 +Result:
1.16 + is: 1.71828182845904523532e+00 0xd.bf0a8b14576953500000p-3
1.17 + should be: 1.71828182845904523543e+00 0xd.bf0a8b14576953600000p-3
1.18 + difference: 1.08420217248550443401e-19 0x8.00000000000000000000p-66
1.19 + ulp : 1.0000
1.20 + max.ulp : 0.0000
1.21 +Maximal error of `expm1'
1.22 + is : 1 ulp
1.23 + accepted: 0 ulp
1.24 +
1.25 +What happens is that the inline expansion of expm1l uses __builtin_expm1l,
1.26 +and GCC 4.3 optimizes calls to __builtin_expm1l with constant argument to
1.27 +a correctly rounded result using MPFR. The result returned is thus the
1.28 +value of e-1 rounded once to long double precision. However, the test
1.29 +expects M_El - 1.0, and the result of rounding e to long double precision,
1.30 +then subtracting 1, differs in the last place from the result of rounding
1.31 +e-1 to long double precision (the latter has smaller exponent, and the
1.32 +last bit is 1).
1.33 +
1.34 +There are two obvious approaches possible to fixing this. The first patch
1.35 +below changes the expectation to a decimal expansion for e-1 (taken from
1.36 +that of M_El) rather than doing arithmetic in the expected value. This in
1.37 +turn requires ulps to be set for the out-of-line version of expm1. It
1.38 +might also need ulps to be set for the inline version for older compilers
1.39 +if they should continue to pass the test, and possibly for other targets.
1.40 +The second patch below takes the alternative approach of keeping the
1.41 +existing expectation (which has the wrong bit in the last place) and
1.42 +setting ulps for the inline expansion of expm1, which avoids the risk of
1.43 +breaking the test for other targets.
1.44 +
1.45 +2008-07-15 Joseph Myers <joseph@codesourcery.com>
1.46 +
1.47 + * sysdeps/i386/fpu/libm-test-ulps: Add inline long double ulps for
1.48 + expm1.
1.49 +
1.50 +-= END original header =-
1.51 +
1.52 +diff -durN glibc-2_9.orig/sysdeps/i386/fpu/libm-test-ulps glibc-2_9/sysdeps/i386/fpu/libm-test-ulps
1.53 +--- glibc-2_9.orig/sysdeps/i386/fpu/libm-test-ulps 2006-01-15 18:59:37.000000000 +0100
1.54 ++++ glibc-2_9/sysdeps/i386/fpu/libm-test-ulps 2009-02-02 22:00:47.000000000 +0100
1.55 +@@ -453,6 +453,10 @@
1.56 + ildouble: 8
1.57 + ldouble: 8
1.58 +
1.59 ++# expm1
1.60 ++Test "expm1 (1) == M_El - 1.0":
1.61 ++ildouble: 1
1.62 ++
1.63 + # gamma
1.64 + Test "gamma (-0.5) == log(2*sqrt(pi))":
1.65 + double: 1
1.66 +@@ -1134,6 +1138,9 @@
1.67 + ildouble: 8
1.68 + ldouble: 8
1.69 +
1.70 ++Function: "expm1":
1.71 ++ildouble: 1
1.72 ++
1.73 + Function: "gamma":
1.74 + double: 1
1.75 + idouble: 1