aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul E. Murphy <murphyp@linux.vnet.ibm.com>2016-11-04 09:57:27 -0200
committerGabriel F. T. Gomes <gftg@linux.vnet.ibm.com>2017-05-25 09:20:39 -0300
commitec9052ea0cb8baceee57ab26ca526b30f365dff9 (patch)
treee3e106ef8acdd2ca61cdeb6f65ee50bb3141c496
parent302bb1a3c327d546b19447d7304bb2b27e9a34de (diff)
downloadglibc-ec9052ea0cb8baceee57ab26ca526b30f365dff9.zip
glibc-ec9052ea0cb8baceee57ab26ca526b30f365dff9.tar.gz
glibc-ec9052ea0cb8baceee57ab26ca526b30f365dff9.tar.bz2
float128: Extend the power of ten tables
Update the power of ten tables used by the common implementation when long double is not the most expressive real type. 2016-11-04 Paul E. Murphy <murphyp@linux.vnet.ibm.com> * stdlib/fpioconst.c (HAVE_EXTENDED_RANGE): New macro for testing how big the power of ten table should be. [TENS_P11_IDX]: Include if above is true. [TENS_P12_IDX]: Include if above is true. [TENS_P13_IDX]: Include if above is true. [TENS_P14_IDX]: Include if above is true. * stdlib/fpioconst.h (FPIOCONST_POW10_ARRAY_SIZE): Use larger table if _Float128 is supported.
-rw-r--r--stdlib/fpioconst.c11
-rw-r--r--stdlib/fpioconst.h11
2 files changed, 16 insertions, 6 deletions
diff --git a/stdlib/fpioconst.c b/stdlib/fpioconst.c
index 7db7fa4..ba911089 100644
--- a/stdlib/fpioconst.c
+++ b/stdlib/fpioconst.c
@@ -27,6 +27,9 @@
with gen-fpioconst.c.
*/
+#define HAVE_EXTENDED_RANGE ((!defined __NO_LONG_DOUBLE_MATH \
+ && __LDBL_MAX_EXP__ > 1024) || __HAVE_DISTINCT_FLOAT128)
+
#if BITS_PER_MP_LIMB == 32
/* Table with constants of 10^(2^i), i=0..12 for 32-bit limbs. */
@@ -112,7 +115,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 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 +662,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 /* HAVE_EXTENDED_RANGE */
};
#elif BITS_PER_MP_LIMB == 64
@@ -748,7 +751,7 @@ const mp_limb_t __tens[] =
0xd2db49ef47187094ull, 0xae6209d4926c3f5bull, 0x34f4a3c62d433949ull,
0xd9d61a05d4305d94ull, 0x0000000000000325ull,
-#if !defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024
+#if 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 +1323,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 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 },
diff --git a/stdlib/fpioconst.h b/stdlib/fpioconst.h
index 6fc476b..7e19b0d 100644
--- a/stdlib/fpioconst.h
+++ b/stdlib/fpioconst.h
@@ -40,9 +40,16 @@
#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)). */
+#if (!defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024) \
+ || __HAVE_DISTINCT_FLOAT128
# define FPIOCONST_POW10_ARRAY_SIZE 15
#else
# define FPIOCONST_POW10_ARRAY_SIZE 11