diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2006-01-02 21:59:49 +0900 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2006-02-07 13:30:25 +0000 |
commit | c5033d780310ddc5b679ed37ccefcdb87a30ef0c (patch) | |
tree | 76d4dbd9b8a34a5540f94abf45a4ecb73ae2d0f0 /arch/mips/math-emu/dp_simple.c | |
parent | d4264f183967db9c2dae4275abb98eb1f79facb2 (diff) |
[MIPS] ieee754[sd]p_neg workaround
It looks glibc's pow() assumes an unary '-' operation for any number
(including NaNs) always inverts its sign bit (though IEEE754 does not
specify the sign bit for NaNs). This patch make the kernel math-emu
emulates real MIPS neg.[ds] instruction.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/math-emu/dp_simple.c')
-rw-r--r-- | arch/mips/math-emu/dp_simple.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/arch/mips/math-emu/dp_simple.c b/arch/mips/math-emu/dp_simple.c index 495c1ac94298..1c555e6c6a9f 100644 --- a/arch/mips/math-emu/dp_simple.c +++ b/arch/mips/math-emu/dp_simple.c @@ -48,16 +48,22 @@ ieee754dp ieee754dp_neg(ieee754dp x) CLEARCX; FLUSHXDP; + /* + * Invert the sign ALWAYS to prevent an endless recursion on + * pow() in libc. + */ + /* quick fix up */ + DPSIGN(x) ^= 1; + if (xc == IEEE754_CLASS_SNAN) { + ieee754dp y = ieee754dp_indef(); SETCX(IEEE754_INVALID_OPERATION); - return ieee754dp_nanxcpt(ieee754dp_indef(), "neg"); + DPSIGN(y) = DPSIGN(x); + return ieee754dp_nanxcpt(y, "neg"); } if (ieee754dp_isnan(x)) /* but not infinity */ return ieee754dp_nanxcpt(x, "neg", x); - - /* quick fix up */ - DPSIGN(x) ^= 1; return x; } |