diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-05-07 22:19:31 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-05-07 22:19:31 +0000 |
commit | 7657493d64c6d80359ef3a35f5de5a09b490b1ea (patch) | |
tree | e59f824bdf0e43a5fdbc0821e0882cf802ee4283 /sys/arch/hppa/spmath/fcnvfxt.c | |
parent | b02e4f767517ffad3d92f4cfb03fd681231fa3e4 (diff) |
bring over our mods; the cnv*c have a problem now, described in the osf version of the cnv_float.h, at the end
Diffstat (limited to 'sys/arch/hppa/spmath/fcnvfxt.c')
-rw-r--r-- | sys/arch/hppa/spmath/fcnvfxt.c | 206 |
1 files changed, 128 insertions, 78 deletions
diff --git a/sys/arch/hppa/spmath/fcnvfxt.c b/sys/arch/hppa/spmath/fcnvfxt.c index e20be8b112a..dad618df8c7 100644 --- a/sys/arch/hppa/spmath/fcnvfxt.c +++ b/sys/arch/hppa/spmath/fcnvfxt.c @@ -1,48 +1,23 @@ -/* $OpenBSD: fcnvfxt.c,v 1.5 2001/03/29 03:58:18 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. - * - */ +/* $OpenBSD: fcnvfxt.c,v 1.6 2002/05/07 22:19:30 mickey Exp $ */ /* - * pmk1.1 - */ -/* - * (c) Copyright 1986 HEWLETT-PACKARD COMPANY - * - * 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 - * suitability of this software for any purpose. - */ + (c) Copyright 1986 HEWLETT-PACKARD COMPANY + 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 + suitability of this software for any purpose. +*/ +/* @(#)fcnvfxt.c: Revision: 2.8.88.2 Date: 93/12/08 13:27:34 */ -#include "../spmath/float.h" -#include "../spmath/sgl_float.h" -#include "../spmath/dbl_float.h" -#include "../spmath/cnv_float.h" +#include "float.h" +#include "sgl_float.h" +#include "dbl_float.h" +#include "cnv_float.h" /* * Convert single floating-point to single fixed-point format @@ -51,10 +26,9 @@ /*ARGSUSED*/ int sgl_to_sgl_fcnvfxt(srcptr,dstptr,status) - -sgl_floating_point *srcptr; -int *dstptr; -unsigned int *status; + sgl_floating_point *srcptr; + int *dstptr; + unsigned int *status; { register unsigned int src, temp; register int src_exponent, result; @@ -69,12 +43,28 @@ unsigned int *status; /* check for MININT */ if ((src_exponent > SGL_FX_MAX_EXP + 1) || Sgl_isnotzero_mantissa(src) || Sgl_iszero_sign(src)) { - /* - * Since source is a number which cannot be - * represented in fixed-point format, return - * largest (or smallest) fixed-point number. - */ - Sgl_return_overflow(src,dstptr); + if( Sgl_isnan(src) ) + /* + * On NaN go unimplemented. + */ + return(UNIMPLEMENTEDEXCEPTION); + else { + if (Sgl_iszero_sign(src)) result = 0x7fffffff; + else result = 0x80000000; + + if (Is_overflowtrap_enabled()) { + if (Is_inexacttrap_enabled()) + return(OVERFLOWEXCEPTION|INEXACTEXCEPTION); + else Set_inexactflag(); + return(OVERFLOWEXCEPTION); + } + Set_overflowflag(); + *dstptr = result; + if (Is_inexacttrap_enabled() ) + return(INEXACTEXCEPTION); + else Set_inexactflag(); + return(NOEXCEPTION); + } } } /* @@ -112,10 +102,9 @@ unsigned int *status; /*ARGSUSED*/ int sgl_to_dbl_fcnvfxt(srcptr,dstptr,status) - -sgl_floating_point *srcptr; -dbl_integer *dstptr; -unsigned int *status; + sgl_floating_point *srcptr; + dbl_integer *dstptr; + unsigned int *status; { register int src_exponent, resultp1; register unsigned int src, temp, resultp2; @@ -130,12 +119,33 @@ unsigned int *status; /* check for MININT */ if ((src_exponent > DBL_FX_MAX_EXP + 1) || Sgl_isnotzero_mantissa(src) || Sgl_iszero_sign(src)) { - /* - * Since source is a number which cannot be - * represented in fixed-point format, return - * largest (or smallest) fixed-point number. - */ - Sgl_return_overflow_dbl(src,dstptr); + if( Sgl_isnan(src) ) + /* + * On NaN go unimplemented. + */ + return(UNIMPLEMENTEDEXCEPTION); + else { + if (Sgl_iszero_sign(src)) { + resultp1 = 0x7fffffff; + resultp2 = 0xffffffff; + } + else { + resultp1 = 0x80000000; + resultp2 = 0; + } + if (Is_overflowtrap_enabled()) { + if (Is_inexacttrap_enabled()) + return(OVERFLOWEXCEPTION|INEXACTEXCEPTION); + else Set_inexactflag(); + return(OVERFLOWEXCEPTION); + } + Set_overflowflag(); + Dint_copytoptr(resultp1,resultp2,dstptr); + if (Is_inexacttrap_enabled() ) + return(INEXACTEXCEPTION); + else Set_inexactflag(); + return(NOEXCEPTION); + } } Dint_set_minint(resultp1,resultp2); Dint_copytoptr(resultp1,resultp2,dstptr); @@ -178,10 +188,9 @@ unsigned int *status; /*ARGSUSED*/ int dbl_to_sgl_fcnvfxt(srcptr,dstptr,status) - -dbl_floating_point *srcptr; -int *dstptr; -unsigned int *status; + dbl_floating_point *srcptr; + int *dstptr; + unsigned int *status; { register unsigned int srcp1, srcp2, tempp1, tempp2; register int src_exponent, result; @@ -195,7 +204,28 @@ unsigned int *status; if (src_exponent > SGL_FX_MAX_EXP) { /* check for MININT */ if (Dbl_isoverflow_to_int(src_exponent,srcp1,srcp2)) { - Dbl_return_overflow(srcp1,srcp2,dstptr); + if( Dbl_isnan(srcp1,srcp2) ) + /* + * On NaN go unimplemented. + */ + return(UNIMPLEMENTEDEXCEPTION); + else { + if (Dbl_iszero_sign(srcp1)) result = 0x7fffffff; + else result = 0x80000000; + + if (Is_overflowtrap_enabled()) { + if (Is_inexacttrap_enabled()) + return(OVERFLOWEXCEPTION|INEXACTEXCEPTION); + else Set_inexactflag(); + return(OVERFLOWEXCEPTION); + } + Set_overflowflag(); + *dstptr = result; + if (Is_inexacttrap_enabled() ) + return(INEXACTEXCEPTION); + else Set_inexactflag(); + return(NOEXCEPTION); + } } } /* @@ -235,10 +265,9 @@ unsigned int *status; /*ARGSUSED*/ int dbl_to_dbl_fcnvfxt(srcptr,dstptr,status) - -dbl_floating_point *srcptr; -dbl_integer *dstptr; -unsigned int *status; + dbl_floating_point *srcptr; + dbl_integer *dstptr; + unsigned int *status; { register int src_exponent, resultp1; register unsigned int srcp1, srcp2, tempp1, tempp2, resultp2; @@ -253,12 +282,33 @@ unsigned int *status; /* check for MININT */ if ((src_exponent > DBL_FX_MAX_EXP + 1) || Dbl_isnotzero_mantissa(srcp1,srcp2) || Dbl_iszero_sign(srcp1)) { - /* - * Since source is a number which cannot be - * represented in fixed-point format, return - * largest (or smallest) fixed-point number. - */ - Dbl_return_overflow_dbl(srcp1,srcp2,dstptr); + if( Dbl_isnan(srcp1,srcp2) ) + /* + * On NaN go unimplemented. + */ + return(UNIMPLEMENTEDEXCEPTION); + else { + if (Dbl_iszero_sign(srcp1)) { + resultp1 = 0x7fffffff; + resultp2 = 0xffffffff; + } + else { + resultp1 = 0x80000000; + resultp2 = 0; + } + if (Is_overflowtrap_enabled()) { + if (Is_inexacttrap_enabled()) + return(OVERFLOWEXCEPTION|INEXACTEXCEPTION); + else Set_inexactflag(); + return(OVERFLOWEXCEPTION); + } + Set_overflowflag(); + Dint_copytoptr(resultp1,resultp2,dstptr); + if (Is_inexacttrap_enabled() ) + return(INEXACTEXCEPTION); + else Set_inexactflag(); + return(NOEXCEPTION); + } } } /* |