diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2006-01-02 07:59:49 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2006-02-07 08:30:25 -0500 |
commit | c5033d780310ddc5b679ed37ccefcdb87a30ef0c (patch) | |
tree | 76d4dbd9b8a34a5540f94abf45a4ecb73ae2d0f0 /arch/mips | |
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')
-rw-r--r-- | arch/mips/math-emu/dp_simple.c | 14 | ||||
-rw-r--r-- | arch/mips/math-emu/sp_simple.c | 14 |
2 files changed, 20 insertions, 8 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 | ||
diff --git a/arch/mips/math-emu/sp_simple.c b/arch/mips/math-emu/sp_simple.c index c809830dffb4..770f0f4677cd 100644 --- a/arch/mips/math-emu/sp_simple.c +++ b/arch/mips/math-emu/sp_simple.c | |||
@@ -48,16 +48,22 @@ ieee754sp ieee754sp_neg(ieee754sp x) | |||
48 | CLEARCX; | 48 | CLEARCX; |
49 | FLUSHXSP; | 49 | FLUSHXSP; |
50 | 50 | ||
51 | /* | ||
52 | * Invert the sign ALWAYS to prevent an endless recursion on | ||
53 | * pow() in libc. | ||
54 | */ | ||
55 | /* quick fix up */ | ||
56 | SPSIGN(x) ^= 1; | ||
57 | |||
51 | if (xc == IEEE754_CLASS_SNAN) { | 58 | if (xc == IEEE754_CLASS_SNAN) { |
59 | ieee754sp y = ieee754sp_indef(); | ||
52 | SETCX(IEEE754_INVALID_OPERATION); | 60 | SETCX(IEEE754_INVALID_OPERATION); |
53 | return ieee754sp_nanxcpt(ieee754sp_indef(), "neg"); | 61 | SPSIGN(y) = SPSIGN(x); |
62 | return ieee754sp_nanxcpt(y, "neg"); | ||
54 | } | 63 | } |
55 | 64 | ||
56 | if (ieee754sp_isnan(x)) /* but not infinity */ | 65 | if (ieee754sp_isnan(x)) /* but not infinity */ |
57 | return ieee754sp_nanxcpt(x, "neg", x); | 66 | return ieee754sp_nanxcpt(x, "neg", x); |
58 | |||
59 | /* quick fix up */ | ||
60 | SPSIGN(x) ^= 1; | ||
61 | return x; | 67 | return x; |
62 | } | 68 | } |
63 | 69 | ||