From cf2046ec7dd4b233180377cc5b8debcf551d1fc9 Mon Sep 17 00:00:00 2001 From: "Gabriel F. T. Gomes" Date: Thu, 3 Nov 2016 12:37:08 -0200 Subject: float128: Add strfromf128 Add strfromf128 to stdlib when _Float128 support is enabled. * 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: Include ieee754_float128.h and ldbl-128/printf_fphex_macros.h (__printf_fphex): Add code to deal with _Float128 numbers. * 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. --- stdio-common/printf_fphex.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'stdio-common/printf_fphex.c') diff --git a/stdio-common/printf_fphex.c b/stdio-common/printf_fphex.c index 7b469c0..004d2aa 100644 --- a/stdio-common/printf_fphex.c +++ b/stdio-common/printf_fphex.c @@ -31,6 +31,14 @@ #include #include +#if __HAVE_DISTINCT_FLOAT128 +# include "ieee754_float128.h" +# include +# define PRINT_FPHEX_FLOAT128 \ + PRINT_FPHEX (_Float128, fpnum.flt128, ieee854_float128, \ + IEEE854_FLOAT128_BIAS) +#endif + /* #define NDEBUG 1*/ /* Undefine this for debugging assertions. */ #include @@ -94,6 +102,9 @@ __printf_fphex (FILE *fp, { union ieee754_double dbl; long double ldbl; +#if __HAVE_DISTINCT_FLOAT128 + _Float128 flt128; +#endif } fpnum; @@ -195,6 +206,11 @@ __printf_fphex (FILE *fp, } /* Fetch the argument value. */ +#if __HAVE_DISTINCT_FLOAT128 + if (info->is_binary128) + PRINTF_FPHEX_FETCH (_Float128, fpnum.flt128) + else +#endif #ifndef __NO_LONG_DOUBLE_MATH if (info->is_long_double && sizeof (long double) > sizeof (double)) PRINTF_FPHEX_FETCH (long double, fpnum.ldbl) @@ -230,6 +246,11 @@ __printf_fphex (FILE *fp, return done; } +#if __HAVE_DISTINCT_FLOAT128 + if (info->is_binary128) + PRINT_FPHEX_FLOAT128; + else +#endif if (info->is_long_double == 0 || sizeof (double) == sizeof (long double)) { /* We have 52 bits of mantissa plus one implicit digit. Since -- cgit v1.1