diff --git a/lib/libc/arch/arm26/softfloat/softfloat.h b/lib/libc/arch/arm26/softfloat/softfloat.h index 4392b5507b42..b373fcf0cfa5 100644 --- a/lib/libc/arch/arm26/softfloat/softfloat.h +++ b/lib/libc/arch/arm26/softfloat/softfloat.h @@ -135,6 +135,9 @@ Software IEC/IEEE single-precision conversion routines. */ int float32_to_int32( float32 ); int float32_to_int32_round_to_zero( float32 ); +#if defined(SOFTFLOAT_FOR_GCC) && !__GNUC_PREREQ__(2,95) +unsigned int float32_to_uint32_round_to_zero( float32 ); +#endif long long float32_to_int64( float32 ); long long float32_to_int64_round_to_zero( float32 ); float64 float32_to_float64( float32 ); @@ -174,6 +177,9 @@ Software IEC/IEEE double-precision conversion routines. */ int float64_to_int32( float64 ); int float64_to_int32_round_to_zero( float64 ); +#if defined(SOFTFLOAT_FOR_GCC) && !__GNUC_PREREQ__(2,95) +unsigned int float64_to_uint32_round_to_zero( float64 ); +#endif long long float64_to_int64( float64 ); long long float64_to_int64_round_to_zero( float64 ); float32 float64_to_float32( float64 ); diff --git a/lib/libc/arch/sh3/softfloat/softfloat.h b/lib/libc/arch/sh3/softfloat/softfloat.h index a338428a29da..dd209280bb7f 100644 --- a/lib/libc/arch/sh3/softfloat/softfloat.h +++ b/lib/libc/arch/sh3/softfloat/softfloat.h @@ -1,4 +1,4 @@ -/* $NetBSD: softfloat.h,v 1.1 2000/06/06 17:28:43 tsubai Exp $ */ +/* $NetBSD: softfloat.h,v 1.2 2000/07/15 13:26:51 bjh21 Exp $ */ /* =============================================================================== @@ -138,6 +138,9 @@ Software IEC/IEEE single-precision conversion routines. */ int float32_to_int32( float32 ); int float32_to_int32_round_to_zero( float32 ); +#if defined(SOFTFLOAT_FOR_GCC) && !__GNUC_PREREQ__(2,95) +unsigned int float32_to_uint32_round_to_zero( float32 ); +#endif long long float32_to_int64( float32 ); long long float32_to_int64_round_to_zero( float32 ); float64 float32_to_float64( float32 ); @@ -177,6 +180,9 @@ Software IEC/IEEE double-precision conversion routines. */ int float64_to_int32( float64 ); int float64_to_int32_round_to_zero( float64 ); +#if defined(SOFTFLOAT_FOR_GCC) && !__GNUC_PREREQ__(2,95) +unsigned int float64_to_uint32_round_to_zero( float64 ); +#endif long long float64_to_int64( float64 ); long long float64_to_int64_round_to_zero( float64 ); float32 float64_to_float32( float64 ); diff --git a/lib/libc/softfloat/softfloat-for-gcc.h b/lib/libc/softfloat/softfloat-for-gcc.h index b47e31e54d7d..880364e142f8 100644 --- a/lib/libc/softfloat/softfloat-for-gcc.h +++ b/lib/libc/softfloat/softfloat-for-gcc.h @@ -1,4 +1,4 @@ -/* $NetBSD: softfloat-for-gcc.h,v 1.1 2000/06/06 08:15:07 bjh21 Exp $ */ +/* $NetBSD: softfloat-for-gcc.h,v 1.2 2000/07/15 13:26:51 bjh21 Exp $ */ /* * Move private identifiers with external linkage into implementation @@ -39,3 +39,7 @@ /* #define float64_to_uint32_round_to_zero __fixunsdfsi */ #define float32_to_float64 __extendsfdf2 #define float64_to_float32 __truncdfsf2 +#if !__GNUC_PREREQ__(2,95) +#define float32_to_uint32_round_to_zero __fixunssfsi +#define float64_to_uint32_round_to_zero __fixunsdfsi +#endif diff --git a/lib/libc/softfloat/softfloat.c b/lib/libc/softfloat/softfloat.c index 4cc8beeac353..1f2c05f1eaa9 100644 --- a/lib/libc/softfloat/softfloat.c +++ b/lib/libc/softfloat/softfloat.c @@ -1,4 +1,4 @@ -/* $NetBSD: softfloat.c,v 1.1 2000/06/06 08:15:10 bjh21 Exp $ */ +/* $NetBSD: softfloat.c,v 1.2 2000/07/15 13:26:51 bjh21 Exp $ */ /* * This version hacked for use with gcc -msoft-float by bjh21. @@ -46,7 +46,7 @@ this code that are retained. #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: softfloat.c,v 1.1 2000/06/06 08:15:10 bjh21 Exp $"); +__RCSID("$NetBSD: softfloat.c,v 1.2 2000/07/15 13:26:51 bjh21 Exp $"); #endif /* LIBC_SCCS and not lint */ #ifdef SOFTFLOAT_FOR_GCC @@ -5391,3 +5391,108 @@ flag float128_lt_quiet( float128 a, float128 b ) #endif +/* Since about GCC 2.95, these functions have been in libgcc2.c */ + +#if defined(SOFTFLOAT_FOR_GCC) && !__GNUC_PREREQ__(2,95) + +/* + * These two routines are not part of the original softfloat distribution. + * + * They are based on the corresponding conversions to integer but return + * unsigned numbers instead since these functions are required by GCC. + * + * Added by Mark Brinicombe 27/09/97 + * + * float64 version overhauled for SoftFloat 2a [bjh21 2000-07-15] + */ + +/* +------------------------------------------------------------------------------- +Returns the result of converting the double-precision floating-point value +`a' to the 32-bit unsigned integer format. The conversion is +performed according to the IEC/IEEE Standard for Binary Floating-point +Arithmetic, except that the conversion is always rounded toward zero. If +`a' is a NaN, the largest positive integer is returned. If the conversion +overflows, the largest integer positive is returned. +------------------------------------------------------------------------------- +*/ +uint32 float64_to_uint32_round_to_zero( float64 a ) +{ + flag aSign; + int16 aExp, shiftCount; + bits64 aSig, savedASig; + uint32 z; + + aSig = extractFloat64Frac( a ); + aExp = extractFloat64Exp( a ); + aSign = extractFloat64Sign( a ); + + if (aSign) { + float_raise( float_flag_invalid ); + return(0); + } + + if ( 0x41E < aExp ) { + float_raise( float_flag_invalid ); + return 0xffffffff; + } + else if ( aExp < 0x3FF ) { + if ( aExp || aSig ) float_exception_flags |= float_flag_inexact; + return 0; + } + aSig |= LIT64( 0x0010000000000000 ); + shiftCount = 0x433 - aExp; + savedASig = aSig; + aSig >>= shiftCount; + z = aSig; + if ( ( aSig<>( - shiftCount ); + if ( aSig<<( shiftCount & 31 ) ) { + float_exception_flags |= float_flag_inexact; + } + return z; + +} + +#endif