aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/math-emu/dp_simple.c
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2006-01-02 07:59:49 -0500
committerRalf Baechle <ralf@linux-mips.org>2006-02-07 08:30:25 -0500
commitc5033d780310ddc5b679ed37ccefcdb87a30ef0c (patch)
tree76d4dbd9b8a34a5540f94abf45a4ecb73ae2d0f0 /arch/mips/math-emu/dp_simple.c
parentd4264f183967db9c2dae4275abb98eb1f79facb2 (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.c14
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)
48 CLEARCX; 48 CLEARCX;
49 FLUSHXDP; 49 FLUSHXDP;
50 50
51 /*
52 * Invert the sign ALWAYS to prevent an endless recursion on
53 * pow() in libc.
54 */
55 /* quick fix up */
56 DPSIGN(x) ^= 1;
57
51 if (xc == IEEE754_CLASS_SNAN) { 58 if (xc == IEEE754_CLASS_SNAN) {
59 ieee754dp y = ieee754dp_indef();
52 SETCX(IEEE754_INVALID_OPERATION); 60 SETCX(IEEE754_INVALID_OPERATION);
53 return ieee754dp_nanxcpt(ieee754dp_indef(), "neg"); 61 DPSIGN(y) = DPSIGN(x);
62 return ieee754dp_nanxcpt(y, "neg");
54 } 63 }
55 64
56 if (ieee754dp_isnan(x)) /* but not infinity */ 65 if (ieee754dp_isnan(x)) /* but not infinity */
57 return ieee754dp_nanxcpt(x, "neg", x); 66 return ieee754dp_nanxcpt(x, "neg", x);
58
59 /* quick fix up */
60 DPSIGN(x) ^= 1;
61 return x; 67 return x;
62} 68}
63 69