提交 1c9afd69 编写于 作者: R Rich Felker

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.
上级 b4712ba4
...@@ -8,6 +8,8 @@ atan: ...@@ -8,6 +8,8 @@ atan:
jb 1f jb 1f
fld1 fld1
fpatan fpatan
fstpl 4(%esp)
fldl 4(%esp)
ret ret
# subnormal x, return x with underflow # subnormal x, return x with underflow
1: fsts 4(%esp) 1: fsts 4(%esp)
......
...@@ -4,7 +4,8 @@ atan2: ...@@ -4,7 +4,8 @@ atan2:
fldl 4(%esp) fldl 4(%esp)
fldl 12(%esp) fldl 12(%esp)
fpatan fpatan
fstl 4(%esp) fstpl 4(%esp)
fldl 4(%esp)
mov 8(%esp),%eax mov 8(%esp),%eax
add %eax,%eax add %eax,%eax
cmp $0x00200000,%eax cmp $0x00200000,%eax
......
...@@ -4,7 +4,8 @@ atan2f: ...@@ -4,7 +4,8 @@ atan2f:
flds 4(%esp) flds 4(%esp)
flds 8(%esp) flds 8(%esp)
fpatan fpatan
fsts 4(%esp) fstps 4(%esp)
flds 4(%esp)
mov 4(%esp),%eax mov 4(%esp),%eax
add %eax,%eax add %eax,%eax
cmp $0x01000000,%eax cmp $0x01000000,%eax
......
...@@ -8,6 +8,8 @@ atanf: ...@@ -8,6 +8,8 @@ atanf:
jb 1f jb 1f
fld1 fld1
fpatan fpatan
fstps 4(%esp)
flds 4(%esp)
ret ret
# subnormal x, return x with underflow # subnormal x, return x with underflow
1: fld %st(0) 1: fld %st(0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册