1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-01 10:06:57 +03:00

Prepare vfscanf to use __strtof128_internal

On powerpc64le, long double can currently take two formats: the same as
double (-mlong-double-64) or IBM Extended Precision (default with
-mlong-double-128 or explicitly with -mabi=ibmlongdouble).  The internal
implementation of scanf-like functions is aware of these possibilites
and, based on the format in use, properly calls __strtold_internal or
__strtod_internal, saving the return to a variable of type double or
long double.

When library support for TS 18661-3 was added to glibc, a new function,
__strtof128_internal, was added to enable reading of floating-point
values with IEEE binary128 format into the _Float128 type.  Now that
powerpc64le is getting support for its third long double format, and
taking into account that this format is the same as the format of
_Float128, this patch extends __vfscanf_internal and __vfwscanf_internal
to call __strtof128_internal or __wcstof128_internal when appropriate.
The result gets saved into a variable of _Float128 type.

Tested for powerpc64le.
This commit is contained in:
Gabriel F. T. Gomes
2018-06-10 22:42:34 -03:00
parent 45f33aac78
commit 10446f5d9f
3 changed files with 41 additions and 3 deletions

View File

@ -98,6 +98,9 @@
# define __strtold_internal __wcstold_internal
# define __strtod_internal __wcstod_internal
# define __strtof_internal __wcstof_internal
# if __HAVE_FLOAT128_UNLIKE_LDBL
# define __strtof128_internal __wcstof128_internal
# endif
# define L_(Str) L##Str
# define CHAR_T wchar_t
@ -2420,6 +2423,17 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
done = EOF;
goto errout;
}
#if __HAVE_FLOAT128_UNLIKE_LDBL
if ((flags & LONGDBL) \
&& (mode_flags & SCANF_LDBL_USES_FLOAT128) != 0)
{
_Float128 d = __strtof128_internal
(char_buffer_start (&charbuf), &tw, flags & GROUP);
if (!(flags & SUPPRESS) && tw != char_buffer_start (&charbuf))
*ARG (_Float128 *) = d;
}
else
#endif
if ((flags & LONGDBL) \
&& __glibc_likely ((mode_flags & SCANF_LDBL_IS_DBL) == 0))
{