]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - stdio-common/printf_fp.c
[powerpc] No need to enter "Ignore Exceptions Mode"
[thirdparty/glibc.git] / stdio-common / printf_fp.c
index 994497cd225d57502179394c94c83fa7067d8ca6..47d2813af792300068d2f4f363d71dc2417c4590 100644 (file)
@@ -1,5 +1,5 @@
 /* Floating point output for `printf'.
-   Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
    This file is part of the GNU C Library.
    Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
 /* The gmp headers need some configuration frobs.  */
 #define HAVE_ALLOCA 1
 
+#include <array_length.h>
 #include <libioP.h>
 #include <alloca.h>
 #include <ctype.h>
 #endif
 #include <assert.h>
 
-/* This defines make it possible to use the same code for GNU C library and
-   the GNU I/O library.         */
 #define PUT(f, s, n) _IO_sputn (f, s, n)
 #define PAD(f, c, n) (wide ? _IO_wpadn (f, c, n) : _IO_padn (f, c, n))
-/* We use this file GNU C library and GNU I/O library. So make
-   names equal.         */
 #undef putc
 #define putc(c, f) (wide \
                    ? (int)_IO_putwc_unlocked (c, f) : _IO_putc_unlocked (c, f))
-#define size_t     _IO_size_t
-#define FILE        _IO_FILE
+
 \f
 /* Macros for doing the actual output.  */
 
@@ -371,8 +367,7 @@ __printf_fp_l (FILE *fp, locale_t loc,
     else                                                               \
       {                                                                        \
        p.fracsize = __mpn_extract_##SUFFIX                             \
-                    (fp_input,                                         \
-                     (sizeof (fp_input) / sizeof (fp_input[0])),       \
+                    (fp_input, array_length (fp_input),                \
                      &p.exponent, &is_neg, VAR);                       \
        to_shift = 1 + p.fracsize * BITS_PER_MP_LIMB - MANT_DIG;        \
       }                                                                        \
@@ -464,8 +459,8 @@ __printf_fp_l (FILE *fp, locale_t loc,
        }
       else
        {
-         cy = __mpn_lshift (p.frac +
-                            (p.exponent + to_shift) / BITS_PER_MP_LIMB,
+         cy = __mpn_lshift (p.frac
+                            (p.exponent + to_shift) / BITS_PER_MP_LIMB,
                             fp_input, p.fracsize,
                             (p.exponent + to_shift) % BITS_PER_MP_LIMB);
          p.fracsize += (p.exponent + to_shift) / BITS_PER_MP_LIMB;
@@ -538,8 +533,8 @@ __printf_fp_l (FILE *fp, locale_t loc,
                                  &__tens[powers->arrayoff
                                         + _FPIO_CONST_OFFSET],
                                  powers->arraysize - _FPIO_CONST_OFFSET);
-                 p.tmpsize = p.scalesize +
-                   powers->arraysize - _FPIO_CONST_OFFSET;
+                 p.tmpsize = p.scalesize
+                   powers->arraysize - _FPIO_CONST_OFFSET;
                  if (cy == 0)
                    --p.tmpsize;
                }
@@ -722,10 +717,10 @@ __printf_fp_l (FILE *fp, locale_t loc,
                 multiplication was not valid.  This is because we cannot
                 determine the number of bits in the result in advance.  */
              if (incr < p.exponent + 3
-                 || (incr == p.exponent + 3 &&
-                     (p.tmp[p.tmpsize - 1] < topval[1]
-                      || (p.tmp[p.tmpsize - 1] == topval[1]
-                          && p.tmp[p.tmpsize - 2] < topval[0]))))
+                 || (incr == p.exponent + 3
+                     && (p.tmp[p.tmpsize - 1] < topval[1]
+                         || (p.tmp[p.tmpsize - 1] == topval[1]
+                             && p.tmp[p.tmpsize - 2] < topval[0]))))
                {
                  /* The factor is right.  Adapt binary and decimal
                     exponents.  */
@@ -814,8 +809,8 @@ __printf_fp_l (FILE *fp, locale_t loc,
         numbers are in the range of 1.0 <= |fp| < 8.0.  We simply
         shift it to the right place and divide it by 1.0 to get the
         leading digit.  (Of course this division is not really made.)  */
-      assert (0 <= p.exponent && p.exponent < 3 &&
-             p.exponent + to_shift < BITS_PER_MP_LIMB);
+      assert (0 <= p.exponent && p.exponent < 3
+             && p.exponent + to_shift < BITS_PER_MP_LIMB);
 
       /* Now shift the input value to its right place. */
       cy = __mpn_lshift (p.frac, fp_input, p.fracsize, (p.exponent + to_shift));