glibc/sysdeps/ieee754/ldbl-128
Joseph Myers e02cabecf0 Refactor strtod parsing of NaN payloads.
The nan* functions handle their string argument by constructing a
NAN(...) string on the stack as a VLA and passing it to strtod
functions.

This approach has problems discussed in bug 16961 and bug 16962: the
stack usage is unbounded, and it gives incorrect results in certain
cases where the argument is not a valid n-char-sequence.

The natural fix for both issues is to refactor the NaN payload parsing
out of strtod into a separate function that the nan* functions can
call directly, so that no temporary string needs constructing on the
stack at all.  This patch does that refactoring in preparation for
fixing those bugs (but without actually using the new functions from
nan* - which will also require exporting them from libc at version
GLIBC_PRIVATE).  This patch is not intended to change any user-visible
behavior, so no tests are added (fixes for the above bugs will of
course add tests for them).

This patch builds on my recent fixes for strtol and strtod issues in
Turkish locales.  Given those fixes, the parsing of NaN payloads is
locale-independent; thus, the new functions do not need to take a
locale_t argument.

Tested for x86_64, x86, mips64 and powerpc.

	* stdlib/strtod_nan.c: New file.
	* stdlib/strtod_nan_double.h: Likewise.
	* stdlib/strtod_nan_float.h: Likewise.
	* stdlib/strtod_nan_main.c: Likewise.
	* stdlib/strtod_nan_narrow.h: Likewise.
	* stdlib/strtod_nan_wide.h: Likewise.
	* stdlib/strtof_nan.c: Likewise.
	* stdlib/strtold_nan.c: Likewise.
	* sysdeps/ieee754/ldbl-128/strtod_nan_ldouble.h: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/strtod_nan_ldouble.h: Likewise.
	* sysdeps/ieee754/ldbl-96/strtod_nan_ldouble.h: Likewise.
	* wcsmbs/wcstod_nan.c: Likewise.
	* wcsmbs/wcstof_nan.c: Likewise.
	* wcsmbs/wcstold_nan.c: Likewise.
	* stdlib/Makefile (routines): Add strtof_nan, strtod_nan and
	strtold_nan.
	* wcsmbs/Makefile (routines): Add wcstod_nan, wcstold_nan and
	wcstof_nan.
	* include/stdlib.h (__strtof_nan): Declare and use
	libc_hidden_proto.
	(__strtod_nan): Likewise.
	(__strtold_nan): Likewise.
	(__wcstof_nan): Likewise.
	(__wcstod_nan): Likewise.
	(__wcstold_nan): Likewise.
	* include/wchar.h (____wcstoull_l_internal): Declare.
	* stdlib/strtod_l.c: Do not include <ieee754.h>.
	(____strtoull_l_internal): Remove declaration.
	(STRTOF_NAN): Define macro.
	(SET_MANTISSA): Remove macro.
	(STRTOULL): Likewise.
	(____STRTOF_INTERNAL): Use STRTOF_NAN to parse NaN payload.
	* stdlib/strtof_l.c (____strtoull_l_internal): Remove declaration.
	(STRTOF_NAN): Define macro.
	(SET_MANTISSA): Remove macro.
	* sysdeps/ieee754/ldbl-128/strtold_l.c (STRTOF_NAN): Define macro.
	(SET_MANTISSA): Remove macro.
	* sysdeps/ieee754/ldbl-128ibm/strtold_l.c (STRTOF_NAN): Define
	macro.
	(SET_MANTISSA): Remove macro.
	* sysdeps/ieee754/ldbl-64-128/strtold_l.c (STRTOF_NAN): Define
	macro.
	(SET_MANTISSA): Remove macro.
	* sysdeps/ieee754/ldbl-96/strtold_l.c (STRTOF_NAN): Define macro.
	(SET_MANTISSA): Remove macro.
	* wcsmbs/wcstod_l.c (____wcstoull_l_internal): Remove declaration.
	* wcsmbs/wcstof_l.c (____wcstoull_l_internal): Likewise.
	* wcsmbs/wcstold_l.c (____wcstoull_l_internal): Likewise.
