From c36abe0dcf91e964fbb194f3f8589dc8f05cd146 Mon Sep 17 00:00:00 2001 From: David Schultz Date: Fri, 20 Jan 2012 06:16:14 +0000 Subject: [PATCH] Merge in the latest SoftFloat changes from NetBSD. (NetBSD isn't the original vendor, but we're using their heavily modified version.) This brings in functions for long double emulation (both extended and quad formats), which may be useful for testing, and also for replacing libc/sparc64/fpu/. --- lib/libc/softfloat/Makefile.inc | 12 +- lib/libc/softfloat/bits32/softfloat-macros | 4 +- lib/libc/softfloat/bits64/softfloat-macros | 6 +- lib/libc/softfloat/bits64/softfloat.c | 99 +++++++++++++++- lib/libc/softfloat/eqtf2.c | 24 ++++ lib/libc/softfloat/getf2.c | 26 +++++ lib/libc/softfloat/gexf2.c | 25 ++++ lib/libc/softfloat/gttf2.c | 26 +++++ lib/libc/softfloat/gtxf2.c | 25 ++++ lib/libc/softfloat/letf2.c | 26 +++++ lib/libc/softfloat/lttf2.c | 26 +++++ lib/libc/softfloat/negtf2.c | 27 +++++ lib/libc/softfloat/negxf2.c | 25 ++++ lib/libc/softfloat/netf2.c | 26 +++++ lib/libc/softfloat/nexf2.c | 25 ++++ lib/libc/softfloat/softfloat-for-gcc.h | 128 ++++++++++++++++++++- lib/libc/softfloat/softfloat-source.txt | 4 +- lib/libc/softfloat/softfloat-specialize | 33 +++++- lib/libc/softfloat/softfloat.txt | 4 +- 19 files changed, 555 insertions(+), 16 deletions(-) create mode 100644 lib/libc/softfloat/eqtf2.c create mode 100644 lib/libc/softfloat/getf2.c create mode 100644 lib/libc/softfloat/gexf2.c create mode 100644 lib/libc/softfloat/gttf2.c create mode 100644 lib/libc/softfloat/gtxf2.c create mode 100644 lib/libc/softfloat/letf2.c create mode 100644 lib/libc/softfloat/lttf2.c create mode 100644 lib/libc/softfloat/negtf2.c create mode 100644 lib/libc/softfloat/negxf2.c create mode 100644 lib/libc/softfloat/netf2.c create mode 100644 lib/libc/softfloat/nexf2.c diff --git a/lib/libc/softfloat/Makefile.inc b/lib/libc/softfloat/Makefile.inc index ac7fbf781278..221340372c5e 100644 --- a/lib/libc/softfloat/Makefile.inc +++ b/lib/libc/softfloat/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.3 2003/05/06 08:58:20 rearnsha Exp $ +# $NetBSD: Makefile.inc,v 1.10 2011/07/04 02:53:15 mrg Exp $ # $FreeBSD$ SOFTFLOAT_BITS?=64 @@ -17,4 +17,14 @@ SRCS+= eqsf2.c nesf2.c gtsf2.c gesf2.c ltsf2.c lesf2.c negsf2.c \ eqdf2.c nedf2.c gtdf2.c gedf2.c ltdf2.c ledf2.c negdf2.c \ unordsf2.c unorddf2.c +.if defined(SOFTFLOAT_128) +CFLAGS+= -DFLOAT128 +SRCS+= eqtf2.c netf2.c gttf2.c getf2.c lttf2.c letf2.c negtf2.c +.endif + +.if defined(SOFTFLOAT_X80) +CFLAGS+= -DFLOATX80 +SRCS+= nexf2.c gtxf2.c gexf2.c negxf2.c +.endif + SYM_MAPS+= ${.CURDIR}/softfloat/Symbol.map diff --git a/lib/libc/softfloat/bits32/softfloat-macros b/lib/libc/softfloat/bits32/softfloat-macros index 4fd4f2f9fc66..db4e038eb0b7 100644 --- a/lib/libc/softfloat/bits32/softfloat-macros +++ b/lib/libc/softfloat/bits32/softfloat-macros @@ -312,7 +312,7 @@ INLINE void carry0 = ( z1 < a1 ); z0 = a0 + b0; z1 += carry1; - z0 += ( z1 < carry1 ); + z0 += ( z1 < (bits32)carry1 ); z0 += carry0; *z2Ptr = z2; *z1Ptr = z1; @@ -369,7 +369,7 @@ INLINE void z1 = a1 - b1; borrow0 = ( a1 < b1 ); z0 = a0 - b0; - z0 -= ( z1 < borrow1 ); + z0 -= ( z1 < (bits32)borrow1 ); z1 -= borrow1; z0 -= borrow0; *z2Ptr = z2; diff --git a/lib/libc/softfloat/bits64/softfloat-macros b/lib/libc/softfloat/bits64/softfloat-macros index 9b478e884eba..f4647def2bd4 100644 --- a/lib/libc/softfloat/bits64/softfloat-macros +++ b/lib/libc/softfloat/bits64/softfloat-macros @@ -1,4 +1,4 @@ -/* $NetBSD: softfloat-macros,v 1.1 2002/05/21 23:51:08 bjh21 Exp $ */ +/* $NetBSD: softfloat-macros,v 1.2 2009/02/16 10:23:35 tron Exp $ */ /* $FreeBSD$ */ /* @@ -387,7 +387,7 @@ INLINE void carry0 = ( z1 < a1 ); z0 = a0 + b0; z1 += carry1; - z0 += ( z1 < carry1 ); + z0 += ( z1 < (bits64)carry1 ); z0 += carry0; *z2Ptr = z2; *z1Ptr = z1; @@ -444,7 +444,7 @@ INLINE void z1 = a1 - b1; borrow0 = ( a1 < b1 ); z0 = a0 - b0; - z0 -= ( z1 < borrow1 ); + z0 -= ( z1 < (bits64)borrow1 ); z1 -= borrow1; z0 -= borrow0; *z2Ptr = z2; diff --git a/lib/libc/softfloat/bits64/softfloat.c b/lib/libc/softfloat/bits64/softfloat.c index 3d614f241320..1065876b8baa 100644 --- a/lib/libc/softfloat/bits64/softfloat.c +++ b/lib/libc/softfloat/bits64/softfloat.c @@ -1,4 +1,4 @@ -/* $NetBSD: softfloat.c,v 1.2 2003/07/26 19:24:52 salo Exp $ */ +/* $NetBSD: softfloat.c,v 1.8 2011/07/10 04:52:23 matt Exp $ */ /* * This version hacked for use with gcc -msoft-float by bjh21. @@ -1126,6 +1126,15 @@ float32 int32_to_float32( int32 a ) } +float32 uint32_to_float32( uint32 a ) +{ + if ( a == 0 ) return 0; + if ( a & (bits32) 0x80000000 ) + return normalizeRoundAndPackFloat32( 0, 0x9D, a >> 1 ); + return normalizeRoundAndPackFloat32( 0, 0x9C, a ); +} + + /* ------------------------------------------------------------------------------- Returns the result of converting the 32-bit two's complement integer `a' @@ -1149,6 +1158,17 @@ float64 int32_to_float64( int32 a ) } +float64 uint32_to_float64( uint32 a ) +{ + int8 shiftCount; + bits64 zSig = a; + + if ( a == 0 ) return 0; + shiftCount = countLeadingZeros32( a ) + 21; + return packFloat64( 0, 0x432 - shiftCount, zSig<>( ( - shiftCount ) & 63 ) ); + if ( (bits64) ( aSig1<>( - shiftCount ); + if (aSig1 || ( shiftCount && (bits64) ( aSig0<<( shiftCount & 63 ) ) ) ) { + float_exception_flags |= float_flag_inexact; + } + } + if ( aSign ) z = - z; + return z; + +} +#endif /* (SOFTFLOATSPARC64_FOR_GCC || SOFTFLOAT_FOR_GCC) && SOFTFLOAT_NEED_FIXUNS */ + /* ------------------------------------------------------------------------------- Returns the result of converting the quadruple-precision floating-point @@ -5110,7 +5205,7 @@ float128 float128_rem( float128 a, float128 b ) sub128( aSig0, aSig1, bSig0, bSig1, &aSig0, &aSig1 ); } while ( 0 <= (sbits64) aSig0 ); add128( - aSig0, aSig1, alternateASig0, alternateASig1, &sigMean0, &sigMean1 ); + aSig0, aSig1, alternateASig0, alternateASig1, (bits64 *)&sigMean0, &sigMean1 ); if ( ( sigMean0 < 0 ) || ( ( ( sigMean0 | sigMean1 ) == 0 ) && ( q & 1 ) ) ) { aSig0 = alternateASig0; diff --git a/lib/libc/softfloat/eqtf2.c b/lib/libc/softfloat/eqtf2.c new file mode 100644 index 000000000000..1839404e1b1a --- /dev/null +++ b/lib/libc/softfloat/eqtf2.c @@ -0,0 +1,24 @@ +/* $NetBSD: eqtf2.c,v 1.1 2011/01/17 10:08:35 matt Exp $ */ + +/* + * Written by Matt Thomas, 2011. This file is in the Public Domain. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "softfloat-for-gcc.h" +#include "milieu.h" +#include "softfloat.h" + +#ifdef FLOAT128 +flag __eqtf2(float128, float128); + +flag +__eqtf2(float128 a, float128 b) +{ + + /* libgcc1.c says !(a == b) */ + return !float128_eq(a, b); +} +#endif /* FLOAT128 */ diff --git a/lib/libc/softfloat/getf2.c b/lib/libc/softfloat/getf2.c new file mode 100644 index 000000000000..8639c4d3916a --- /dev/null +++ b/lib/libc/softfloat/getf2.c @@ -0,0 +1,26 @@ +/* $NetBSD: getf2.c,v 1.1 2011/01/17 10:08:35 matt Exp $ */ + +/* + * Written by Matt Thomas, 2011. This file is in the Public Domain. + */ + +#include "softfloat-for-gcc.h" +#include "milieu.h" +#include "softfloat.h" + +#include +__FBSDID("$FreeBSD$"); + +#ifdef FLOAT128 + +flag __getf2(float128, float128); + +flag +__getf2(float128 a, float128 b) +{ + + /* libgcc1.c says (a >= b) - 1 */ + return float128_le(b, a) - 1; +} + +#endif /* FLOAT128 */ diff --git a/lib/libc/softfloat/gexf2.c b/lib/libc/softfloat/gexf2.c new file mode 100644 index 000000000000..70cf1c32d7ec --- /dev/null +++ b/lib/libc/softfloat/gexf2.c @@ -0,0 +1,25 @@ +/* $NetBSD: gexf2.c,v 1.2 2004/09/27 10:16:24 he Exp $ */ + +/* + * Written by Ben Harris, 2000. This file is in the Public Domain. + */ + +#include "softfloat-for-gcc.h" +#include "milieu.h" +#include "softfloat.h" + +#include +__FBSDID("$FreeBSD$"); + +#ifdef FLOATX80 + +flag __gexf2(floatx80, floatx80); + +flag +__gexf2(floatx80 a, floatx80 b) +{ + + /* libgcc1.c says (a >= b) - 1 */ + return floatx80_le(b, a) - 1; +} +#endif /* FLOATX80 */ diff --git a/lib/libc/softfloat/gttf2.c b/lib/libc/softfloat/gttf2.c new file mode 100644 index 000000000000..519ea845f00c --- /dev/null +++ b/lib/libc/softfloat/gttf2.c @@ -0,0 +1,26 @@ +/* $NetBSD: gttf2.c,v 1.1 2011/01/17 10:08:35 matt Exp $ */ + +/* + * Written by Matt Thomas, 2011. This file is in the Public Domain. + */ + +#include "softfloat-for-gcc.h" +#include "milieu.h" +#include "softfloat.h" + +#include +__FBSDID("$FreeBSD$"); + +#ifdef FLOAT128 + +flag __gttf2(float128, float128); + +flag +__gttf2(float128 a, float128 b) +{ + + /* libgcc1.c says a > b */ + return float128_lt(b, a); +} + +#endif /* FLOAT128 */ diff --git a/lib/libc/softfloat/gtxf2.c b/lib/libc/softfloat/gtxf2.c new file mode 100644 index 000000000000..fe8be52e7e2d --- /dev/null +++ b/lib/libc/softfloat/gtxf2.c @@ -0,0 +1,25 @@ +/* $NetBSD: gtxf2.c,v 1.2 2004/09/27 10:16:24 he Exp $ */ + +/* + * Written by Ben Harris, 2000. This file is in the Public Domain. + */ + +#include "softfloat-for-gcc.h" +#include "milieu.h" +#include "softfloat.h" + +#include +__FBSDID("$FreeBSD$"); + +#ifdef FLOATX80 + +flag __gtxf2(floatx80, floatx80); + +flag +__gtxf2(floatx80 a, floatx80 b) +{ + + /* libgcc1.c says a > b */ + return floatx80_lt(b, a); +} +#endif /* FLOATX80 */ diff --git a/lib/libc/softfloat/letf2.c b/lib/libc/softfloat/letf2.c new file mode 100644 index 000000000000..e9a18f8d5e5d --- /dev/null +++ b/lib/libc/softfloat/letf2.c @@ -0,0 +1,26 @@ +/* $NetBSD: letf2.c,v 1.1 2011/01/17 10:08:35 matt Exp $ */ + +/* + * Written by Matt Thomas, 2011. This file is in the Public Domain. + */ + +#include "softfloat-for-gcc.h" +#include "milieu.h" +#include "softfloat.h" + +#include +__FBSDID("$FreeBSD$"); + +#ifdef FLOAT128 + +flag __letf2(float128, float128); + +flag +__letf2(float128 a, float128 b) +{ + + /* libgcc1.c says 1 - (a <= b) */ + return 1 - float128_le(a, b); +} + +#endif /* FLOAT128 */ diff --git a/lib/libc/softfloat/lttf2.c b/lib/libc/softfloat/lttf2.c new file mode 100644 index 000000000000..13c01b19528d --- /dev/null +++ b/lib/libc/softfloat/lttf2.c @@ -0,0 +1,26 @@ +/* $NetBSD: lttf2.c,v 1.1 2011/01/17 10:08:35 matt Exp $ */ + +/* + * Written by Matt Thomas, 2011. This file is in the Public Domain. + */ + +#include "softfloat-for-gcc.h" +#include "milieu.h" +#include "softfloat.h" + +#include +__FBSDID("$FreeBSD$"); + +#ifdef FLOAT128 + +flag __lttf2(float128, float128); + +flag +__lttf2(float128 a, float128 b) +{ + + /* libgcc1.c says -(a < b) */ + return -float128_lt(a, b); +} + +#endif /* FLOAT128 */ diff --git a/lib/libc/softfloat/negtf2.c b/lib/libc/softfloat/negtf2.c new file mode 100644 index 000000000000..5be582dd8937 --- /dev/null +++ b/lib/libc/softfloat/negtf2.c @@ -0,0 +1,27 @@ +/* $NetBSD: negtf2.c,v 1.1 2011/01/17 10:08:35 matt Exp $ */ + +/* + * Written by Matt Thomas, 2011. This file is in the Public Domain. + */ + +#include "softfloat-for-gcc.h" +#include "milieu.h" +#include "softfloat.h" + +#include +__FBSDID("$FreeBSD$"); + +#ifdef FLOAT128 + +float128 __negtf2(float128); + +float128 +__negtf2(float128 a) +{ + + /* libgcc1.c says -a */ + a.high ^= FLOAT64_MANGLE(0x8000000000000000ULL); + return a; +} + +#endif /* FLOAT128 */ diff --git a/lib/libc/softfloat/negxf2.c b/lib/libc/softfloat/negxf2.c new file mode 100644 index 000000000000..0e2d08b25a67 --- /dev/null +++ b/lib/libc/softfloat/negxf2.c @@ -0,0 +1,25 @@ +/* $NetBSD: negxf2.c,v 1.2 2004/09/27 10:16:24 he Exp $ */ + +/* + * Written by Ben Harris, 2000. This file is in the Public Domain. + */ + +#include "softfloat-for-gcc.h" +#include "milieu.h" +#include "softfloat.h" + +#include +__FBSDID("$FreeBSD$"); + +#ifdef FLOATX80 + +floatx80 __negxf2(floatx80); + +floatx80 +__negxf2(floatx80 a) +{ + + /* libgcc1.c says -a */ + return __mulxf3(a,__floatsixf(-1)); +} +#endif /* FLOATX80 */ diff --git a/lib/libc/softfloat/netf2.c b/lib/libc/softfloat/netf2.c new file mode 100644 index 000000000000..26e17cd1f52d --- /dev/null +++ b/lib/libc/softfloat/netf2.c @@ -0,0 +1,26 @@ +/* $NetBSD: netf2.c,v 1.1 2011/01/17 10:08:35 matt Exp $ */ + +/* + * Written by Matt Thomas, 2011. This file is in the Public Domain. + */ + +#include "softfloat-for-gcc.h" +#include "milieu.h" +#include "softfloat.h" + +#include +__FBSDID("$FreeBSD$"); + +#ifdef FLOAT128 + +flag __netf2(float128, float128); + +flag +__netf2(float128 a, float128 b) +{ + + /* libgcc1.c says a != b */ + return !float128_eq(a, b); +} + +#endif /* FLOAT128 */ diff --git a/lib/libc/softfloat/nexf2.c b/lib/libc/softfloat/nexf2.c new file mode 100644 index 000000000000..153a70392d16 --- /dev/null +++ b/lib/libc/softfloat/nexf2.c @@ -0,0 +1,25 @@ +/* $NetBSD: nexf2.c,v 1.2 2004/09/27 10:16:24 he Exp $ */ + +/* + * Written by Ben Harris, 2000. This file is in the Public Domain. + */ + +#include "softfloat-for-gcc.h" +#include "milieu.h" +#include "softfloat.h" + +#include +__FBSDID("$FreeBSD$"); + +#ifdef FLOATX80 + +flag __nexf2(floatx80, floatx80); + +flag +__nexf2(floatx80 a, floatx80 b) +{ + + /* libgcc1.c says a != b */ + return !floatx80_eq(a, b); +} +#endif /* FLOATX80 */ diff --git a/lib/libc/softfloat/softfloat-for-gcc.h b/lib/libc/softfloat/softfloat-for-gcc.h index 602554c3bf79..cf17e56768a9 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.6 2003/07/26 19:24:51 salo Exp $ */ +/* $NetBSD: softfloat-for-gcc.h,v 1.8 2009/12/14 01:07:42 matt Exp $ */ /* $FreeBSD$ */ /* @@ -16,6 +16,9 @@ #define float64_eq __softfloat_float64_eq #define float64_le __softfloat_float64_le #define float64_lt __softfloat_float64_lt +#define float128_eq __softfloat_float128_eq +#define float128_le __softfloat_float128_le +#define float128_lt __softfloat_float128_lt /* * Macros to define functions with the GCC expected names @@ -23,21 +26,144 @@ #define float32_add __addsf3 #define float64_add __adddf3 +#define floatx80_add __addxf3 +#define float128_add __addtf3 + #define float32_sub __subsf3 #define float64_sub __subdf3 +#define floatx80_sub __subxf3 +#define float128_sub __subtf3 + #define float32_mul __mulsf3 #define float64_mul __muldf3 +#define floatx80_mul __mulxf3 +#define float128_mul __multf3 + #define float32_div __divsf3 #define float64_div __divdf3 +#define floatx80_div __divxf3 +#define float128_div __divtf3 + +#if 0 +#define float32_neg __negsf2 +#define float64_neg __negdf2 +#define floatx80_neg __negxf2 +#define float128_neg __negtf2 +#endif + #define int32_to_float32 __floatsisf #define int32_to_float64 __floatsidf +#define int32_to_floatx80 __floatsixf +#define int32_to_float128 __floatsitf + #define int64_to_float32 __floatdisf #define int64_to_float64 __floatdidf +#define int64_to_floatx80 __floatdixf +#define int64_to_float128 __floatditf + +#define int128_to_float32 __floattisf +#define int128_to_float64 __floattidf +#define int128_to_floatx80 __floattixf +#define int128_to_float128 __floattitf + +#define uint32_to_float32 __floatunsisf +#define uint32_to_float64 __floatunsidf +#define uint32_to_floatx80 __floatunsixf +#define uint32_to_float128 __floatunsitf + +#define uint64_to_float32 __floatundisf +#define uint64_to_float64 __floatundidf +#define uint64_to_floatx80 __floatundixf +#define uint64_to_float128 __floatunditf + +#define uint128_to_float32 __floatuntisf +#define uint128_to_float64 __floatuntidf +#define uint128_to_floatx80 __floatuntixf +#define uint128_to_float128 __floatuntitf + #define float32_to_int32_round_to_zero __fixsfsi #define float64_to_int32_round_to_zero __fixdfsi +#define floatx80_to_int32_round_to_zero __fixxfsi +#define float128_to_int32_round_to_zero __fixtfsi + #define float32_to_int64_round_to_zero __fixsfdi #define float64_to_int64_round_to_zero __fixdfdi +#define floatx80_to_int64_round_to_zero __fixxfdi +#define float128_to_int64_round_to_zero __fixtfdi + +#define float32_to_int128_round_to_zero __fixsfti +#define float64_to_int128_round_to_zero __fixdfti +#define floatx80_to_int128_round_to_zero __fixxfti +#define float128_to_int128_round_to_zero __fixtfti + #define float32_to_uint32_round_to_zero __fixunssfsi #define float64_to_uint32_round_to_zero __fixunsdfsi +#define floatx80_to_uint32_round_to_zero __fixunsxfsi +#define float128_to_uint32_round_to_zero __fixunstfsi + +#define float32_to_uint64_round_to_zero __fixunssfdi +#define float64_to_uint64_round_to_zero __fixunsdfdi +#define floatx80_to_uint64_round_to_zero __fixunsxfdi +#define float128_to_uint64_round_to_zero __fixunstfdi + +#define float32_to_uint128_round_to_zero __fixunssfti +#define float64_to_uint128_round_to_zero __fixunsdfti +#define floatx80_to_uint128_round_to_zero __fixunsxfti +#define float128_to_uint128_round_to_zero __fixunstfti + #define float32_to_float64 __extendsfdf2 +#define float32_to_floatx80 __extendsfxf2 +#define float32_to_float128 __extendsftf2 +#define float64_to_floatx80 __extenddfxf2 +#define float64_to_float128 __extenddftf2 + +#define float128_to_float64 __trunctfdf2 +#define floatx80_to_float64 __truncxfdf2 +#define float128_to_float32 __trunctfsf2 +#define floatx80_to_float32 __truncxfsf2 #define float64_to_float32 __truncdfsf2 + +#if 0 +#define float32_cmp __cmpsf2 +#define float32_unord __unordsf2 +#define float32_eq __eqsf2 +#define float32_ne __nesf2 +#define float32_ge __gesf2 +#define float32_lt __ltsf2 +#define float32_le __lesf2 +#define float32_gt __gtsf2 +#endif + +#if 0 +#define float64_cmp __cmpdf2 +#define float64_unord __unorddf2 +#define float64_eq __eqdf2 +#define float64_ne __nedf2 +#define float64_ge __gedf2 +#define float64_lt __ltdf2 +#define float64_le __ledf2 +#define float64_gt __gtdf2 +#endif + +/* XXX not in libgcc */ +#if 1 +#define floatx80_cmp __cmpxf2 +#define floatx80_unord __unordxf2 +#define floatx80_eq __eqxf2 +#define floatx80_ne __nexf2 +#define floatx80_ge __gexf2 +#define floatx80_lt __ltxf2 +#define floatx80_le __lexf2 +#define floatx80_gt __gtxf2 +#endif + +#if 0 +#define float128_cmp __cmptf2 +#define float128_unord __unordtf2 +#define float128_eq __eqtf2 +#define float128_ne __netf2 +#define float128_ge __getf2 +#define float128_lt __lttf2 +#define float128_le __letf2 +#define float128_gt __gttf2 +#endif diff --git a/lib/libc/softfloat/softfloat-source.txt b/lib/libc/softfloat/softfloat-source.txt index 06759664ebe6..2a15f2add95b 100644 --- a/lib/libc/softfloat/softfloat-source.txt +++ b/lib/libc/softfloat/softfloat-source.txt @@ -1,4 +1,4 @@ -$NetBSD: softfloat-source.txt,v 1.1 2000/06/06 08:15:10 bjh21 Exp $ +$NetBSD: softfloat-source.txt,v 1.2 2006/11/24 19:46:58 christos Exp $ $FreeBSD$ SoftFloat Release 2a Source Documentation @@ -33,7 +33,7 @@ C Compiler (`gcc') for several platforms. Limitations SoftFloat as written requires an ISO/ANSI-style C compiler. No attempt has -been made to accomodate compilers that are not ISO-conformant. Older ``K&R- +been made to accommodate compilers that are not ISO-conformant. Older ``K&R- style'' compilers are not adequate for compiling SoftFloat. All testing I have done so far has been with the GNU C Compiler. Compilation with other compilers should be possible but has not been tested. diff --git a/lib/libc/softfloat/softfloat-specialize b/lib/libc/softfloat/softfloat-specialize index 2daa90fd252f..b5eb8c34cdc8 100644 --- a/lib/libc/softfloat/softfloat-specialize +++ b/lib/libc/softfloat/softfloat-specialize @@ -1,4 +1,4 @@ -/* $NetBSD: softfloat-specialize,v 1.3 2002/05/12 13:12:45 bjh21 Exp $ */ +/* $NetBSD: softfloat-specialize,v 1.6 2011/03/06 10:27:37 martin Exp $ */ /* $FreeBSD$ */ /* This is a derivative work. */ @@ -34,6 +34,8 @@ this code that are retained. */ #include +#include +#include /* ------------------------------------------------------------------------------- @@ -58,6 +60,9 @@ substitute a result value. If traps are not implemented, this routine should be simply `float_exception_flags |= flags;'. ------------------------------------------------------------------------------- */ +#ifdef SOFTFLOAT_FOR_GCC +#define float_exception_mask __softfloat_float_exception_mask +#endif int float_exception_mask = 0; void float_raise( int flags ) { @@ -65,9 +70,29 @@ void float_raise( int flags ) float_exception_flags |= flags; if ( flags & float_exception_mask ) { +#if 0 + siginfo_t info; + memset(&info, 0, sizeof info); + info.si_signo = SIGFPE; + info.si_pid = getpid(); + info.si_uid = geteuid(); + if (flags & float_flag_underflow) + info.si_code = FPE_FLTUND; + else if (flags & float_flag_overflow) + info.si_code = FPE_FLTOVF; + else if (flags & float_flag_divbyzero) + info.si_code = FPE_FLTDIV; + else if (flags & float_flag_invalid) + info.si_code = FPE_FLTINV; + else if (flags & float_flag_inexact) + info.si_code = FPE_FLTRES; + sigqueueinfo(getpid(), &info); +#else raise( SIGFPE ); +#endif } } +#undef float_exception_mask /* ------------------------------------------------------------------------------- @@ -108,7 +133,8 @@ Returns 1 if the single-precision floating-point value `a' is a signaling NaN; otherwise returns 0. ------------------------------------------------------------------------------- */ -#if defined(SOFTFLOAT_FOR_GCC) && !defined(SOFTFLOATSPARC64_FOR_GCC) +#if defined(SOFTFLOAT_FOR_GCC) && !defined(SOFTFLOATSPARC64_FOR_GCC) && \ + !defined(SOFTFLOAT_M68K_FOR_GCC) static #endif flag float32_is_signaling_nan( float32 a ) @@ -207,7 +233,8 @@ Returns 1 if the double-precision floating-point value `a' is a signaling NaN; otherwise returns 0. ------------------------------------------------------------------------------- */ -#if defined(SOFTFLOAT_FOR_GCC) && !defined(SOFTFLOATSPARC64_FOR_GCC) +#if defined(SOFTFLOAT_FOR_GCC) && !defined(SOFTFLOATSPARC64_FOR_GCC) && \ + !defined(SOFTFLOATM68K_FOR_GCC) static #endif flag float64_is_signaling_nan( float64 a ) diff --git a/lib/libc/softfloat/softfloat.txt b/lib/libc/softfloat/softfloat.txt index bd63324faa96..414506f7fef2 100644 --- a/lib/libc/softfloat/softfloat.txt +++ b/lib/libc/softfloat/softfloat.txt @@ -1,4 +1,4 @@ -$NetBSD: softfloat.txt,v 1.1 2000/06/06 08:15:10 bjh21 Exp $ +$NetBSD: softfloat.txt,v 1.2 2006/11/24 19:46:58 christos Exp $ $FreeBSD$ SoftFloat Release 2a General Documentation @@ -27,7 +27,7 @@ Limitations SoftFloat is written in C and is designed to work with other C code. The SoftFloat header files assume an ISO/ANSI-style C compiler. No attempt -has been made to accomodate compilers that are not ISO-conformant. In +has been made to accommodate compilers that are not ISO-conformant. In particular, the distributed header files will not be acceptable to any compiler that does not recognize function prototypes.