public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 5/6] float128: Add strfromf128, strtof128, and wcstof128 to the manual
  2017-05-26 12:57 [PATCH 0/6] Add string functions and libm tests for _Float128 Gabriel F. T. Gomes
  2017-05-26 12:57 ` [PATCH 2/6] float128: Add conversion from float128 to mpn Gabriel F. T. Gomes
  2017-05-26 12:57 ` [PATCH 6/6] float128: Add test-{float128,ifloat128,float128-finite} Gabriel F. T. Gomes
@ 2017-05-26 12:57 ` Gabriel F. T. Gomes
  2017-05-26 13:29   ` Florian Weimer
  2017-05-26 16:17   ` Joseph Myers
  2017-05-26 12:57 ` [PATCH 1/6] float128: Extend the power of ten tables Gabriel F. T. Gomes
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 20+ messages in thread
From: Gabriel F. T. Gomes @ 2017-05-26 12:57 UTC (permalink / raw)
  To: libc-alpha

2016-11-14  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>

	* manual/arith.texi: Add descriptions for strfromf128, strtof128,
	and wcstof128.
---
 manual/arith.texi | 39 +++++++++++++++++++++++++++++++++------
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/manual/arith.texi b/manual/arith.texi
index dec12a0..fa1fd88 100644
--- a/manual/arith.texi
+++ b/manual/arith.texi
@@ -2990,23 +2990,38 @@ double} is a separate type).
 These functions have been GNU extensions and are new to @w{ISO C99}.
 @end deftypefun
 
+@comment stdlib.h
+@comment ISO/IEC TS 18661-3
+@deftypefun _Float128 strtof128 (const char *@var{string}, char **@var{tailptr})
+@safety{@prelim{}@mtsafe{@mtslocale{}}@assafe{}@acsafe{}}
+The @code{strtof128} function (``string-to-float128'') is like
+@code{strtod}, except that it returns a @code{_Float128} value.
+
+The @code{strtof128} function was introduced in @w{ISO/IEC TS 18661-3}.
+@end deftypefun
+
 @comment wchar.h
 @comment ISO
 @deftypefun double wcstod (const wchar_t *restrict @var{string}, wchar_t **restrict @var{tailptr})
-@comment stdlib.h
+@comment wchar.h
 @comment ISO
 @deftypefunx float wcstof (const wchar_t *@var{string}, wchar_t **@var{tailptr})
-@comment stdlib.h
+@comment wchar.h
 @comment ISO
 @deftypefunx {long double} wcstold (const wchar_t *@var{string}, wchar_t **@var{tailptr})
+@comment wchar.h
+@deftypefunx _Float128 wcstof128 (const wchar_t *@var{string}, wchar_t **@var{tailptr})
 @safety{@prelim{}@mtsafe{@mtslocale{}}@assafe{}@acsafe{}}
-The @code{wcstod}, @code{wcstof}, and @code{wcstol} functions are
-equivalent in nearly all aspect to the @code{strtod}, @code{strtof}, and
-@code{strtold} functions but it handles wide character string.
+The @code{wcstod}, @code{wcstof}, @code{wcstol}, and @code{wcstof128}
+functions are equivalent in nearly all aspect to the @code{strtod},
+@code{strtof}, @code{strtold}, and @code{strtof128} functions but they
+handle wide character string.
 
 The @code{wcstod} function was introduced in @w{Amendment 1} of @w{ISO
 C90}.  The @code{wcstof} and @code{wcstold} functions were introduced in
-@w{ISO C99}.
+@w{ISO C99}.  The @code{wcstof128} function is not in any standard, but is
+added to provide completeness for the non-deprecated interface of wide
+character string to floating-point conversion functions.
 @end deftypefun
 
 @comment stdlib.h
@@ -3064,6 +3079,18 @@ has been completely written if and only if the returned value is less than
 These functions were introduced by ISO/IEC TS 18661-1.
 @end deftypefun
 
+@comment stdlib.h
+@comment ISO/IEC TS 18661-3
+@deftypefun int strfromf128 (char *restrict @var{string}, size_t @var{size}, const char *restrict @var{format}, _Float128 @var{value})
+@safety{@prelim{}@mtsafe{@mtslocale{}}@asunsafe{@ascuheap{}}@acunsafe{@acsmem{}}}
+@comment this function depends on __printf_fp and __printf_fphex, which are
+@comment AS-unsafe (ascuheap) and AC-unsafe (acsmem).
+The @code{strfromf128} function (``string-from-float128'') is like
+@code{strfromd}, except that @var{value} has floating type _Float128.
+
+The @code{strfromf128} function was introduced by ISO/IEC TS 18661-3.
+@end deftypefun
+
 @node System V Number Conversion
 @section Old-fashioned System V number-to-string functions
 
-- 
2.4.11

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 2/6] float128: Add conversion from float128 to mpn
  2017-05-26 12:57 [PATCH 0/6] Add string functions and libm tests for _Float128 Gabriel F. T. Gomes
@ 2017-05-26 12:57 ` Gabriel F. T. Gomes
  2017-05-26 15:35   ` Joseph Myers
  2017-05-26 12:57 ` [PATCH 6/6] float128: Add test-{float128,ifloat128,float128-finite} Gabriel F. T. Gomes
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 20+ messages in thread
From: Gabriel F. T. Gomes @ 2017-05-26 12:57 UTC (permalink / raw)
  To: libc-alpha

Reuse the code for __mpn_extract_long_double to implement
__mpn_extract_float128.

2017-05-15  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>

	* include/gmp.h (__mpn_extract_float128): Declare when
	__HAVE_DISTINCT_FLOAT128 is 1.
	* misc/sys/param.h (MIN, MAX): Only define if not yet defined.
	* sysdeps/ieee754/float128/Makefile: New file.
	* sysdeps/ieee754/float128/float1282mpn.c: New file.
	* sysdeps/ieee754/ldbl-128/ldbl2mpn.c (__mpn_extract_float128): New
	function, which is built when __FLOAT128_OVERRIDE is defined.
---
 include/gmp.h                           |  6 ++++++
 misc/sys/param.h                        |  8 ++++++--
 sysdeps/ieee754/float128/Makefile       |  3 +++
 sysdeps/ieee754/float128/float1282mpn.c | 20 ++++++++++++++++++++
 sysdeps/ieee754/ldbl-128/ldbl2mpn.c     | 18 ++++++++++++++----
 5 files changed, 49 insertions(+), 6 deletions(-)
 create mode 100644 sysdeps/ieee754/float128/Makefile
 create mode 100644 sysdeps/ieee754/float128/float1282mpn.c

diff --git a/include/gmp.h b/include/gmp.h
index b741670..95d6c16 100644
--- a/include/gmp.h
+++ b/include/gmp.h
@@ -15,6 +15,12 @@ extern mp_size_t __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
 					    int *expt, int *is_neg,
 					    long double value);
 
+#if __HAVE_DISTINCT_FLOAT128
+extern mp_size_t __mpn_extract_float128 (mp_ptr res_ptr, mp_size_t size,
+					 int *expt, int *is_neg,
+					 _Float128 value);
+#endif
+
 extern float __mpn_construct_float (mp_srcptr frac_ptr, int expt, int sign);
 
 extern double __mpn_construct_double (mp_srcptr frac_ptr, int expt,
diff --git a/misc/sys/param.h b/misc/sys/param.h
index 9721613..02d6b1c 100644
--- a/misc/sys/param.h
+++ b/misc/sys/param.h
@@ -99,8 +99,12 @@
 #define powerof2(x)     ((((x) - 1) & (x)) == 0)
 
 /* Macros for min/max.  */
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#define MAX(a,b) (((a)>(b))?(a):(b))
+#ifndef MIN
+# define MIN(a,b) (((a)<(b))?(a):(b))
+#endif
+#ifndef MAX
+# define MAX(a,b) (((a)>(b))?(a):(b))
+#endif
 
 
 #endif  /* sys/param.h */
diff --git a/sysdeps/ieee754/float128/Makefile b/sysdeps/ieee754/float128/Makefile
new file mode 100644
index 0000000..6a7b0e0
--- /dev/null
+++ b/sysdeps/ieee754/float128/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),stdlib)
+routines += float1282mpn
+endif
diff --git a/sysdeps/ieee754/float128/float1282mpn.c b/sysdeps/ieee754/float128/float1282mpn.c
new file mode 100644
index 0000000..b0dd2e9
--- /dev/null
+++ b/sysdeps/ieee754/float128/float1282mpn.c
@@ -0,0 +1,20 @@
+/* Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   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/>.  */
+
+#define __FLOAT128_OVERRIDE
+
+#include "../ldbl-128/ldbl2mpn.c"
diff --git a/sysdeps/ieee754/ldbl-128/ldbl2mpn.c b/sysdeps/ieee754/ldbl-128/ldbl2mpn.c
index 71a6f04..e23cb76 100644
--- a/sysdeps/ieee754/ldbl-128/ldbl2mpn.c
+++ b/sysdeps/ieee754/ldbl-128/ldbl2mpn.c
@@ -18,10 +18,14 @@
 #include "gmp.h"
 #include "gmp-impl.h"
 #include "longlong.h"
-#include <ieee754.h>
-#include <float.h>
-#include <math.h>
-#include <stdlib.h>
+
+#ifdef __FLOAT128_OVERRIDE
+# include <float128_private.h>
+#else
+# include <ieee754.h>
+# include <float.h>
+# include <math.h>
+#endif
 
 /* Convert a `long double' in IEEE854 quad-precision format to a
    multi-precision integer representing the significand scaled up by its
@@ -29,9 +33,15 @@
    (MPN frexpl). */
 
 mp_size_t
+#ifdef __FLOAT128_OVERRIDE
+__mpn_extract_float128 (mp_ptr res_ptr, mp_size_t size,
+			int *expt, int *is_neg,
+			_Float128 value)
+#else
 __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
 			   int *expt, int *is_neg,
 			   long double value)
+#endif
 {
   union ieee854_long_double u;
   u.d = value;
-- 
2.4.11

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 3/6] float128: Add strfromf128
  2017-05-26 12:57 [PATCH 0/6] Add string functions and libm tests for _Float128 Gabriel F. T. Gomes
                   ` (3 preceding siblings ...)
  2017-05-26 12:57 ` [PATCH 1/6] float128: Extend the power of ten tables Gabriel F. T. Gomes
