From 57fa34b52e7c26f780c6bcae7a8ea863dfe710e1 Mon Sep 17 00:00:00 2001 From: joseph Date: Sun, 18 Mar 2007 18:01:40 +0000 Subject: Merge changes between r1382 and r1748 from /fsf/trunk. git-svn-id: svn://svn.eglibc.org/trunk@1749 7b3dc134-2b1b-0410-93df-9e9f96275f8d --- libc/stdlib/bits/stdlib.h | 12 +++++----- libc/stdlib/gmp.h | 6 +++-- libc/stdlib/stdlib.h | 28 +++++++++++------------ libc/stdlib/strtod_l.c | 57 ++++++++++++++++++++++++++--------------------- 4 files changed, 56 insertions(+), 47 deletions(-) (limited to 'libc/stdlib') diff --git a/libc/stdlib/bits/stdlib.h b/libc/stdlib/bits/stdlib.h index 4bacb09a0..7ee7bf558 100644 --- a/libc/stdlib/bits/stdlib.h +++ b/libc/stdlib/bits/stdlib.h @@ -1,5 +1,5 @@ /* Checking macros for stdlib functions. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -28,7 +28,7 @@ extern char *__REDIRECT_NTH (__realpath_alias, (__const char *__restrict __name, char *__restrict __resolved), realpath) __wur; -extern __always_inline __wur char * +__extern_always_inline __wur char * __NTH (realpath (__const char *__restrict __name, char *__restrict __resolved)) { if (__bos (__resolved) != (size_t) -1) @@ -44,7 +44,7 @@ extern int __REDIRECT_NTH (__ptsname_r_alias, (int __fd, char *__buf, size_t __buflen), ptsname_r) __nonnull ((2)); -extern __always_inline int +__extern_always_inline int __NTH (ptsname_r (int __fd, char *__buf, size_t __buflen)) { if (__bos (__buf) != (size_t) -1 @@ -59,7 +59,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 +__extern_always_inline __wur int __NTH (wctomb (char *__s, wchar_t __wchar)) { /* We would have to include to get a definition of MB_LEN_MAX. @@ -83,7 +83,7 @@ extern size_t __REDIRECT_NTH (__mbstowcs_alias, __const char *__restrict __src, size_t __len), mbstowcs); -extern __always_inline size_t +__extern_always_inline size_t __NTH (mbstowcs (wchar_t *__restrict __dst, __const char *__restrict __src, size_t __len)) { @@ -104,7 +104,7 @@ extern size_t __REDIRECT_NTH (__wcstombs_alias, __const wchar_t *__restrict __src, size_t __len), wcstombs); -extern __always_inline size_t +__extern_always_inline size_t __NTH (wcstombs (char *__restrict __dst, __const wchar_t *__restrict __src, size_t __len)) { diff --git a/libc/stdlib/gmp.h b/libc/stdlib/gmp.h index 0ecc6d102..cace8be23 100644 --- a/libc/stdlib/gmp.h +++ b/libc/stdlib/gmp.h @@ -1,6 +1,6 @@ /* gmp.h -- Definitions for GNU multiple precision functions. -Copyright (C) 1991, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. +Copyright (C) 1991, 1993, 1994, 1995, 1996, 2007 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -21,6 +21,8 @@ MA 02111-1307, USA. */ #ifndef __GMP_H__ +#include + #ifndef __GNU_MP__ #define __GNU_MP__ 2 #define __need_size_t @@ -41,7 +43,7 @@ MA 02111-1307, USA. */ #ifndef _EXTERN_INLINE #ifdef __GNUC__ -#define _EXTERN_INLINE extern __inline__ +#define _EXTERN_INLINE __extern_inline #else #define _EXTERN_INLINE static #endif diff --git a/libc/stdlib/stdlib.h b/libc/stdlib/stdlib.h index 7b39bc018..af27d09e3 100644 --- a/libc/stdlib/stdlib.h +++ b/libc/stdlib/stdlib.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2003,2004,2005,2006 Free Software Foundation, Inc. +/* Copyright (C) 1991-2003,2004,2005,2006,2007 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -324,18 +324,18 @@ extern unsigned long long int __strtoull_internal (__const char * /* Define inline functions which call the internal entry points. */ __BEGIN_NAMESPACE_STD -extern __inline double +__extern_inline double __NTH (strtod (__const char *__restrict __nptr, char **__restrict __endptr)) { return __strtod_internal (__nptr, __endptr, 0); } -extern __inline long int +__extern_inline long int __NTH (strtol (__const char *__restrict __nptr, char **__restrict __endptr, int __base)) { return __strtol_internal (__nptr, __endptr, __base, 0); } -extern __inline unsigned long int +__extern_inline unsigned long int __NTH (strtoul (__const char *__restrict __nptr, char **__restrict __endptr, int __base)) { @@ -345,13 +345,13 @@ __END_NAMESPACE_STD # ifdef __USE_ISOC99 __BEGIN_NAMESPACE_C99 -extern __inline float +__extern_inline float __NTH (strtof (__const char *__restrict __nptr, char **__restrict __endptr)) { return __strtof_internal (__nptr, __endptr, 0); } # ifndef __LDBL_COMPAT -extern __inline long double +__extern_inline long double __NTH (strtold (__const char *__restrict __nptr, char **__restrict __endptr)) { return __strtold_internal (__nptr, __endptr, 0); @@ -361,13 +361,13 @@ __END_NAMESPACE_C99 # endif # ifdef __USE_BSD -__extension__ extern __inline long long int +__extension__ __extern_inline long long int __NTH (strtoq (__const char *__restrict __nptr, char **__restrict __endptr, int __base)) { return __strtoll_internal (__nptr, __endptr, __base, 0); } -__extension__ extern __inline unsigned long long int +__extension__ __extern_inline unsigned long long int __NTH (strtouq (__const char *__restrict __nptr, char **__restrict __endptr, int __base)) { @@ -377,13 +377,13 @@ __NTH (strtouq (__const char *__restrict __nptr, char **__restrict __endptr, # if defined __USE_MISC || defined __USE_ISOC99 __BEGIN_NAMESPACE_C99 -__extension__ extern __inline long long int +__extension__ __extern_inline long long int __NTH (strtoll (__const char *__restrict __nptr, char **__restrict __endptr, int __base)) { return __strtoll_internal (__nptr, __endptr, __base, 0); } -__extension__ extern __inline unsigned long long int +__extension__ __extern_inline unsigned long long int __NTH (strtoull (__const char * __restrict __nptr, char **__restrict __endptr, int __base)) { @@ -393,17 +393,17 @@ __END_NAMESPACE_C99 # endif __BEGIN_NAMESPACE_STD -extern __inline double +__extern_inline double __NTH (atof (__const char *__nptr)) { return strtod (__nptr, (char **) NULL); } -extern __inline int +__extern_inline int __NTH (atoi (__const char *__nptr)) { return (int) strtol (__nptr, (char **) NULL, 10); } -extern __inline long int +__extern_inline long int __NTH (atol (__const char *__nptr)) { return strtol (__nptr, (char **) NULL, 10); @@ -412,7 +412,7 @@ __END_NAMESPACE_STD # if defined __USE_MISC || defined __USE_ISOC99 __BEGIN_NAMESPACE_C99 -__extension__ extern __inline long long int +__extension__ __extern_inline long long int __NTH (atoll (__const char *__nptr)) { return strtoll (__nptr, (char **) NULL, 10); diff --git a/libc/stdlib/strtod_l.c b/libc/stdlib/strtod_l.c index bb7493bff..4033e3bef 100644 --- a/libc/stdlib/strtod_l.c +++ b/libc/stdlib/strtod_l.c @@ -482,7 +482,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) struct locale_data *current = loc->__locales[LC_NUMERIC]; - if (group) + if (__builtin_expect (group, 0)) { grouping = _NL_CURRENT (LC_NUMERIC, GROUPING); if (*grouping <= 0 || *grouping == CHAR_MAX) @@ -548,7 +548,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) && (wint_t) cp[1] >= L'0' && (wint_t) cp[1] <= L'9') { /* We accept it. This funny construct is here only to indent - the code directly. */ + the code correctly. */ } #else for (cnt = 0; decimal[cnt] != '\0'; ++cnt) @@ -557,13 +557,15 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) if (decimal[cnt] == '\0' && cp[cnt] >= '0' && cp[cnt] <= '9') { /* We accept it. This funny construct is here only to indent - the code directly. */ + the code correctly. */ } #endif else if (c < L_('0') || c > L_('9')) { /* Check for `INF' or `INFINITY'. */ - if (TOLOWER_C (c) == L_('i') && STRNCASECMP (cp, L_("inf"), 3) == 0) + CHAR_TYPE lowc = TOLOWER_C (c); + + if (lowc == L_('i') && STRNCASECMP (cp, L_("inf"), 3) == 0) { /* Return +/- infinity. */ if (endptr != NULL) @@ -574,7 +576,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) return negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL; } - if (TOLOWER_C (c) == L_('n') && STRNCASECMP (cp, L_("nan"), 3) == 0) + if (lowc == L_('n') && STRNCASECMP (cp, L_("nan"), 3) == 0) { /* Return NaN. */ FLOAT retval = NAN; @@ -588,7 +590,8 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) do ++cp; while ((*cp >= L_('0') && *cp <= L_('9')) - || (TOLOWER (*cp) >= L_('a') && TOLOWER (*cp) <= L_('z')) + || ({ CHAR_TYPE lo = TOLOWER (*cp); + lo >= L_('a') && lo <= L_('z'); }) || *cp == L_('_')); if (*cp != L_(')')) @@ -640,7 +643,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) while (c == L'0' || ((wint_t) thousands != L'\0' && c == (wint_t) thousands)) c = *++cp; #else - if (thousands == NULL) + if (__builtin_expect (thousands == NULL, 1)) while (c == '0') c = *++cp; else @@ -664,9 +667,9 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) /* If no other digit but a '0' is found the result is 0.0. Return current read pointer. */ + CHAR_TYPE lowc = TOLOWER (c); if (!((c >= L_('0') && c <= L_('9')) - || (base == 16 && ((CHAR_TYPE) TOLOWER (c) >= L_('a') - && (CHAR_TYPE) TOLOWER (c) <= L_('f'))) + || (base == 16 && lowc >= L_('a') && lowc <= L_('f')) || ( #ifdef USE_WIDE_CHAR c == (wint_t) decimal @@ -682,11 +685,11 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) && (base != 16 || cp != start_of_digits || (cp[decimal_len] >= L_('0') && cp[decimal_len] <= L_('9')) - || ((CHAR_TYPE) TOLOWER (cp[decimal_len]) >= L_('a') - && (CHAR_TYPE) TOLOWER (cp[decimal_len]) <= L_('f')))) + || ({ CHAR_TYPE lo = TOLOWER (cp[decimal_len]); + lo >= L_('a') && lo <= L_('f'); }))) || (base == 16 && (cp != start_of_digits - && (CHAR_TYPE) TOLOWER (c) == L_('p'))) - || (base != 16 && (CHAR_TYPE) TOLOWER (c) == L_('e')))) + && lowc == L_('p'))) + || (base != 16 && lowc == L_('e')))) { #ifdef USE_WIDE_CHAR tp = __correctly_grouped_prefixwc (start_of_digits, cp, thousands, @@ -707,17 +710,19 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) while (1) { if ((c >= L_('0') && c <= L_('9')) - || (base == 16 && (wint_t) TOLOWER (c) >= L_('a') - && (wint_t) TOLOWER (c) <= L_('f'))) + || (base == 16 + && ({ CHAR_TYPE lo = TOLOWER (c); + lo >= L_('a') && lo <= L_('f'); }))) ++dig_no; else { #ifdef USE_WIDE_CHAR - if ((wint_t) thousands == L'\0' || c != (wint_t) thousands) + if (__builtin_expect ((wint_t) thousands == L'\0', 1) + || c != (wint_t) thousands) /* Not a digit or separator: end of the integer part. */ break; #else - if (thousands == NULL) + if (__builtin_expect (thousands == NULL, 1)) break; else { @@ -733,7 +738,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) c = *++cp; } - if (grouping && cp > start_of_digits) + if (__builtin_expect (grouping != NULL, 0) && cp > start_of_digits) { /* Check the grouping of the digits. */ #ifdef USE_WIDE_CHAR @@ -794,7 +799,8 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) cp += decimal_len; c = *cp; while ((c >= L_('0') && c <= L_('9')) || - (base == 16 && TOLOWER (c) >= L_('a') && TOLOWER (c) <= L_('f'))) + (base == 16 && ({ CHAR_TYPE lo = TOLOWER (c); + lo >= L_('a') && lo <= L_('f'); }))) { if (c != L_('0') && lead_zero == -1) lead_zero = dig_no - int_no; @@ -807,8 +813,9 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) expp = cp; /* Read exponent. */ - if ((base == 16 && TOLOWER (c) == L_('p')) - || (base != 16 && TOLOWER (c) == L_('e'))) + lowc = TOLOWER (c); + if ((base == 16 && lowc == L_('p')) + || (base != 16 && lowc == L_('e'))) { int exp_negative = 0; @@ -840,7 +847,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) exponent *= 10; exponent += c - L_('0'); - if (exponent > exp_limit) + if (__builtin_expect (exponent > exp_limit, 0)) /* The exponent is too large/small to represent a valid number. */ { @@ -1024,13 +1031,13 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) exponent -= incr; } - if (int_no + exponent > MAX_10_EXP + 1) + if (__builtin_expect (int_no + exponent > MAX_10_EXP + 1, 0)) { __set_errno (ERANGE); return negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL; } - if (exponent < MIN_10_EXP - (DIG + 1)) + if (__builtin_expect (exponent < MIN_10_EXP - (DIG + 1), 0)) { __set_errno (ERANGE); return 0.0; @@ -1094,7 +1101,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) /* Now we know the exponent of the number in base two. Check it against the maximum possible exponent. */ - if (bits > MAX_EXP) + if (__builtin_expect (bits > MAX_EXP, 0)) { __set_errno (ERANGE); return negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL; -- cgit v1.2.3