glibc/sysdeps
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
..
aarch64 Enable _STRING_ARCH_unaligned on AArch64. 2015-11-10 11:15:59 +00:00
alpha
arm Fix math_private.h multiple include guards. 2015-11-20 23:46:23 +00:00
generic Replace MUTEX_INITIALIZER with _LIBC_LOCK_INITIALIZER in generic code 2015-11-24 16:37:15 +01:00
gnu
hppa Fix math_private.h multiple include guards. 2015-11-20 23:46:23 +00:00
i386 Fix math_private.h multiple include guards. 2015-11-20 23:46:23 +00:00
ia64 Fix lgamma setting signgam for ISO C (bug 15421). 2015-11-20 22:49:59 +00:00
ieee754 Refactor strtod parsing of NaN payloads. 2015-11-24 22:24:52 +00:00
init_array
m68k Fix math_private.h multiple include guards. 2015-11-20 23:46:23 +00:00
mach Replace MUTEX_INITIALIZER with _LIBC_LOCK_INITIALIZER in generic code 2015-11-24 16:37:15 +01:00
microblaze Fix math_private.h multiple include guards. 2015-11-20 23:46:23 +00:00
mips Fix math_private.h multiple include guards. 2015-11-20 23:46:23 +00:00
nacl NaCl: Use allocate_code_data after dyncode_create 2015-11-20 16:16:35 -08:00
nios2 Fix math_private.h multiple include guards. 2015-11-20 23:46:23 +00:00
nptl Replace MUTEX_INITIALIZER with _LIBC_LOCK_INITIALIZER in generic code 2015-11-24 16:37:15 +01:00
posix Remove signal handling for nanosleep (bug 16364) 2015-11-20 11:16:07 -02:00
powerpc powerpc: Spinlock optimization and cleanup 2015-11-19 18:04:30 -02:00
pthread
s390 S390: Use __asm__ instead of asm. 2015-11-20 08:56:40 +01:00
sh
sparc
tile tile: define __NO_LONG_DOUBLE_MATH 2015-11-24 14:09:31 -05:00
unix tile: define __NO_LONG_DOUBLE_MATH 2015-11-24 14:09:31 -05:00
wordsize-32
wordsize-64 Add LFS support for fts functions (bug 11460) 2015-11-06 11:24:16 +01:00
x86 Run tst-prelink test for GLOB_DAT reloc 2015-11-14 12:00:38 -08:00
x86_64