]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - soft-fp/op-common.h
soft-fp: Fix used without set warning in _FP_MUL and _FP_DIV
[thirdparty/glibc.git] / soft-fp / op-common.h
index b70026f9091ae14b3247315a7195bdfb18d5cc7e..6e81b138d31fb4e61afb3391632510d7c239d64e 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),
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define _FP_DECL(wc, X)                                                \
-  _FP_I_TYPE X##_c __attribute__((unused)), X##_s, X##_e;      \
+#define _FP_DECL(wc, X)                                \
+  _FP_I_TYPE X##_c __attribute__((unused));    \
+  _FP_I_TYPE X##_s __attribute__((unused));    \
+  _FP_I_TYPE X##_e;                            \
   _FP_FRAC_DECL_##wc(X)
 
 /*
@@ -134,6 +136,12 @@ do {                                                                       \
 #define _FP_PACK_SEMIRAW(fs, wc, X)                            \
 do {                                                           \
   _FP_ROUND(wc, X);                                            \
+  if (X##_e == 0 && !_FP_FRAC_ZEROP_##wc(X))                   \
+       { \
+         if ((FP_CUR_EXCEPTIONS & FP_EX_INEXACT)               \
+             || (FP_TRAPPING_EXCEPTIONS & FP_EX_UNDERFLOW))    \
+           FP_SET_EXCEPTION(FP_EX_UNDERFLOW);                  \
+       } \
   if (_FP_FRAC_HIGH_##fs(X)                                    \
       & (_FP_OVERFLOW_##fs >> 1))                              \
     {                                                          \
@@ -143,20 +151,15 @@ do {                                                              \
        _FP_OVERFLOW_SEMIRAW(fs, wc, X);                        \
     }                                                          \
   _FP_FRAC_SRL_##wc(X, _FP_WORKBITS);                          \
-  if (!_FP_EXP_NORMAL(fs, wc, X) && !_FP_FRAC_ZEROP_##wc(X))   \
+  if (X##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(X))     \
     {                                                          \
-      if (X##_e == 0)                                          \
-       FP_SET_EXCEPTION(FP_EX_UNDERFLOW);                      \
-      else                                                     \
+      if (!_FP_KEEPNANFRACP)                                   \
        {                                                       \
-         if (!_FP_KEEPNANFRACP)                                \
-           {                                                   \
-             _FP_FRAC_SET_##wc(X, _FP_NANFRAC_##fs);           \
-             X##_s = _FP_NANSIGN_##fs;                         \
-           }                                                   \
-         else                                                  \
-           _FP_FRAC_HIGH_RAW_##fs(X) |= _FP_QNANBIT_##fs;      \
+         _FP_FRAC_SET_##wc(X, _FP_NANFRAC_##fs);               \
+         X##_s = _FP_NANSIGN_##fs;                             \
        }                                                       \
+      else                                                     \
+       _FP_FRAC_HIGH_RAW_##fs(X) |= _FP_QNANBIT_##fs;          \
     }                                                          \
 } while (0)
 
@@ -226,13 +229,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                                                    \
          {                                                     \
@@ -742,11 +748,11 @@ do {                                                                       \
 #define _FP_MUL(fs, wc, R, X, Y)                       \
 do {                                                   \
   R##_s = X##_s ^ Y##_s;                               \
+  R##_e = X##_e + Y##_e + 1;                           \
   switch (_FP_CLS_COMBINE(X##_c, Y##_c))               \
   {                                                    \
   case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_NORMAL):   \
     R##_c = FP_CLS_NORMAL;                             \
-    R##_e = X##_e + Y##_e + 1;                         \
                                                        \
     _FP_MUL_MEAT_##fs(R,X,Y);                          \
                                                        \
@@ -805,11 +811,11 @@ do {                                                      \
 #define _FP_DIV(fs, wc, R, X, Y)                       \
 do {                                                   \
   R##_s = X##_s ^ Y##_s;                               \
+  R##_e = X##_e - Y##_e;                               \
   switch (_FP_CLS_COMBINE(X##_c, Y##_c))               \
   {                                                    \
   case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_NORMAL):   \
     R##_c = FP_CLS_NORMAL;                             \
-    R##_e = X##_e - Y##_e;                             \
                                                        \
     _FP_DIV_MEAT_##fs(R,X,Y);                          \
     break;                                             \