patch-2.4.19 linux-2.4.19/arch/mips/math-emu/sp_sqrt.c
Next file: linux-2.4.19/arch/mips/math-emu/sp_sub.c
Previous file: linux-2.4.19/arch/mips/math-emu/sp_simple.c
Back to the patch index
Back to the overall index
- Lines: 67
- Date:
Fri Aug 2 17:39:43 2002
- Orig file:
linux-2.4.18/arch/mips/math-emu/sp_sqrt.c
- Orig date:
Fri Apr 13 20:26:07 2001
diff -urN linux-2.4.18/arch/mips/math-emu/sp_sqrt.c linux-2.4.19/arch/mips/math-emu/sp_sqrt.c
@@ -27,43 +27,45 @@
#include "ieee754sp.h"
-static const struct ieee754sp_konst knan = {
- 0, SP_EBIAS + SP_EMAX + 1, 0
-};
-
-#define nan ((ieee754sp)knan)
-
ieee754sp ieee754sp_sqrt(ieee754sp x)
{
int sign = (int) 0x80000000;
int ix, s, q, m, t, i;
unsigned int r;
- COMPXDP;
+ COMPXSP;
/* take care of Inf and NaN */
- EXPLODEXDP;
+ EXPLODEXSP;
+ CLEARCX;
+ FLUSHXSP;
/* x == INF or NAN? */
switch (xc) {
case IEEE754_CLASS_QNAN:
- case IEEE754_CLASS_SNAN:
/* sqrt(Nan) = Nan */
return ieee754sp_nanxcpt(x, "sqrt");
+ case IEEE754_CLASS_SNAN:
+ SETCX(IEEE754_INVALID_OPERATION);
+ return ieee754sp_nanxcpt(ieee754sp_indef(), "sqrt");
case IEEE754_CLASS_ZERO:
/* sqrt(0) = 0 */
return x;
case IEEE754_CLASS_INF:
- if (xs)
+ if (xs) {
/* sqrt(-Inf) = Nan */
- return ieee754sp_nanxcpt(nan, "sqrt");
+ SETCX(IEEE754_INVALID_OPERATION);
+ return ieee754sp_nanxcpt(ieee754sp_indef(), "sqrt");
+ }
/* sqrt(+Inf) = Inf */
return x;
case IEEE754_CLASS_DNORM:
case IEEE754_CLASS_NORM:
- if (xs)
+ if (xs) {
/* sqrt(-x) = Nan */
- return ieee754sp_nanxcpt(nan, "sqrt");
+ SETCX(IEEE754_INVALID_OPERATION);
+ return ieee754sp_nanxcpt(ieee754sp_indef(), "sqrt");
+ }
break;
}
@@ -99,6 +101,7 @@
}
if (ix != 0) {
+ SETCX(IEEE754_INEXACT);
switch (ieee754_csr.rm) {
case IEEE754_RP:
q += 2;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)