diff options
author | Rich Felker <dalias@aerifal.cx> | 2020-02-06 11:34:54 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2020-02-06 13:18:00 -0500 |
commit | 1c9afd69051a64cf085c6fb3674a444ff9a43857 (patch) | |
tree | cf65884fe30ea7acb77644e07ce41997067e29bf /src/math/i386 | |
parent | b4712ba445a5cb589d1ac37785c29164cd3cf1f9 (diff) | |
download | musl-1c9afd69051a64cf085c6fb3674a444ff9a43857.tar.gz musl-1c9afd69051a64cf085c6fb3674a444ff9a43857.tar.xz musl-1c9afd69051a64cf085c6fb3674a444ff9a43857.zip |
fix excess precision in return value of i386 atan[2][f]
for functions implemented in C, this is a requirement of C11 (F.6); strictly speaking that text does not apply to standard library functions, but it seems to be intended to apply to them, and C2x is expected to make it a requirement. failure to drop excess precision is particularly bad for inverse trig functions, where a value with excess precision can be outside the range of the function (entire range, or range for a particular subdomain), breaking reasonable invariants a caller may expect.
Diffstat (limited to 'src/math/i386')
-rw-r--r-- | src/math/i386/atan.s | 2 | ||||
-rw-r--r-- | src/math/i386/atan2.s | 3 | ||||
-rw-r--r-- | src/math/i386/atan2f.s | 3 | ||||
-rw-r--r-- | src/math/i386/atanf.s | 2 |
4 files changed, 8 insertions, 2 deletions
diff --git a/src/math/i386/atan.s b/src/math/i386/atan.s index a26feae1..2c57f6b3 100644 --- a/src/math/i386/atan.s +++ b/src/math/i386/atan.s @@ -8,6 +8,8 @@ atan: jb 1f fld1 fpatan + fstpl 4(%esp) + fldl 4(%esp) ret # subnormal x, return x with underflow 1: fsts 4(%esp) diff --git a/src/math/i386/atan2.s b/src/math/i386/atan2.s index 76b95f31..8bc441b1 100644 --- a/src/math/i386/atan2.s +++ b/src/math/i386/atan2.s @@ -4,7 +4,8 @@ atan2: fldl 4(%esp) fldl 12(%esp) fpatan - fstl 4(%esp) + fstpl 4(%esp) + fldl 4(%esp) mov 8(%esp),%eax add %eax,%eax cmp $0x00200000,%eax diff --git a/src/math/i386/atan2f.s b/src/math/i386/atan2f.s index c9408a90..3908c86d 100644 --- a/src/math/i386/atan2f.s +++ b/src/math/i386/atan2f.s @@ -4,7 +4,8 @@ atan2f: flds 4(%esp) flds 8(%esp) fpatan - fsts 4(%esp) + fstps 4(%esp) + flds 4(%esp) mov 4(%esp),%eax add %eax,%eax cmp $0x01000000,%eax diff --git a/src/math/i386/atanf.s b/src/math/i386/atanf.s index 893beac5..c2cbe2e0 100644 --- a/src/math/i386/atanf.s +++ b/src/math/i386/atanf.s @@ -8,6 +8,8 @@ atanf: jb 1f fld1 fpatan + fstps 4(%esp) + flds 4(%esp) ret # subnormal x, return x with underflow 1: fld %st(0) |