@ 2017-05-26 12:57 ` Gabriel F. T. Gomes
  2017-05-26 15:56   ` Joseph Myers
  2017-05-26 12:57 ` [PATCH 4/6] float128: Add strtof128, wcstof128, and related functions Gabriel F. T. Gomes
  5 siblings, 1 reply; 20+ messages in thread
From: Gabriel F. T. Gomes @ 2017-05-26 12:57 UTC (permalink / raw)
  To: libc-alpha

Add strfromf128 to stdlib when _Float128 support is enabled.

2016-11-07  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>

	* NEWS: Mention the addition of strfromf128.
	* include/gmp.h: Include bits/floatn.h for _Float128 support.
	* stdio-common/printf-parsemb.c (__parse_one_specmb): Initialize
	spec->info.is_binary128 to zero.
	* stdio-common/printf.h (printf_info): Add new member is_binary128
	to indicate that the number being converted to string is compatible
	with the IEC 60559 binary128 format.
	* stdio-common/printf_fp.c (__printf_fp_l): Add code to deal with
	_Float128 numbers.
	* stdio-common/printf_fphex.c (__printf_fphex): Likewise.
	* stdio-common/printf_size.c (__printf_size): Likewise.
	* stdio-common/vfprintf.c (process_arg): Initialize member
	info.is_binary128 to zero.
	* stdlib/fpioconst.h (FLT128_MAX_10_EXP_LOG): New macro.
	* stdlib/stdlib.h: Include bits/floatn.h for _Float128 support.
	(strfromf128): New declaration.
	* stdlib/strfrom-skeleton.c (STRFROM): Set member info.is_binary128
	to one.
	* sysdeps/ieee754/float128/Makefile: Add strfromf128.
	* sysdeps/ieee754/float128/Versions: Likewise.
	* sysdeps/ieee754/float128/strfromf128.c: New file.
---
 NEWS                                   |   3 +
 include/gmp.h                          |   2 +
 stdio-common/printf-parsemb.c          |   1 +
 stdio-common/printf.h                  |   4 +-
 stdio-common/printf_fp.c               | 103 ++++++++++++++++++++++++-
 stdio-common/printf_fphex.c            | 134 +++++++++++++++++++++++++++++++++
 stdio-common/printf_size.c             |  29 +++++++
 stdio-common/vfprintf.c                |  10 ++-
 stdlib/fpioconst.h                     |   4 +
 stdlib/stdlib.h                        |   8 ++
 stdlib/strfrom-skeleton.c              |   6 ++
 sysdeps/ieee754/float128/Makefile      |   2 +-
 sysdeps/ieee754/float128/Versions      |   5 ++
 sysdeps/ieee754/float128/strfromf128.c |  25 ++++++
 14 files changed, 328 insertions(+), 8 deletions(-)
 create mode 100644 sysdeps/ieee754/float128/strfromf128.c

diff --git a/NEWS b/NEWS
index b4ecd62..8cb17cc 100644
--- a/NEWS
+++ b/NEWS
@@ -66,6 +66,9 @@ Version 2.26
 * The port to Native Client running on ARMv7-A (--host=arm-nacl) has been
   removed.
 
+* The function strfromf128, from ISO/IEC TS 18661-3:2015, is added to libc.
+  It converts a _Float128 value into string.
+
 Security related changes:
 
 * The DNS stub resolver limits the advertised UDP buffer size to 1200 bytes,
diff --git a/include/gmp.h b/include/gmp.h
index 95d6c16..e6f635e 100644
--- a/include/gmp.h
+++ b/include/gmp.h
@@ -6,6 +6,8 @@
 
 #include <stdlib/gmp.h>
 
+#include <bits/floatn.h>
+
 /* Now define the internal interfaces.  */
 extern mp_size_t __mpn_extract_double (mp_ptr res_ptr, mp_size_t size,
 				       int *expt, int *is_neg,
diff --git a/stdio-common/printf-parsemb.c b/stdio-common/printf-parsemb.c
index edb066e..a42336c 100644
--- a/stdio-common/printf-parsemb.c
+++ b/stdio-common/printf-parsemb.c
@@ -79,6 +79,7 @@ __parse_one_specmb (const UCHAR_T *format, size_t posn,
   spec->info.extra = 0;
   spec->info.pad = ' ';
   spec->info.wide = sizeof (UCHAR_T) > 1;
+  spec->info.is_binary128 = 0;
 
   /* Test for positional argument.  */
   if (ISDIGIT (*format))
diff --git a/stdio-common/printf.h b/stdio-common/printf.h
index 5d82e8d..6b207d2 100644
--- a/stdio-common/printf.h
+++ b/stdio-common/printf.h
@@ -47,7 +47,9 @@ struct printf_info
   unsigned int is_char:1;	/* hh flag.  */
   unsigned int wide:1;		/* Nonzero for wide character streams.  */
   unsigned int i18n:1;		/* I flag.  */
-  unsigned int __pad:4;		/* Unused so far.  */
+  unsigned int is_binary128:1;	/* Floating-point argument is ABI-compatible
+				   with IEC 60559 binary128.  */
+  unsigned int __pad:3;		/* Unused so far.  */
   unsigned short int user;	/* Bits for user-installed modifiers.  */
   wchar_t pad;			/* Padding character.  */
 };
diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c
index 7845d96..f6335c5 100644
--- a/stdio-common/printf_fp.c
+++ b/stdio-common/printf_fp.c
@@ -218,6 +218,9 @@ __printf_fp_l (FILE *fp, locale_t loc,
     {
       double dbl;
       __long_double_t ldbl;
+#if __HAVE_DISTINCT_FLOAT128
+      _Float128 f128;
+#endif
     }
   fpnum;
 
@@ -234,9 +237,17 @@ __printf_fp_l (FILE *fp, locale_t loc,
   const char *special = NULL;
   const wchar_t *wspecial = NULL;
 
+  /* When _Float128 is enabled in the library and ABI-distinct from long
+     double, we need mp_limbs enough for any of them.  */
+#if __HAVE_DISTINCT_FLOAT128
+# define GREATER_MANT_DIG FLT128_MANT_DIG
+#else
+# define GREATER_MANT_DIG LDBL_MANT_DIG
+#endif
   /* We need just a few limbs for the input before shifting to the right
      position.	*/
-  mp_limb_t fp_input[(LDBL_MANT_DIG + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB];
+  mp_limb_t fp_input[(GREATER_MANT_DIG + BITS_PER_MP_LIMB - 1)
+		     / BITS_PER_MP_LIMB];
   /* We need to shift the contents of fp_input by this amount of bits.	*/
   int to_shift = 0;
 
@@ -328,6 +339,52 @@ __printf_fp_l (FILE *fp, locale_t loc,
     grouping = NULL;
 
   /* Fetch the argument value.	*/
+#if __HAVE_DISTINCT_FLOAT128
+  if (info->is_binary128)
+    {
+      fpnum.f128 = *(const _Float128 *) args[0];
+
+      /* Check for special values: not a number or infinity.  */
+      if (isnan (fpnum.f128))
+	{
+	  is_neg = signbit (fpnum.f128);
+	  if (isupper (info->spec))
+	    {
+	      special = "NAN";
+	      wspecial = L"NAN";
+	    }
+	    else
+	      {
+		special = "nan";
+		wspecial = L"nan";
+	      }
+	}
+      else if (isinf (fpnum.f128))
+	{
+	  is_neg = signbit (fpnum.f128);
+	  if (isupper (info->spec))
+	    {
+	      special = "INF";
+	      wspecial = L"INF";
+	    }
+	  else
+	    {
+	      special = "inf";
+	      wspecial = L"inf";
+	    }
+	}
+      else
+	{
+	  p.fracsize = __mpn_extract_float128 (fp_input,
+					       (sizeof (fp_input) /
+						sizeof (fp_input[0])),
+					       &p.exponent, &is_neg,
+					       fpnum.f128);
+	  to_shift = 1 + p.fracsize * BITS_PER_MP_LIMB - FLT128_MANT_DIG;
+	}
+    }
+  else
+#endif /* __HAVE_DISTINCT_FLOAT128 */
 #ifndef __NO_LONG_DOUBLE_MATH
   if (info->is_long_double && sizeof (long double) > sizeof (double))
     {
@@ -450,7 +507,8 @@ __printf_fp_l (FILE *fp, locale_t loc,
   {
     mp_size_t bignum_size = ((abs (p.exponent) + BITS_PER_MP_LIMB - 1)
 			     / BITS_PER_MP_LIMB
-			     + (LDBL_MANT_DIG / BITS_PER_MP_LIMB > 2 ? 8 : 4))
+			     + (GREATER_MANT_DIG / BITS_PER_MP_LIMB > 2
+				? 8 : 4))
 			    * sizeof (mp_limb_t);
     p.frac = (mp_limb_t *) alloca (bignum_size);
     p.tmp = (mp_limb_t *) alloca (bignum_size);
@@ -465,7 +523,15 @@ __printf_fp_l (FILE *fp, locale_t loc,
     {
       /* |FP| >= 8.0.  */
       int scaleexpo = 0;
-      int explog = LDBL_MAX_10_EXP_LOG;
+      int explog;
+#if __HAVE_DISTINCT_FLOAT128
+      if (info->is_binary128)
+	explog = FLT128_MAX_10_EXP_LOG;
+      else
+	explog = LDBL_MAX_10_EXP_LOG;
+#else
+      explog = LDBL_MAX_10_EXP_LOG;
+#endif
       int exp10 = 0;
       const struct mp_power *powers = &_fpioconst_pow10[explog + 1];
       int cnt_h, cnt_l, i;
@@ -499,6 +565,27 @@ __printf_fp_l (FILE *fp, locale_t loc,
 	    {
 	      if (p.scalesize == 0)
 		{
+#if __HAVE_DISTINCT_FLOAT128
+		  if ((FLT128_MANT_DIG
+			    > _FPIO_CONST_OFFSET * BITS_PER_MP_LIMB)
+			   && info->is_binary128)
+		    {
+#define _FLT128_FPIO_CONST_SHIFT \
+  (((FLT128_MANT_DIG + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB) \
+   - _FPIO_CONST_OFFSET)
+		      /* 64bit const offset is not enough for
+			 IEEE 854 quad long double (_Float128).  */
+		      p.tmpsize = powers->arraysize + _FLT128_FPIO_CONST_SHIFT;
+		      memcpy (p.tmp + _FLT128_FPIO_CONST_SHIFT,
+			      &__tens[powers->arrayoff],
+			      p.tmpsize * sizeof (mp_limb_t));
+		      MPN_ZERO (p.tmp, _FLT128_FPIO_CONST_SHIFT);
+		      /* Adjust p.exponent, as scaleexpo will be this much
+			 bigger too.  */
+		      p.exponent += _FLT128_FPIO_CONST_SHIFT * BITS_PER_MP_LIMB;
+		    }
+		  else
+#endif /* __HAVE_DISTINCT_FLOAT128 */
 #ifndef __NO_LONG_DOUBLE_MATH
 		  if (LDBL_MANT_DIG > _FPIO_CONST_OFFSET * BITS_PER_MP_LIMB
 		      && info->is_long_double)
@@ -639,7 +726,15 @@ __printf_fp_l (FILE *fp, locale_t loc,
     {
       /* |FP| < 1.0.  */
       int exp10 = 0;
-      int explog = LDBL_MAX_10_EXP_LOG;
+      int explog;
+#if __HAVE_DISTINCT_FLOAT128
+      if (info->is_binary128)
+	explog = FLT128_MAX_10_EXP_LOG;
+      else
+	explog = LDBL_MAX_10_EXP_LOG;
+#else
+      explog = LDBL_MAX_10_EXP_LOG;
+#endif
       const struct mp_power *powers = &_fpioconst_pow10[explog + 1];
 
       /* Now shift the input value to its right place.	*/
diff --git a/stdio-common/printf_fphex.c b/stdio-common/printf_fphex.c
index b207e00..d5573b1 100644
--- a/stdio-common/printf_fphex.c
+++ b/stdio-common/printf_fphex.c
@@ -31,6 +31,10 @@
 #include <stdbool.h>
 #include <rounding-mode.h>
 
+#if __HAVE_DISTINCT_FLOAT128
+# include "ieee754_float128.h"
+#endif
+
 /* #define NDEBUG 1*/		/* Undefine this for debugging assertions.  */
 #include <assert.h>
 
@@ -94,6 +98,9 @@ __printf_fphex (FILE *fp,
     {
       union ieee754_double dbl;
       long double ldbl;
+#if __HAVE_DISTINCT_FLOAT128
+      _Float128 flt128;
+#endif
     }
   fpnum;
 
@@ -159,6 +166,45 @@ __printf_fphex (FILE *fp,
 
 
   /* Fetch the argument value.	*/
+#if __HAVE_DISTINCT_FLOAT128
+  if (info->is_binary128)
+    {
+      fpnum.flt128 = *(const _Float128 *) args[0];
+
+      /* Check for special values: not a number or infinity.  */
+      if (isnan (fpnum.flt128))
+	{
+	  if (isupper (info->spec))
+	    {
+	      special = "NAN";
+	      wspecial = L"NAN";
+	    }
+	  else
+	    {
+	      special = "nan";
+	      wspecial = L"nan";
+	    }
+	}
+      else
+	{
+	  if (isinf (fpnum.flt128))
+	    {
+	      if (isupper (info->spec))
+		{
+		  special = "INF";
+		  wspecial = L"INF";
+		}
+	      else
+		{
+		  special = "inf";
+		  wspecial = L"inf";
+		}
+	    }
+	}
+      negative = signbit (fpnum.flt128);
+    }
+  else
+#endif  /* __HAVE_DISTINCT_FLOAT128 */
 #ifndef __NO_LONG_DOUBLE_MATH
   if (info->is_long_double && sizeof (long double) > sizeof (double))
     {
@@ -260,6 +306,94 @@ __printf_fphex (FILE *fp,
       return done;
     }
 
+#if __HAVE_DISTINCT_FLOAT128
+  /* This block is copied from sysdeps/ieee754/ldbl-128/printf_fphex.c.  */
+  if (info->is_binary128)
+    {
+      /* We have 112 bits of mantissa plus one implicit digit.  Since
+	 112 bits are representable without rest using hexadecimal
+	 digits we use only the implicit digits for the number before
+	 the decimal point.  */
+      unsigned long long int num0, num1;
+      union ieee854_float128 u;
+      u.d = fpnum.flt128;
+
+      num0 = (((unsigned long long int) u.ieee.mantissa0) << 32
+	     | u.ieee.mantissa1);
+      num1 = (((unsigned long long int) u.ieee.mantissa2) << 32
+	     | u.ieee.mantissa3);
+
+      zero_mantissa = (num0|num1) == 0;
+
+      if (sizeof (unsigned long int) > 6)
+	{
+	  numstr = _itoa_word (num1, numbuf + sizeof numbuf, 16,
+			       info->spec == 'A');
+	  wnumstr = _itowa_word (num1,
+				 wnumbuf + sizeof (wnumbuf) / sizeof (wchar_t),
+				 16, info->spec == 'A');
+	}
+      else
+	{
+	  numstr = _itoa (num1, numbuf + sizeof numbuf, 16,
+			  info->spec == 'A');
+	  wnumstr = _itowa (num1,
+			    wnumbuf + sizeof (wnumbuf) / sizeof (wchar_t),
+			    16, info->spec == 'A');
+	}
+
+      while (numstr > numbuf + (sizeof numbuf - 64 / 4))
+	{
+	  *--numstr = '0';
+	  *--wnumstr = L'0';
+	}
+
+      if (sizeof (unsigned long int) > 6)
+	{
+	  numstr = _itoa_word (num0, numstr, 16, info->spec == 'A');
+	  wnumstr = _itowa_word (num0, wnumstr, 16, info->spec == 'A');
+	}
+      else
+	{
+	  numstr = _itoa (num0, numstr, 16, info->spec == 'A');
+	  wnumstr = _itowa (num0, wnumstr, 16, info->spec == 'A');
+	}
+
+      /* Fill with zeroes.  */
+      while (numstr > numbuf + (sizeof numbuf - 112 / 4))
+	{
+	  *--numstr = '0';
+	  *--wnumstr = L'0';
+	}
+
+      leading = u.ieee.exponent == 0 ? '0' : '1';
+
+      exponent = u.ieee.exponent;
+
+      if (exponent == 0)
+	{
+	  if (zero_mantissa)
+	    expnegative = 0;
+	  else
+	    {
+	      /* This is a denormalized number.  */
+	      expnegative = 1;
+	      exponent = IEEE854_FLOAT128_BIAS - 1;
+	    }
+	}
+      else if (exponent >= IEEE854_FLOAT128_BIAS)
+	{
+	  expnegative = 0;
+	  exponent -= IEEE854_FLOAT128_BIAS;
+	}
+      else
+	{
+	  expnegative = 1;
+	  exponent = -(exponent - IEEE854_FLOAT128_BIAS);
+	}
+    }
+  else
+#endif /* __HAVE_DISTINCT_FLOAT128 */
   if (info->is_long_double == 0 || sizeof (double) == sizeof (long double))
     {
       /* We have 52 bits of mantissa plus one implicit digit.  Since
diff --git a/stdio-common/printf_size.c b/stdio-common/printf_size.c
index 9403aea..3449d17 100644
--- a/stdio-common/printf_size.c
+++ b/stdio-common/printf_size.c
@@ -104,6 +104,9 @@ __printf_size (FILE *fp, const struct printf_info *info,
     {
       union ieee754_double dbl;
       long double ldbl;
+#if __HAVE_DISTINCT_FLOAT128
+      _Float128 f128;
+#endif
     }
   fpnum;
   const void *ptr = &fpnum;
@@ -119,6 +122,32 @@ __printf_size (FILE *fp, const struct printf_info *info,
   int wide = info->wide;
 
   /* Fetch the argument value.	*/
+#if __HAVE_DISTINCT_FLOAT128
+  if (info->is_binary128)
+    {
+      fpnum.f128 = *(const _Float128 *) args[0];
+
+      /* Check for special values: not a number or infinity.  */
+      if (isnan (fpnum.f128))
+	{
+	  special = "nan";
+	  wspecial = L"nan";
+	}
+      else if (isinf (fpnum.f128))
+	{
+	  is_neg = signbit (fpnum.f128);
+	  special = "inf";
+	  wspecial = L"inf";
+	}
+      else
+	while (fpnum.f128 >= divisor && tag[1] != '\0')
+	  {
+	    fpnum.f128 /= divisor;
+	    ++tag;
+	  }
+    }
+  else
+#endif /* __HAVE_DISTINCT_FLOAT128 */
 #ifndef __NO_LONG_DOUBLE_MATH
   if (info->is_long_double && sizeof (long double) > sizeof (double))
     {
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index 2cf7c8a..b8c87a5 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -770,7 +770,8 @@ static const uint8_t jump_table[] =
 					.pad = pad,			      \
 					.extra = 0,			      \
 					.i18n = use_outdigits,		      \
-					.wide = sizeof (CHAR_T) != 1 };	      \
+					.wide = sizeof (CHAR_T) != 1,	      \
+					.is_binary128 = 0};		      \
 									      \
 	    if (is_long_double)						      \
 	      the_arg.pa_long_double = va_arg (ap, long double);	      \
@@ -788,6 +789,8 @@ static const uint8_t jump_table[] =
 		fspec->data_arg_type = PA_DOUBLE;			      \
 		fspec->info.is_long_double = 0;				      \
 	      }								      \
+	    /* Not supported by *printf functions.  */			      \
+	    fspec->info.is_binary128 = 0;				      \
 									      \
 	    function_done = __printf_fp (s, &fspec->info, &ptr);	      \
 	  }								      \
@@ -827,7 +830,8 @@ static const uint8_t jump_table[] =
 					.group = group,			      \
 					.pad = pad,			      \
 					.extra = 0,			      \
-					.wide = sizeof (CHAR_T) != 1 };	      \
+					.wide = sizeof (CHAR_T) != 1,	      \
+					.is_binary128 = 0};		      \
 									      \
 	    if (is_long_double)						      \
 	      the_arg.pa_long_double = va_arg (ap, long double);	      \
@@ -842,6 +846,8 @@ static const uint8_t jump_table[] =
 	    ptr = (const void *) &args_value[fspec->data_arg];		      \
 	    if (__ldbl_is_dbl)						      \
 	      fspec->info.is_long_double = 0;				      \
+	    /* Not supported by *printf functions.  */			      \
+	    fspec->info.is_binary128 = 0;				      \
 									      \
 	    function_done = __printf_fphex (s, &fspec->info, &ptr);	      \
 	  }								      \
diff --git a/stdlib/fpioconst.h b/stdlib/fpioconst.h
index 7e19b0d..aab46d6 100644
--- a/stdlib/fpioconst.h
+++ b/stdlib/fpioconst.h
@@ -44,6 +44,10 @@
    IBM extended precision).  */
 #include <bits/floatn.h>
 
+#if __HAVE_DISTINCT_FLOAT128
+# define FLT128_MAX_10_EXP_LOG	12 /* = floor(log_2(FLT128_MAX_10_EXP)) */
+#endif
+
 /* For strtold, we need powers of 10 up to floor (log_2 (LDBL_MANT_DIG
    - 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
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index 99125f2..1313aa5 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -51,6 +51,9 @@ __BEGIN_DECLS
 # endif
 #endif	/* X/Open or XPG7 and <sys/wait.h> not included.  */
 
+/* _FloatN API tests for enablement.  */
+#include <bits/floatn.h>
+
 /* Returned by `div'.  */
 typedef struct
   {
@@ -173,6 +176,11 @@ extern int strfromf (char *__dest, size_t __size, const char *__format,
 extern int strfroml (char *__dest, size_t __size, const char *__format,
 		     long double __f)
      __THROW __nonnull ((3));
+# if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
+extern int strfromf128 (char *__dest, size_t __size, const char * __format,
+			_Float128 __f)
+     __THROW __nonnull ((3));
+# endif
 #endif
 
 
diff --git a/stdlib/strfrom-skeleton.c b/stdlib/strfrom-skeleton.c
index 811a29c..5841919 100644
--- a/stdlib/strfrom-skeleton.c
+++ b/stdlib/strfrom-skeleton.c
@@ -132,6 +132,12 @@ STRFROM (char *dest, size_t size, const char *format, FLOAT f)
      which type of floating-point number is being passed.  */
   info.is_long_double = __builtin_types_compatible_p (FLOAT, long double);
 
+  /* Similarly, the function strfromf128 passes a floating-point number in
+     _Float128 format to printf_fp.  */
+#if __HAVE_DISTINCT_FLOAT128
+  info.is_binary128 = __builtin_types_compatible_p (FLOAT, _Float128);
+#endif
+
   /* Set info according to the format string.  */
   info.prec = precision;
   info.spec = specifier;
diff --git a/sysdeps/ieee754/float128/Makefile b/sysdeps/ieee754/float128/Makefile
index 6a7b0e0..c07586c 100644
--- a/sysdeps/ieee754/float128/Makefile
+++ b/sysdeps/ieee754/float128/Makefile
@@ -1,3 +1,3 @@
 ifeq ($(subdir),stdlib)
-routines += float1282mpn
+routines += float1282mpn strfromf128
 endif
diff --git a/sysdeps/ieee754/float128/Versions b/sysdeps/ieee754/float128/Versions
index 9f431d9..caf2064 100644
--- a/sysdeps/ieee754/float128/Versions
+++ b/sysdeps/ieee754/float128/Versions
@@ -2,6 +2,11 @@
 %ifndef FLOAT128_VERSION
 % error "float128-abi.h must define FLOAT128_VERSION"
 %endif
+libc {
+  FLOAT128_VERSION {
+    strfromf128;
+  }
+}
 libm {
   FLOAT128_VERSION {
     __acosf128_finite;
diff --git a/sysdeps/ieee754/float128/strfromf128.c b/sysdeps/ieee754/float128/strfromf128.c
new file mode 100644
index 0000000..597c7e6
--- /dev/null
+++ b/sysdeps/ieee754/float128/strfromf128.c
@@ -0,0 +1,25 @@
+/* Definitions for strfromf128.  Implementation in stdlib/strfrom-skeleton.c.
+
+   Copyright (C) 2017 Free Software Foundation, Inc.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   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/>.  */
+
+#define	FLOAT		_Float128
+#define STRFROM		strfromf128
+
+#include <bits/floatn.h>
+#include <float128_private.h>
+
+#include <stdlib/strfrom-skeleton.c>
-- 
2.4.11

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 4/6] float128: Add strtof128, wcstof128, and related functions.
  2017-05-26 12:57 [PATCH 0/6] Add string functions and libm tests for _Float128 Gabriel F. T. Gomes
                   ` (4 preceding siblings ...)
  2017-05-26 12:57 ` [PATCH 3/6] float128: Add strfromf128 Gabriel F. T. Gomes
@ 2017-05-26 12:57 ` Gabriel F. T. Gomes
  2017-05-26 16:07   ` Joseph Myers
  5 siblings, 1 reply; 20+ messages in thread
From: Gabriel F. T. Gomes @ 2017-05-26 12:57 UTC (permalink / raw)
  To: libc-alpha

From: "Paul E. Murphy" <murphyp@linux.vnet.ibm.com>

The implementations are contained with sysdeps/ieee754/float128 as
they are only built when _Float128 is enabled within libc/m.

2017-05-23  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>

	* NEWS: Mention the addition of strtof128 and wcstof128.

	* include/gmp.h (__mpn_construct_float128): New declaration.
	* include/stdlib.h: Include bits/floatn.h for _Float128 tests.
	(__strtof128_l): New declaration.
	(__strtof128_nan): Likewise.
	(__wcstof128_nan): Likewise.
	(__strtof128_internal): Likewise.
	(____strtof128_l_internal): Likewise.
	* include/wchar.h: Include bits/floatn.h for _Float128 tests.
	(__wcstof128_l): New declaration.
	(__wcstof128_internal): Likewise.

	* stdlib/Makefile (bug-strtod2): Link libm too.

	* stdlib/stdlib.h (strtof128): New declaration.
	(strtof128_l): Likewise.

	* stdlib/tst-strtod-nan-locale-main.c: Updated to use
	tst-strtod.h macros to ensure float128 gets tested too.

	* stdlib/tst-strtod-round-skeleton.c (CHOOSE_f128): New macro.

	* stdlib/tst-strtod.h: Include bits/floatn.h for _Float128
	tests.
	(_GEN_F128): New macro.
	(_GEN): Likewise.
	(_GENx): Likewise.
	(_DO_F128): Likewise.
	(_DO): Likewise.
	(_DOx): Likewise.
	(GEN_TEST_STRTOD): Update to optionally include _Float128 in
	the tests.
	(STRTOD_TEST_FOREACH): Likewise.

	* sysdeps/ieee754/float128/Makefile: Insert new strtof128 and
	wcstof128 functions into libc.

	* sysdeps/ieee754/float128/Versions: Add exports for the above
	new functions.

	* sysdeps/ieee754/float128/mpn2float128.c: New file.
	* sysdeps/ieee754/float128/strtod_nan_float128.h: New file.
	* sysdeps/ieee754/float128/strtof128.c: New file.
	* sysdeps/ieee754/float128/strtof128_l.c: New file.
	* sysdeps/ieee754/float128/strtof128_nan.c: New file.
	* sysdeps/ieee754/float128/wcstof128.c: New file.
	* sysdeps/ieee754/float128/wcstof128_l.c: New file.
	* sysdeps/ieee754/float128/wcstof128_nan.c: New fike.
	* wcsmbs/Makefile: (CFLAGS-wcstof128.c): Append strtox-CFLAGS.
	(CFLAGS-wcstof128_l): Likewise.

	* wcsmbs/wchar.h (wcstof128): New declaration.
	(wcstof128_l): Likewise.
---
 NEWS                                           |  4 ++
 include/gmp.h                                  |  4 ++
 include/stdlib.h                               | 29 ++++++++++++++
 include/wchar.h                                | 13 +++++++
 stdlib/Makefile                                |  1 +
 stdlib/stdlib.h                                | 15 ++++++++
 stdlib/tst-strtod-nan-locale-main.c            | 36 ++++++++---------
 stdlib/tst-strtod-round-skeleton.c             |  1 +
 stdlib/tst-strtod.h                            | 42 ++++++++++++++++----
 sysdeps/ieee754/float128/Makefile              |  5 +++
 sysdeps/ieee754/float128/Versions              | 10 +++++
 sysdeps/ieee754/float128/mpn2float128.c        | 53 ++++++++++++++++++++++++++
 sysdeps/ieee754/float128/strtod_nan_float128.h | 33 ++++++++++++++++
 sysdeps/ieee754/float128/strtof128.c           | 34 +++++++++++++++++
 sysdeps/ieee754/float128/strtof128_l.c         | 43 +++++++++++++++++++++
 sysdeps/ieee754/float128/strtof128_nan.c       | 28 ++++++++++++++
 sysdeps/ieee754/float128/wcstof128.c           | 29 ++++++++++++++
 sysdeps/ieee754/float128/wcstof128_l.c         | 30 +++++++++++++++
 sysdeps/ieee754/float128/wcstof128_nan.c       | 24 ++++++++++++
 wcsmbs/Makefile                                |  2 +
 wcsmbs/wchar.h                                 | 16 ++++++++
 21 files changed, 426 insertions(+), 26 deletions(-)
 create mode 100644 sysdeps/ieee754/float128/mpn2float128.c
 create mode 100644 sysdeps/ieee754/float128/strtod_nan_float128.h
 create mode 100644 sysdeps/ieee754/float128/strtof128.c
 create mode 100644 sysdeps/ieee754/float128/strtof128_l.c
 create mode 100644 sysdeps/ieee754/float128/strtof128_nan.c
 create mode 100644 sysdeps/ieee754/float128/wcstof128.c
 create mode 100644 sysdeps/ieee754/float128/wcstof128_l.c
 create mode 100644 sysdeps/ieee754/float128/wcstof128_nan.c

diff --git a/NEWS b/NEWS
index 8cb17cc..39e15fa 100644
--- a/NEWS
+++ b/NEWS
@@ -69,6 +69,10 @@ Version 2.26
 * The function strfromf128, from ISO/IEC TS 18661-3:2015, is added to libc.
   It converts a _Float128 value into string.
 
+* The function strtof128, from ISO/IEC TS 18661-3:2015, is added to libc.
+  It converts a string into a floating-point number of _Float128 type.  Its
+  wide character counterpart, wsctof128, is added as a GNU extension.
+
 Security related changes:
 
 * The DNS stub resolver limits the advertised UDP buffer size to 1200 bytes,
diff --git a/include/gmp.h b/include/gmp.h
index e6f635e..3590acf 100644
--- a/include/gmp.h
+++ b/include/gmp.h
@@ -31,5 +31,9 @@ extern double __mpn_construct_double (mp_srcptr frac_ptr, int expt,
 extern long double __mpn_construct_long_double (mp_srcptr frac_ptr, int expt,
 						int sign);
 
+#if __HAVE_DISTINCT_FLOAT128
+extern _Float128 __mpn_construct_float128 (mp_srcptr frac_ptr, int expt,
+					   int sign);
+#endif
 
 #endif
diff --git a/include/stdlib.h b/include/stdlib.h
index c3ee680..b8de20e 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -215,6 +215,35 @@ libc_hidden_proto (__wcstof_nan)
 libc_hidden_proto (__wcstod_nan)
 libc_hidden_proto (__wcstold_nan)
 
+/* Enable _FloatN bits as needed.  */
+#include <bits/floatn.h>
+
+#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (strtof128_l) __strtof128_l;
+
+libc_hidden_proto (__strtof128_l)
+libc_hidden_proto (strtof128)
+
+extern _Float128 __strtof128_nan (const char *, char **, char)
+     internal_function;
+extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t)
+     internal_function;
+
+libc_hidden_proto (__strtof128_nan)
+libc_hidden_proto (__wcstof128_nan)
+
+extern _Float128 __strtof128_internal (const char *__restrict __nptr,
+				       char **__restrict __endptr,
+				       int __group);
+libc_hidden_proto (__strtof128_internal)
+
+extern _Float128 ____strtof128_l_internal (const char *__restrict __nptr,
+					   char **__restrict __endptr,
+					   int __group, __locale_t __loc);
+
+libc_hidden_proto (____strtof128_l_internal)
+#endif
+
 extern char *__ecvt (double __value, int __ndigit, int *__restrict __decpt,
 		     int *__restrict __sign);
 extern char *__fcvt (double __value, int __ndigit, int *__restrict __decpt,
diff --git a/include/wchar.h b/include/wchar.h
index e2579a1..66e8aab 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -4,6 +4,8 @@
 # ifndef _ISOMAC
 # ifdef _WCHAR_H
 
+#include <bits/floatn.h>
+
 extern __typeof (wcscasecmp_l) __wcscasecmp_l;
 extern __typeof (wcsncasecmp_l) __wcsncasecmp_l;
 extern __typeof (wcscoll_l) __wcscoll_l;
@@ -70,6 +72,17 @@ libc_hidden_proto (wcstoll)
 libc_hidden_proto (wcstoul)
 libc_hidden_proto (wcstoull)
 
+#if __HAVE_DISTINCT_FLOAT128
+extern __typeof (wcstof128_l) __wcstof128_l;
+libc_hidden_proto (__wcstof128_l)
+extern _Float128 __wcstof128_internal (const wchar_t *__restrict __nptr,
+				       wchar_t **__restrict __endptr,
+				       int __group) __THROW;
+
+libc_hidden_proto (__wcstof128_internal)
+libc_hidden_proto (wcstof128)
+#endif
+
 libc_hidden_proto (__wcscasecmp_l)
 libc_hidden_proto (__wcsncasecmp_l)
 
diff --git a/stdlib/Makefile b/stdlib/Makefile
index 9b0acce..0314d59 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -198,6 +198,7 @@ $(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os $(link-libc-deps)
 libof-tst-putenvmod = extramodules
 
 $(objpfx)bug-getcontext: $(libm)
+$(objpfx)bug-strtod2: $(libm)
 $(objpfx)tst-strtod-round: $(libm)
 $(objpfx)tst-tininess: $(libm)
 $(objpfx)tst-strtod-underflow: $(libm)
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index 1313aa5..36987b4 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -128,6 +128,13 @@ extern long double strtold (const char *__restrict __nptr,
      __THROW __nonnull ((1));
 #endif
 
+#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
+/* Likewise for the '_Float128' format  */
+extern _Float128 strtof128 (const char *__restrict __nptr,
+		      char **__restrict __endptr)
+     __THROW __nonnull ((1));
+#endif
+
 /* Convert a string to a long integer.  */
 extern long int strtol (const char *__restrict __nptr,
 			char **__restrict __endptr, int __base)
@@ -235,6 +242,14 @@ extern long double strtold_l (const char *__restrict __nptr,
 			      char **__restrict __endptr,
 			      __locale_t __loc)
      __THROW __nonnull ((1, 3));
+
+# if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
+extern _Float128 strtof128_l (const char *__restrict __nptr,
+			      char **__restrict __endptr,
+			      __locale_t __loc)
+     __THROW __nonnull ((1, 3));
+# endif
+
 #endif /* GNU */
 
 
diff --git a/stdlib/tst-strtod-nan-locale-main.c b/stdlib/tst-strtod-nan-locale-main.c
index 8044dad..8222174 100644
--- a/stdlib/tst-strtod-nan-locale-main.c
+++ b/stdlib/tst-strtod-nan-locale-main.c
@@ -23,6 +23,8 @@
 #include <stdlib.h>
 #include <wchar.h>
 
+#include <stdlib/tst-strtod.h>
+
 #define STR_(X) #X
 #define STR(X) STR_(X)
 #define FNPFXS STR (FNPFX)
@@ -30,20 +32,22 @@
 #define CONCAT(X, Y) CONCAT_ (X, Y)
 #define FNX(FN) CONCAT (FNPFX, FN)
 
-#define TEST(LOC, STR, FN, TYPE)					\
-  do									\
+#define TEST_STRTOD(FSUF, FTYPE, FTOSTR, LSUF, CSUF)			\
+static int								\
+test_strto ## FSUF (const char * loc, CHAR * s)				\
+{									\
+  CHAR *ep;								\
+  FTYPE val = FNX (FSUF) (s, &ep);					\
+  if (isnan (val) && *ep == 0)						\
+    printf ("PASS: %s: " FNPFXS #FSUF " (" SFMT ")\n", loc, s);		\
+  else									\
     {									\
-      CHAR *ep;								\
-      TYPE val = FNX (FN) (STR, &ep);					\
-      if (isnan (val) && *ep == 0)					\
-	printf ("PASS: %s: " FNPFXS #FN " (" SFMT ")\n", LOC, STR);	\
-      else								\
-	{								\
-	  printf ("FAIL: %s: " FNPFXS #FN " (" SFMT ")\n", LOC, STR);	\
-	  result = 1;							\
-	}								\
+      printf ("FAIL: %s: " FNPFXS #FSUF " (" SFMT ")\n", loc, s);	\
+      return 1;							        \
     }									\
-  while (0)
+  return 0;								\
+}
+GEN_TEST_STRTOD_FOREACH (TEST_STRTOD)
 
 static int
 test_one_locale (const char *loc)
@@ -64,13 +68,9 @@ test_one_locale (const char *loc)
       s[4] = L_('A') + i - 10;
       s[5] = L_(')');
       s[6] = 0;
-      TEST (loc, s, f, float);
-      TEST (loc, s, d, double);
-      TEST (loc, s, ld, long double);
+      result |= STRTOD_TEST_FOREACH (test_strto, loc, s);
       s[4] = L_('a') + i - 10;
-      TEST (loc, s, f, float);
-      TEST (loc, s, d, double);
-      TEST (loc, s, ld, long double);
+      result |= STRTOD_TEST_FOREACH (test_strto, loc, s);
     }
   return result;
 }
diff --git a/stdlib/tst-strtod-round-skeleton.c b/stdlib/tst-strtod-round-skeleton.c
index 73603e6..1a9f663 100644
--- a/stdlib/tst-strtod-round-skeleton.c
+++ b/stdlib/tst-strtod-round-skeleton.c
@@ -93,6 +93,7 @@
 /* Add type specific choosing macros below.  */
 #define CHOOSE_f(f,...) f
 #define CHOOSE_d(f,d,...) d
+#define CHOOSE_f128(f,d,ld64i,ld64m,ld106,ld113,...) ld113
 /* long double is special, and handled above.  */
 
 /* Selector for expected result field of a given type.  */
diff --git a/stdlib/tst-strtod.h b/stdlib/tst-strtod.h
index bf5f901..d862a67 100644
--- a/stdlib/tst-strtod.h
+++ b/stdlib/tst-strtod.h
@@ -21,11 +21,36 @@
 
 #define FSTRLENMAX 128
 
+#include <bits/floatn.h>
+
+#if !__GNUC_PREREQ(7,0)
+# define F128 Q
+#endif
+
+/* Test strfromf128 and strtof128 on all platforms that provide them,
+   whether or not the type _FLoat128 is ABI-distinct from long double.  */
+#if __HAVE_FLOAT128
+# define _GEN_f128(mfunc, ...) mfunc (__VA_ARGS__)
+# define _DO_f128(mfunc,...) (mfunc ## f128) (__VA_ARGS__)
+# ifndef CHAR
+#  define CHAR char
+# endif
+#else
+# define _GEN_f128(...)
+# define _DO_f128(...) 0
+#endif
+
+#define _GEN(mfunc, type, ...) _GENx(_GEN_ ## type, mfunc, type, __VA_ARGS__)
+#define _GENx(mmfunc, mfunc, type, ...) mmfunc (mfunc, type, __VA_ARGS__)
+#define _DO(mfunc, type, ...) _DOx(_DO_ ## type, mfunc, ##__VA_ARGS__)
+#define _DOx(mmfunc, mfunc, ...) mmfunc (mfunc, ##__VA_ARGS__)
+
 /* Splat n variants of the same test for the various strtod functions.  */
 #define GEN_TEST_STRTOD_FOREACH(mfunc, ...)			 \
     mfunc (  f,       float, strfromf, f, f, ##__VA_ARGS__)	 \
     mfunc (  d,      double, strfromd,  ,  , ##__VA_ARGS__)	 \
-    mfunc ( ld, long double, strfroml, L, l, ##__VA_ARGS__)
+    mfunc ( ld, long double, strfroml, L, l, ##__VA_ARGS__)	 \
+    _GEN ( mfunc,  f128, _Float128,   strfromf128, F128, f128, ##__VA_ARGS__)
 /* The arguments to the generated macros are:
    FSUF - Function suffix
    FTYPE - float type
@@ -36,13 +61,14 @@
 
 
 
-#define STRTOD_TEST_FOREACH(mfunc, ...)	  \
-({					  \
-   int result = 0;			  \
-   result |= mfunc ## f  (__VA_ARGS__);   \
-   result |= mfunc ## d  (__VA_ARGS__);   \
-   result |= mfunc ## ld (__VA_ARGS__);   \
-   result;				  \
+#define STRTOD_TEST_FOREACH(mfunc, ...)		\
+({						\
+   int result = 0;				\
+   result |= mfunc ## f  (__VA_ARGS__);		\
+   result |= mfunc ## d  (__VA_ARGS__);		\
+   result |= mfunc ## ld (__VA_ARGS__);		\
+   result |= _DO (mfunc, f128, ##__VA_ARGS__);	\
+   result;					\
 })
 
 
diff --git a/sysdeps/ieee754/float128/Makefile b/sysdeps/ieee754/float128/Makefile
index c07586c..166e630 100644
--- a/sysdeps/ieee754/float128/Makefile
+++ b/sysdeps/ieee754/float128/Makefile
@@ -1,3 +1,8 @@
 ifeq ($(subdir),stdlib)
 routines += float1282mpn strfromf128
+routines += strtof128 strtof128_l strtof128_nan mpn2float128
+endif
+
+ifeq ($(subdir),wcsmbs)
+routines += wcstof128_l wcstof128 wcstof128_nan
 endif
diff --git a/sysdeps/ieee754/float128/Versions b/sysdeps/ieee754/float128/Versions
index caf2064..ef9df2d 100644
--- a/sysdeps/ieee754/float128/Versions
+++ b/sysdeps/ieee754/float128/Versions
@@ -4,7 +4,17 @@
 %endif
 libc {
   FLOAT128_VERSION {
+    __strtof128_internal;
+    __wcstof128_internal;
     strfromf128;
+    strtof128;
+    strtof128_l;
+    wcstof128;
+    wcstof128_l;
+  }
+  GLIBC_PRIVATE {
+    # For __nanf128.
+    __strtof128_nan;
   }
 }
 libm {
diff --git a/sysdeps/ieee754/float128/mpn2float128.c b/sysdeps/ieee754/float128/mpn2float128.c
new file mode 100644
index 0000000..ad2e699
--- /dev/null
+++ b/sysdeps/ieee754/float128/mpn2float128.c
@@ -0,0 +1,53 @@
+/* Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   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/>.  */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include <float.h>
+#include <math.h>
+
+#include "ieee754_float128.h"
+
+/* Convert a multi-precision integer of the needed number of bits (113 for
+   binary128) and an integral power of two to a `__float128' in IEEE854
+   quad-precision format.  */
+
+_Float128
+__mpn_construct_float128 (mp_srcptr frac_ptr, int expt, int sign)
+{
+  union ieee854_float128 u;
+
+  u.ieee.negative = sign;
+  u.ieee.exponent = expt + IEEE854_FLOAT128_BIAS;
+#if BITS_PER_MP_LIMB == 32
+  u.ieee.mantissa3 = frac_ptr[0];
+  u.ieee.mantissa2 = frac_ptr[1];
+  u.ieee.mantissa1 = frac_ptr[2];
+  u.ieee.mantissa0 = frac_ptr[3] & (((mp_limb_t) 1
+				     << (FLT128_MANT_DIG - 96)) - 1);
+#elif BITS_PER_MP_LIMB == 64
+  u.ieee.mantissa3 = frac_ptr[0] & (((mp_limb_t) 1 << 32) - 1);
+  u.ieee.mantissa2 = frac_ptr[0] >> 32;
+  u.ieee.mantissa1 = frac_ptr[1] & (((mp_limb_t) 1 << 32) - 1);
+  u.ieee.mantissa0 = (frac_ptr[1] >> 32) & (((mp_limb_t) 1
+					     << (FLT128_MANT_DIG - 96)) - 1);
+#else
+  #error "mp_limb size " BITS_PER_MP_LIMB "not accounted for"
+#endif
+
+  return u.d;
+}
diff --git a/sysdeps/ieee754/float128/strtod_nan_float128.h b/sysdeps/ieee754/float128/strtod_nan_float128.h
new file mode 100644
index 0000000..79329fb
--- /dev/null
+++ b/sysdeps/ieee754/float128/strtod_nan_float128.h
@@ -0,0 +1,33 @@
+/* Convert string for NaN payload to corresponding NaN.  For _Float128.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   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/>.  */
+
+#define FLOAT		_Float128
+#define SET_MANTISSA(flt, mant)				\
+  do							\
+    {							\
+      union ieee854_float128 u;				\
+      u.d = (flt);					\
+      u.ieee_nan.mantissa0 = 0;				\
+      u.ieee_nan.mantissa1 = 0;				\
+      u.ieee_nan.mantissa2 = (mant) >> 32;		\
+      u.ieee_nan.mantissa3 = (mant);			\
+      if ((u.ieee.mantissa0 | u.ieee.mantissa1		\
+	   | u.ieee.mantissa2 | u.ieee.mantissa3) != 0)	\
+	(flt) = u.d;					\
+    }							\
+  while (0)
diff --git a/sysdeps/ieee754/float128/strtof128.c b/sysdeps/ieee754/float128/strtof128.c
new file mode 100644
index 0000000..63cc80d
--- /dev/null
+++ b/sysdeps/ieee754/float128/strtof128.c
@@ -0,0 +1,34 @@
+/* strtof128 wrapper of strtof128_l.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   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/>.  */
+
+/* The actual implementation for all floating point sizes is in strtod.c.
+   These macros tell it to produce the `_Float128' version, `strtof128'.  */
+
+#define FLOAT		_Float128
+#define FLT		FLT128
+#ifdef USE_WIDE_CHAR
+# define STRTOF		wcstof128
+# define STRTOF_L	__wcstof128_l
+#else
+# define STRTOF		strtof128
+# define STRTOF_L	__strtof128_l
+#endif
+
+#include <float128_private.h>
+
+#include <stdlib/strtod.c>
diff --git a/sysdeps/ieee754/float128/strtof128_l.c b/sysdeps/ieee754/float128/strtof128_l.c
new file mode 100644
index 0000000..0f768a3
--- /dev/null
+++ b/sysdeps/ieee754/float128/strtof128_l.c
@@ -0,0 +1,43 @@
+/* Convert string representing a number to a _Float128 value, with locale.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   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/>.  */
+
+#include <xlocale.h>
+
+/* Bring in potential typedef for _Float128 early for declaration below.  */
+#include <bits/floatn.h>
+
+extern _Float128 ____strtof128_l_internal (const char *, char **,
+					   int, __locale_t);
+
+#define	FLOAT		_Float128
+#define	FLT		FLT128
+#ifdef USE_WIDE_CHAR
+# define STRTOF		wcstof128_l
+# define __STRTOF	__wcstof128_l
+# define STRTOF_NAN	__wcstof128_nan
+#else
+# define STRTOF		strtof128_l
+# define __STRTOF	__strtof128_l
+# define STRTOF_NAN	__strtof128_nan
+#endif
+#define	MPN2FLOAT	__mpn_construct_float128
+#define	FLOAT_HUGE_VAL	__builtin_huge_valf128 ()
+
+#include <float128_private.h>
+
+#include <stdlib/strtod_l.c>
diff --git a/sysdeps/ieee754/float128/strtof128_nan.c b/sysdeps/ieee754/float128/strtof128_nan.c
new file mode 100644
index 0000000..b9d79e3
--- /dev/null
+++ b/sysdeps/ieee754/float128/strtof128_nan.c
@@ -0,0 +1,28 @@
+/* Convert string for NaN payload to corresponding NaN.  Narrow
+   strings, __float128.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   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/>.  */
+
+#include <math.h>
+
+#include <float128_private.h>
+
+#include <strtod_nan_narrow.h>
+#include <strtod_nan_float128.h>
+
+#define STRTOD_NAN __strtof128_nan
+#include <stdlib/strtod_nan_main.c>
diff --git a/sysdeps/ieee754/float128/wcstof128.c b/sysdeps/ieee754/float128/wcstof128.c
new file mode 100644
index 0000000..d87eff9
--- /dev/null
+++ b/sysdeps/ieee754/float128/wcstof128.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   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/>.  */
+
+#include <stddef.h>
+#include <xlocale.h>
+
+#define	USE_WIDE_CHAR	1
+
+/* Bring in _Float128 typedef if needed.  */
+#include <bits/floatn.h>
+
+extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
+					   __locale_t);
+
+#include "strtof128.c"
diff --git a/sysdeps/ieee754/float128/wcstof128_l.c b/sysdeps/ieee754/float128/wcstof128_l.c
new file mode 100644
index 0000000..670b6af
--- /dev/null
+++ b/sysdeps/ieee754/float128/wcstof128_l.c
@@ -0,0 +1,30 @@
+/* Convert string representing a number to integer value, using given locale.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   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/>.  */
+
+#include <stddef.h>
+#include <xlocale.h>
+
+
+#define	USE_WIDE_CHAR	1
+
+#include <bits/floatn.h>
+
+extern _Float128 ____wcstof128_l_internal (const wchar_t *, wchar_t **, int,
+					   __locale_t);
+
+#include "strtof128_l.c"
diff --git a/sysdeps/ieee754/float128/wcstof128_nan.c b/sysdeps/ieee754/float128/wcstof128_nan.c
new file mode 100644
index 0000000..abad881
--- /dev/null
+++ b/sysdeps/ieee754/float128/wcstof128_nan.c
@@ -0,0 +1,24 @@
+/* Convert string for NaN payload to corresponding NaN.  Wide strings,
+   _Float128.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   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/>.  */
+
+#include <stdlib/strtod_nan_wide.h>
+#include <float128_private.h>
+#include <strtod_nan_float128.h>
+#define STRTOD_NAN __wcstof128_nan
+#include <stdlib/strtod_nan_main.c>
diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
index d6b214b..84cf986 100644
--- a/wcsmbs/Makefile
+++ b/wcsmbs/Makefile
@@ -81,6 +81,7 @@ CFLAGS-wcstoll.c = $(strtox-CFLAGS)
 CFLAGS-wcstoull.c = $(strtox-CFLAGS)
 CFLAGS-wcstod.c = $(strtox-CFLAGS)
 CFLAGS-wcstold.c = $(strtox-CFLAGS)
+CFLAGS-wcstof128.c = $(strtox-CFLAGS)
 CFLAGS-wcstof.c = $(strtox-CFLAGS)
 CFLAGS-wcstol_l.c = $(strtox-CFLAGS)
 CFLAGS-wcstoul_l.c = $(strtox-CFLAGS)
@@ -88,6 +89,7 @@ CFLAGS-wcstoll_l.c = $(strtox-CFLAGS)
 CFLAGS-wcstoull_l.c = $(strtox-CFLAGS)
 CFLAGS-wcstod_l.c = $(strtox-CFLAGS)
 CFLAGS-wcstold_l.c = $(strtox-CFLAGS)
+CFLAGS-wcstof128_l.c = $(strtox-CFLAGS)
 CFLAGS-wcstof_l.c = $(strtox-CFLAGS)
 CPPFLAGS-tst-wchar-h.c = -D_FORTIFY_SOURCE=2
 
diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
index 79be9fc..ba89c22 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -468,6 +468,15 @@ __extension__
 extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr,
 				       wchar_t **__restrict __endptr,
 				       int __base) __THROW;
+
+/* Include _Float128 variants of strtof128 if available.  */
+#include <bits/floatn.h>
+
+#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
+extern _Float128 wcstof128 (const wchar_t *__restrict __nptr,
+			    wchar_t **__restrict __endptr) __THROW;
+#endif
+
 #endif /* Use GNU.  */
 
 #ifdef __USE_GNU
@@ -518,6 +527,13 @@ extern float wcstof_l (const wchar_t *__restrict __nptr,
 extern long double wcstold_l (const wchar_t *__restrict __nptr,
 			      wchar_t **__restrict __endptr,
 			      __locale_t __loc) __THROW;
+
+#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
+extern _Float128 wcstof128_l (const wchar_t *__restrict __nptr,
+			      wchar_t **__restrict __endptr,
+			      __locale_t __loc) __THROW;
+#endif
+
 #endif	/* use GNU */
 
 
-- 
2.4.11

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/6] float128: Extend the power of ten tables
  2017-05-26 12:57 [PATCH 0/6] Add string functions and libm tests for _Float128 Gabriel F. T. Gomes
                   ` (2 preceding siblings ...)
  2017-05-26 12:57 ` [PATCH 5/6] float128: Add strfromf128, strtof128, and wcstof128 to the manual Gabriel F. T. Gomes
@ 2017-05-26 12:57 ` Gabriel F. T. Gomes
  2017-05-26 15:30   ` Joseph Myers
  2017-05-26 12:57 ` [PATCH 3/6] float128: Add strfromf128 Gabriel F. T. Gomes
  2017-05-26 12:57 ` [PATCH 4/6] float128: Add strtof128, wcstof128, and related functions Gabriel F. T. Gomes
  5 siblings, 1 reply; 20+ messages in thread
From: Gabriel F. T. Gomes @ 2017-05-26 12:57 UTC (permalink / raw)
  To: libc-alpha

From: "Paul E. Murphy" <murphyp@linux.vnet.ibm.com>

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.
---
 stdlib/fpioconst.c | 11 +++++++----
 stdlib/fpioconst.h | 11 +++++++++--
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/stdlib/fpioconst.c b/stdlib/fpioconst.c
index 7db7fa4..ba91108 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 */
 };
 \f
 #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
-- 
2.4.11

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 0/6] Add string functions and libm tests for _Float128
@ 2017-05-26 12:57 Gabriel F. T. Gomes
  2017-05-26 12:57 ` [PATCH 2/6] float128: Add conversion from float128 to mpn Gabriel F. T. Gomes
                   ` (5 more replies)
  0 siblings, 6 replies; 20+ messages in thread
From: Gabriel F. T. Gomes @ 2017-05-26 12:57 UTC (permalink / raw)
  To: libc-alpha

Testing of these patches was done using the branch tuliom/float128, where
we keep the remaining patches to enable float128 on powerpc64le.

Gabriel F. T. Gomes (3):
  float128: Add conversion from float128 to mpn
  float128: Add strfromf128
  float128: Add strfromf128, strtof128, and wcstof128 to the manual

Paul E. Murphy (3):
  float128: Extend the power of ten tables
  float128: Add strtof128, wcstof128, and related functions.
  float128: Add test-{float128,ifloat128,float128-finite}

 NEWS                                           |   7 ++
 include/gmp.h                                  |  12 +++
 include/stdlib.h                               |  29 ++++++
 include/wchar.h                                |  13 +++
 manual/arith.texi                              |  39 ++++++--
 math/gen-libm-test.pl                          |   4 +-
 math/libm-test-exp10.inc                       |   2 +
 math/libm-test-lgamma.inc                      |   2 +
 math/libm-test-nexttoward.inc                  |   4 +
 math/libm-test-remainder.inc                   |   2 +
 math/libm-test-scalb.inc                       |   4 +
 math/libm-test-significand.inc                 |   4 +
 math/libm-test-support.c                       |   4 +-
 math/libm-test-support.h                       |  10 +-
 math/test-float128.h                           |  63 ++++++++++++
 math/test-math-floatn.h                        |  21 ++++
 misc/sys/param.h                               |   8 +-
 stdio-common/printf-parsemb.c                  |   1 +
 stdio-common/printf.h                          |   4 +-
 stdio-common/printf_fp.c                       |  70 +++++++++++++
 stdio-common/printf_fphex.c                    | 133 +++++++++++++++++++++++++
 stdio-common/printf_size.c                     |  29 ++++++
 stdio-common/vfprintf.c                        |  10 +-
 stdlib/Makefile                                |   1 +
 stdlib/fpioconst.c                             |  11 +-
 stdlib/fpioconst.h                             |  15 ++-
 stdlib/stdlib.h                                |  23 +++++
 stdlib/strfrom-skeleton.c                      |   6 ++
 stdlib/tst-strtod-nan-locale-main.c            |  36 +++----
 stdlib/tst-strtod-round-skeleton.c             |   1 +
 stdlib/tst-strtod.h                            |  42 ++++++--
 sysdeps/ieee754/float128/Makefile              |   8 ++
 sysdeps/ieee754/float128/Versions              |  15 +++
 sysdeps/ieee754/float128/float1282mpn.c        |  20 ++++
 sysdeps/ieee754/float128/mpn2float128.c        |  53 ++++++++++
 sysdeps/ieee754/float128/strfromf128.c         |  25 +++++
 sysdeps/ieee754/float128/strtod_nan_float128.h |  33 ++++++
 sysdeps/ieee754/float128/strtof128.c           |  34 +++++++
 sysdeps/ieee754/float128/strtof128_l.c         |  43 ++++++++
 sysdeps/ieee754/float128/strtof128_nan.c       |  28 ++++++
 sysdeps/ieee754/float128/wcstof128.c           |  29 ++++++
 sysdeps/ieee754/float128/wcstof128_l.c         |  30 ++++++
 sysdeps/ieee754/float128/wcstof128_nan.c       |  24 +++++
 sysdeps/ieee754/ldbl-128/ldbl2mpn.c            |  18 +++-
 wcsmbs/Makefile                                |   2 +
 wcsmbs/wchar.h                                 |  16 +++
 46 files changed, 937 insertions(+), 51 deletions(-)
 create mode 100644 math/test-float128.h
 create mode 100644 math/test-math-floatn.h
 create mode 100644 sysdeps/ieee754/float128/Makefile
 create mode 100644 sysdeps/ieee754/float128/float1282mpn.c
 create mode 100644 sysdeps/ieee754/float128/mpn2float128.c
 create mode 100644 sysdeps/ieee754/float128/strfromf128.c
 create mode 100644 sysdeps/ieee754/float128/strtod_nan_float128.h
 create mode 100644 sysdeps/ieee754/float128/strtof128.c
 create mode 100644 sysdeps/ieee754/float128/strtof128_l.c
 create mode 100644 sysdeps/ieee754/float128/strtof128_nan.c
 create mode 100644 sysdeps/ieee754/float128/wcstof128.c
 create mode 100644 sysdeps/ieee754/float128/wcstof128_l.c
 create mode 100644 sysdeps/ieee754/float128/wcstof128_nan.c

-- 
2.4.11

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 6/6] float128: Add test-{float128,ifloat128,float128-finite}
  2017-05-26 12:57 [PATCH 0/6] Add string functions and libm tests for _Float128 Gabriel F. T. Gomes
  2017-05-26 12:57 ` [PATCH 2/6] float128: Add conversion from float128 to mpn Gabriel F. T. Gomes
@ 2017-05-26 12:57 ` Gabriel F. T. Gomes
  2017-05-26 16:26   ` Joseph Myers
  2017-05-26 12:57 ` [PATCH 5/6] float128: Add strfromf128, strtof128, and wcstof128 to the manual Gabriel F. T. Gomes
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 20+ messages in thread
From: Gabriel F. T. Gomes @ 2017-05-26 12:57 UTC (permalink / raw)
  To: libc-alpha

From: "Paul E. Murphy" <murphyp@linux.vnet.ibm.com>

This adds test support for float128, and lays some
groundwork for future _FloatN types.

	* math/Makefile
	(CFLAGS-test-float128.c): Add appropriate test flags.
	(CFLAGS-test-float128-finite.c): Likewise
	(CPPFLAGS-test-ifloat128.c): Likewise

	* math/test-support.h (CFLOAT): New macro to compensate for older
	compilers not supporting _Complex __float128.
	* math/libm-test-support.c (check_complex): Use CFLOAT instead
	of __complex__ FLOAT.

	* math/test-float128-finite.c: New file.
	* math/test-float128.c: New file.
	* math/test-float128.h: New file.
	* math/test-ifloat128.c: New file.
	* math/test-math-floatn.h: New file.

	* math/gen-libm-test.pl (all_floats): Add float128 variants.
	(all_floats_pfx): Add float128 mapping.

	* math/gen-libm-have-vector-test.sh: Add support for float128.
---
 math/gen-libm-test.pl          |  4 ++-
 math/libm-test-exp10.inc       |  2 ++
 math/libm-test-lgamma.inc      |  2 ++
 math/libm-test-nexttoward.inc  |  4 +++
 math/libm-test-remainder.inc   |  2 ++
 math/libm-test-scalb.inc       |  4 +++
 math/libm-test-significand.inc |  4 +++
 math/libm-test-support.c       |  4 +--
 math/libm-test-support.h       | 10 ++++++-
 math/test-float128.h           | 63 ++++++++++++++++++++++++++++++++++++++++++
 math/test-math-floatn.h        | 21 ++++++++++++++
 11 files changed, 116 insertions(+), 4 deletions(-)
 create mode 100644 math/test-float128.h
 create mode 100644 math/test-math-floatn.h

diff --git a/math/gen-libm-test.pl b/math/gen-libm-test.pl
index a931bc5..e82b2ac 100755
--- a/math/gen-libm-test.pl
+++ b/math/gen-libm-test.pl
@@ -45,13 +45,15 @@ use vars qw (%auto_tests);
 
 # all_floats is sorted and contains all recognised float types
 @all_floats = ('double', 'float', 'idouble',
-	       'ifloat', 'ildouble', 'ldouble');
+	       'ifloat', 'ildouble', 'ldouble',
+	       'ifloat128', 'float128');
 
 # all_floats_pfx maps C types to their C like prefix for macros.
 %all_floats_pfx =
   ( "double" => "DBL",
     "ldouble" => "LDBL",
     "float" => "FLT",
+    "float128" => "FLT128",
   );
 
 %beautify =
diff --git a/math/libm-test-exp10.inc b/math/libm-test-exp10.inc
index 92c81ad..374d12a 100644
--- a/math/libm-test-exp10.inc
+++ b/math/libm-test-exp10.inc
@@ -39,8 +39,10 @@ exp10_test (void)
 static void
 pow10_test (void)
 {
+#if !TEST_FLOATN
   /* pow10 uses the same test data as exp10.  */
   ALL_RM_TEST (pow10, 0, exp10_test_data, RUN_TEST_LOOP_f_f, END);
+#endif
 }
 
 static void
diff --git a/math/libm-test-lgamma.inc b/math/libm-test-lgamma.inc
index 9799aa9..0927dd0 100644
--- a/math/libm-test-lgamma.inc
+++ b/math/libm-test-lgamma.inc
@@ -45,8 +45,10 @@ lgamma_test (void)
 static void
 gamma_test (void)
 {
+#if !TEST_FLOATN
   /* gamma uses the same test data as lgamma.  */
   ALL_RM_TEST (gamma, 0, lgamma_test_data, RUN_TEST_LOOP_f_f1, END, signgam);
+#endif
 }
 
 static void
diff --git a/math/libm-test-nexttoward.inc b/math/libm-test-nexttoward.inc
index f05cf5f..37a9338 100644
--- a/math/libm-test-nexttoward.inc
+++ b/math/libm-test-nexttoward.inc
@@ -20,6 +20,7 @@
 
 static const struct test_fj_f_data nexttoward_test_data[] =
   {
+#if !TEST_FLOATN
     TEST_fj_f (nexttoward, 0, 0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
     TEST_fj_f (nexttoward, minus_zero, 0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
     TEST_fj_f (nexttoward, 0, minus_zero, minus_zero, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
@@ -80,6 +81,7 @@ static const struct test_fj_f_data nexttoward_test_data[] =
     TEST_fj_f (nexttoward, min_subnorm_value, minus_zero, 0, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_ERANGE),
     TEST_fj_f (nexttoward, -min_subnorm_value, 0, minus_zero, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_ERANGE),
     TEST_fj_f (nexttoward, -min_subnorm_value, minus_zero, minus_zero, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_ERANGE),
+#endif
 
 #if TEST_COND_binary32
     TEST_fj_f (nexttoward, 1.0, 1.1L, 0x1.000002p0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
@@ -153,7 +155,9 @@ static const struct test_fj_f_data nexttoward_test_data[] =
 static void
 nexttoward_test (void)
 {
+#if !TEST_FLOATN
   ALL_RM_TEST (nexttoward, 1, nexttoward_test_data, RUN_TEST_LOOP_fj_f, END);
+#endif
 }
 
 static void
diff --git a/math/libm-test-remainder.inc b/math/libm-test-remainder.inc
index ddeba66..65503c7 100644
--- a/math/libm-test-remainder.inc
+++ b/math/libm-test-remainder.inc
@@ -184,8 +184,10 @@ remainder_test (void)
 static void
 drem_test (void)
 {
+#if !TEST_FLOATN
   /* drem uses the same test data as remainder.  */
   ALL_RM_TEST (drem, 1, remainder_test_data, RUN_TEST_LOOP_ff_f, END);
+#endif
 }
 
 static void
diff --git a/math/libm-test-scalb.inc b/math/libm-test-scalb.inc
index 228a93d..b96f767 100644
--- a/math/libm-test-scalb.inc
+++ b/math/libm-test-scalb.inc
@@ -20,6 +20,7 @@
 
 static const struct test_ff_f_data scalb_test_data[] =
   {
+#if !TEST_FLOATN
     /* Results in this case are unspecified by POSIX, so, for an
        otherwise fully-determined function, spurious "inexact"
        exceptions are OK.  */
@@ -144,12 +145,15 @@ static const struct test_ff_f_data scalb_test_data[] =
 
     TEST_ff_f (scalb, 0.8L, 4, 12.8L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
     TEST_ff_f (scalb, -0.854375L, 5, -27.34L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
   };
 
 static void
 scalb_test (void)
 {
+#if !TEST_FLOATN
   ALL_RM_TEST (scalb, 1, scalb_test_data, RUN_TEST_LOOP_ff_f, END);
+#endif
 }
 
 static void
diff --git a/math/libm-test-significand.inc b/math/libm-test-significand.inc
index 372c076..5797e97 100644
--- a/math/libm-test-significand.inc
+++ b/math/libm-test-significand.inc
@@ -20,6 +20,7 @@
 
 static const struct test_f_f_data significand_test_data[] =
   {
+#if !TEST_FLOATN
     /* significand returns the mantissa of the exponential
        representation.  Tests for infinities, zero and NaNs reflect
        the implementation (including possibility of "inexact" and
@@ -45,12 +46,15 @@ static const struct test_f_f_data significand_test_data[] =
     TEST_f_f (significand, -6.0, -1.5, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
     TEST_f_f (significand, 8.0, 1.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
     TEST_f_f (significand, -8.0, -1.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
   };
 
 static void
 significand_test (void)
 {
+#if !TEST_FLOATN
   ALL_RM_TEST (significand, 1, significand_test_data, RUN_TEST_LOOP_f_f, END);
+#endif
 }
 
 static void
diff --git a/math/libm-test-support.c b/math/libm-test-support.c
index 07b8f25..7612d39 100644
--- a/math/libm-test-support.c
+++ b/math/libm-test-support.c
@@ -732,8 +732,8 @@ check_float (const char *test_name, FLOAT computed, FLOAT expected,
 
 
 void
-check_complex (const char *test_name, __complex__ FLOAT computed,
-	       __complex__ FLOAT expected,
+check_complex (const char *test_name, CFLOAT computed,
+	       CFLOAT expected,
 	       int exception)
 {
   FLOAT part_comp, part_exp;
diff --git a/math/libm-test-support.h b/math/libm-test-support.h
index 0e78144..a57a8b3 100644
--- a/math/libm-test-support.h
+++ b/math/libm-test-support.h
@@ -138,12 +138,20 @@ extern const char doc[];
 #define TEST_COND_before_rounding	(!TININESS_AFTER_ROUNDING)
 #define TEST_COND_after_rounding	TININESS_AFTER_ROUNDING
 
+#ifndef TEST_FLOATN
+# define TEST_FLOATN 0
+#endif
+
+#ifndef CFLOAT
+# define CFLOAT __complex__ FLOAT
+#endif
+
 int enable_test (int);
 void init_max_error (const char *, int);
 void print_max_error (const char *);
 void print_complex_max_error (const char *);
 void check_float (const char *, FLOAT, FLOAT, int);
-void check_complex (const char *, __complex__ FLOAT, __complex__ FLOAT, int);
+void check_complex (const char *, CFLOAT, CFLOAT, int);
 void check_int (const char *, int, int, int);
 void check_long (const char *, long int, long int, int);
 void check_bool (const char *, int, int, int);
diff --git a/math/test-float128.h b/math/test-float128.h
new file mode 100644
index 0000000..177c10c
--- /dev/null
+++ b/math/test-float128.h
@@ -0,0 +1,63 @@
+/* Common definitions for libm tests for _Float128.
+
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   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/>.  */
+
+#define FUNC(function) function ## f128
+#define PRINTF_EXPR "e"
+#define PRINTF_XEXPR "a"
+#define PRINTF_NEXPR "f"
+#define BUILD_COMPLEX(real, imag) (CMPLXF128 ((real), (imag)))
+#define PREFIX FLT128
+#define TYPE_STR "float128"
+#define LITM(x) x ## f128
+#define FTOSTR strfromf128
+#define snan_value_MACRO SNANF128
+
+/* Fixup builtins and constants for older compilers.  */
+#include <features.h>
+#if !__GNUC_PREREQ (7, 0)
+# define LIT(x) (x ## Q)
+# define FLOAT __float128
+# define CFLOAT __CFLOAT128
+/* The following macros are only provided since GCC 7.0.  */
+# define FLT128_MANT_DIG	113
+# define FLT128_DECIMAL_DIG	36
+# define FLT128_DIG		33
+# define FLT128_MIN_EXP		(-16381)
+# define FLT128_MIN_10_EXP	(-4931)
+# define FLT128_MAX_EXP		16384
+# define FLT128_MAX_10_EXP	4932
+# define FLT128_MAX		1.18973149535723176508575932662800702e+4932Q
+# define FLT128_EPSILON		1.92592994438723585305597794258492732e-34Q
+# define FLT128_MIN		3.36210314311209350626267781732175260e-4932Q
+# define FLT128_TRUE_MIN	6.47517511943802511092443895822764655e-4966Q
+#else
+# define LIT(x) (x ## f128)
+# define FLOAT _Float128
+#endif
+
+#include "test-math-floatn.h"
+
+/* Similarly, finitef128 is not API */
+extern int __finitef128 (FLOAT);
+
+static inline int
+finitef128(FLOAT f)
+{
+  return __finitef128 (f);
+}
diff --git a/math/test-math-floatn.h b/math/test-math-floatn.h
new file mode 100644
index 0000000..a5e2eee
--- /dev/null
+++ b/math/test-math-floatn.h
@@ -0,0 +1,21 @@
+/* Common definitions for libm tests for TS 18661-3 derived types.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   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/>.  */
+
+#define TEST_FLOATN 1
+#define __STDC_WANT_IEC_60559_BFP_EXT__
+#define __STDC_WANT_IEC_60559_TYPES_EXT__
-- 
2.4.11

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 5/6] float128: Add strfromf128, strtof128, and wcstof128 to the manual
  2017-05-26 12:57 ` [PATCH 5/6] float128: Add strfromf128, strtof128, and wcstof128 to the manual Gabriel F. T. Gomes
@ 2017-05-26 13:29   ` Florian Weimer
  2017-05-26 16:17   ` Joseph Myers
  1 sibling, 0 replies; 20+ messages in thread
From: Florian Weimer @ 2017-05-26 13:29 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

On Fri, May 26, 2017 at 2:56 PM, Gabriel F. T. Gomes
<gftg@linux.vnet.ibm.com> wrote:
> 2016-11-14  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>
>
>         * manual/arith.texi: Add descriptions for strfromf128, strtof128,
>         and wcstof128.

I think the entry should allude to the @comment changes, too.

Thanks,
Florian

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/6] float128: Extend the power of ten tables
  2017-05-26 12:57 ` [PATCH 1/6] float128: Extend the power of ten tables Gabriel F. T. Gomes
@ 2017-05-26 15:30   ` Joseph Myers
  0 siblings, 0 replies; 20+ messages in thread
From: Joseph Myers @ 2017-05-26 15:30 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

On Fri, 26 May 2017, Gabriel F. T. Gomes wrote:

> +#define HAVE_EXTENDED_RANGE ((!defined __NO_LONG_DOUBLE_MATH \
> +  && __LDBL_MAX_EXP__ > 1024) || __HAVE_DISTINCT_FLOAT128)

This is not the normal line wrapping approach (where the && would align 
with the corresponding open parenthesis).  Rather, do:

#define HAVE_EXTENDED_RANGE \
  ((!defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024) \
   || __HAVE_DISTINCT_FLOAT128)

or similar, so that operators are properly aligned after line breaks.

> 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

Also, I don't think duplicating the conditional is a good idea.  It would 
be better to rename the macro to FPIOCONST_HAVE_EXTENDED_RANGE and move 
the definition to fpioconst.h.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/6] float128: Add conversion from float128 to mpn
  2017-05-26 12:57 ` [PATCH 2/6] float128: Add conversion from float128 to mpn Gabriel F. T. Gomes
@ 2017-05-26 15:35   ` Joseph Myers
  2017-05-30  2:31     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 20+ messages in thread
From: Joseph Myers @ 2017-05-26 15:35 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

On Fri, 26 May 2017, Gabriel F. T. Gomes wrote:

> diff --git a/misc/sys/param.h b/misc/sys/param.h
> index 9721613..02d6b1c 100644
> --- a/misc/sys/param.h
> +++ b/misc/sys/param.h
> @@ -99,8 +99,12 @@
>  #define powerof2(x)     ((((x) - 1) & (x)) == 0)
>  
>  /* Macros for min/max.  */
> -#define MIN(a,b) (((a)<(b))?(a):(b))
> -#define MAX(a,b) (((a)>(b))?(a):(b))
> +#ifndef MIN
> +# define MIN(a,b) (((a)<(b))?(a):(b))
> +#endif
> +#ifndef MAX
> +# define MAX(a,b) (((a)>(b))?(a):(b))
> +#endif

This seems to have nothing to do with the rest of the patch.

If you have something that has its own conflicting definitions of MIN and 
MAX that ends up including sys/param.h as well, and those definitions of 
MIN and MAX are semantically the same as those in sys/param.h, make it 
include sys/param.h directly instead of having its own definitions.

If you have something that defines MIN and MAX in ways that are 
semantically different from sys/param.h, rename the conflicting macros.

> +#define __FLOAT128_OVERRIDE
> +
> +#include "../ldbl-128/ldbl2mpn.c"

Is there a reason you need a sepcial __FLOAT128_OVERRIDE macro, instead of 
the approach used by the other float128 files of including 
<float128_private.h>, which defines all relevant macros (e.g. defining 
__mpn_extract_long_double to __mpn_extract_float128, and with the 
__mpn_extract_long_double definition using _Float128 as the type name and 
letting math_ldbl.h redefine that back to long double as needed)?

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/6] float128: Add strfromf128
  2017-05-26 12:57 ` [PATCH 3/6] float128: Add strfromf128 Gabriel F. T. Gomes
@ 2017-05-26 15:56   ` Joseph Myers
  2017-05-30  2:32     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 20+ messages in thread
From: Joseph Myers @ 2017-05-26 15:56 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

On Fri, 26 May 2017, Gabriel F. T. Gomes wrote:

> diff --git a/NEWS b/NEWS
> index b4ecd62..8cb17cc 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -66,6 +66,9 @@ Version 2.26
>  * The port to Native Client running on ARMv7-A (--host=arm-nacl) has been
>    removed.
>  
> +* The function strfromf128, from ISO/IEC TS 18661-3:2015, is added to libc.
> +  It converts a _Float128 value into string.

Such a NEWS entry, for a function not available for all glibc 
configurations, needs to indicate what systems the function is available 
on.  (I'd say that means there should be one NEWS entry for all the 
float128 functions, added only when the powerpc64le support is enabled, 
rather than piecemeal entries before then.)

> diff --git a/include/gmp.h b/include/gmp.h
> index 95d6c16..e6f635e 100644
> --- a/include/gmp.h
> +++ b/include/gmp.h
> @@ -6,6 +6,8 @@
>  
>  #include <stdlib/gmp.h>
>  
> +#include <bits/floatn.h>
> +
>  /* Now define the internal interfaces.  */
>  extern mp_size_t __mpn_extract_double (mp_ptr res_ptr, mp_size_t size,
>  				       int *expt, int *is_neg,

Presumably this belongs in patch 2, which adds a test 
of__HAVE_DISTINCT_FLOAT128 to this header; it seems to have nothing to do 
with this patch.

> @@ -328,6 +339,52 @@ __printf_fp_l (FILE *fp, locale_t loc,
>      grouping = NULL;
>  
>    /* Fetch the argument value.	*/
> +#if __HAVE_DISTINCT_FLOAT128
> +  if (info->is_binary128)

I don't like this duplication of a large section of code.

As I see it, the code inside the conditional only varies between types 
for: the field name (f128 in this case); the type name; the 
__mpn_extract_* function called; the MANT_DIG value.  (It *used* to differ 
more, before we moved to using type-generic isnan / signbit / isinf macros 
throughout glibc instead of direct calls to the functions those macros 
might call.)

So refactor the existing code to have a macro for the code inside the 
conditional, used for both the long double and double cases.  Then you 
just need to add a third call to the macro for the _Float128 case.

>    /* Fetch the argument value.	*/
> +#if __HAVE_DISTINCT_FLOAT128
> +  if (info->is_binary128)

The same comment about duplication applies here.

> +#if __HAVE_DISTINCT_FLOAT128
> +  /* This block is copied from sysdeps/ieee754/ldbl-128/printf_fphex.c.  */
> +  if (info->is_binary128)

And here, the definition of PRINT_FPHEX_LONG_DOUBLE should be refactored 
in some way to allow it to be shared.  (It's fine for type names such as 
union ieee854_float128 to be visible internally in glibc for both 
binary128 long double and for _Float128, if it helps have a common macro 
that can be used as-is in defining both PRINT_FPHEX_LONG_DOUBLE and e.g. 
PRINT_FPHEX_FLOAT128.)

> diff --git a/stdlib/strfrom-skeleton.c b/stdlib/strfrom-skeleton.c
> index 811a29c..5841919 100644
> --- a/stdlib/strfrom-skeleton.c
> +++ b/stdlib/strfrom-skeleton.c
> @@ -132,6 +132,12 @@ STRFROM (char *dest, size_t size, const char *format, FLOAT f)
>       which type of floating-point number is being passed.  */
>    info.is_long_double = __builtin_types_compatible_p (FLOAT, long double);
>  
> +  /* Similarly, the function strfromf128 passes a floating-point number in
> +     _Float128 format to printf_fp.  */
> +#if __HAVE_DISTINCT_FLOAT128
> +  info.is_binary128 = __builtin_types_compatible_p (FLOAT, _Float128);
> +#endif

In other places you set is_binary128 even when !__HAVE_DISTINCT_FLOAT128.  
It's not *used* when !__HAVE_DISTINCT_FLOAT128 - is there a deliberate 
choice that in this place it shouldn't be set either?

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/6] float128: Add strtof128, wcstof128, and related functions.
  2017-05-26 12:57 ` [PATCH 4/6] float128: Add strtof128, wcstof128, and related functions Gabriel F. T. Gomes
@ 2017-05-26 16:07   ` Joseph Myers
  0 siblings, 0 replies; 20+ messages in thread
From: Joseph Myers @ 2017-05-26 16:07 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

On Fri, 26 May 2017, Gabriel F. T. Gomes wrote:

> diff --git a/NEWS b/NEWS
> index 8cb17cc..39e15fa 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -69,6 +69,10 @@ Version 2.26
>  * The function strfromf128, from ISO/IEC TS 18661-3:2015, is added to libc.
>    It converts a _Float128 value into string.
>  
> +* The function strtof128, from ISO/IEC TS 18661-3:2015, is added to libc.
> +  It converts a string into a floating-point number of _Float128 type.  Its
> +  wide character counterpart, wsctof128, is added as a GNU extension.

Same comment as before applies about having a NEWS entry saying what 
systems a feature is supported for, only when that is a nonempty set.

> @@ -235,6 +242,14 @@ extern long double strtold_l (const char *__restrict __nptr,
>  			      char **__restrict __endptr,
>  			      __locale_t __loc)
>       __THROW __nonnull ((1, 3));
> +
> +# if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
> +extern _Float128 strtof128_l (const char *__restrict __nptr,
> +			      char **__restrict __endptr,
> +			      __locale_t __loc)
> +     __THROW __nonnull ((1, 3));
> +# endif
> +
>  #endif /* GNU */

As you're inside a __USE_GNU conditional, the && __GLIBC_USE 
(IEC_60559_TYPES_EXT) is not necessary here.

> diff --git a/stdlib/tst-strtod.h b/stdlib/tst-strtod.h
> index bf5f901..d862a67 100644
> --- a/stdlib/tst-strtod.h
> +++ b/stdlib/tst-strtod.h
> @@ -21,11 +21,36 @@
>  
>  #define FSTRLENMAX 128
>  
> +#include <bits/floatn.h>
> +
> +#if !__GNUC_PREREQ(7,0)
> +# define F128 Q
> +#endif

Can we avoid this duplication of backwards compatibility with old GCC 
versions?  E.g. use __f128 () to get the required suffix.

> +#define _GEN(mfunc, type, ...) _GENx(_GEN_ ## type, mfunc, type, __VA_ARGS__)
> +#define _GENx(mmfunc, mfunc, type, ...) mmfunc (mfunc, type, __VA_ARGS__)
> +#define _DO(mfunc, type, ...) _DOx(_DO_ ## type, mfunc, ##__VA_ARGS__)
> +#define _DOx(mmfunc, mfunc, ...) mmfunc (mfunc, ##__VA_ARGS__)

Missing spaces before '(' in macro calls.

> diff --git a/sysdeps/ieee754/float128/mpn2float128.c b/sysdeps/ieee754/float128/mpn2float128.c
> new file mode 100644
> index 0000000..ad2e699
> --- /dev/null
> +++ b/sysdeps/ieee754/float128/mpn2float128.c
> @@ -0,0 +1,53 @@
> +/* Copyright (C) 2017 Free Software Foundation, Inc.

Descriptive comment needed before copyright notice at the start of each 
new file.

> diff --git a/sysdeps/ieee754/float128/wcstof128.c b/sysdeps/ieee754/float128/wcstof128.c
> new file mode 100644
> index 0000000..d87eff9
> --- /dev/null
> +++ b/sysdeps/ieee754/float128/wcstof128.c
> @@ -0,0 +1,29 @@
> +/* Copyright (C) 2017 Free Software Foundation, Inc.

Likewise.

> diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
> index 79be9fc..ba89c22 100644
> --- a/wcsmbs/wchar.h
> +++ b/wcsmbs/wchar.h
> @@ -468,6 +468,15 @@ __extension__
>  extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr,
>  				       wchar_t **__restrict __endptr,
>  				       int __base) __THROW;
> +
> +/* Include _Float128 variants of strtof128 if available.  */
> +#include <bits/floatn.h>
> +
> +#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
> +extern _Float128 wcstof128 (const wchar_t *__restrict __nptr,
> +			    wchar_t **__restrict __endptr) __THROW;
> +#endif

This seems like the wrong place in the header.  Just after wcstof/wcstold 
would be better (with __HAVE_FLOAT128 && defined __USE_GNU as the 
conditional).  And with <bits/floatn.h> included along with the other 
<bits/*.h> includes at the start of the header.

> @@ -518,6 +527,13 @@ extern float wcstof_l (const wchar_t *__restrict __nptr,
>  extern long double wcstold_l (const wchar_t *__restrict __nptr,
>  			      wchar_t **__restrict __endptr,
>  			      __locale_t __loc) __THROW;
> +
> +#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
> +extern _Float128 wcstof128_l (const wchar_t *__restrict __nptr,
> +			      wchar_t **__restrict __endptr,
> +			      __locale_t __loc) __THROW;
> +#endif

No need for __GLIBC_USE (IEC_60559_TYPES_EXT) inside __USE_GNU 
conditional.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 5/6] float128: Add strfromf128, strtof128, and wcstof128 to the manual
  2017-05-26 12:57 ` [PATCH 5/6] float128: Add strfromf128, strtof128, and wcstof128 to the manual Gabriel F. T. Gomes
  2017-05-26 13:29   ` Florian Weimer
@ 2017-05-26 16:17   ` Joseph Myers
  1 sibling, 0 replies; 20+ messages in thread
From: Joseph Myers @ 2017-05-26 16:17 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

On Fri, 26 May 2017, Gabriel F. T. Gomes wrote:

> 2016-11-14  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>
> 
> 	* manual/arith.texi: Add descriptions for strfromf128, strtof128,
> 	and wcstof128.

The documentation needs to be clear about what systems the functions are 
supported on.

Rather than repeating that for every _Float128 function, I think an 
appropriate structure would be to have a section of arith.texi that 
discusses the C floating-point types, including explaining _Float@var{n} 
and _Float@var{n}x and that such types are supported by glibc on only some 
systems (currently the empty set, powerpc64le patch would change that 
section to say that _Float128 is supported on powerpc64le).  Then the 
documentation of each function would be written in a type-generic way, say 
documenting

@deftypefun _Float@var{n} strtof@var{n} (const char *@var{string}, char **@var{tailptr})
@deftypefunx _Float@var{n}x strtof@var{n}x (const char *@var{string}, char **@var{tailptr})

(documenting the _FloatNx functions optional since your patches aren't 
adding any such functions), so that it would apply automatically to all 
_FloatN types for which support is added to glibc (likewise, use @var{n} 
instead of literal 128 in the documentation text, ideally avoiding text 
that would need additional duplication when there are _FloatNx functions 
as well).  (I'm assuming here that such uses of @var in function names and 
return / argument types work properly.)

E.g. the text might say simply:

  These functions are like @code{strtod}, except for the return type.

  They were introduced in @w{ISO/IEC TS 18661-3}.

which avoids the text needing changing when more such types are supported.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 6/6] float128: Add test-{float128,ifloat128,float128-finite}
  2017-05-26 12:57 ` [PATCH 6/6] float128: Add test-{float128,ifloat128,float128-finite} Gabriel F. T. Gomes
@ 2017-05-26 16:26   ` Joseph Myers
  0 siblings, 0 replies; 20+ messages in thread
From: Joseph Myers @ 2017-05-26 16:26 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

On Fri, 26 May 2017, Gabriel F. T. Gomes wrote:

> 	* math/test-float128-finite.c: New file.
> 	* math/test-float128.c: New file.
> 	* math/test-float128.h: New file.
> 	* math/test-ifloat128.c: New file.
> 	* math/test-math-floatn.h: New file.

The ChangeLog entry needs updating to reflect the patch contents; various 
of these files no longer exist.

> 	* math/gen-libm-have-vector-test.sh: Add support for float128.

Likewise.

> diff --git a/math/libm-test-support.h b/math/libm-test-support.h
> index 0e78144..a57a8b3 100644
> --- a/math/libm-test-support.h
> +++ b/math/libm-test-support.h
> @@ -138,12 +138,20 @@ extern const char doc[];
>  #define TEST_COND_before_rounding	(!TININESS_AFTER_ROUNDING)
>  #define TEST_COND_after_rounding	TININESS_AFTER_ROUNDING
>  
> +#ifndef TEST_FLOATN
> +# define TEST_FLOATN 0
> +#endif

No, define to 0 in test-float.h etc.

> +#ifndef CFLOAT
> +# define CFLOAT __complex__ FLOAT
> +#endif

I'd rather put that in test-float.h etc. as well to avoid #ifndef.

> +/* Fixup builtins and constants for older compilers.  */
> +#include <features.h>
> +#if !__GNUC_PREREQ (7, 0)
> +# define LIT(x) (x ## Q)
> +# define FLOAT __float128
> +# define CFLOAT __CFLOAT128
> +/* The following macros are only provided since GCC 7.0.  */
> +# define FLT128_MANT_DIG	113
> +# define FLT128_DECIMAL_DIG	36
> +# define FLT128_DIG		33
> +# define FLT128_MIN_EXP		(-16381)
> +# define FLT128_MIN_10_EXP	(-4931)
> +# define FLT128_MAX_EXP		16384
> +# define FLT128_MAX_10_EXP	4932
> +# define FLT128_MAX		1.18973149535723176508575932662800702e+4932Q
> +# define FLT128_EPSILON		1.92592994438723585305597794258492732e-34Q
> +# define FLT128_MIN		3.36210314311209350626267781732175260e-4932Q
> +# define FLT128_TRUE_MIN	6.47517511943802511092443895822764655e-4966Q
> +#else
> +# define LIT(x) (x ## f128)
> +# define FLOAT _Float128
> +#endif

Rather than duplicating the compatibility code, use macros from 
bits/floatn.h to define LIT, FLOAT etc.

Then, for FLT128_ you want the !_ISOMAC definitions from include/float.h.  
Maybe either separate those out into a separate header, or make 
include/float.h define them in the !_ISOMAC case if 
__STDC_WANT_IEC_60559_TYPES_EXT__ is defined?

> +/* Similarly, finitef128 is not API */
> +extern int __finitef128 (FLOAT);
> +
> +static inline int
> +finitef128(FLOAT f)
> +{
> +  return __finitef128 (f);
> +}

No, nothing should be trying to call finitef128.  Disable the tests of 
finite in libm-test-isfinite.inc in the TEST_FLOATN case.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/6] float128: Add conversion from float128 to mpn
  2017-05-26 15:35   ` Joseph Myers
@ 2017-05-30  2:31     ` Gabriel F. T. Gomes
  2017-06-01 13:23       ` Joseph Myers
  0 siblings, 1 reply; 20+ messages in thread
From: Gabriel F. T. Gomes @ 2017-05-30  2:31 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 1890 bytes --]

On Fri, 26 May 2017 15:35:16 +0000
Joseph Myers <joseph@codesourcery.com> wrote:

> On Fri, 26 May 2017, Gabriel F. T. Gomes wrote:
> >  
> >  /* Macros for min/max.  */
> > -#define MIN(a,b) (((a)<(b))?(a):(b))
> > -#define MAX(a,b) (((a)>(b))?(a):(b))
> > +#ifndef MIN
> > +# define MIN(a,b) (((a)<(b))?(a):(b))
> > +#endif
> > +#ifndef MAX
> > +# define MAX(a,b) (((a)>(b))?(a):(b))
> > +#endif  
> 
> This seems to have nothing to do with the rest of the patch.
> 
> If you have something that has its own conflicting definitions of MIN and 
> MAX that ends up including sys/param.h as well, and those definitions of 
> MIN and MAX are semantically the same as those in sys/param.h, make it 
> include sys/param.h directly instead of having its own definitions.

The file sysdeps/ieee754/ldbl-128/ldbl2mpn.c includes stdlib/gmp-impl.h,
which defines MAX and MIN.  With the changes to ldbl2mpn.c, the inclusion
of float128_private.h will indirectly include sys/param.h, redefining the
macros.

I attached a new patch which replaces the definition of MAX and MIN in
stdlib/gmp-impl.h with an inclusion of sys/param.h.

Is the attached patch OK for master?

> > +#define __FLOAT128_OVERRIDE
> > +
> > +#include "../ldbl-128/ldbl2mpn.c"  
> 
> Is there a reason you need a sepcial __FLOAT128_OVERRIDE macro, instead of 
> the approach used by the other float128 files of including 
> <float128_private.h>, which defines all relevant macros (e.g. defining 
> __mpn_extract_long_double to __mpn_extract_float128, and with the 
> __mpn_extract_long_double definition using _Float128 as the type name and 
> letting math_ldbl.h redefine that back to long double as needed)?

I could not use the same approach, because ldbl2mpn.c includes the header
include/gmp.h, which declares both __mpn_extract_long_double and
__mpn_extract_float128.  I would end up declaring __mpn_extract_float128
twice.

[-- Attachment #2: 0001-Include-sys-param.h-in-stdlib-gmp-impl.h-instead-of-.patch --]
[-- Type: text/x-patch, Size: 1215 bytes --]

From 50013e699a36b896287ac95393b345fc85fa5421 Mon Sep 17 00:00:00 2001
From: "Gabriel F. T. Gomes" <gftg@linux.vnet.ibm.com>
Date: Fri, 26 May 2017 19:29:20 -0300
Subject: [PATCH] Include sys/param.h in stdlib/gmp-impl.h instead of
 redefining MAX/MIN

In stdlib/gmp-impl.h, the macros MAX and MIN are defined exactly the same
as in sys/param.h.  This patch removes the redefinition and makes
gmp-impl.h include sys/param.h instead.

Tested for powerpc64le and s390x.

2017-05-25  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>

	* stdlib/gmp-impl.h: Include sys/param.h instead of redefining the
	macros MAX and MIN.
---
 stdlib/gmp-impl.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/stdlib/gmp-impl.h b/stdlib/gmp-impl.h
index a6594ff..89693c4 100644
--- a/stdlib/gmp-impl.h
+++ b/stdlib/gmp-impl.h
@@ -64,12 +64,8 @@ along with the GNU MP Library; see the file COPYING.LIB.  If not, see
 #define inline			/* Empty */
 #endif
 
-#ifndef MIN
-#define MIN(l,o) ((l) < (o) ? (l) : (o))
-#endif
-#ifndef MAX
-#define MAX(h,i) ((h) > (i) ? (h) : (i))
-#endif
+/* Get MAX/MIN macros.  */
+#include <sys/param.h>
 
 /* Field access macros.  */
 #define SIZ(x) ((x)->_mp_size)
-- 
2.4.11


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/6] float128: Add strfromf128
  2017-05-26 15:56   ` Joseph Myers
@ 2017-05-30  2:32     ` Gabriel F. T. Gomes
  2017-06-02 16:31       ` Joseph Myers
  0 siblings, 1 reply; 20+ messages in thread
From: Gabriel F. T. Gomes @ 2017-05-30  2:32 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 3815 bytes --]

On Fri, 26 May 2017 15:56:04 +0000
Joseph Myers <joseph@codesourcery.com> wrote:

> On Fri, 26 May 2017, Gabriel F. T. Gomes wrote:
> 
> > diff --git a/NEWS b/NEWS
> > index b4ecd62..8cb17cc 100644
> > --- a/NEWS
> > +++ b/NEWS
> > @@ -66,6 +66,9 @@ Version 2.26
> >  * The port to Native Client running on ARMv7-A (--host=arm-nacl) has been
> >    removed.
> >  
> > +* The function strfromf128, from ISO/IEC TS 18661-3:2015, is added to libc.
> > +  It converts a _Float128 value into string.  
> 
> Such a NEWS entry, for a function not available for all glibc 
> configurations, needs to indicate what systems the function is available 
> on.  (I'd say that means there should be one NEWS entry for all the 
> float128 functions, added only when the powerpc64le support is enabled, 
> rather than piecemeal entries before then.)

OK.

> 
> > diff --git a/include/gmp.h b/include/gmp.h
> > index 95d6c16..e6f635e 100644
> > --- a/include/gmp.h
> > +++ b/include/gmp.h
> > @@ -6,6 +6,8 @@
> >  
> >  #include <stdlib/gmp.h>
> >  
> > +#include <bits/floatn.h>
> > +
> >  /* Now define the internal interfaces.  */
> >  extern mp_size_t __mpn_extract_double (mp_ptr res_ptr, mp_size_t size,
> >  				       int *expt, int *is_neg,  
> 
> Presumably this belongs in patch 2, which adds a test 
> of__HAVE_DISTINCT_FLOAT128 to this header; it seems to have nothing to do 
> with this patch.

Indeed.

> > @@ -328,6 +339,52 @@ __printf_fp_l (FILE *fp, locale_t loc,
> >      grouping = NULL;
> >  
> >    /* Fetch the argument value.	*/
> > +#if __HAVE_DISTINCT_FLOAT128
> > +  if (info->is_binary128)  
> 
> I don't like this duplication of a large section of code.
> 
> As I see it, the code inside the conditional only varies between types 
> for: the field name (f128 in this case); the type name; the 
> __mpn_extract_* function called; the MANT_DIG value.  (It *used* to differ 
> more, before we moved to using type-generic isnan / signbit / isinf macros 
> throughout glibc instead of direct calls to the functions those macros 
> might call.)
> 
> So refactor the existing code to have a macro for the code inside the 
> conditional, used for both the long double and double cases.  Then you 
> just need to add a third call to the macro for the _Float128 case.
> 
> >    /* Fetch the argument value.	*/
> > +#if __HAVE_DISTINCT_FLOAT128
> > +  if (info->is_binary128)  
> 
> The same comment about duplication applies here.

I attached a patch with this refactoring for double and long double.  I'll
update this block for float128 in the next version of this patch.

Is the attached patch (with the refactoring) OK for master?

> > diff --git a/stdlib/strfrom-skeleton.c b/stdlib/strfrom-skeleton.c
> > index 811a29c..5841919 100644
> > --- a/stdlib/strfrom-skeleton.c
> > +++ b/stdlib/strfrom-skeleton.c
> > @@ -132,6 +132,12 @@ STRFROM (char *dest, size_t size, const char *format, FLOAT f)
> >       which type of floating-point number is being passed.  */
> >    info.is_long_double = __builtin_types_compatible_p (FLOAT, long double);
> >  
> > +  /* Similarly, the function strfromf128 passes a floating-point number in
> > +     _Float128 format to printf_fp.  */
> > +#if __HAVE_DISTINCT_FLOAT128
> > +  info.is_binary128 = __builtin_types_compatible_p (FLOAT, _Float128);
> > +#endif  
> 
> In other places you set is_binary128 even when !__HAVE_DISTINCT_FLOAT128.  
> It's not *used* when !__HAVE_DISTINCT_FLOAT128 - is there a deliberate 
> choice that in this place it shouldn't be set either?

The reason why I chose to not set it here, is because the struct info is
zero'd by a memset some lines above (the narrowness of the diff context
hid it):

  /* Prepare the format specification for printf_fp.  */    
  memset (&info, '\0', sizeof (info));    

Would it be more clear to set it anyway?

[-- Attachment #2: 0001-Remove-duplicated-code-from-__printf_fp_l-and-__prin.patch --]
[-- Type: text/x-patch, Size: 7557 bytes --]

From 84ac9620ca9bc76622d69708c279bd1658eebd28 Mon Sep 17 00:00:00 2001
From: "Gabriel F. T. Gomes" <gftg@linux.vnet.ibm.com>
Date: Mon, 29 May 2017 10:49:42 -0300
Subject: [PATCH] Remove duplicated code from __printf_fp_l and __printf_fphex

In __printf_fp_l and __printf_fphex, the blocks of code that are used to read a
double or long double argument, check for special values and convert to
multiprecision are similar.  When adding float128 support to libc, more code
would be duplicated to deal with the extra type.  This patch moves the
repetitive code to a macro which is now used by double and long double and will
be used for float128 when support is added, thus avoiding more duplication.

Tested for powerpc64le and s390x.

2017-05-29  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>

	* stdio-common/printf_fp.c (PRINTF_FP_FETCH): New macro.
	(__printf_fp_l): Use the new macro to avoid duplicating code.
	* stdio-common/printf_fphex.c (PRINTF_FPHEX_FETCH): New macro.
	(__printf_fphex): Use the new macro to avoid duplicating code.
---
 stdio-common/printf_fp.c    | 130 ++++++++++++++++----------------------------
 stdio-common/printf_fphex.c | 110 ++++++++++++++-----------------------
 2 files changed, 87 insertions(+), 153 deletions(-)

diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c
index 7845d96..6d8c381 100644
--- a/stdio-common/printf_fp.c
+++ b/stdio-common/printf_fp.c
@@ -327,94 +327,58 @@ __printf_fp_l (FILE *fp, locale_t loc,
   else
     grouping = NULL;
 
+#define PRINTF_FP_FETCH(FLOAT, VAR, SUFFIX, MANT_DIG)			\
+  {									\
+    VAR = *(const FLOAT *) args[0];					\
+									\
+    /* Check for special values: not a number or infinity.  */		\
+    if (isnan (VAR))							\
+      {									\
+	is_neg = signbit (VAR);						\
+	if (isupper (info->spec))					\
+	  {								\
+	    special = "NAN";						\
+	    wspecial = L"NAN";						\
+	  }								\
+	else								\
+	  {								\
+	    special = "nan";						\
+	    wspecial = L"nan";						\
+	  }								\
+      }									\
+    else if (isinf (VAR))						\
+      {									\
+	is_neg = signbit (VAR);						\
+	if (isupper (info->spec))					\
+	  {								\
+	    special = "INF";						\
+	    wspecial = L"INF";						\
+	  }								\
+	else								\
+	  {								\
+	    special = "inf";						\
+	    wspecial = L"inf";						\
+	  }								\
+      }									\
+    else								\
+      {									\
+	p.fracsize = __mpn_extract_##SUFFIX				\
+		     (fp_input,						\
+		      (sizeof (fp_input) / sizeof (fp_input[0])),	\
+		      &p.exponent, &is_neg, VAR);			\
+	to_shift = 1 + p.fracsize * BITS_PER_MP_LIMB - MANT_DIG;	\
+      }									\
+  }
+
   /* Fetch the argument value.	*/
 #ifndef __NO_LONG_DOUBLE_MATH
   if (info->is_long_double && sizeof (long double) > sizeof (double))
-    {
-      fpnum.ldbl = *(const long double *) args[0];
-
-      /* Check for special values: not a number or infinity.  */
-      if (isnan (fpnum.ldbl))
-	{
-	  is_neg = signbit (fpnum.ldbl);
-	  if (isupper (info->spec))
-	    {
-	      special = "NAN";
-	      wspecial = L"NAN";
-	    }
-	    else
-	      {
-		special = "nan";
-		wspecial = L"nan";
-	      }
-	}
-      else if (isinf (fpnum.ldbl))
-	{
-	  is_neg = signbit (fpnum.ldbl);
-	  if (isupper (info->spec))
-	    {
-	      special = "INF";
-	      wspecial = L"INF";
-	    }
-	  else
-	    {
-	      special = "inf";
-	      wspecial = L"inf";
-	    }
-	}
-      else
-	{
-	  p.fracsize = __mpn_extract_long_double (fp_input,
-						(sizeof (fp_input) /
-						 sizeof (fp_input[0])),
-						&p.exponent, &is_neg,
-						fpnum.ldbl);
-	  to_shift = 1 + p.fracsize * BITS_PER_MP_LIMB - LDBL_MANT_DIG;
-	}
-    }
+    PRINTF_FP_FETCH (long double, fpnum.ldbl, long_double, LDBL_MANT_DIG)
   else
-#endif	/* no long double */
-    {
-      fpnum.dbl = *(const double *) args[0];
+#endif
+    PRINTF_FP_FETCH (double, fpnum.dbl, double, DBL_MANT_DIG)
 
-      /* Check for special values: not a number or infinity.  */
-      if (isnan (fpnum.dbl))
-	{
-	  is_neg = signbit (fpnum.dbl);
-	  if (isupper (info->spec))
-	    {
-	      special = "NAN";
-	      wspecial = L"NAN";
-	    }
-	  else
-	    {
-	      special = "nan";
-	      wspecial = L"nan";
-	    }
-	}
-      else if (isinf (fpnum.dbl))
-	{
-	  is_neg = signbit (fpnum.dbl);
-	  if (isupper (info->spec))
-	    {
-	      special = "INF";
-	      wspecial = L"INF";
-	    }
-	  else
-	    {
-	      special = "inf";
-	      wspecial = L"inf";
-	    }
-	}
-      else
-	{
-	  p.fracsize = __mpn_extract_double (fp_input,
-					   (sizeof (fp_input)
-					    / sizeof (fp_input[0])),
-					   &p.exponent, &is_neg, fpnum.dbl);
-	  to_shift = 1 + p.fracsize * BITS_PER_MP_LIMB - DBL_MANT_DIG;
-	}
-    }
+#undef PRINTF_FP_FETCH
 
   if (special)
     {
diff --git a/stdio-common/printf_fphex.c b/stdio-common/printf_fphex.c
index b207e00..3a25854 100644
--- a/stdio-common/printf_fphex.c
+++ b/stdio-common/printf_fphex.c
@@ -157,82 +157,52 @@ __printf_fphex (FILE *fp,
   /* The decimal point character must never be zero.  */
   assert (*decimal != '\0' && decimalwc != L'\0');
 
+#define PRINTF_FPHEX_FETCH(FLOAT, VAR)					\
+  {									\
+    VAR = *(const FLOAT *) args[0];					\
+									\
+    /* Check for special values: not a number or infinity.  */		\
+    if (isnan (VAR))							\
+      {									\
+	if (isupper (info->spec))					\
+	  {								\
+	    special = "NAN";						\
+	    wspecial = L"NAN";						\
+	  }								\
+	else								\
+	  {								\
+	    special = "nan";						\
+	    wspecial = L"nan";						\
+	  }								\
+      }									\
+    else								\
+      {									\
+	if (isinf (VAR))						\
+	  {								\
+	    if (isupper (info->spec))					\
+	      {								\
+		special = "INF";					\
+		wspecial = L"INF";					\
+	      }								\
+	    else							\
+	      {								\
+		special = "inf";					\
+		wspecial = L"inf";					\
+	      }								\
+	  }								\
+      }									\
+    negative = signbit (VAR);						\
+  }
 
   /* Fetch the argument value.	*/
 #ifndef __NO_LONG_DOUBLE_MATH
   if (info->is_long_double && sizeof (long double) > sizeof (double))
-    {
-      fpnum.ldbl = *(const long double *) args[0];
-
-      /* Check for special values: not a number or infinity.  */
-      if (isnan (fpnum.ldbl))
-	{
-	  if (isupper (info->spec))
-	    {
-	      special = "NAN";
-	      wspecial = L"NAN";
-	    }
-	  else
-	    {
-	      special = "nan";
-	      wspecial = L"nan";
-	    }
-	}
-      else
-	{
-	  if (isinf (fpnum.ldbl))
-	    {
-	      if (isupper (info->spec))
-		{
-		  special = "INF";
-		  wspecial = L"INF";
-		}
-	      else
-		{
-		  special = "inf";
-		  wspecial = L"inf";
-		}
-	    }
-	}
-      negative = signbit (fpnum.ldbl);
-    }
+    PRINTF_FPHEX_FETCH (long double, fpnum.ldbl)
   else
-#endif	/* no long double */
-    {
-      fpnum.dbl.d = *(const double *) args[0];
+#endif
+    PRINTF_FPHEX_FETCH (double, fpnum.dbl.d)
 
-      /* Check for special values: not a number or infinity.  */
-      if (isnan (fpnum.dbl.d))
-	{
-	  if (isupper (info->spec))
-	    {
-	      special = "NAN";
-	      wspecial = L"NAN";
-	    }
-	  else
-	    {
-	      special = "nan";
-	      wspecial = L"nan";
-	    }
-	}
-      else
-	{
-	  if (isinf (fpnum.dbl.d))
-	    {
-	      if (isupper (info->spec))
-		{
-		  special = "INF";
-		  wspecial = L"INF";
-		}
-	      else
-		{
-		  special = "inf";
-		  wspecial = L"inf";
-		}
-	    }
-	}
-      negative = signbit (fpnum.dbl.d);
-    }
+#undef PRINTF_FPHEX_FETCH
 
   if (special)
     {
-- 
2.4.11


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/6] float128: Add conversion from float128 to mpn
  2017-05-30  2:31     ` Gabriel F. T. Gomes
@ 2017-06-01 13:23       ` Joseph Myers
  2017-06-01 23:52         ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 20+ messages in thread
From: Joseph Myers @ 2017-06-01 13:23 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

On Mon, 29 May 2017, Gabriel F. T. Gomes wrote:

> The file sysdeps/ieee754/ldbl-128/ldbl2mpn.c includes stdlib/gmp-impl.h,
> which defines MAX and MIN.  With the changes to ldbl2mpn.c, the inclusion
> of float128_private.h will indirectly include sys/param.h, redefining the
> macros.
> 
> I attached a new patch which replaces the definition of MAX and MIN in
> stdlib/gmp-impl.h with an inclusion of sys/param.h.
> 
> Is the attached patch OK for master?

That patch is OK.

> > > +#define __FLOAT128_OVERRIDE
> > > +
> > > +#include "../ldbl-128/ldbl2mpn.c"  
> > 
> > Is there a reason you need a sepcial __FLOAT128_OVERRIDE macro, instead of 
> > the approach used by the other float128 files of including 
> > <float128_private.h>, which defines all relevant macros (e.g. defining 
> > __mpn_extract_long_double to __mpn_extract_float128, and with the 
> > __mpn_extract_long_double definition using _Float128 as the type name and 
> > letting math_ldbl.h redefine that back to long double as needed)?
> 
> I could not use the same approach, because ldbl2mpn.c includes the header
> include/gmp.h, which declares both __mpn_extract_long_double and
> __mpn_extract_float128.  I would end up declaring __mpn_extract_float128
> twice.

This sounds like an include ordering problem.  float128_private.h 
redefines lots of names from math_private.h and math.h.  But that doesn't 
cause problems because it includes those headers first.  So how about 
making float128_private.h include gmp.h before redefining 
__mpn_extract_long_double?

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/6] float128: Add conversion from float128 to mpn
  2017-06-01 13:23       ` Joseph Myers
@ 2017-06-01 23:52         ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 20+ messages in thread
From: Gabriel F. T. Gomes @ 2017-06-01 23:52 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

On Thu, 1 Jun 2017 13:23:25 +0000
Joseph Myers <joseph@codesourcery.com> wrote:

> On Mon, 29 May 2017, Gabriel F. T. Gomes wrote:
> 
> > I attached a new patch which replaces the definition of MAX and MIN in
> > stdlib/gmp-impl.h with an inclusion of sys/param.h.
> > 
> > Is the attached patch OK for master?  
> 
> That patch is OK.

Thanks.  I've committed it.

> This sounds like an include ordering problem.  float128_private.h 
> redefines lots of names from math_private.h and math.h.  But that doesn't 
> cause problems because it includes those headers first.  So how about 
> making float128_private.h include gmp.h before redefining 
> __mpn_extract_long_double?

Thanks again.  I rewrote this and I'll send again with the other patches
in the series.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/6] float128: Add strfromf128
  2017-05-30  2:32     ` Gabriel F. T. Gomes
@ 2017-06-02 16:31       ` Joseph Myers
  2017-06-02 23:27         ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 20+ messages in thread
From: Joseph Myers @ 2017-06-02 16:31 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

On Mon, 29 May 2017, Gabriel F. T. Gomes wrote:

> I attached a patch with this refactoring for double and long double.  I'll
> update this block for float128 in the next version of this patch.
> 
> Is the attached patch (with the refactoring) OK for master?

This refactoring patch is OK.

> > In other places you set is_binary128 even when !__HAVE_DISTINCT_FLOAT128.  
> > It's not *used* when !__HAVE_DISTINCT_FLOAT128 - is there a deliberate 
> > choice that in this place it shouldn't be set either?
> 
> The reason why I chose to not set it here, is because the struct info is
> zero'd by a memset some lines above (the narrowness of the diff context
> hid it):
> 
>   /* Prepare the format specification for printf_fp.  */    
>   memset (&info, '\0', sizeof (info));    
> 
> Would it be more clear to set it anyway?

Given the memset, it seems reasonable not to zero it again.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/6] float128: Add strfromf128
  2017-06-02 16:31       ` Joseph Myers
@ 2017-06-02 23:27         ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 20+ messages in thread
From: Gabriel F. T. Gomes @ 2017-06-02 23:27 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

On Fri, 2 Jun 2017 16:31:02 +0000
Joseph Myers <joseph@codesourcery.com> wrote:

> On Mon, 29 May 2017, Gabriel F. T. Gomes wrote:
> 
> > I attached a patch with this refactoring for double and long double.  I'll
> > update this block for float128 in the next version of this patch.
> > 
> > Is the attached patch (with the refactoring) OK for master?  
> 
> This refactoring patch is OK.

Thanks.  I just noticed that I missed the same change for printf_size
(which had the same duplication problem), so I'll send a new version of
this patch along with the new version of this series.  Could you please
review it again (I only changed printf_size)?  Thank you.

> Given the memset, it seems reasonable not to zero it again.

OK.

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2017-06-02 23:27 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-26 12:57 [PATCH 0/6] Add string functions and libm tests for _Float128 Gabriel F. T. Gomes
2017-05-26 12:57 ` [PATCH 2/6] float128: Add conversion from float128 to mpn Gabriel F. T. Gomes
2017-05-26 15:35   ` Joseph Myers
2017-05-30  2:31     ` Gabriel F. T. Gomes
2017-06-01 13:23       ` Joseph Myers
2017-06-01 23:52         ` Gabriel F. T. Gomes
2017-05-26 12:57 ` [PATCH 6/6] float128: Add test-{float128,ifloat128,float128-finite} Gabriel F. T. Gomes
2017-05-26 16:26   ` Joseph Myers
2017-05-26 12:57 ` [PATCH 5/6] float128: Add strfromf128, strtof128, and wcstof128 to the manual Gabriel F. T. Gomes
2017-05-26 13:29   ` Florian Weimer
2017-05-26 16:17   ` Joseph Myers
2017-05-26 12:57 ` [PATCH 1/6] float128: Extend the power of ten tables Gabriel F. T. Gomes
2017-05-26 15:30   ` Joseph Myers
2017-05-26 12:57 ` [PATCH 3/6] float128: Add strfromf128 Gabriel F. T. Gomes
2017-05-26 15:56   ` Joseph Myers
2017-05-30  2:32     ` Gabriel F. T. Gomes
2017-06-02 16:31       ` Joseph Myers
2017-06-02 23:27         ` Gabriel F. T. Gomes
2017-05-26 12:57 ` [PATCH 4/6] float128: Add strtof128, wcstof128, and related functions Gabriel F. T. Gomes
2017-05-26 16:07   ` Joseph Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).