about summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
authorGabriel F. T. Gomes <gftg@linux.vnet.ibm.com>2016-11-03 12:37:08 -0200
committerGabriel F. T. Gomes <gftg@linux.vnet.ibm.com>2017-05-25 16:14:46 -0300
commitb2da97305ccbfbbe16778ba3b6acb59268ab625c (patch)
tree569aed42477c529fe8741d06ffacf33603f06a1c /stdlib
parentfb91e22c252dbefd1b141fdf151903cf5aea7727 (diff)
downloadglibc-b2da97305ccbfbbe16778ba3b6acb59268ab625c.tar.gz
glibc-b2da97305ccbfbbe16778ba3b6acb59268ab625c.tar.xz
glibc-b2da97305ccbfbbe16778ba3b6acb59268ab625c.zip
float128: Add strfromf128
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.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/fpioconst.h4
-rw-r--r--stdlib/stdlib.h8
-rw-r--r--stdlib/strfrom-skeleton.c6
3 files changed, 18 insertions, 0 deletions
diff --git a/stdlib/fpioconst.h b/stdlib/fpioconst.h
index 7e19b0d33e..aab46d68c1 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 99125f2d23..1313aa5eb5 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 811a29c7d3..5841919fe4 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;