patches/glibc/2.9/180-math-tests.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jan 17 23:06:02 2010 +0100 (2010-01-17)
changeset 1740 c57458bb354d
parent 1201 c9967a6e3b25
permissions -rw-r--r--
configure: do not require hg when configuring in an hg clone

When configuring in an hg clone, we need hg to compute the version string.
It can happen that users do not have Mercurial (eg. if they got a snapshot
rather that they did a full clone). In this case, we can still run, of
course, so simply fill the version string with a sufficiently explicit
value, that does not require hg. The date is a good candidate.
yann@1201
     1
Original patch from: gentoo/src/patchsets/glibc/2.9/0090_all_glibc-math-tests.patch
yann@1201
     2
yann@1201
     3
-= BEGIN original header =-
yann@1201
     4
From: "Joseph S. Myers" <joseph at codesourcery dot com>
yann@1201
     5
To: libc-alpha at sourceware dot org
yann@1201
     6
Date: Tue, 15 Jul 2008 14:43:04 +0000 (UTC)
yann@1201
     7
Subject: expm1 ulps
yann@1201
     8
yann@1201
     9
If you test glibc on i686 with GCC 4.3, you get a test-ildoubl failure:
yann@1201
    10
yann@1201
    11
Failure: Test: expm1 (1) == M_El - 1.0
yann@1201
    12
Result:
yann@1201
    13
 is:          1.71828182845904523532e+00   0xd.bf0a8b14576953500000p-3
yann@1201
    14
 should be:   1.71828182845904523543e+00   0xd.bf0a8b14576953600000p-3
yann@1201
    15
 difference:  1.08420217248550443401e-19   0x8.00000000000000000000p-66
yann@1201
    16
 ulp       :  1.0000
yann@1201
    17
 max.ulp   :  0.0000
yann@1201
    18
Maximal error of `expm1'
yann@1201
    19
 is      : 1 ulp
yann@1201
    20
 accepted: 0 ulp
yann@1201
    21
yann@1201
    22
What happens is that the inline expansion of expm1l uses __builtin_expm1l,
yann@1201
    23
and GCC 4.3 optimizes calls to __builtin_expm1l with constant argument to
yann@1201
    24
a correctly rounded result using MPFR.  The result returned is thus the
yann@1201
    25
value of e-1 rounded once to long double precision.  However, the test
yann@1201
    26
expects M_El - 1.0, and the result of rounding e to long double precision,
yann@1201
    27
then subtracting 1, differs in the last place from the result of rounding
yann@1201
    28
e-1 to long double precision (the latter has smaller exponent, and the
yann@1201
    29
last bit is 1).
yann@1201
    30
yann@1201
    31
There are two obvious approaches possible to fixing this.  The first patch
yann@1201
    32
below changes the expectation to a decimal expansion for e-1 (taken from
yann@1201
    33
that of M_El) rather than doing arithmetic in the expected value.  This in
yann@1201
    34
turn requires ulps to be set for the out-of-line version of expm1.  It
yann@1201
    35
might also need ulps to be set for the inline version for older compilers
yann@1201
    36
if they should continue to pass the test, and possibly for other targets.
yann@1201
    37
The second patch below takes the alternative approach of keeping the
yann@1201
    38
existing expectation (which has the wrong bit in the last place) and
yann@1201
    39
setting ulps for the inline expansion of expm1, which avoids the risk of
yann@1201
    40
breaking the test for other targets.
yann@1201
    41
yann@1201
    42
2008-07-15  Joseph Myers  <joseph@codesourcery.com>
yann@1201
    43
yann@1201
    44
        * sysdeps/i386/fpu/libm-test-ulps: Add inline long double ulps for
yann@1201
    45
        expm1.
yann@1201
    46
yann@1201
    47
-= END original header =-
yann@1201
    48
yann@1201
    49
diff -durN glibc-2_9.orig/sysdeps/i386/fpu/libm-test-ulps glibc-2_9/sysdeps/i386/fpu/libm-test-ulps
yann@1201
    50
--- glibc-2_9.orig/sysdeps/i386/fpu/libm-test-ulps	2006-01-15 18:59:37.000000000 +0100
yann@1201
    51
+++ glibc-2_9/sysdeps/i386/fpu/libm-test-ulps	2009-02-02 22:00:47.000000000 +0100
yann@1201
    52
@@ -453,6 +453,10 @@
yann@1201
    53
 ildouble: 8
yann@1201
    54
 ldouble: 8
yann@1201
    55
 
yann@1201
    56
+# expm1
yann@1201
    57
+Test "expm1 (1) == M_El - 1.0":
yann@1201
    58
+ildouble: 1
yann@1201
    59
+
yann@1201
    60
 # gamma
yann@1201
    61
 Test "gamma (-0.5) == log(2*sqrt(pi))":
yann@1201
    62
 double: 1
yann@1201
    63
@@ -1134,6 +1138,9 @@
yann@1201
    64
 ildouble: 8
yann@1201
    65
 ldouble: 8
yann@1201
    66
 
yann@1201
    67
+Function: "expm1":
yann@1201
    68
+ildouble: 1
yann@1201
    69
+
yann@1201
    70
 Function: "gamma":
yann@1201
    71
 double: 1
yann@1201
    72
 idouble: 1