-/* $OpenBSD: fcnvfx.c,v 1.7 2003/04/10 17:27:58 mickey Exp $ */
+/* $OpenBSD: fcnvfx.c,v 1.8 2010/07/30 18:05:23 kettenis Exp $ */
/*
(c) Copyright 1986 HEWLETT-PACKARD COMPANY
To anyone who acknowledges that this file is provided "AS IS"
/* check for MININT */
if ((src_exponent > SGL_FX_MAX_EXP + 1) ||
Sgl_isnotzero_mantissa(src) || Sgl_iszero_sign(src)) {
- if( Sgl_isnan(src) )
- /*
- * On NaN go unimplemented.
- */
- return(UNIMPLEMENTEDEXCEPTION);
- else {
- if (Sgl_iszero_sign(src)) result = 0x7fffffff;
- else result = 0x80000000;
+ 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);
+ if (Is_invalidtrap_enabled()) {
+ return(INVALIDEXCEPTION);
}
+ Set_invalidflag();
+ *dstptr = result;
+ return(NOEXCEPTION);
}
}
/*
/* check for MININT */
if ((src_exponent > DBL_FX_MAX_EXP + 1) ||
Sgl_isnotzero_mantissa(src) || Sgl_iszero_sign(src)) {
- if( Sgl_isnan(src) )
- /*
- * On NaN go unimplemented.
- */
- return(UNIMPLEMENTEDEXCEPTION);
- else {
- if (Sgl_iszero_sign(src)) {
+ 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);
+ resultp2 = 0xffffffff;
+ }
+ else {
+ resultp1 = 0x80000000;
+ resultp2 = 0;
+ }
+
+ if (Is_invalidtrap_enabled()) {
+ return(INVALIDEXCEPTION);
}
+ Set_invalidflag();
+ Dint_copytoptr(resultp1,resultp2,dstptr);
+ return(NOEXCEPTION);
}
Dint_set_minint(resultp1,resultp2);
Dint_copytoptr(resultp1,resultp2,dstptr);
if (src_exponent > SGL_FX_MAX_EXP) {
/* check for MININT */
if (Dbl_isoverflow_to_int(src_exponent,srcp1,srcp2)) {
- if( Dbl_isnan(srcp1,srcp2) )
- /*
- * On NaN go unimplemented.
- */
- return(UNIMPLEMENTEDEXCEPTION);
- else {
- if (Dbl_iszero_sign(srcp1)) result = 0x7fffffff;
- else result = 0x80000000;
+ 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);
+ if (Is_invalidtrap_enabled()) {
+ return(INVALIDEXCEPTION);
}
+ Set_invalidflag();
+ *dstptr = result;
+ return(NOEXCEPTION);
}
}
/*
/* check for MININT */
if ((src_exponent > DBL_FX_MAX_EXP + 1) ||
Dbl_isnotzero_mantissa(srcp1,srcp2) || Dbl_iszero_sign(srcp1)) {
- if( Dbl_isnan(srcp1,srcp2) )
- /*
- * On NaN go unimplemented.
- */
- return(UNIMPLEMENTEDEXCEPTION);
+ if (Dbl_iszero_sign(srcp1)) {
+ resultp1 = 0x7fffffff;
+ resultp2 = 0xffffffff;
+ }
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);
+ resultp1 = 0x80000000;
+ resultp2 = 0;
+ }
+
+ if (Is_invalidtrap_enabled()) {
+ return(INVALIDEXCEPTION);
}
+ Set_invalidflag();
+ Dint_copytoptr(resultp1,resultp2,dstptr);
+ return(NOEXCEPTION);
}
}
-/* $OpenBSD: fcnvfxt.c,v 1.7 2003/04/10 17:27:58 mickey Exp $ */
+/* $OpenBSD: fcnvfxt.c,v 1.8 2010/07/30 18:05:23 kettenis Exp $ */
/*
(c) Copyright 1986 HEWLETT-PACKARD COMPANY
To anyone who acknowledges that this file is provided "AS IS"
/* check for MININT */
if ((src_exponent > SGL_FX_MAX_EXP + 1) ||
Sgl_isnotzero_mantissa(src) || Sgl_iszero_sign(src)) {
- if( Sgl_isnan(src) )
- /*
- * On NaN go unimplemented.
- */
- return(UNIMPLEMENTEDEXCEPTION);
- else {
- if (Sgl_iszero_sign(src)) result = 0x7fffffff;
- else result = 0x80000000;
+ 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);
+ if (Is_invalidtrap_enabled()) {
+ return(INVALIDEXCEPTION);
}
+ Set_invalidflag();
+ *dstptr = result;
+ return(NOEXCEPTION);
}
}
/*
/* check for MININT */
if ((src_exponent > DBL_FX_MAX_EXP + 1) ||
Sgl_isnotzero_mantissa(src) || Sgl_iszero_sign(src)) {
- if( Sgl_isnan(src) )
- /*
- * On NaN go unimplemented.
- */
- return(UNIMPLEMENTEDEXCEPTION);
- else {
- if (Sgl_iszero_sign(src)) {
+ 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);
}
+ else {
+ resultp1 = 0x80000000;
+ resultp2 = 0;
+ }
+
+ if (Is_invalidtrap_enabled()) {
+ return(INVALIDEXCEPTION);
+ }
+ Set_invalidflag();
+ Dint_copytoptr(resultp1,resultp2,dstptr);
+ return(NOEXCEPTION);
}
Dint_set_minint(resultp1,resultp2);
Dint_copytoptr(resultp1,resultp2,dstptr);
if (src_exponent > SGL_FX_MAX_EXP) {
/* check for MININT */
if (Dbl_isoverflow_to_int(src_exponent,srcp1,srcp2)) {
- if( Dbl_isnan(srcp1,srcp2) )
- /*
- * On NaN go unimplemented.
- */
- return(UNIMPLEMENTEDEXCEPTION);
- else {
- if (Dbl_iszero_sign(srcp1)) result = 0x7fffffff;
- else result = 0x80000000;
+ 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);
+ if (Is_invalidtrap_enabled()) {
+ return(INVALIDEXCEPTION);
}
+ Set_invalidflag();
+ *dstptr = result;
+ return(NOEXCEPTION);
}
}
/*
/* check for MININT */
if ((src_exponent > DBL_FX_MAX_EXP + 1) ||
Dbl_isnotzero_mantissa(srcp1,srcp2) || Dbl_iszero_sign(srcp1)) {
- if( Dbl_isnan(srcp1,srcp2) )
- /*
- * On NaN go unimplemented.
- */
- return(UNIMPLEMENTEDEXCEPTION);
- else {
- if (Dbl_iszero_sign(srcp1)) {
+ 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);
}
+ else {
+ resultp1 = 0x80000000;
+ resultp2 = 0;
+ }
+
+ if (Is_invalidtrap_enabled()) {
+ return(INVALIDEXCEPTION);
+ }
+ Set_invalidflag();
+ Dint_copytoptr(resultp1,resultp2,dstptr);
+ return(NOEXCEPTION);
}
}
/*