]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix underflow generation in soft-fp.
authorDavid S. Miller <davem@davemloft.net>
Wed, 30 May 2012 20:41:01 +0000 (13:41 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 30 May 2012 20:41:01 +0000 (13:41 -0700)
* soft-fp/soft-fp.h (FP_CUR_EXCEPTIONS): Define.
(FP_TRAPPING_EXCEPTIONS): Provide default implementation.
* sysdeps/sparc/sparc32/soft-fp/sfp-machine.h
(FP_TRAPPING_EXCEPTIONS): Define.
* sysdeps/sparc/sparc64/soft-fp/sfp-machine.h
(FP_TRAPPING_EXCEPTIONS): Define.
* soft-fp/op-common.h (_FP_PACK_SEMIRAW): Signal underflow for
subnormals only when inexact has been signalled or underflow
exceptions are enabled.
(_FP_PACK_CANONICAL): Likewise.

ChangeLog
soft-fp/op-common.h
soft-fp/soft-fp.h
sysdeps/sparc/sparc32/soft-fp/sfp-machine.h
sysdeps/sparc/sparc64/soft-fp/sfp-machine.h

index 42df8d72b5fd56a2ea04a5d4330c498cdc0f22e3..4adb73a8c8a18f2d0b231c80e9113ec37909862d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2012-05-30  David S. Miller  <davem@davemloft.net>
+
+       * soft-fp/soft-fp.h (FP_CUR_EXCEPTIONS): Define.
+       (FP_TRAPPING_EXCEPTIONS): Provide default implementation.
+       * sysdeps/sparc/sparc32/soft-fp/sfp-machine.h
+       (FP_TRAPPING_EXCEPTIONS): Define.
+       * sysdeps/sparc/sparc64/soft-fp/sfp-machine.h
+       (FP_TRAPPING_EXCEPTIONS): Define.
+       * soft-fp/op-common.h (_FP_PACK_SEMIRAW): Signal underflow for
+       subnormals only when inexact has been signalled or underflow
+       exceptions are enabled.
+       (_FP_PACK_CANONICAL): Likewise.
+
 2012-05-30  H.J. Lu  <hongjiu.lu@intel.com>
 
        [BZ #14183]
index b70026f9091ae14b3247315a7195bdfb18d5cc7e..db75af53e6054fc48e3bd2ec583817fa626c4723 100644 (file)
@@ -1,5 +1,5 @@
 /* Software floating-point emulation. Common operations.
-   Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
+   Copyright (C) 1997,1998,1999,2006,2007,2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Richard Henderson (rth@cygnus.com),
                  Jakub Jelinek (jj@ultra.linux.cz),
@@ -146,7 +146,11 @@ do {                                                               \
   if (!_FP_EXP_NORMAL(fs, wc, X) && !_FP_FRAC_ZEROP_##wc(X))   \
     {                                                          \
       if (X##_e == 0)                                          \
-       FP_SET_EXCEPTION(FP_EX_UNDERFLOW);                      \
+       {                                                       \
+         if ((FP_CUR_EXCEPTIONS & FP_EX_INEXACT)               \
+             || (FP_TRAPPING_EXCEPTIONS & FP_EX_UNDERFLOW))    \
+           FP_SET_EXCEPTION(FP_EX_UNDERFLOW);                  \
+       }                                                       \
       else                                                     \
        {                                                       \
          if (!_FP_KEEPNANFRACP)                                \
@@ -226,13 +230,16 @@ do {                                                              \
              {                                                 \
                X##_e = 1;                                      \
                _FP_FRAC_SET_##wc(X, _FP_ZEROFRAC_##wc);        \
+               FP_SET_EXCEPTION(FP_EX_INEXACT);                \
              }                                                 \
            else                                                \
              {                                                 \
                X##_e = 0;                                      \
                _FP_FRAC_SRL_##wc(X, _FP_WORKBITS);             \
-               FP_SET_EXCEPTION(FP_EX_UNDERFLOW);              \
              }                                                 \
+           if ((FP_CUR_EXCEPTIONS & FP_EX_INEXACT)             \
+               || (FP_TRAPPING_EXCEPTIONS & FP_EX_UNDERFLOW))  \
+             FP_SET_EXCEPTION(FP_EX_UNDERFLOW);                \
          }                                                     \
        else                                                    \
          {                                                     \
index 46cb1cfaef83fa260a75defbc00de8d7060d565a..750c7fea2d1d3ec91b3e74e242952478589b9498 100644 (file)
 #define FP_CLEAR_EXCEPTIONS                            \
   _fex = 0
 
+#define FP_CUR_EXCEPTIONS                              \
+  (_fex)
+
+#ifndef FP_TRAPPING_EXCEPTIONS
+#define FP_TRAPPING_EXCEPTIONS 0
+#endif
+
 #define _FP_ROUND_NEAREST(wc, X)                       \
 do {                                                   \
     if ((_FP_FRAC_LOW_##wc(X) & 15) != _FP_WORK_ROUND) \
index 4314082f70ed9a8e40193daa04cea3f5c5cc3a40..e60f1cadaa1e55fe4439d13dfedf5bc1bf16402c 100644 (file)
@@ -1,6 +1,6 @@
 /* Machine-dependent software floating-point definitions.
    Sparc userland (_Q_*) version.
-   Copyright (C) 1997,1998,1999, 2002, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1997,1998,1999,2002,2006,2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Richard Henderson (rth@cygnus.com),
                  Jakub Jelinek (jj@ultra.linux.cz) and
@@ -192,6 +192,7 @@ do {                                                                \
   _FPU_GETCW(_fcw);                                            \
 } while (0)
 
+#define FP_TRAPPING_EXCEPTIONS ((_fcw >> 23) & 0x1f)
 #define FP_INHIBIT_RESULTS ((_fcw >> 23) & _fex)
 
 /* Simulate exceptions using double arithmetics. */
index 36f92d64fbb19c93d24ce5f2d3630ad29a8c2616..9bd4298c9cacc1850875edaa61f4d5630a114836 100644 (file)
@@ -1,6 +1,6 @@
 /* Machine-dependent software floating-point definitions.
    Sparc64 userland (_Q_* and _Qp_*) version.
-   Copyright (C) 1997, 1998, 1999, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2006, 2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Richard Henderson (rth@cygnus.com),
                  Jakub Jelinek (jj@ultra.linux.cz) and
@@ -100,6 +100,7 @@ do {                                                                \
   _FPU_GETCW(_fcw);                                            \
 } while (0)
 
+#define FP_TRAPPING_EXCEPTIONS ((_fcw >> 23) & 0x1f)
 #define FP_INHIBIT_RESULTS ((_fcw >> 23) & _fex)
 
 /* Simulate exceptions using double arithmetics. */