Mail Archives: djgpp-workers/2009/09/14/15:23:22
The code of atan2 contains a bug. As can be seen it is tried to check if
the double x variable is inf by checking if the mantissa is identical zero.
On the stack the 64 bit x variable occupies esp + 16 and esp + 12. It makes
no sense to check the mantissa high part at esp + 16 that corresponds to
the x variable and the manstissa low part at esp + 4 that corresponds to
the y variable.
|s|exp|man h| <-- esp + 16 \
| man l | <-- esp + 12 / (64 bit ieee) double x
|s|exp|man h| <-- esp + 8 \
| man l | <-- esp + 4 / (64 bit ieee) double y
It seems to be a "copy and paste" error.
Regards,
Juan M. Guerrero
2009-09-14 Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
Diffs against djgpp CVS head of 2009-08-16.
* src/libc/ansi/math/atan2.S: Check mantissa of y and not mantissa of x.
diff -aprNU5 djgpp.orig/src/libc/ansi/math/atan2.S djgpp/src/libc/ansi/math/atan2.S
--- djgpp.orig/src/libc/ansi/math/atan2.S 1999-08-04 19:58:20 +0000
+++ djgpp/src/libc/ansi/math/atan2.S 2009-09-14 20:55:50 +0000
@@ -45,12 +45,12 @@ aby:
jmp badarg
abx:
movl 16(%esp), %eax /* inf or NaN */
testl $0x000FFFFF, %eax
- jnz badarg
- movl 4(%esp), %eax
+ jne badarg /* x = NaN */
+ movl 12(%esp), %eax
testl %eax, %eax
jnz badarg
movl 8(%esp), %eax
andl $0x7FF00000,%eax
- Raw text -