diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2012-05-04 19:29:27 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2012-05-04 19:29:27 +0000 |
commit | a19eeb99758498e918043d50b57ba75b2d938e50 (patch) | |
tree | 0b179455707ed727766787b7ef0d276d5d7dd315 /libc/stdlib | |
parent | ded28410835671021876e845572816d3083efe34 (diff) |
Merge changes between r18165 and r18362 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@18363 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/stdlib')
-rw-r--r-- | libc/stdlib/Makefile | 1 | ||||
-rw-r--r-- | libc/stdlib/bits/stdlib.h | 10 | ||||
-rw-r--r-- | libc/stdlib/stdlib.h | 34 | ||||
-rw-r--r-- | libc/stdlib/strtod_l.c | 19 | ||||
-rw-r--r-- | libc/stdlib/tst-strtod.c | 5 |
5 files changed, 43 insertions, 26 deletions
diff --git a/libc/stdlib/Makefile b/libc/stdlib/Makefile index 2200dd07d..0ae7047c1 100644 --- a/libc/stdlib/Makefile +++ b/libc/stdlib/Makefile @@ -152,6 +152,7 @@ $(objpfx)tst-fmtmsg.out: tst-fmtmsg.sh $(objpfx)tst-fmtmsg $(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)stdlib/ $(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so +LDFLAGS-tst-putenv = $(no-as-needed) $(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os $(build-module) diff --git a/libc/stdlib/bits/stdlib.h b/libc/stdlib/bits/stdlib.h index 43c45a63a..084b43847 100644 --- a/libc/stdlib/bits/stdlib.h +++ b/libc/stdlib/bits/stdlib.h @@ -33,7 +33,7 @@ extern char *__REDIRECT_NTH (__realpath_chk_warn, __warnattr ("second argument of realpath must be either NULL or at " "least PATH_MAX bytes long buffer"); -__extern_always_inline __wur char * +__fortify_function __wur char * __NTH (realpath (const char *__restrict __name, char *__restrict __resolved)) { if (__bos (__resolved) != (size_t) -1) @@ -60,7 +60,7 @@ extern int __REDIRECT_NTH (__ptsname_r_chk_warn, __nonnull ((2)) __warnattr ("ptsname_r called with buflen bigger than " "size of buf"); -__extern_always_inline int +__fortify_function int __NTH (ptsname_r (int __fd, char *__buf, size_t __buflen)) { if (__bos (__buf) != (size_t) -1) @@ -79,7 +79,7 @@ extern int __wctomb_chk (char *__s, wchar_t __wchar, size_t __buflen) extern int __REDIRECT_NTH (__wctomb_alias, (char *__s, wchar_t __wchar), wctomb) __wur; -__extern_always_inline __wur int +__fortify_function __wur int __NTH (wctomb (char *__s, wchar_t __wchar)) { /* We would have to include <limits.h> to get a definition of MB_LEN_MAX. @@ -109,7 +109,7 @@ extern size_t __REDIRECT_NTH (__mbstowcs_chk_warn, __warnattr ("mbstowcs called with dst buffer smaller than len " "* sizeof (wchar_t)"); -__extern_always_inline size_t +__fortify_function size_t __NTH (mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src, size_t __len)) { @@ -140,7 +140,7 @@ extern size_t __REDIRECT_NTH (__wcstombs_chk_warn, size_t __len, size_t __dstlen), __wcstombs_chk) __warnattr ("wcstombs called with dst buffer smaller than len"); -__extern_always_inline size_t +__fortify_function size_t __NTH (wcstombs (char *__restrict __dst, const wchar_t *__restrict __src, size_t __len)) { diff --git a/libc/stdlib/stdlib.h b/libc/stdlib/stdlib.h index 4da4678f8..f652eda3f 100644 --- a/libc/stdlib/stdlib.h +++ b/libc/stdlib/stdlib.h @@ -163,18 +163,18 @@ __BEGIN_NAMESPACE_STD /* Convert a string to a floating-point number. */ extern double strtod (const char *__restrict __nptr, char **__restrict __endptr) - __THROW __nonnull ((1)) __wur; + __THROW __nonnull ((1)); __END_NAMESPACE_STD #ifdef __USE_ISOC99 __BEGIN_NAMESPACE_C99 /* Likewise for `float' and `long double' sizes of floating-point numbers. */ extern float strtof (const char *__restrict __nptr, - char **__restrict __endptr) __THROW __nonnull ((1)) __wur; + char **__restrict __endptr) __THROW __nonnull ((1)); extern long double strtold (const char *__restrict __nptr, char **__restrict __endptr) - __THROW __nonnull ((1)) __wur; + __THROW __nonnull ((1)); __END_NAMESPACE_C99 #endif @@ -182,11 +182,11 @@ __BEGIN_NAMESPACE_STD /* Convert a string to a long integer. */ extern long int strtol (const char *__restrict __nptr, char **__restrict __endptr, int __base) - __THROW __nonnull ((1)) __wur; + __THROW __nonnull ((1)); /* Convert a string to an unsigned long integer. */ extern unsigned long int strtoul (const char *__restrict __nptr, char **__restrict __endptr, int __base) - __THROW __nonnull ((1)) __wur; + __THROW __nonnull ((1)); __END_NAMESPACE_STD #if defined __GLIBC_HAVE_LONG_LONG && defined __USE_BSD @@ -194,12 +194,12 @@ __END_NAMESPACE_STD __extension__ extern long long int strtoq (const char *__restrict __nptr, char **__restrict __endptr, int __base) - __THROW __nonnull ((1)) __wur; + __THROW __nonnull ((1)); /* Convert a string to an unsigned quadword integer. */ __extension__ extern unsigned long long int strtouq (const char *__restrict __nptr, char **__restrict __endptr, int __base) - __THROW __nonnull ((1)) __wur; + __THROW __nonnull ((1)); #endif /* GCC and use BSD. */ #if defined __USE_ISOC99 || (defined __GLIBC_HAVE_LONG_LONG && defined __USE_MISC) @@ -208,12 +208,12 @@ __BEGIN_NAMESPACE_C99 __extension__ extern long long int strtoll (const char *__restrict __nptr, char **__restrict __endptr, int __base) - __THROW __nonnull ((1)) __wur; + __THROW __nonnull ((1)); /* Convert a string to an unsigned quadword integer. */ __extension__ extern unsigned long long int strtoull (const char *__restrict __nptr, char **__restrict __endptr, int __base) - __THROW __nonnull ((1)) __wur; + __THROW __nonnull ((1)); __END_NAMESPACE_C99 #endif /* ISO C99 or GCC and use MISC. */ @@ -238,37 +238,37 @@ __END_NAMESPACE_C99 use as an additional parameter. */ extern long int strtol_l (const char *__restrict __nptr, char **__restrict __endptr, int __base, - __locale_t __loc) __THROW __nonnull ((1, 4)) __wur; + __locale_t __loc) __THROW __nonnull ((1, 4)); extern unsigned long int strtoul_l (const char *__restrict __nptr, char **__restrict __endptr, int __base, __locale_t __loc) - __THROW __nonnull ((1, 4)) __wur; + __THROW __nonnull ((1, 4)); __extension__ extern long long int strtoll_l (const char *__restrict __nptr, char **__restrict __endptr, int __base, __locale_t __loc) - __THROW __nonnull ((1, 4)) __wur; + __THROW __nonnull ((1, 4)); __extension__ extern unsigned long long int strtoull_l (const char *__restrict __nptr, char **__restrict __endptr, int __base, __locale_t __loc) - __THROW __nonnull ((1, 4)) __wur; + __THROW __nonnull ((1, 4)); extern double strtod_l (const char *__restrict __nptr, char **__restrict __endptr, __locale_t __loc) - __THROW __nonnull ((1, 3)) __wur; + __THROW __nonnull ((1, 3)); extern float strtof_l (const char *__restrict __nptr, char **__restrict __endptr, __locale_t __loc) - __THROW __nonnull ((1, 3)) __wur; + __THROW __nonnull ((1, 3)); extern long double strtold_l (const char *__restrict __nptr, char **__restrict __endptr, __locale_t __loc) - __THROW __nonnull ((1, 3)) __wur; + __THROW __nonnull ((1, 3)); #endif /* GNU */ @@ -953,7 +953,7 @@ extern int getloadavg (double __loadavg[], int __nelem) /* Define some macros helping to catch buffer overflows. */ -#if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline +#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function # include <bits/stdlib.h> #endif #ifdef __LDBL_COMPAT diff --git a/libc/stdlib/strtod_l.c b/libc/stdlib/strtod_l.c index b587687a5..14c0e4892 100644 --- a/libc/stdlib/strtod_l.c +++ b/libc/stdlib/strtod_l.c @@ -1,6 +1,5 @@ /* Convert string representing a number to float value, using given locale. - Copyright (C) 1997,1998,2002,2004,2005,2006,2007,2008,2009,2010,2011 - Free Software Foundation, Inc. + Copyright (C) 1997-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -1007,8 +1006,20 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) retval[idx--] |= val >> (4 - pos - 1); val <<= BITS_PER_MP_LIMB - (4 - pos - 1); if (idx < 0) - return round_and_return (retval, exponent, negative, val, - BITS_PER_MP_LIMB - 1, dig_no > 0); + { + int rest_nonzero = 0; + while (--dig_no > 0) + { + if (*startp != L_('0')) + { + rest_nonzero = 1; + break; + } + startp++; + } + return round_and_return (retval, exponent, negative, val, + BITS_PER_MP_LIMB - 1, rest_nonzero); + } retval[idx] = val; pos = BITS_PER_MP_LIMB - 1 - (4 - pos - 1); diff --git a/libc/stdlib/tst-strtod.c b/libc/stdlib/tst-strtod.c index 5b3cd0cdf..1f43b7ffe 100644 --- a/libc/stdlib/tst-strtod.c +++ b/libc/stdlib/tst-strtod.c @@ -70,6 +70,11 @@ static const struct ltest tests[] = { "+InFiNiTy", HUGE_VAL, '\0', 0 }, { "0x80000Ap-23", 0x80000Ap-23, '\0', 0 }, { "1e-324", 0, '\0', ERANGE }, + { "0x100000000000008p0", 0x1p56, '\0', 0 }, + { "0x100000000000008.p0", 0x1p56, '\0', 0 }, + { "0x100000000000008.00p0", 0x1p56, '\0', 0 }, + { "0x10000000000000800p0", 0x1p64, '\0', 0 }, + { "0x10000000000000801p0", 0x1.0000000000001p64, '\0', 0 }, { NULL, 0, '\0', 0 } }; |