float128: Extend the power of ten tables
authorPaul E. Murphy <murphyp@linux.vnet.ibm.com>
Fri, 4 Nov 2016 11:57:27 +0000 (09:57 -0200)
committerGabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
Wed, 7 Jun 2017 19:58:42 +0000 (16:58 -0300)
Update the power of ten tables used by the common implementation when long
double is not the most expressive real type.

* stdlib/fpioconst.h: Include bits/floatn.h.
(FPIOCONST_HAVE_EXTENDED_RANGE): New macro for testing how big the
power of ten table should be.
(FPIOCONST_POW10_ARRAY_SIZE): Use larger table if above is true.
* stdlib/fpioconst.c (__tens): Use FPIOCONST_HAVE_EXTENDED_RANGE
to include larger tables when _Float128 support is enabled.
(_fpioconst_pow10): Likewise.

ChangeLog
stdlib/fpioconst.c
stdlib/fpioconst.h

index e571155..742e492 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2017-06-07  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
+
+       * stdlib/fpioconst.h: Include bits/floatn.h.
+       (FPIOCONST_HAVE_EXTENDED_RANGE): New macro for testing how big the
+       power of ten table should be.
+       (FPIOCONST_POW10_ARRAY_SIZE): Use larger table if above is true.
+       * stdlib/fpioconst.c (__tens): Use FPIOCONST_HAVE_EXTENDED_RANGE
+       to include larger tables when _Float128 support is enabled.
+       (_fpioconst_pow10): Likewise.
+
 2017-06-07  Joseph Myers  <joseph@codesourcery.com>
 
        * include/bits/types/clock_t.h: Use #include <path> instead of
index 7db7fa4..a0563b9 100644 (file)
@@ -112,7 +112,7 @@ const mp_limb_t __tens[] =
   0xd2db49ef, 0x926c3f5b, 0xae6209d4, 0x2d433949, 0x34f4a3c6, 0xd4305d94,
   0xd9d61a05, 0x00000325,
 
-#if !defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024
+#if FPIOCONST_HAVE_EXTENDED_RANGE
 # define TENS_P11_IDX  (TENS_P10_IDX + TENS_P10_SIZE)
 # define TENS_P11_SIZE 215
   [TENS_P11_IDX] = 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -659,7 +659,7 @@ const mp_limb_t __tens[] =
   0x6d6c0267, 0x06f9c25b, 0xbd6078e0, 0xb5fcdc81, 0xd742fa41, 0xcccc2399,
   0xc691adc0, 0x215ad82c, 0xea73b0c3, 0xa511e5b0, 0xf499e0a6, 0x53e27ab0,
   0xd94440a2, 0x47752521, 0x9a6e3644, 0xab113708, 0x8f8b301d, 0x058a42a3,
-#endif /* !__NO_LONG_DOUBLE_MATH */
+#endif /* FPIOCONST_HAVE_EXTENDED_RANGE */
 };
 \f
 #elif BITS_PER_MP_LIMB == 64
@@ -748,7 +748,7 @@ const mp_limb_t __tens[] =
   0xd2db49ef47187094ull, 0xae6209d4926c3f5bull, 0x34f4a3c62d433949ull,
   0xd9d61a05d4305d94ull, 0x0000000000000325ull,
 
-#if !defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024
+#if FPIOCONST_HAVE_EXTENDED_RANGE
 # define TENS_P11_IDX  (TENS_P10_IDX + TENS_P10_SIZE)
 # define TENS_P11_SIZE 108
   [TENS_P11_IDX] = 0x0000000000000000ull, 0x0000000000000000ull,
@@ -1320,7 +1320,7 @@ const struct mp_power _fpioconst_pow10[FPIOCONST_POW10_ARRAY_SIZE] =
   { TENS_P8_IDX, TENS_P8_SIZE,         851,     848 },
   { TENS_P9_IDX, TENS_P9_SIZE,         1701,   1698 },
   { TENS_P10_IDX, TENS_P10_SIZE,       3402,   3399 },
-#if !defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024
+#if FPIOCONST_HAVE_EXTENDED_RANGE
   { TENS_P11_IDX, TENS_P11_SIZE,       6804,   6800 },
   { TENS_P12_IDX, TENS_P12_SIZE,       13607,  13604 },
   { TENS_P13_IDX, TENS_P13_SIZE,       27214,  27210 },
index 6fc476b..2559d7a 100644 (file)
 #define DBL_MAX_10_EXP_LOG     8 /* = floor(log_2(DBL_MAX_10_EXP)) */
 #define FLT_MAX_10_EXP_LOG     5 /* = floor(log_2(FLT_MAX_10_EXP)) */
 
+/* On some machines, _Float128 may be ABI-distinct from long double (e.g
+   IBM extended precision).  */
+#include <bits/floatn.h>
+
 /* For strtold, we need powers of 10 up to floor (log_2 (LDBL_MANT_DIG
-   - LDBL_MIN_EXP + 2)).  */
-#if !defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024
+   - LDBL_MIN_EXP + 2)).  When _Float128 is enabled in libm and it is
+   ABI-distinct from long double (e.g. on powerpc64le), we also need powers
+   of 10 up to floor (log_2 (FLT128_MANT_DIG - FLT128_MIN_EXP + 2)).  */
+#define FPIOCONST_HAVE_EXTENDED_RANGE \
+  ((!defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024) \
+   || __HAVE_DISTINCT_FLOAT128)
+
+#if FPIOCONST_HAVE_EXTENDED_RANGE
 # define FPIOCONST_POW10_ARRAY_SIZE    15
 #else
 # define FPIOCONST_POW10_ARRAY_SIZE    11