Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/softfloat Add hooks to softfloat to support per-lwp...



details:   https://anonhg.NetBSD.org/src/rev/cdbd2fac3296
branches:  trunk
changeset: 783837:cdbd2fac3296
user:      matt <matt%NetBSD.org@localhost>
date:      Thu Jan 10 08:16:10 2013 +0000

description:
Add hooks to softfloat to support per-lwp exception state.

diffstat:

 lib/libc/softfloat/bits32/softfloat.c   |  34 ++++++----
 lib/libc/softfloat/bits64/softfloat.c   |  96 +++++++++++++++++---------------
 lib/libc/softfloat/fpsetmask.c          |  12 ++-
 lib/libc/softfloat/fpsetround.c         |  12 ++-
 lib/libc/softfloat/fpsetsticky.c        |  12 ++-
 lib/libc/softfloat/softfloat-specialize |  18 +++++-
 6 files changed, 107 insertions(+), 77 deletions(-)

diffs (truncated from 680 to 300 lines):

diff -r 534e2c665560 -r cdbd2fac3296 lib/libc/softfloat/bits32/softfloat.c
--- a/lib/libc/softfloat/bits32/softfloat.c     Thu Jan 10 06:52:35 2013 +0000
+++ b/lib/libc/softfloat/bits32/softfloat.c     Thu Jan 10 08:16:10 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: softfloat.c,v 1.2 2012/03/21 14:17:54 christos Exp $ */
+/* $NetBSD: softfloat.c,v 1.3 2013/01/10 08:16:11 matt Exp $ */
 
 /*
  * This version hacked for use with gcc -msoft-float by bjh21.
@@ -53,7 +53,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: softfloat.c,v 1.2 2012/03/21 14:17:54 christos Exp $");
+__RCSID("$NetBSD: softfloat.c,v 1.3 2013/01/10 08:16:11 matt Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #ifdef SOFTFLOAT_FOR_GCC
@@ -79,8 +79,14 @@
 Floating-point rounding mode and exception flags.
 -------------------------------------------------------------------------------
 */
+#ifndef set_float_rounding_mode
 fp_rnd float_rounding_mode = float_round_nearest_even;
 fp_except float_exception_flags = 0;