2015-11-24 22:24:52 +00:00
..
e_acoshl.c
e_acosl.c
e_asinl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
e_atan2l.c
e_atanhl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
e_coshl.c
e_exp10l.c
e_expl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
e_fmodl.c
e_gammal_r.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
e_hypotl.c Fix hypot missing underflows (bug 18803). 2015-09-24 23:43:57 +00:00
e_ilogbl.c
e_j0l.c Fix ldbl-128 j0l spurious underflows (bug 19156). 2015-10-21 16:40:20 +00:00
e_j1l.c Fix j1, jn missing errno setting on underflow (bug 18611). 2015-10-23 21:37:33 +00:00
e_jnl.c Fix j1, jn missing errno setting on underflow (bug 18611). 2015-10-23 21:37:33 +00:00
e_lgammal_r.c Fix ldbl-128 / ldbl-128ibm lgamma overflow handling (bug 16347, bug 19046). 2015-10-01 17:15:54 +00:00
e_log2l.c Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
e_log10l.c
e_logl.c
e_powl.c Fix pow missing underflows (bug 18825). 2015-09-25 22:29:10 +00:00
e_rem_pio2l.c
e_remainderl.c
e_sinhl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
gamma_productl.c
ieee754.h
k_cosl.c
k_sincosl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
k_sinl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
k_tanl.c Remove GCC version conditionals on -Wmaybe-uninitialized pragmas. 2015-10-27 23:42:20 +00:00
ldbl2mpn.c
lgamma_negl.c
lgamma_productl.c
Makefile
math_ldbl.h
mpn2ldbl.c
printf_fphex.c
s_asinhl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_atanl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_cbrtl.c
s_ceill.c
s_copysignl.c
s_cosl.c
s_erfl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_expm1l.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_fabsl.c
s_finitel.c Reduce number of constants in __finite* (bug 15384). 2015-09-17 16:47:14 +00:00
s_floorl.c
s_fma.c
s_fmal.c Use C11 *_TRUE_MIN macros where applicable. 2015-10-28 21:42:52 +00:00
s_fpclassifyl.c
s_frexpl.c
s_isinfl.c
s_isnanl.c
s_issignalingl.c
s_llrintl.c Fix lrint, llrint missing exceptions close to overflow threshold (bug 19094). 2015-10-08 22:17:45 +00:00
s_llroundl.c Fix lround, llround missing exceptions close to overflow threshold (bug 19088). 2015-10-07 23:45:29 +00:00
s_log1pl.c Fix ldbl-128 log1pl (-qNaN) spurious "invalid" exception (bug 19189). 2015-10-29 23:09:51 +00:00
s_logbl.c
s_lrintl.c Fix lrint, llrint missing exceptions close to overflow threshold (bug 19094). 2015-10-08 22:17:45 +00:00
s_lroundl.c Fix lround, llround missing exceptions close to overflow threshold (bug 19088). 2015-10-07 23:45:29 +00:00
s_modfl.c
s_nearbyintl.c
s_nextafterl.c Make nextafter, nexttoward set errno (bug 6799). 2015-11-02 18:54:19 +00:00
s_nexttoward.c Make nextafter, nexttoward set errno (bug 6799). 2015-11-02 18:54:19 +00:00
s_nexttowardf.c Make nextafter, nexttoward set errno (bug 6799). 2015-11-02 18:54:19 +00:00
s_remquol.c
s_rintl.c
s_roundl.c
s_scalblnl.c
s_scalbnl.c Make scalbn set errno (bug 6803). 2015-09-16 21:11:00 +00:00
s_signbitl.c Use the GCC builtin functions for the non-inlined signbit implementations. 2015-09-18 16:39:08 +01:00
s_sincosl.c Since we now inline isinf, isnan and isfinite in math.h, replace uses of __isinf_ns(l/f) 2015-09-18 20:51:52 +01:00
s_sinl.c
s_tanhl.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_tanl.c
s_truncl.c
strtod_nan_ldouble.h Refactor strtod parsing of NaN payloads. 2015-11-24 22:24:52 +00:00
strtold_l.c Refactor strtod parsing of NaN payloads. 2015-11-24 22:24:52 +00:00
t_expl.h
t_sincosl.c
w_expl.c
x2y2m1l.c Fix clog, clog10 inaccuracy (bug 19016). 2015-09-28 22:11:22 +00:00