aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/mips/math-emu/dp_simple.c55
-rw-r--r--arch/mips/math-emu/sp_simple.c55
2 files changed, 38 insertions, 72 deletions
diff --git a/arch/mips/math-emu/dp_simple.c b/arch/mips/math-emu/dp_simple.c
index bccbe90efceb..926d56bf37f2 100644
--- a/arch/mips/math-emu/dp_simple.c
+++ b/arch/mips/math-emu/dp_simple.c
@@ -23,44 +23,27 @@
23 23
24union ieee754dp ieee754dp_neg(union ieee754dp x) 24union ieee754dp ieee754dp_neg(union ieee754dp x)
25{ 25{
26 COMPXDP; 26 unsigned int oldrm;
27 27 union ieee754dp y;
28 EXPLODEXDP; 28
29 ieee754_clearcx(); 29 oldrm = ieee754_csr.rm;
30 FLUSHXDP; 30 ieee754_csr.rm = FPU_CSR_RD;
31 31 y = ieee754dp_sub(ieee754dp_zero(0), x);
32 /* 32 ieee754_csr.rm = oldrm;
33 * Invert the sign ALWAYS to prevent an endless recursion on 33 return y;
34 * pow() in libc.
35 */
36 /* quick fix up */
37 DPSIGN(x) ^= 1;
38
39 if (xc == IEEE754_CLASS_SNAN) {
40 union ieee754dp y = ieee754dp_indef();
41 ieee754_setcx(IEEE754_INVALID_OPERATION);
42 DPSIGN(y) = DPSIGN(x);
43 return ieee754dp_nanxcpt(y);
44 }
45
46 return x;
47} 34}
48 35
49union ieee754dp ieee754dp_abs(union ieee754dp x) 36union ieee754dp ieee754dp_abs(union ieee754dp x)
50{ 37{
51 COMPXDP; 38 unsigned int oldrm;
52 39 union ieee754dp y;
53 EXPLODEXDP; 40
54 ieee754_clearcx(); 41 oldrm = ieee754_csr.rm;
55 FLUSHXDP; 42 ieee754_csr.rm = FPU_CSR_RD;
56 43 if (DPSIGN(x))
57 /* Clear sign ALWAYS, irrespective of NaN */ 44 y = ieee754dp_sub(ieee754dp_zero(0), x);
58 DPSIGN(x) = 0; 45 else
59 46 y = ieee754dp_add(ieee754dp_zero(0), x);
60 if (xc == IEEE754_CLASS_SNAN) { 47 ieee754_csr.rm = oldrm;
61 ieee754_setcx(IEEE754_INVALID_OPERATION); 48 return y;
62 return ieee754dp_nanxcpt(ieee754dp_indef());
63 }
64
65 return x;
66} 49}
diff --git a/arch/mips/math-emu/sp_simple.c b/arch/mips/math-emu/sp_simple.c
index f1ffaa9a17e0..c50e9451f2d2 100644
--- a/arch/mips/math-emu/sp_simple.c
+++ b/arch/mips/math-emu/sp_simple.c
@@ -23,44 +23,27 @@
23 23
24union ieee754sp ieee754sp_neg(union ieee754sp x) 24union ieee754sp ieee754sp_neg(union ieee754sp x)
25{ 25{
26 COMPXSP; 26 unsigned int oldrm;
27 27 union ieee754sp y;
28 EXPLODEXSP; 28
29 ieee754_clearcx(); 29 oldrm = ieee754_csr.rm;
30 FLUSHXSP; 30 ieee754_csr.rm = FPU_CSR_RD;
31 31 y = ieee754sp_sub(ieee754sp_zero(0), x);
32 /* 32 ieee754_csr.rm = oldrm;
33 * Invert the sign ALWAYS to prevent an endless recursion on 33 return y;
34 * pow() in libc.
35 */
36 /* quick fix up */
37 SPSIGN(x) ^= 1;
38
39 if (xc == IEEE754_CLASS_SNAN) {
40 union ieee754sp y = ieee754sp_indef();
41 ieee754_setcx(IEEE754_INVALID_OPERATION);
42 SPSIGN(y) = SPSIGN(x);
43 return ieee754sp_nanxcpt(y);
44 }
45
46 return x;
47} 34}
48 35
49union ieee754sp ieee754sp_abs(union ieee754sp x) 36union ieee754sp ieee754sp_abs(union ieee754sp x)
50{ 37{
51 COMPXSP; 38 unsigned int oldrm;
52 39 union ieee754sp y;
53 EXPLODEXSP; 40
54 ieee754_clearcx(); 41 oldrm = ieee754_csr.rm;
55 FLUSHXSP; 42 ieee754_csr.rm = FPU_CSR_RD;
56 43 if (SPSIGN(x))
57 /* Clear sign ALWAYS, irrespective of NaN */ 44 y = ieee754sp_sub(ieee754sp_zero(0), x);
58 SPSIGN(x) = 0; 45 else
59 46 y = ieee754sp_add(ieee754sp_zero(0), x);
60 if (xc == IEEE754_CLASS_SNAN) { 47 ieee754_csr.rm = oldrm;
61 ieee754_setcx(IEEE754_INVALID_OPERATION); 48 return y;
62 return ieee754sp_nanxcpt(ieee754sp_indef());
63 }
64
65 return x;
66} 49}