diff options
Diffstat (limited to 'arch/mips/math-emu/dp_sqrt.c')
| -rw-r--r-- | arch/mips/math-emu/dp_sqrt.c | 46 | 
1 files changed, 23 insertions, 23 deletions
diff --git a/arch/mips/math-emu/dp_sqrt.c b/arch/mips/math-emu/dp_sqrt.c index b874d60a942..041bbb6124b 100644 --- a/arch/mips/math-emu/dp_sqrt.c +++ b/arch/mips/math-emu/dp_sqrt.c @@ -5,8 +5,6 @@   * MIPS floating point support   * Copyright (C) 1994-2000 Algorithmics Ltd.   * - * ######################################################################## - *   *  This program is free software; you can distribute it and/or modify it   *  under the terms of the GNU General Public License (Version 2) as   *  published by the Free Software Foundation. @@ -18,12 +16,9 @@   *   *  You should have received a copy of the GNU General Public License along   *  with this program; if not, write to the Free Software Foundation, Inc., - *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * ######################################################################## + *  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.   */ -  #include "ieee754dp.h"  static const unsigned table[] = { @@ -34,44 +29,49 @@ static const unsigned table[] = {  	1742, 661, 130  }; -ieee754dp ieee754dp_sqrt(ieee754dp x) +union ieee754dp ieee754dp_sqrt(union ieee754dp x)  {  	struct _ieee754_csr oldcsr; -	ieee754dp y, z, t; +	union ieee754dp y, z, t;  	unsigned scalx, yh;  	COMPXDP;  	EXPLODEXDP; -	CLEARCX; +	ieee754_clearcx();  	FLUSHXDP;  	/* x == INF or NAN? */  	switch (xc) {  	case IEEE754_CLASS_QNAN:  		/* sqrt(Nan) = Nan */ -		return ieee754dp_nanxcpt(x, "sqrt"); +		return ieee754dp_nanxcpt(x); +  	case IEEE754_CLASS_SNAN: -		SETCX(IEEE754_INVALID_OPERATION); -		return ieee754dp_nanxcpt(ieee754dp_indef(), "sqrt"); +		ieee754_setcx(IEEE754_INVALID_OPERATION); +		return ieee754dp_nanxcpt(ieee754dp_indef()); +  	case IEEE754_CLASS_ZERO:  		/* sqrt(0) = 0 */  		return x; +  	case IEEE754_CLASS_INF:  		if (xs) {  			/* sqrt(-Inf) = Nan */ -			SETCX(IEEE754_INVALID_OPERATION); -			return ieee754dp_nanxcpt(ieee754dp_indef(), "sqrt"); +			ieee754_setcx(IEEE754_INVALID_OPERATION); +			return ieee754dp_nanxcpt(ieee754dp_indef());  		}  		/* sqrt(+Inf) = Inf */  		return x; +  	case IEEE754_CLASS_DNORM:  		DPDNORMX;  		/* fall through */ +  	case IEEE754_CLASS_NORM:  		if (xs) {  			/* sqrt(-x) = Nan */ -			SETCX(IEEE754_INVALID_OPERATION); -			return ieee754dp_nanxcpt(ieee754dp_indef(), "sqrt"); +			ieee754_setcx(IEEE754_INVALID_OPERATION); +			return ieee754dp_nanxcpt(ieee754dp_indef());  		}  		break;  	} @@ -80,7 +80,7 @@ ieee754dp ieee754dp_sqrt(ieee754dp x)  	oldcsr = ieee754_csr;  	ieee754_csr.mx &= ~IEEE754_INEXACT;  	ieee754_csr.sx &= ~IEEE754_INEXACT; -	ieee754_csr.rm = IEEE754_RN; +	ieee754_csr.rm = FPU_CSR_RN;  	/* adjust exponent to prevent overflow */  	scalx = 0; @@ -110,19 +110,19 @@ ieee754dp ieee754dp_sqrt(ieee754dp x)  	/* triple to almost 56 sig. bits: y ~= sqrt(x) to within 1 ulp */  	/* t=y*y; z=t;	pt[n0]+=0x00100000; t+=z; z=(x-z)*y; */  	z = t = ieee754dp_mul(y, y); -	t.parts.bexp += 0x001; +	t.bexp += 0x001;  	t = ieee754dp_add(t, z);  	z = ieee754dp_mul(ieee754dp_sub(x, z), y);  	/* t=z/(t+x) ;	pt[n0]+=0x00100000; y+=t; */  	t = ieee754dp_div(z, ieee754dp_add(t, x)); -	t.parts.bexp += 0x001; +	t.bexp += 0x001;  	y = ieee754dp_add(y, t);  	/* twiddle last bit to force y correctly rounded */  	/* set RZ, clear INEX flag */ -	ieee754_csr.rm = IEEE754_RZ; +	ieee754_csr.rm = FPU_CSR_RZ;  	ieee754_csr.sx &= ~IEEE754_INEXACT;  	/* t=x/y; ...chopped quotient, possibly inexact */ @@ -139,10 +139,10 @@ ieee754dp ieee754dp_sqrt(ieee754dp x)  		oldcsr.sx |= IEEE754_INEXACT;  		switch (oldcsr.rm) { -		case IEEE754_RP: +		case FPU_CSR_RU:  			y.bits += 1;  			/* drop through */ -		case IEEE754_RN: +		case FPU_CSR_RN:  			t.bits += 1;  			break;  		} @@ -155,7 +155,7 @@ ieee754dp ieee754dp_sqrt(ieee754dp x)  	}  	/* py[n0]=py[n0]+scalx; ...scale back y */ -	y.parts.bexp += scalx; +	y.bexp += scalx;  	/* restore rounding mode, possibly set inexact */  	ieee754_csr = oldcsr;  | 
