Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Atsushi Nemoto and committed by
Ralf Baechle
c5033d78 d4264f18

+20 -8
+10 -4
arch/mips/math-emu/dp_simple.c
··· 48 48 CLEARCX; 49 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 58 if (xc == IEEE754_CLASS_SNAN) { 59 + ieee754dp y = ieee754dp_indef(); 52 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 65 if (ieee754dp_isnan(x)) /* but not infinity */ 57 66 return ieee754dp_nanxcpt(x, "neg", x); 58 - 59 - /* quick fix up */ 60 - DPSIGN(x) ^= 1; 61 67 return x; 62 68 } 63 69
+10 -4
arch/mips/math-emu/sp_simple.c
··· 48 48 CLEARCX; 49 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 58 if (xc == IEEE754_CLASS_SNAN) { 59 + ieee754sp y = ieee754sp_indef(); 52 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 65 if (ieee754sp_isnan(x)) /* but not infinity */ 57 66 return ieee754sp_nanxcpt(x, "neg", x); 58 - 59 - /* quick fix up */ 60 - SPSIGN(x) ^= 1; 61 67 return x; 62 68 } 63 69