+#endif
+#ifndef set_float_exception_inexact_flag
+#define set_float_exception_inexact_flag() \
+       ((void)(float_exception_flags |= float_flag_inexact))
+#endif
 
 /*
 -------------------------------------------------------------------------------
@@ -244,7 +250,7 @@
             if ( isTiny && roundBits ) float_raise( float_flag_underflow );
         }
     }
-    if ( roundBits ) float_exception_flags |= float_flag_inexact;
+    if ( roundBits ) set_float_exception_inexact_flag();
     zSig = ( zSig + roundIncrement )>>7;
     zSig &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
     if ( zSig == 0 ) zExp = 0;
@@ -472,7 +478,7 @@
             }
         }
     }
-    if ( zSig2 ) float_exception_flags |= float_flag_inexact;
+    if ( zSig2 ) set_float_exception_inexact_flag();
     if ( increment ) {
         add64( zSig0, zSig1, 0, 1, &zSig0, &zSig1 );
         zSig1 &= ~ ( ( zSig2 + zSig2 == 0 ) & roundNearestEven );
@@ -615,7 +621,7 @@
             aSigExtra = aSig<<( shiftCount & 31 );
             z = aSig>>( - shiftCount );
         }
-        if ( aSigExtra ) float_exception_flags |= float_flag_inexact;
+        if ( aSigExtra ) set_float_exception_inexact_flag();
         roundingMode = float_rounding_mode;
         if ( roundingMode == float_round_nearest_even ) {
             if ( (sbits32) aSigExtra < 0 ) {
@@ -670,13 +676,13 @@
         return (sbits32) 0x80000000;
     }
     else if ( aExp <= 0x7E ) {
-        if ( aExp | aSig ) float_exception_flags |= float_flag_inexact;
+        if ( aExp | aSig ) set_float_exception_inexact_flag();
         return 0;
     }
     aSig = ( aSig | 0x00800000 )<<8;
     z = aSig>>( - shiftCount );
     if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) {
-        float_exception_flags |= float_flag_inexact;
+        set_float_exception_inexact_flag();
     }
     if ( aSign ) z = - z;
     return z;
@@ -740,7 +746,7 @@
     }
     if ( aExp <= 0x7E ) {
         if ( (bits32) ( a<<1 ) == 0 ) return a;
-        float_exception_flags |= float_flag_inexact;
+        set_float_exception_inexact_flag();
         aSign = extractFloat32Sign( a );
         switch ( float_rounding_mode ) {
          case float_round_nearest_even:
@@ -772,7 +778,7 @@
         }
     }
     z &= ~ roundBitsMask;
-    if ( z != a ) float_exception_flags |= float_flag_inexact;
+    if ( z != a ) set_float_exception_inexact_flag();
     return z;
 
 }
@@ -1463,7 +1469,7 @@
         float_raise( float_flag_invalid );
         return aSign ? (sbits32) 0x80000000 : 0x7FFFFFFF;
     }
-    if ( aSigExtra ) float_exception_flags |= float_flag_inexact;
+    if ( aSigExtra ) set_float_exception_inexact_flag();
     return z;
 
 }
@@ -1503,7 +1509,7 @@
     else {
         if ( aExp < 0x3FF ) {
             if ( aExp | aSig0 | aSig1 ) {
-                float_exception_flags |= float_flag_inexact;
+                set_float_exception_inexact_flag();
             }
             return 0;
         }
@@ -1517,7 +1523,7 @@
         float_raise( float_flag_invalid );
         return aSign ? (sbits32) 0x80000000 : 0x7FFFFFFF;
     }
-    if ( aSigExtra ) float_exception_flags |= float_flag_inexact;
+    if ( aSigExtra ) set_float_exception_inexact_flag();
     return z;
 
 }
@@ -1607,7 +1613,7 @@
     else {
         if ( aExp <= 0x3FE ) {
             if ( ( ( (bits32) ( a.high<<1 ) ) | a.low ) == 0 ) return a;
-            float_exception_flags |= float_flag_inexact;
+            set_float_exception_inexact_flag();
             aSign = extractFloat64Sign( a );
             switch ( float_rounding_mode ) {
              case float_round_nearest_even:
@@ -1650,7 +1656,7 @@
         z.high &= ~ roundBitsMask;
     }
     if ( ( z.low != a.low ) || ( z.high != a.high ) ) {
-        float_exception_flags |= float_flag_inexact;
+        set_float_exception_inexact_flag();
     }
     return z;
 
diff -r 534e2c665560 -r cdbd2fac3296 lib/libc/softfloat/bits64/softfloat.c
--- a/lib/libc/softfloat/bits64/softfloat.c     Thu Jan 10 06:52:35 2013 +0000
+++ b/lib/libc/softfloat/bits64/softfloat.c     Thu Jan 10 08:16:10 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: softfloat.c,v 1.11 2012/03/24 00:06:20 matt Exp $ */
+/* $NetBSD: softfloat.c,v 1.12 2013/01/10 08:16:11 matt Exp $ */
 
 /*
  * This version hacked for use with gcc -msoft-float by bjh21.
@@ -46,7 +46,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: softfloat.c,v 1.11 2012/03/24 00:06:20 matt Exp $");
+__RCSID("$NetBSD: softfloat.c,v 1.12 2013/01/10 08:16:11 matt Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #ifdef SOFTFLOAT_FOR_GCC
@@ -73,8 +73,14 @@
 and exception flags.
 -------------------------------------------------------------------------------
 */
+#ifndef set_float_rounding_mode
 fp_rnd float_rounding_mode = float_round_nearest_even;
 fp_except float_exception_flags = 0;
+#endif
+#ifndef set_float_exception_inexact_flag
+#define        set_float_exception_inexact_flag() \
+       ((void)(float_exception_flags |= float_flag_inexact))
+#endif
 #ifdef FLOATX80
 int8 floatx80_rounding_precision = 80;
 #endif
@@ -146,7 +152,7 @@
         float_raise( float_flag_invalid );
         return zSign ? (sbits32) 0x80000000 : 0x7FFFFFFF;
     }
-    if ( roundBits ) float_exception_flags |= float_flag_inexact;
+    if ( roundBits ) set_float_exception_inexact_flag();
     return z;
 
 }
@@ -200,7 +206,7 @@
               zSign ? (sbits64) LIT64( 0x8000000000000000 )
             : LIT64( 0x7FFFFFFFFFFFFFFF );
     }
-    if ( absZ1 ) float_exception_flags |= float_flag_inexact;
+    if ( absZ1 ) set_float_exception_inexact_flag();
     return z;
 
 }
@@ -347,7 +353,7 @@
             if ( isTiny && roundBits ) float_raise( float_flag_underflow );
         }
     }
-    if ( roundBits ) float_exception_flags |= float_flag_inexact;
+    if ( roundBits ) set_float_exception_inexact_flag();
     zSig = ( zSig + roundIncrement )>>7;
     zSig &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
     if ( zSig == 0 ) zExp = 0;
