diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-03-29 03:58:20 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-03-29 03:58:20 +0000 |
commit | b7d2cadef3354bbbd97a98d382291d18fce6200c (patch) | |
tree | a5232eeba7a692164b2bedee650cab64a874adda /sys/arch/hppa/spmath/sfadd.c | |
parent | 8da71daa70fb2878a11a7d02439e45d2f4f59baa (diff) |
big bang
Diffstat (limited to 'sys/arch/hppa/spmath/sfadd.c')
-rw-r--r-- | sys/arch/hppa/spmath/sfadd.c | 204 |
1 files changed, 102 insertions, 102 deletions
diff --git a/sys/arch/hppa/spmath/sfadd.c b/sys/arch/hppa/spmath/sfadd.c index 3e052e85d50..98afffe8929 100644 --- a/sys/arch/hppa/spmath/sfadd.c +++ b/sys/arch/hppa/spmath/sfadd.c @@ -1,25 +1,25 @@ -/* $OpenBSD: sfadd.c,v 1.3 1998/07/02 19:05:51 mickey Exp $ */ +/* $OpenBSD: sfadd.c,v 1.4 2001/03/29 03:58:19 mickey Exp $ */ /* - * Copyright 1996 1995 by Open Software Foundation, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * + * Copyright 1996 1995 by Open Software Foundation, Inc. + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * */ /* * pmk1.1 @@ -27,15 +27,15 @@ /* * (c) Copyright 1986 HEWLETT-PACKARD COMPANY * - * To anyone who acknowledges that this file is provided "AS IS" + * To anyone who acknowledges that this file is provided "AS IS" * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of Hewlett-Packard Company not be - * used in advertising or publicity pertaining to distribution - * of the software without specific, written prior permission. - * Hewlett-Packard Company makes no representations about the + * permission to use, copy, modify, and distribute this file + * for any purpose is hereby granted without fee, provided that + * the above copyright notice and this notice appears in all + * copies, and that the name of Hewlett-Packard Company not be + * used in advertising or publicity pertaining to distribution + * of the software without specific, written prior permission. + * Hewlett-Packard Company makes no representations about the * suitability of this software for any purpose. */ @@ -52,19 +52,19 @@ sgl_fadd(leftptr, rightptr, dstptr, status) { register unsigned int left, right, result, extent; register unsigned int signless_upper_left, signless_upper_right, save; - - + + register int result_exponent, right_exponent, diff_exponent; register int sign_save, jumpsize; - register boolean inexact = FALSE; - register boolean underflowtrap; - + register int inexact = FALSE; + register int underflowtrap; + /* Create local copies of the numbers */ left = *leftptr; right = *rightptr; - /* A zero "save" helps discover equal operands (for later), * - * and is used in swapping operands (if needed). */ + /* A zero "save" helps discover equal operands (for later), * + * and is used in swapping operands (if needed). */ Sgl_xortointp1(left,right,/*to*/save); /* @@ -72,48 +72,48 @@ sgl_fadd(leftptr, rightptr, dstptr, status) */ if ((result_exponent = Sgl_exponent(left)) == SGL_INFINITY_EXPONENT) { - if (Sgl_iszero_mantissa(left)) + if (Sgl_iszero_mantissa(left)) { - if (Sgl_isnotnan(right)) + if (Sgl_isnotnan(right)) { - if (Sgl_isinfinity(right) && save!=0) + if (Sgl_isinfinity(right) && save!=0) { - /* + /* * invalid since operands are opposite signed infinity's */ if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - Set_invalidflag(); - Sgl_makequietnan(result); + Set_invalidflag(); + Sgl_makequietnan(result); *dstptr = result; return(NOEXCEPTION); } /* - * return infinity - */ + * return infinity + */ *dstptr = left; return(NOEXCEPTION); } } - else + else { - /* - * is NaN; signaling or quiet? - */ - if (Sgl_isone_signaling(left)) + /* + * is NaN; signaling or quiet? + */ + if (Sgl_isone_signaling(left)) { - /* trap if INVALIDTRAP enabled */ + /* trap if INVALIDTRAP enabled */ if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Sgl_set_quiet(left); - } - /* - * is second operand a signaling NaN? + /* make NaN quiet */ + Set_invalidflag(); + Sgl_set_quiet(left); + } + /* + * is second operand a signaling NaN? */ - else if (Sgl_is_signalingnan(right)) + else if (Sgl_is_signalingnan(right)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); + /* trap if INVALIDTRAP enabled */ + if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); /* make NaN quiet */ Set_invalidflag(); Sgl_set_quiet(right); @@ -121,29 +121,29 @@ sgl_fadd(leftptr, rightptr, dstptr, status) return(NOEXCEPTION); } /* - * return quiet NaN - */ - *dstptr = left; - return(NOEXCEPTION); + * return quiet NaN + */ + *dstptr = left; + return(NOEXCEPTION); } } /* End left NaN or Infinity processing */ /* * check second operand for NaN's or infinity */ - if (Sgl_isinfinity_exponent(right)) + if (Sgl_isinfinity_exponent(right)) { - if (Sgl_iszero_mantissa(right)) + if (Sgl_iszero_mantissa(right)) { /* return infinity */ *dstptr = right; return(NOEXCEPTION); } - /* - * is NaN; signaling or quiet? - */ - if (Sgl_isone_signaling(right)) + /* + * is NaN; signaling or quiet? + */ + if (Sgl_isone_signaling(right)) { - /* trap if INVALIDTRAP enabled */ + /* trap if INVALIDTRAP enabled */ if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); /* make NaN quiet */ Set_invalidflag(); @@ -151,10 +151,10 @@ sgl_fadd(leftptr, rightptr, dstptr, status) } /* * return quiet NaN - */ + */ *dstptr = right; return(NOEXCEPTION); - } /* End right NaN or Infinity processing */ + } /* End right NaN or Infinity processing */ /* Invariant: Must be dealing with finite numbers */ @@ -166,17 +166,17 @@ sgl_fadd(leftptr, rightptr, dstptr, status) if(Sgl_ismagnitudeless(signless_upper_left,signless_upper_right)) { /* Set the left operand to the larger one by XOR swap * - * First finish the first word using "save" */ + * First finish the first word using "save" */ Sgl_xorfromintp1(save,right,/*to*/right); Sgl_xorfromintp1(save,left,/*to*/left); result_exponent = Sgl_exponent(left); } - /* Invariant: left is not smaller than right. */ + /* Invariant: left is not smaller than right. */ if((right_exponent = Sgl_exponent(right)) == 0) - { + { /* Denormalized operands. First look for zeroes */ - if(Sgl_iszero_mantissa(right)) + if(Sgl_iszero_mantissa(right)) { /* right is zero */ if(Sgl_iszero_exponentmantissa(left)) @@ -191,7 +191,7 @@ sgl_fadd(leftptr, rightptr, dstptr, status) Sgl_and_signs(left,/*with*/right); } } - else + else { /* Left is not a zero and must be the result. Trapped * underflows are signaled if left is denormalized. Result @@ -199,7 +199,7 @@ sgl_fadd(leftptr, rightptr, dstptr, status) if( (result_exponent == 0) && Is_underflowtrap_enabled() ) { /* need to normalize results mantissa */ - sign_save = Sgl_signextendedsign(left); + sign_save = Sgl_signextendedsign(left); Sgl_leftshiftby1(left); Sgl_normalize(left,result_exponent); Sgl_set_sign(left,/*using*/sign_save); @@ -248,11 +248,11 @@ sgl_fadd(leftptr, rightptr, dstptr, status) if(Is_underflowtrap_enabled()) { /* need to normalize result */ - sign_save = Sgl_signextendedsign(result); + sign_save = Sgl_signextendedsign(result); Sgl_leftshiftby1(result); Sgl_normalize(result,result_exponent); Sgl_set_sign(result,/*using*/sign_save); - Sgl_setwrapped_exponent(result,result_exponent,unfl); + Sgl_setwrapped_exponent(result,result_exponent,unfl); *dstptr = result; return(UNDERFLOWEXCEPTION); } @@ -269,8 +269,8 @@ sgl_fadd(leftptr, rightptr, dstptr, status) Sgl_clear_exponent_set_hidden(left); diff_exponent = result_exponent - right_exponent; - /* - * Special case alignment of operands that would force alignment + /* + * Special case alignment of operands that would force alignment * beyond the extent of the extension. A further optimization * could special case this but only reduces the path length for this * infrequent case. @@ -279,7 +279,7 @@ sgl_fadd(leftptr, rightptr, dstptr, status) { diff_exponent = SGL_THRESHOLD; } - + /* Align right operand by shifting to right */ Sgl_right_align(/*operand*/right,/*shifted by*/diff_exponent, /*and lower to*/extent); @@ -302,17 +302,17 @@ sgl_fadd(leftptr, rightptr, dstptr, status) * Only the two most significant bits (round and guard) are * needed. If only a single shift is needed then the guard * bit becomes a significant low order bit and the extension - * must participate in the rounding. If more than a single - * shift is needed, then all bits to the right of the guard + * must participate in the rounding. If more than a single + * shift is needed, then all bits to the right of the guard * bit are zeros, and the guard bit may or may not be zero. */ sign_save = Sgl_signextendedsign(result); - Sgl_leftshiftby1_withextent(result,extent,result); + Sgl_leftshiftby1_withextent(result,extent,result); - /* Need to check for a zero result. The sign and exponent + /* Need to check for a zero result. The sign and exponent * fields have already been zeroed. The more efficient test * of the full object can be used. */ - if(Sgl_iszero(result)) + if(Sgl_iszero(result)) /* Must have been "x-x" or "x+(-x)". */ { if(Is_rounding_mode(ROUNDMINUS)) Sgl_setone_sign(result); @@ -326,19 +326,19 @@ sgl_fadd(leftptr, rightptr, dstptr, status) if(result_exponent==0) { /* Denormalized, exponent should be zero. Left operand * - * was normalized, so extent (guard, round) was zero */ + * was normalized, so extent (guard, round) was zero */ goto underflow; } else { /* No further normalization is needed. */ Sgl_set_sign(result,/*using*/sign_save); - Ext_leftshiftby1(extent); + Ext_leftshiftby1(extent); goto round; } } - /* Check for denormalized, exponent should be zero. Left * + /* Check for denormalized, exponent should be zero. Left * * operand was normalized, so extent (guard, round) was zero */ if(!(underflowtrap = Is_underflowtrap_enabled()) && result_exponent==0) goto underflow; @@ -378,7 +378,7 @@ sgl_fadd(leftptr, rightptr, dstptr, status) return(NOEXCEPTION); } Sgl_sethigh4bits(result,/*using*/sign_save); - switch(jumpsize) + switch(jumpsize) { case 1: { @@ -403,7 +403,7 @@ sgl_fadd(leftptr, rightptr, dstptr, status) break; } } - if(result_exponent > 0) + if(result_exponent > 0) { Sgl_set_exponent(result,/*using*/result_exponent); *dstptr = result; @@ -414,12 +414,12 @@ sgl_fadd(leftptr, rightptr, dstptr, status) if(Is_underflowtrap_enabled()) { Sgl_set_sign(result,sign_save); - Sgl_setwrapped_exponent(result,result_exponent,unfl); + Sgl_setwrapped_exponent(result,result_exponent,unfl); *dstptr = result; /* inexact = FALSE; */ return(UNDERFLOWEXCEPTION); } - /* + /* * Since we cannot get an inexact denormalized result, * we can now return. */ @@ -431,7 +431,7 @@ sgl_fadd(leftptr, rightptr, dstptr, status) } /* end if(hidden...)... */ /* Fall through and round */ } /* end if(save < 0)... */ - else + else { /* Add magnitudes */ Sgl_addition(left,right,/*to*/result); @@ -443,7 +443,7 @@ sgl_fadd(leftptr, rightptr, dstptr, status) result_exponent++; } /* end if hiddenoverflow... */ } /* end else ...add magnitudes... */ - + /* Round the result. If the extension is all zeros,then the result is * exact. Otherwise round in the correct direction. No underflow is * possible. If a postnormalization is necessary, then the mantissa is @@ -474,23 +474,23 @@ sgl_fadd(leftptr, rightptr, dstptr, status) Sgl_increment(result); } break; - + case ROUNDMINUS: if(Sgl_isone_sign(result)) { /* Round down negative results */ Sgl_increment(result); } - + case ROUNDZERO:; /* truncate is simple */ } /* end switch... */ if(Sgl_isone_hiddenoverflow(result)) result_exponent++; } if(result_exponent == SGL_INFINITY_EXPONENT) - { - /* Overflow */ - if(Is_overflowtrap_enabled()) + { + /* Overflow */ + if(Is_overflowtrap_enabled()) { Sgl_setwrapped_exponent(result,result_exponent,ovfl); *dstptr = result; @@ -501,7 +501,7 @@ sgl_fadd(leftptr, rightptr, dstptr, status) } return(OVERFLOWEXCEPTION); } - else + else { Set_overflowflag(); inexact = TRUE; |