@@ -519,7 +525,7 @@
             if ( isTiny && roundBits ) float_raise( float_flag_underflow );
         }
     }
-    if ( roundBits ) float_exception_flags |= float_flag_inexact;
+    if ( roundBits ) set_float_exception_inexact_flag();
     zSig = ( zSig + roundIncrement )>>10;
     zSig &= ~ ( ( ( roundBits ^ 0x200 ) == 0 ) & roundNearestEven );
     if ( zSig == 0 ) zExp = 0;
@@ -702,7 +708,7 @@
             zExp = 0;
             roundBits = zSig0 & roundMask;
             if ( isTiny && roundBits ) float_raise( float_flag_underflow );
-            if ( roundBits ) float_exception_flags |= float_flag_inexact;
+            if ( roundBits ) set_float_exception_inexact_flag();
             zSig0 += roundIncrement;
             if ( (sbits64) zSig0 < 0 ) zExp = 1;
             roundIncrement = roundMask + 1;
@@ -713,7 +719,7 @@
             return packFloatx80( zSign, zExp, zSig0 );
         }
     }
-    if ( roundBits ) float_exception_flags |= float_flag_inexact;
+    if ( roundBits ) set_float_exception_inexact_flag();
     zSig0 += roundIncrement;
     if ( zSig0 < roundIncrement ) {
         ++zExp;
@@ -768,7 +774,7 @@
             shift64ExtraRightJamming( zSig0, zSig1, 1 - zExp, &zSig0, &zSig1 );
             zExp = 0;
             if ( isTiny && zSig1 ) float_raise( float_flag_underflow );
-            if ( zSig1 ) float_exception_flags |= float_flag_inexact;
+            if ( zSig1 ) set_float_exception_inexact_flag();
             if ( roundNearestEven ) {
                 increment = ( (sbits64) zSig1 < 0 );
             }
@@ -789,7 +795,7 @@
             return packFloatx80( zSign, zExp, zSig0 );
         }
     }
-    if ( zSig1 ) float_exception_flags |= float_flag_inexact;
+    if ( zSig1 ) set_float_exception_inexact_flag();
     if ( increment ) {
         ++zSig0;
         if ( zSig0 == 0 ) {
@@ -1059,7 +1065,7 @@
             }
         }
     }
-    if ( zSig2 ) float_exception_flags |= float_flag_inexact;
+    if ( zSig2 ) set_float_exception_inexact_flag();
     if ( increment ) {
         add128( zSig0, zSig1, 0, 1, &zSig0, &zSig1 );
         zSig1 &= ~ ( ( zSig2 + zSig2 == 0 ) & roundNearestEven );
@@ -1431,13 +1437,13 @@
         return (sbits32) 0x80000000;
     }
     else if ( aExp <= 0x7E ) {
-        if ( aExp | aSig ) float_exception_flags |= float_flag_inexact;
+        if ( aExp | aSig ) set_float_exception_inexact_flag();
         return 0;
     }
     aSig = ( aSig | 0x00800000 )<<8;
     z = aSig>>( - shiftCount );
     if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) {
-        float_exception_flags |= float_flag_inexact;
+        set_float_exception_inexact_flag();
     }
     if ( aSign ) z = - z;
     return z;
@@ -1515,14 +1521,14 @@
         return (sbits64) LIT64( 0x8000000000000000 );
     }
     else if ( aExp <= 0x7E ) {
-        if ( aExp | aSig ) float_exception_flags |= float_flag_inexact;
+        if ( aExp | aSig ) set_float_exception_inexact_flag();
         return 0;
     }
     aSig64 = aSig | 0x00800000;
     aSig64 <<= 40;
     z = aSig64>>( - shiftCount );
     if ( (bits64) ( aSig64<<( shiftCount & 63 ) ) ) {
-        float_exception_flags |= float_flag_inexact;
+        set_float_exception_inexact_flag();
     }
     if ( aSign ) z = - z;
     return z;
@@ -1654,7 +1660,7 @@
     }
     if ( aExp <= 0x7E ) {
         if ( (bits32) ( a<<1 ) == 0 ) return a;
-        float_exception_flags |= float_flag_inexact;
+        set_float_exception_inexact_flag();
         aSign = extractFloat32Sign( a );
         switch ( float_rounding_mode ) {
          case float_round_nearest_even:
@@ -1686,7 +1692,7 @@
         }
     }
     z &= ~ roundBitsMask;
-    if ( z != a ) float_exception_flags |= float_flag_inexact;



Home | Main Index | Thread Index | Old Index