diff options
author | Jakub Jelinek <jakub@redhat.com> | 2009-02-04 22:36:03 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2009-02-04 22:36:03 +0000 |
commit | 73c5dd45bc405428148ee740cac61a1279fe57d4 (patch) | |
tree | 878555d8c116d7ac9cb716b79e10d240fde946a3 | |
parent | 23a4b43d6a98912d505458daeced44b22830a773 (diff) | |
download | glibc-73c5dd45bc405428148ee740cac61a1279fe57d4.tar.gz glibc-73c5dd45bc405428148ee740cac61a1279fe57d4.tar.xz glibc-73c5dd45bc405428148ee740cac61a1279fe57d4.zip |
Updated to fedora-glibc-20090204T2135 cvs/fedora-glibc-2_9_90-3
76 files changed, 1313 insertions, 276 deletions
diff --git a/ChangeLog b/ChangeLog index cf23772cff..d8e6650e09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,175 @@ +2009-02-04 Ulrich Drepper <drepper@redhat.com> + + * libio/wfileops.c (_IO_wfile_underflow): Fix handling of + incomplete characters at end of input buffer. + * libio/Makefile (tests): Add tst-fgetwc. + * libio/tst-fgetwc.c: New file. + * libio/tst-fgetwc.input: New file. + +2009-02-02 Andrew Stubbs <ams@codesourcery.com> + + * sysdeps/unix/sysv/linux/sh/Makefile (libm.so-no-z-defs): Define. + +2009-02-02 Ulrich Drepper <drepper@redhat.com> + + [BZ #9793] + * iconv/gconv_trans.c (__gconv_transliterate): Don't change + *OUTBUFSTART unless the whole output fit into the buffer. + * iconv/Makefile (tests): Add tst-iconv4. + * iconv/tst-iconv4.c: New file. + +2009-02-01 Ulrich Drepper <drepper@redhat.com> + + * sysdeps/x86_64/cacheinfo.c (intel_02_known): Add new descriptors. + * sysdeps/unix/sysv/linux/i386/sysconf.c (intel_02_known): Likewise. + +2009-01-29 Andrew Stubbs <ams@codesourcery.com> + + * elf/Makefile (ld.so): Adjust the sed script to insert _begin in to + newer linker scripts. + +2009-01-30 Ulrich Drepper <drepper@redhat.com> + + [BZ #7040] + * sysdeps/unix/sysv/linux/sys/inotify.h: Second parameter of + inotify_rm_watch should have type int. + +2009-01-06 Steven Munroe <sjmunroe@us.ibm.com> + + * sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S (__longjmp): + Make aligned_restore_vmx a local symbol. + * sysdeps/powerpc/powerpc64/__longjmp-common.S (__longjmp): + Likewise. + +2009-01-30 Andreas Jaeger <aj@suse.de> + + * sysdeps/unix/sysv/linux/bits/shm.h (SHM_EXEC): Define. + * sysdeps/unix/sysv/linux/ia64/bits/shm.h (SHM_EXEC): Define. + * sysdeps/unix/sysv/linux/powerpc/bits/shm.h (SHM_EXEC): Define. + * sysdeps/unix/sysv/linux/s390/bits/shm.h (SHM_EXEC): Define. + * sysdeps/unix/sysv/linux/sh/bits/shm.h (SHM_EXEC): Define. + * sysdeps/unix/sysv/linux/sparc/bits/shm.h (SHM_EXEC): Define. + * sysdeps/unix/sysv/linux/x86_64/bits/shm.h (SHM_EXEC): Define. + +2009-01-11 Ryan S. Arnold <rsa@us.ibm.com> + + [BZ #9726] + * sysdeps/powerpc/fpu/tst-setcontext-fpscr.c (_SET_DI_FPSCR, + _SET_SI_FPSCR): Clobber fp0 to prevent erroneous test-case passes. + +2009-01-08 Ryan S. Arnold <rsa@us.ibm.com> + + [BZ #9726] + * sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S + (__CONTEXT_FUNC_NAME): Fix mtfsf to use fp31 instead of fp0. + * sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S + (__CONTEXT_FUNC_NAME): Fix mtfsf to use fp31 instead of fp0. + +2009-01-11 Thomas Schwinge <tschwinge@gnu.org> + + * sysdeps/generic/dl-osinfo.h (_dl_setup_stack_chk_guard): Use + memcpy instead of memcmp. + (_dl_setup_pointer_guard): Likewise. + +2009-01-30 Ulrich Drepper <drepper@redhat.com> + + * malloc/malloc.c (sYSMALLOc): Don't use assert when detecting + manipulated brk, use malloc_printerr. + * misc/sbrk.c (__sbrk): Better error handling for nonsense + requests. + +2009-01-30 Jakub Jelinek <jakub@redhat.com> + + * string/string.h (memchr, strchr, strrchr, strpbrk, strstr, index, + rindex): For C++ add inlines so that they can be recognized as + builtins. + * string/strings.h: Define correct C++ prototypes for gcc 4.4. + +2009-01-29 Ulrich Drepper <drepper@redhat.com> + Jakub Jelinek <jakub@redhat.com> + + * string/string.h: Define correct C++ prototypes for gcc 4.4. + * wcsmbs/wchar.h: Likewise. + +2009-01-29 Ulrich Drepper <drepper@redhat.com> + + * sysdeps/i386/stackinfo.h (stackinfo_get_sp): Define. + (stackinfo_sub_sp): Define. + +2009-01-28 Ulrich Drepper <drepper@redhat.com> + + [BZ #9750] + * nscd/mem.c (gc): Use alloca_count to get the real stack usage. + * include/alloca.h (alloca_account): Define. + * sysdeps/x86_64/stackinfo.h (stackinfo_get_sp): Define. + (stackinfo_sub_sp): Define. + + * nscd/connections.c (nscd_init): If database file access fails + check whether this is due to permission problems and bail in that + case. + + [BZ #9741] + * nscd/mem.c (gc): Fix assignment of he_data in case malloc is used. + Reported by Jun'ichi Nomura <j-nomura@ce.jp.nec.com>. + +2009-01-14 Kaz Kojima <kkojima@rr.iij4u.or.jp> + + * sysdeps/unix/sysv/linux/sh/sysdep.h (INTERNAL_SYSCALL): + Add "t" to clobber list. + (INTERNAL_SYSCALL_NCS): Likewise. + +2009-01-28 Ulrich Drepper <drepper@redhat.com> + + * nss/getent.c (print_networks): Don't print comma between aliases. + +2009-01-23 Ulrich Drepper <drepper@redhat.com> + + * sysdeps/unix/sysv/linux/tst-clone.c (do_test): Avoid warning. + + * misc/hsearch_r.c (hcreate_r): We need at least three elements in + the hash table. + * misc/Makefile (tests): Add bug-hsearch1. + * misc/bug-hsearch1.c: New file. + +2009-01-22 Roland McGrath <roland@redhat.com> + + * Makeconfig (%.v.i): Strip trailing # comments, + not only whole-line comments. + +2009-01-10 Ulrich Drepper <drepper@redhat.com> + + * sysdeps/generic/dl-osinfo.h (_dl_setup_stack_chk_guard): Take + one parameter. If non-NULL use it to initialize return value. + (_dl_setup_pointer_guard): New function. + * sysdeps/unix/sysv/linux/dl-osinfo.h: Likewise. + * sysdeps/generic/ldsodefs.h: Declare _dl_random. + * elf/rtld.c (security_init): Pass _dl_random to + _dl_setup_stack_chk_guard. Call _dl_setup_pointer_guard to initialize + pointer_chk_guard. + * elf/dl-sysdep.c (_dl_random): New variable. + (_dl_sysdep_start): Handle AT_RANDOM. + (_dl_show_auxv): Likewise. + * elf/dl-support.c (_dl_random): New variable. + (_dl_aux_init): Handle AT_RANDOM. + * csu/libc-start.c [!SHARED] (libc_start_main): Pass _dl_random + to _dl_setup_stack_chk_guard. + + * elf/elf.h (AT_RANDOM): Define AT_BASE_PLATFORM and AT_RANDOM. + +2009-01-10 Roland McGrath <roland@redhat.com> + + * nscd/nscd.c (parse_opt): Use argp_error for bad -i argument. + +2009-01-08 Ulrich Drepper <drepper@redhat.com> + + * sysdeps/i386/fpu/libm-test-ulps: Adjust expm1 errors. + + [BZ #9706] + * nss/nss_files/files-parse.c (strtou32): New function. + (INT_FIELD): Use strotu32 instead of strtoul to unify behavior + across 32-bit and 64-bit platforms. + (INT_FIELD_MAYBE_NULL): Likewise. + 2009-01-08 Jakub Jelinek <jakub@redhat.com> [BZ #9720] @@ -8,14 +180,14 @@ 2009-01-05 Paolo Bonzini <bonzini@gnu.org> - [BZ 697] + [BZ #697] * posix/regexec.c (prune_impossible_nodes): Handle sifted_states[0] being NULL also if there are no backreferences. * posix/rxspencer/tests: Add testcases. 2009-01-04 Paolo Bonzini <bonzini@gnu.org> - [BZ 9697] + [BZ #9697] * posix/bug-regex17.c: Add testcases. * posix/regcomp.c (re_compile_fastmap_iter): Rewrite COMPLEX_BRACKET handling. @@ -535,7 +707,7 @@ [BZ #6942] * resolv/res_send.c (send_vc): Fix use of unaligned address. - Properly handle partial reads. + Properly handle partial reads. 2008-10-01 Mark Shinwell <shinwell@codesourcery.com> @@ -586,7 +758,7 @@ Patch by Michael Solberg <msolberg@redhat.com>. 2008-09-12 Flavio Leitner <fleitner@redhat.com> - Ulrich Drepper <drepper@redhat.com> + Ulrich Drepper <drepper@redhat.com> * malloc/malloc.c (public_vALLOc): Try other arenas in case _int_valloc fails. @@ -4539,7 +4711,7 @@ 2007-08-16 Andreas Jaeger <aj@suse.de> * locale/localeinfo.h: Make _nl_category_name_idxs extern. - Reported by Peter Festner <peter.festner@ewetel.net>. + Reported by Peter Festner <peter.festner@ewetel.net>. 2007-08-17 Jakub Jelinek <jakub@redhat.com> @@ -5629,8 +5801,8 @@ * sysdeps/generic/ldsodefs.h (_dl_addr_inside_object): New prototype. 2007-06-18 Jakub Jelinek <jakub@redhat.com> - Tomas Janousek <tjanouse@redhat.com> - Ulrich Drepper <drepper@redhat.com> + Tomas Janousek <tjanouse@redhat.com> + Ulrich Drepper <drepper@redhat.com> [BZ #4647] * resolv/res_send.c (send_dg): Remove socket_pf. Use ipv6_unavail diff --git a/FAQ b/FAQ index 9b557dae17..54f422a09e 100644 --- a/FAQ +++ b/FAQ @@ -570,8 +570,6 @@ Please note that `make check' might fail for a number of the math tests because of problems of the FPU emulation in the Linux kernel (the MIPS FPU doesn't handle all cases and needs help from the kernel). -For details check also my page <http://www.suse.de/~aj/glibc-mips.html>. - 1.21. Which compiler should I use for powerpc64? diff --git a/FAQ.in b/FAQ.in index a5c7123ad6..0eb6bac154 100644 --- a/FAQ.in +++ b/FAQ.in @@ -367,7 +367,6 @@ Please note that `make check' might fail for a number of the math tests because of problems of the FPU emulation in the Linux kernel (the MIPS FPU doesn't handle all cases and needs help from the kernel). -For details check also my page <http://www.suse.de/~aj/glibc-mips.html>. ??powerpc64 Which compiler should I use for powerpc64? diff --git a/Makeconfig b/Makeconfig index 83e14094c4..5451560745 100644 --- a/Makeconfig +++ b/Makeconfig @@ -1,4 +1,4 @@ -# Copyright (C) 1991-2003,2004,2005,2006,2007,2008 +# Copyright (C) 1991-2003,2004,2005,2006,2007,2008,2009 # Free Software Foundation, Inc. # This file is part of the GNU C Library. @@ -794,7 +794,8 @@ ifeq (yes, $(build-shared)) # listing both its input files, and any header files that it may reference # (but no commands). %.v.i: $(common-objpfx)config.h - sed '/^[ ]*#/d;s/^[ ]*%/#/' $(filter-out FORCE %.h,$^) \ + sed 's/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' \ + $(filter-out FORCE %.h,$^) \ | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \ > $@T mv -f $@T $@ diff --git a/NEWS b/NEWS index 095dbab44e..5c2d9a7ef7 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,5 @@ -GNU C Library NEWS -- history of user-visible changes. 2008-12-2 -Copyright (C) 1992-2007, 2008 Free Software Foundation, Inc. +GNU C Library NEWS -- history of user-visible changes. 2009-1-30 +Copyright (C) 1992-2008, 2009 Free Software Foundation, Inc. See the end for copying conditions. Please send GNU C library bug reports via <http://sources.redhat.com/bugzilla/> @@ -9,6 +9,9 @@ Version 2.10 * New Linux interface: accept4 +* Correct declarations of string function when used in C++ code. This + could lead to compile error for invalid C++ code. + Version 2.9 diff --git a/csu/libc-start.c b/csu/libc-start.c index a14ed71616..80b672f88d 100644 --- a/csu/libc-start.c +++ b/csu/libc-start.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 1998-2006, 2007, 2009 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 @@ -140,7 +140,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), __pthread_initialize_minimal (); /* Set up the stack checker's canary. */ - uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (); + uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (_dl_random); # ifdef THREAD_SET_STACK_GUARD THREAD_SET_STACK_GUARD (stack_chk_guard); # else diff --git a/elf/Makefile b/elf/Makefile index 8079fe9f96..e44ff1d382 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1995-2007, 2008 Free Software Foundation, Inc. +# Copyright (C) 1995-2007, 2008, 2009 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 @@ -304,7 +304,7 @@ $(objpfx)ld.so: $(objpfx)librtld.os $(ld-map) $(LDFLAGS-rtld) -Wl,-z,defs -Wl,--verbose 2>&1 | \ LC_ALL=C \ sed -e '/^=========/,/^=========/!d;/^=========/d' \ - -e 's/\. = 0 + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \ + -e 's/\. = .* + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \ > $@.lds $(LINK.o) -nostdlib -nostartfiles -shared -o $@ \ $(LDFLAGS-rtld) -Wl,-z,defs $(z-now-$(bind-now)) \ diff --git a/elf/dl-support.c b/elf/dl-support.c index 6bd573ec57..59a8dd9b97 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -1,5 +1,5 @@ /* Support for dynamic linking code in static libc. - Copyright (C) 1996-2005, 2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1996-2008, 2009 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 @@ -84,6 +84,9 @@ struct r_scope_elem _dl_initial_searchlist; int _dl_starting_up = 1; #endif +/* Random data provided by the kernel. */ +void *_dl_random; + /* Get architecture specific initializer. */ #include <dl-procinfo.c> @@ -216,6 +219,9 @@ _dl_aux_init (ElfW(auxv_t) *av) __libc_enable_secure = av->a_un.a_val; __libc_enable_secure_decided = 1; break; + case AT_RANDOM: + _dl_random = (void *) av->a_un.a_val; + break; # ifdef DL_PLATFORM_AUXV DL_PLATFORM_AUXV # endif diff --git a/elf/dl-sysdep.c b/elf/dl-sysdep.c index e6f4272a63..a44bee7086 100644 --- a/elf/dl-sysdep.c +++ b/elf/dl-sysdep.c @@ -1,5 +1,5 @@ /* Operating system support for run-time dynamic linker. Generic Unix version. - Copyright (C) 1995-1998, 2000-2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1995-1998, 2000-2008, 2009 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 @@ -62,6 +62,7 @@ int __libc_multiple_libcs = 0; /* Defining this here avoids the inclusion void *__libc_stack_end attribute_relro = NULL; rtld_hidden_data_def(__libc_stack_end) static ElfW(auxv_t) *_dl_auxv attribute_relro; +void *_dl_random attribute_relro = NULL; #ifndef DL_FIND_ARG_COMPONENTS # define DL_FIND_ARG_COMPONENTS(cookie, argc, argv, envp, auxp) \ @@ -173,6 +174,9 @@ _dl_sysdep_start (void **start_argptr, GLRO(dl_sysinfo_dso) = (void *) av->a_un.a_val; break; #endif + case AT_RANDOM: + _dl_random = (void *) av->a_un.a_val; + break; #ifdef DL_PLATFORM_AUXV DL_PLATFORM_AUXV #endif @@ -294,6 +298,7 @@ _dl_show_auxv (void) [AT_SECURE - 2] = { "AT_SECURE: ", dec }, [AT_SYSINFO - 2] = { "AT_SYSINFO: 0x", hex }, [AT_SYSINFO_EHDR - 2] = { "AT_SYSINFO_EHDR: 0x", hex }, + [AT_RANDOM - 2] = { "AT_RANDOM: 0x", hex }, }; unsigned int idx = (unsigned int) (av->a_type - 2); diff --git a/elf/elf.h b/elf/elf.h index b4d34754a5..2792820c35 100644 --- a/elf/elf.h +++ b/elf/elf.h @@ -972,6 +972,10 @@ typedef struct #define AT_SECURE 23 /* Boolean, was exec setuid-like? */ +#define AT_BASE_PLATFORM 24 /* String identifying real platforms.*/ + +#define AT_RANDOM 25 /* Address of 16 random bytes. */ + #define AT_EXECFN 31 /* Filename of executable. */ /* Pointer to the global system page used for system calls and other diff --git a/elf/rtld.c b/elf/rtld.c index 46bece7fa3..aa4c030f73 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -1,5 +1,5 @@ /* Run time dynamic linker. - Copyright (C) 1995-2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1995-2006, 2007, 2008, 2009 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 @@ -841,7 +841,7 @@ static void security_init (void) { /* Set up the stack checker's canary. */ - uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (); + uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (_dl_random); #ifdef THREAD_SET_STACK_GUARD THREAD_SET_STACK_GUARD (stack_chk_guard); #else @@ -851,18 +851,18 @@ security_init (void) /* Set up the pointer guard as well, if necessary. */ if (GLRO(dl_pointer_guard)) { - // XXX If it is cheap, we should use a separate value. - uintptr_t pointer_chk_guard = stack_chk_guard; -#ifndef HP_TIMING_NONAVAIL - hp_timing_t now; - HP_TIMING_NOW (now); - pointer_chk_guard ^= now; -#endif + uintptr_t pointer_chk_guard = _dl_setup_pointer_guard (_dl_random, + stack_chk_guard); #ifdef THREAD_SET_POINTER_GUARD THREAD_SET_POINTER_GUARD (pointer_chk_guard); #endif __pointer_chk_guard_local = pointer_chk_guard; } + + /* We do not need the _dl_random value anymore. The less + information we leave behind, the better, so clear the + variable. */ + _dl_random = NULL; } diff --git a/fedora/branch.mk b/fedora/branch.mk index ab7838aba8..9add5a7ef7 100644 --- a/fedora/branch.mk +++ b/fedora/branch.mk @@ -3,5 +3,5 @@ glibc-branch := fedora glibc-base := HEAD DIST_BRANCH := devel COLLECTION := dist-f8 -fedora-sync-date := 2009-01-08 10:17 UTC -fedora-sync-tag := fedora-glibc-20090108T1017 +fedora-sync-date := 2009-02-04 21:35 UTC +fedora-sync-tag := fedora-glibc-20090204T2135 diff --git a/fedora/glibc.spec.in b/fedora/glibc.spec.in index 5537f3b448..515d87441c 100644 --- a/fedora/glibc.spec.in +++ b/fedora/glibc.spec.in @@ -19,7 +19,7 @@ Summary: The GNU libc libraries Name: glibc Version: @glibcversion@ -Release: 2 +Release: 3 # GPLv2+ is used in a bunch of programs, LGPLv2+ is used for libraries. # Things that are linked directly into dynamically linked programs # and shared libraries (e.g. crt files, lib*_nonshared.a) have an additional @@ -984,6 +984,11 @@ rm -f *.filelist* %endif %changelog +* Wed Feb 4 2009 Jakub Jelinek <jakub@redhat.com> 2.9.90-3 +- update from trunk + - ISO C++ compliant strchr etc. with GCC 4.4+ + - AT_RANDOM support + * Thu Jan 8 2009 Jakub Jelinek <jakub@redhat.com> 2.9.90-2 - update from trunk diff --git a/iconv/Makefile b/iconv/Makefile index f0f16f81b3..77a9ad7666 100644 --- a/iconv/Makefile +++ b/iconv/Makefile @@ -1,5 +1,4 @@ -# Copyright (C) 1997,1998,2000,2001,2002,2003,2004,2007 -# Free Software Foundation, Inc. +# Copyright (C) 1997,1998,2000-2004,2007,2009 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 @@ -50,7 +49,7 @@ CFLAGS-charmap.c = -DCHARMAP_PATH='"$(i18ndir)/charmaps"' \ CFLAGS-linereader.c = -DNO_TRANSLITERATION CFLAGS-simple-hash.c = -I../locale -tests = tst-iconv1 tst-iconv2 tst-iconv3 tst-iconv5 +tests = tst-iconv1 tst-iconv2 tst-iconv3 tst-iconv4 tst-iconv5 distribute = gconv_builtin.h gconv_int.h loop.c skeleton.c iconv_prog.h \ iconv_charmap.c dummy-repertoire.c gconv_charset.h strtab.c \ diff --git a/iconv/gconv_trans.c b/iconv/gconv_trans.c index 9e04e64ee2..1f1dd01b19 100644 --- a/iconv/gconv_trans.c +++ b/iconv/gconv_trans.c @@ -1,5 +1,5 @@ /* Transliteration using the locale's data. - Copyright (C) 2000 Free Software Foundation, Inc. + Copyright (C) 2000, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000. @@ -139,7 +139,10 @@ __gconv_transliterate (struct __gconv_step *step, ++*irreversible; res = __GCONV_OK; } - *outbufstart = outptr; + /* Do not increment the output pointer if we could not + store the entire output. */ + if (res != __GCONV_FULL_OUTPUT) + *outbufstart = outptr; return res; } diff --git a/iconv/tst-iconv4.c b/iconv/tst-iconv4.c new file mode 100644 index 0000000000..b5ff39306c --- /dev/null +++ b/iconv/tst-iconv4.c @@ -0,0 +1,65 @@ +// Derived from BZ #9793 +#include <errno.h> +#include <iconv.h> +#include <stdio.h> + + +static int +do_test (void) +{ + iconv_t cd = iconv_open ("ASCII//TRANSLIT", "UTF-8"); + if (cd == (iconv_t) -1) + { + puts ("iconv_open failed"); + return 1; + } + + char input[2] = { 0xc2, 0xae }; /* Registered trademark */ + char *inptr = input; + size_t insize = sizeof (input); + char output[2]; /* Too short to contain "(R)". */ + char *outptr = output; + size_t outsize = sizeof (output); + + size_t ret = iconv (cd, &inptr, &insize, &outptr, &outsize); + if (ret != (size_t) -1) + { + puts ("iconv succeeded"); + return 1; + } + if (errno != E2BIG) + { + puts ("iconv did not set errno to E2BIG"); + return 1; + } + int res = 0; + if (inptr != input) + { + puts ("inptr changed"); + res = 1; + } + if (insize != sizeof (input)) + { + puts ("insize changed"); + res = 1; + } + if (outptr != output) + { + puts ("outptr changed"); + res = 1; + } + if (outsize != sizeof (output)) + { + puts ("outsize changed"); + res = 1; + } + if (iconv_close (cd) == -1) + { + puts ("iconv_close failed"); + res = 1; + } + return res; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/include/alloca.h b/include/alloca.h index 563d7868bd..9a4b5c7da0 100644 --- a/include/alloca.h +++ b/include/alloca.h @@ -46,4 +46,17 @@ extern int __libc_alloca_cutoff (size_t size) __attribute__ ((const)); __alloca (((len) = (newlen))) #endif +#if defined stackinfo_get_sp && defined stackinfo_sub_sp +# define alloca_account(size, avar) \ + ({ void *old__ = stackinfo_get_sp (); \ + void *m__ = __alloca (size); \ + avar += stackinfo_sub_sp (old__); \ + m__; }) +#else +# define alloca_account(size, avar) \ + ({ size_t s__ = (size); \ + avar += s__; \ + __alloca (s__); }) +#endif + #endif diff --git a/libio/Makefile b/libio/Makefile index 385040fb96..b94d047f5a 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1995-2004,2006,2007,2008 Free Software Foundation, Inc. +# Copyright (C) 1995-2004,2006,2007,2008,2009 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 @@ -58,7 +58,7 @@ tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \ tst-memstream1 tst-memstream2 \ tst-wmemstream1 tst-wmemstream2 \ bug-memstream1 bug-wmemstream1 \ - tst-setvbuf1 tst-popen1 + tst-setvbuf1 tst-popen1 tst-fgetwc test-srcs = test-freopen all: # Make this the default target; it will be defined in Rules. diff --git a/libio/tst-fgetwc.c b/libio/tst-fgetwc.c new file mode 100644 index 0000000000..9ccfeb1526 --- /dev/null +++ b/libio/tst-fgetwc.c @@ -0,0 +1,52 @@ +#include <locale.h> +#include <stdio.h> +#include <wchar.h> + + +static int +do_test (void) +{ + if (setlocale (LC_ALL, "de_DE.utf8") == NULL) + { + puts ("setlocale failed"); + return 1; + } + + if (setvbuf (stdin, NULL, _IONBF, 0) != 0) + { + puts ("setvbuf failed"); + return 1; + } + + wchar_t buf[100]; + size_t nbuf = 0; + wint_t c; + while ((c = fgetwc (stdin)) != WEOF) + buf[nbuf++] = c; + + if (ferror (stdin)) + { + puts ("error on stdin"); + return 1; + } + + const wchar_t expected[] = + { + 0x00000439, 0x00000446, 0x00000443, 0x0000043a, + 0x00000435, 0x0000043d, 0x0000000a, 0x00000071, + 0x00000077, 0x00000065, 0x00000072, 0x00000074, + 0x00000079, 0x0000000a + }; + + if (nbuf != sizeof (expected) / sizeof (expected[0]) + || wmemcmp (expected, buf, nbuf) != 0) + { + puts ("incorrect result"); + return 1; + } + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/libio/tst-fgetwc.input b/libio/tst-fgetwc.input new file mode 100644 index 0000000000..b1a48dadb8 --- /dev/null +++ b/libio/tst-fgetwc.input @@ -0,0 +1,2 @@ +йцукен +qwerty diff --git a/libio/wfileops.c b/libio/wfileops.c index b930aad067..c5f0eaf6a7 100644 --- a/libio/wfileops.c +++ b/libio/wfileops.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993,1995,1997-2003,2004, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1993,1995,1997-2004,2006,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper <drepper@cygnus.com>. Based on the single byte version by Per Bothner <bothner@cygnus.com>. @@ -123,8 +123,6 @@ _IO_wfile_underflow (fp) struct _IO_codecvt *cd; enum __codecvt_result status; _IO_ssize_t count; - int tries; - const char *read_ptr_copy; if (__builtin_expect (fp->_flags & _IO_NO_READS, 0)) { @@ -236,13 +234,15 @@ _IO_wfile_underflow (fp) fp->_wide_data->_IO_write_base = fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_end = fp->_wide_data->_IO_buf_base; - tries = 0; + const char *read_ptr_copy; + char accbuf[MB_LEN_MAX]; + size_t naccbuf = 0; again: count = _IO_SYSREAD (fp, fp->_IO_read_end, fp->_IO_buf_end - fp->_IO_read_end); if (count <= 0) { - if (count == 0 && tries == 0) + if (count == 0 && naccbuf == 0) fp->_flags |= _IO_EOF_SEEN; else fp->_flags |= _IO_ERR_SEEN, count = 0; @@ -250,7 +250,7 @@ _IO_wfile_underflow (fp) fp->_IO_read_end += count; if (count == 0) { - if (tries != 0) + if (naccbuf != 0) /* There are some bytes in the external buffer but they don't convert to anything. */ __set_errno (EILSEQ); @@ -262,18 +262,31 @@ _IO_wfile_underflow (fp) /* Now convert the read input. */ fp->_wide_data->_IO_last_state = fp->_wide_data->_IO_state; fp->_IO_read_base = fp->_IO_read_ptr; + const char *from = fp->_IO_read_ptr; + const char *to = fp->_IO_read_end; + size_t to_copy = count; + if (__builtin_expect (naccbuf != 0, 0)) + { + to_copy = MIN (sizeof (accbuf) - naccbuf, count); + to = __mempcpy (&accbuf[naccbuf], from, to_copy); + naccbuf += to_copy; + from = accbuf; + } status = (*cd->__codecvt_do_in) (cd, &fp->_wide_data->_IO_state, - fp->_IO_read_ptr, fp->_IO_read_end, - &read_ptr_copy, + from, to, &read_ptr_copy, fp->_wide_data->_IO_read_end, fp->_wide_data->_IO_buf_end, &fp->_wide_data->_IO_read_end); - fp->_IO_read_ptr = (char *) read_ptr_copy; + if (__builtin_expect (naccbuf != 0, 0)) + fp->_IO_read_ptr += MAX (0, read_ptr_copy - &accbuf[naccbuf - to_copy]); + else + fp->_IO_read_ptr = (char *) read_ptr_copy; if (fp->_wide_data->_IO_read_end == fp->_wide_data->_IO_buf_base) { - if (status == __codecvt_error || fp->_IO_read_end == fp->_IO_buf_end) + if (status == __codecvt_error) { + out_eilseq: __set_errno (EILSEQ); fp->_flags |= _IO_ERR_SEEN; return WEOF; @@ -281,7 +294,20 @@ _IO_wfile_underflow (fp) /* The read bytes make no complete character. Try reading again. */ assert (status == __codecvt_partial); - ++tries; + + if (naccbuf == 0) + { + naccbuf = fp->_IO_read_end - fp->_IO_read_ptr; + if (naccbuf >= sizeof (accbuf)) + goto out_eilseq; + + memcpy (accbuf, fp->_IO_read_ptr, naccbuf); + } + else if (naccbuf == sizeof (accbuf)) + goto out_eilseq; + + fp->_IO_read_ptr = fp->_IO_read_end = fp->_IO_read_base; + goto again; } diff --git a/localedata/ChangeLog b/localedata/ChangeLog index 7fb68e4f46..594a71c98f 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,3 +1,23 @@ +2009-01-28 Ulrich Drepper <drepper@redhat.com> + + * locales/as_IN: Break circular include loops introduced in last patch. + * locales/bn_BD: Likewise. + * locales/bn_IN: Likewise. + * locales/hi_IN: Likewise. + * locales/mr_IN: Likewise. + Patch by Pravin Satpute <psatpute@redhat.com>. + +2009-01-08 Ulrich Drepper <drepper@redhat.com> + + [BZ #9701] + * locales/sk_SK: Slovakia uses the Euro. + + [BZ #9704] + * locales/mt_MT: Malta uses the Euro. + + [BZ #9705] + * locales/el_CY: Cyprus uses the Euro. + 2008-12-31 Ulrich Drepper <drepper@redhat.com> * locales/iso14651_t1_common: Fix sorting of U+0AB3. diff --git a/localedata/locales/as_IN b/localedata/locales/as_IN index 3e1c4cb8ab..6fbd66ee2f 100644 --- a/localedata/locales/as_IN +++ b/localedata/locales/as_IN @@ -32,11 +32,7 @@ END LC_IDENTIFICATION %%%%%%%%%%%%% LC_CTYPE -copy "bn_IN" - -translit_start -include "translit_combining";"" -translit_end +copy "bn_BD" END LC_CTYPE %%%%%%%%%%%%% diff --git a/localedata/locales/bn_BD b/localedata/locales/bn_BD index dceacc34ad..a2c0f5c5bd 100644 --- a/localedata/locales/bn_BD +++ b/localedata/locales/bn_BD @@ -37,7 +37,24 @@ copy "iso14651_t1" END LC_COLLATE LC_CTYPE -copy "bn_IN" +copy "i18n" + +% Bengali uses the alternate digits U+09E6..U+09EF +outdigit <U09E6>..<U09EF> + +% This is used in the scanf family of functions to read Bengali numbers +% using "%Id" and such. +map to_inpunct; / + (<U0030>,<U09E6>); / + (<U0031>,<U09E7>); / + (<U0032>,<U09E8>); / + (<U0033>,<U09E9>); / + (<U0034>,<U09EA>); / + (<U0035>,<U09EB>); / + (<U0036>,<U09EC>); / + (<U0037>,<U09ED>); / + (<U0038>,<U09EE>); / + (<U0039>,<U09EF>); translit_start include "translit_combining";"" diff --git a/localedata/locales/bn_IN b/localedata/locales/bn_IN index 43a682549e..1a792acd8a 100644 --- a/localedata/locales/bn_IN +++ b/localedata/locales/bn_IN @@ -34,28 +34,7 @@ END LC_IDENTIFICATION LC_CTYPE -copy "i18n" - -% Bengali uses the alternate digits U+09E6..U+09EF -outdigit <U09E6>..<U09EF> - -% This is used in the scanf family of functions to read Bengali numbers -% using "%Id" and such. -map to_inpunct; / - (<U0030>,<U09E6>); / - (<U0031>,<U09E7>); / - (<U0032>,<U09E8>); / - (<U0033>,<U09E9>); / - (<U0034>,<U09EA>); / - (<U0035>,<U09EB>); / - (<U0036>,<U09EC>); / - (<U0037>,<U09ED>); / - (<U0038>,<U09EE>); / - (<U0039>,<U09EF>); - -translit_start -include "translit_combining";"" -translit_end +copy "bn_BD" END LC_CTYPE diff --git a/localedata/locales/el_CY b/localedata/locales/el_CY index 66acb12508..7213924233 100644 --- a/localedata/locales/el_CY +++ b/localedata/locales/el_CY @@ -44,8 +44,8 @@ copy "el_GR" END LC_MESSAGES LC_MONETARY -int_curr_symbol "<U0043><U0059><U0050><U0020>" -currency_symbol "<U00A3>" +int_curr_symbol "<U0045><U0055><U0052><U0020>" +currency_symbol "<U20AC>" mon_decimal_point "<U002C>" mon_thousands_sep "<U002E>" mon_grouping 3 diff --git a/localedata/locales/hi_IN b/localedata/locales/hi_IN index c8a5051089..5ce3e03520 100644 --- a/localedata/locales/hi_IN +++ b/localedata/locales/hi_IN @@ -32,7 +32,24 @@ category "hi_IN:2000";LC_TELEPHONE END LC_IDENTIFICATION LC_CTYPE -copy "mr_IN" +copy "i18n" + +% Devanagari uses the alternate digits U+0966..U+096F +outdigit <U0966>..<U096F> + +% This is used in the scanf family of functions to read devanagari numbers +% using "%Id" and such. +map to_inpunct; / + (<U0030>,<U0966>); / + (<U0031>,<U0967>); / + (<U0032>,<U0968>); / + (<U0033>,<U0969>); / + (<U0034>,<U096A>); / + (<U0035>,<U096B>); / + (<U0036>,<U096C>); / + (<U0037>,<U096D>); / + (<U0038>,<U096E>); / + (<U0039>,<U096F>); translit_start include "translit_combining";"" diff --git a/localedata/locales/mr_IN b/localedata/locales/mr_IN index 7c9d439fcb..174e0e3f1d 100644 --- a/localedata/locales/mr_IN +++ b/localedata/locales/mr_IN @@ -32,28 +32,7 @@ category "mr_IN:2000";LC_TELEPHONE END LC_IDENTIFICATION LC_CTYPE -copy "i18n" - -% Devanagari uses the alternate digits U+0966..U+096F -outdigit <U0966>..<U096F> - -% This is used in the scanf family of functions to read devanagari numbers -% using "%Id" and such. -map to_inpunct; / - (<U0030>,<U0966>); / - (<U0031>,<U0967>); / - (<U0032>,<U0968>); / - (<U0033>,<U0969>); / - (<U0034>,<U096A>); / - (<U0035>,<U096B>); / - (<U0036>,<U096C>); / - (<U0037>,<U096D>); / - (<U0038>,<U096E>); / - (<U0039>,<U096F>); - -translit_start -include "translit_combining";"" -translit_end +copy "hi_IN" END LC_CTYPE LC_COLLATE diff --git a/localedata/locales/mt_MT b/localedata/locales/mt_MT index a882de478a..81c134fde1 100644 --- a/localedata/locales/mt_MT +++ b/localedata/locales/mt_MT @@ -131,8 +131,8 @@ LC_MONETARY % These are generated based on XML base Locale defintion file % for IBM Class for Unicode. % -int_curr_symbol "<U004D><U0054><U004C><U0020>" -currency_symbol "<U004C><U006D>" +int_curr_symbol "<U0045><U0055><U0052><U0020>" +currency_symbol "<U20AC>" mon_decimal_point "<U002E>" mon_thousands_sep "<U002C>" mon_grouping 3 @@ -140,9 +140,9 @@ positive_sign "" negative_sign "<U002D>" int_frac_digits 2 frac_digits 2 -p_cs_precedes 1 +p_cs_precedes 0 p_sep_by_space 0 -n_cs_precedes 1 +n_cs_precedes 0 n_sep_by_space 0 p_sign_posn 1 n_sign_posn 0 diff --git a/localedata/locales/sk_SK b/localedata/locales/sk_SK index 45d7da87eb..6a458582a7 100644 --- a/localedata/locales/sk_SK +++ b/localedata/locales/sk_SK @@ -91,8 +91,8 @@ END LC_MESSAGES LC_MONETARY -int_curr_symbol "<U0053><U004B><U004B><U0020>" -currency_symbol "<U0053><U006B>" +int_curr_symbol "<U0045><U0055><U0052><U0020>" +currency_symbol "<U20AC>" mon_decimal_point "<U002C>" mon_thousands_sep "<U00A0>" mon_grouping 3;3 diff --git a/malloc/malloc.c b/malloc/malloc.c index d6102a4528..a918934740 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -1,5 +1,5 @@ /* Malloc implementation for multiple threads without lock contention. - Copyright (C) 1996-2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1996-2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Wolfram Gloger <wg@malloc.de> and Doug Lea <dl@cs.oswego.edu>, 2001. @@ -3189,7 +3189,7 @@ static Void_t* sYSMALLOc(nb, av) INTERNAL_SIZE_T nb; mstate av; else if (contiguous(av) && old_size && brk < old_end) { /* Oops! Someone else killed our space.. Can't touch anything. */ - assert(0); + malloc_printerr (3, "break adjusted to free malloc space", brk); } /* diff --git a/misc/Makefile b/misc/Makefile index eb97ac1767..a256068c2b 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991-2006, 2007 Free Software Foundation, Inc. +# Copyright (C) 1991-2006, 2007, 2009 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 @@ -79,7 +79,7 @@ endif gpl2lgpl := error.c error.h tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \ - tst-error1 tst-pselect tst-insremque tst-mntent2 + tst-error1 tst-pselect tst-insremque tst-mntent2 bug-hsearch1 ifeq (no,$(cross-compiling)) tests: $(objpfx)tst-error1-mem endif diff --git a/misc/bug-hsearch1.c b/misc/bug-hsearch1.c new file mode 100644 index 0000000000..6097b5ad04 --- /dev/null +++ b/misc/bug-hsearch1.c @@ -0,0 +1,31 @@ +#include <search.h> +#include <stdio.h> + +static int +do_test (void) +{ + if (hcreate (1) == 0) + { + puts ("hcreate failed"); + return 1; + } + ENTRY e; + e.key = (char *) "a"; + e.data = (char *) "b"; + if (hsearch (e, ENTER) == NULL) + { + puts ("ENTER failed"); + return 1; + } + ENTRY s; + s.key = (char *) "c"; + if (hsearch (s, FIND) != NULL) + { + puts ("FIND succeeded"); + return 1; + } + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/misc/hsearch_r.c b/misc/hsearch_r.c index c855a41846..6e32afc43e 100644 --- a/misc/hsearch_r.c +++ b/misc/hsearch_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993,1995-1997,2002,2005,2007,2008 +/* Copyright (C) 1993,1995-1997,2002,2005,2007,2008,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1993. @@ -79,6 +79,10 @@ hcreate_r (nel, htab) if (htab->table != NULL) return 0; + /* We need a size of at least 3. Otherwise the hash functions we + use will not work. */ + if (nel < 3) + nel = 3; /* Change nel to the first prime number not smaller as nel. */ nel |= 1; /* make odd */ while (!isprime (nel)) diff --git a/misc/sbrk.c b/misc/sbrk.c index 0df60076cc..985b34749a 100644 --- a/misc/sbrk.c +++ b/misc/sbrk.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,1995,1996,1997,2000,2002 Free Software Foundation, Inc. +/* Copyright (C) 1991,1995-1997,2000,2002,2009 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 @@ -16,8 +16,9 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <unistd.h> #include <errno.h> +#include <stdint.h> +#include <unistd.h> /* Defined in brk.c. */ extern void *__curbrk; @@ -47,7 +48,10 @@ __sbrk (intptr_t increment) return __curbrk; oldbrk = __curbrk; - if (__brk (oldbrk + increment) < 0) + if ((increment > 0 + ? ((uintptr_t) oldbrk + (uintptr_t) increment < (uintptr_t) oldbrk) + : ((uintptr_t) oldbrk < (uintptr_t) -increment)) + || __brk (oldbrk + increment) < 0) return (void *) -1; return oldbrk; diff --git a/nptl/ChangeLog b/nptl/ChangeLog index e3c752ee63..eb0f345cd8 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,39 @@ +2009-01-29 Ulrich Drepper <drepper@redhat.com> + + * sysdeps/pthread/unwind-forcedunwind.c: Encrypt all function + pointer variables. + + * allocatestack.c (__free_stacks): Renamed from free_stacks. + (__free_stack_cache): Removed. Change callers to call __free_stacks. + * init.c (nptl_freeres): New function. + (pthread_functions): Initialize ptr_freeres to nptl_freeres. + * pthreadP.h: Don't declare __free_stack_cache. Declare __free_stacks. + * sysdeps/pthread/unwind-forcedunwind.c (libgcc_s_handle): New + variable. + (pthread_cancel_init): Depend in libgcc_s_handle for decision to + load DSO. Assign last. + (__unwind_freeres): New function. + + * allocatestack.c (__reclaim_stacks): Reset in_flight_stack later + for better debugging. No need to use stack_list_add here. + +2009-01-14 Kaz Kojima <kkojima@rr.iij4u.or.jp> + + * sysdeps/unix/sysv/linux/sh/lowlevellock.S + (__lll_timedlock_wait): Use FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME + instead of computing relative timeout. + * sysdeps/unix/sysv/linux/sh/lowlevellock.h: Define + FUTEX_CLOCK_REALTIME and FUTEX_BITSET_MATCH_ANY. + +2009-01-25 Ulrich Drepper <drepper@redhat.com> + + * pthread_mutex_lock.c (__pthread_mutex_lock): Remove unused label out. + +2009-01-08 Ulrich Drepper <drepper@redhat.com> + + * sysdeps/pthread/list.h (list_add): Initialize new element first. + (list_add_tail): Removed. + 2009-01-04 Ulrich Drepper <drepper@redhat.com> * init.c (__pthread_initialize_minimal_internal): Optimize test diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index ce05770e56..67ea0c68f8 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -248,8 +248,8 @@ get_cached_stack (size_t *sizep, void **memp) /* Free stacks until cache size is lower than LIMIT. */ -static void -free_stacks (size_t limit) +void +__free_stacks (size_t limit) { /* We reduce the size of the cache. Remove the last entries until the size is below the limit. */ @@ -299,15 +299,7 @@ queue_stack (struct pthread *stack) stack_cache_actsize += stack->stackblock_size; if (__builtin_expect (stack_cache_actsize > stack_cache_maxsize, 0)) - free_stacks (stack_cache_maxsize); -} - - -/* This function is called indirectly from the freeres code in libc. */ -void -__free_stack_cache (void) -{ - free_stacks (0); + __free_stacks (stack_cache_maxsize); } @@ -849,8 +841,6 @@ __reclaim_stacks (void) elem->next->prev = elem->prev; elem->prev->next = elem->next; } - - in_flight_stack = 0; } /* Mark all stacks except the still running one as free. */ @@ -913,11 +903,13 @@ __reclaim_stacks (void) if (__builtin_expect (THREAD_GETMEM (self, user_stack), 0)) list_add (&self->list, &__stack_user); else - stack_list_add (&self->list, &stack_used); + list_add (&self->list, &stack_used); /* There is one thread running. */ __nptl_nthreads = 1; + in_flight_stack = 0; + /* Initialize the lock. */ stack_cache_lock = LLL_LOCK_INITIALIZER; } diff --git a/nptl/init.c b/nptl/init.c index 7a6dec5935..d0f1fc3be7 100644 --- a/nptl/init.c +++ b/nptl/init.c @@ -67,6 +67,8 @@ static const char nptl_version[] __attribute_used__ = VERSION; extern void __libc_setup_tls (size_t tcbsize, size_t tcbalign); #endif +static void nptl_freeres (void); + #ifdef SHARED static const struct pthread_functions pthread_functions = @@ -128,7 +130,7 @@ static const struct pthread_functions pthread_functions = .ptr__nptl_deallocate_tsd = __nptl_deallocate_tsd, .ptr__nptl_setxid = __nptl_setxid, /* For now only the stack cache needs to be freed. */ - .ptr_freeres = __free_stack_cache + .ptr_freeres = nptl_freeres }; # define ptr_pthread_functions &pthread_functions #else @@ -136,6 +138,18 @@ static const struct pthread_functions pthread_functions = #endif +/* This function is called indirectly from the freeres code in libc. */ +static void +__libc_freeres_fn_section +nptl_freeres (void) +{ +#ifdef SHARED + __unwind_freeres (); +#endif + __free_stacks (0); +} + + /* For asynchronous cancellation we use a signal. This is the handler. */ static void sigcancel_handler (int sig, siginfo_t *si, void *ctx) diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 17b6492ad8..ed9fc625ba 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc. +/* Copyright (C) 2002-2007, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -247,6 +247,7 @@ hidden_proto (__pthread_register_cancel) hidden_proto (__pthread_unregister_cancel) # ifdef SHARED extern void attribute_hidden pthread_cancel_init (void); +extern void __unwind_freeres (void); # endif #endif @@ -564,7 +565,7 @@ extern void __nptl_deallocate_tsd (void) attribute_hidden; extern int __nptl_setxid (struct xid_command *cmdp) attribute_hidden; -extern void __free_stack_cache (void) attribute_hidden; +extern void __free_stacks (size_t limit) attribute_hidden; extern void __wait_lookup_done (void) attribute_hidden; diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c index 4cb98beefb..406e588fdb 100644 --- a/nptl/pthread_mutex_lock.c +++ b/nptl/pthread_mutex_lock.c @@ -121,7 +121,6 @@ __pthread_mutex_lock (mutex) goto simple; } - out: /* Record the ownership. */ mutex->__data.__owner = id; #ifndef NO_INCR diff --git a/nptl/sysdeps/pthread/list.h b/nptl/sysdeps/pthread/list.h index 43186a2d51..6ddccb9fb9 100644 --- a/nptl/sysdeps/pthread/list.h +++ b/nptl/sysdeps/pthread/list.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -46,24 +46,13 @@ typedef struct list_head static inline void list_add (list_t *newp, list_t *head) { - head->next->prev = newp; newp->next = head->next; newp->prev = head; + head->next->prev = newp; head->next = newp; } -/* Add new element at the tail of the list. */ -static inline void -list_add_tail (list_t *newp, list_t *head) -{ - head->prev->next = newp; - newp->next = head; - newp->prev = head->prev; - head->prev = newp; -} - - /* Remove element from list. */ static inline void list_del (list_t *elem) diff --git a/nptl/sysdeps/pthread/unwind-forcedunwind.c b/nptl/sysdeps/pthread/unwind-forcedunwind.c index 6792d719d3..402591f6e4 100644 --- a/nptl/sysdeps/pthread/unwind-forcedunwind.c +++ b/nptl/sysdeps/pthread/unwind-forcedunwind.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2005, 2006, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>. @@ -21,7 +21,9 @@ #include <stdio.h> #include <unwind.h> #include <pthreadP.h> +#include <sysdep.h> +static void *libgcc_s_handle; static void (*libgcc_s_resume) (struct _Unwind_Exception *exc); static _Unwind_Reason_Code (*libgcc_s_personality) (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *, @@ -34,10 +36,13 @@ void __attribute_noinline__ pthread_cancel_init (void) { - void *resume, *personality, *forcedunwind, *getcfa; + void *resume; + void *personality; + void *forcedunwind; + void *getcfa; void *handle; - if (__builtin_expect (libgcc_s_getcfa != NULL, 1)) + if (__builtin_expect (libgcc_s_handle != NULL, 1)) { /* Force gcc to reload all values. */ asm volatile ("" ::: "memory"); @@ -58,23 +63,42 @@ pthread_cancel_init (void) ) __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n"); + PTR_MANGLE (resume); libgcc_s_resume = resume; + PTR_MANGLE (personality); libgcc_s_personality = personality; + PTR_MANGLE (forcedunwind); libgcc_s_forcedunwind = forcedunwind; - /* Make sure libgcc_s_getcfa is written last. Otherwise, + PTR_MANGLE (getcfa); + libgcc_s_getcfa = getcfa; + /* Make sure libgcc_s_handle is written last. Otherwise, pthread_cancel_init might return early even when the pointer the caller is interested in is not initialized yet. */ atomic_write_barrier (); - libgcc_s_getcfa = getcfa; + libgcc_s_handle = handle; +} + +void +__libc_freeres_fn_section +__unwind_freeres (void) +{ + void *handle = libgcc_s_handle; + if (handle != NULL) + { + libgcc_s_handle = NULL; + __libc_dlclose (handle); + } } void _Unwind_Resume (struct _Unwind_Exception *exc) { - if (__builtin_expect (libgcc_s_resume == NULL, 0)) + if (__builtin_expect (libgcc_s_handle == NULL, 0)) pthread_cancel_init (); - libgcc_s_resume (exc); + void (*resume) (struct _Unwind_Exception *exc) = libgcc_s_resume; + PTR_DEMANGLE (resume); + resume (exc); } _Unwind_Reason_Code @@ -83,28 +107,37 @@ __gcc_personality_v0 (int version, _Unwind_Action actions, struct _Unwind_Exception *ue_header, struct _Unwind_Context *context) { - if (__builtin_expect (libgcc_s_personality == NULL, 0)) + if (__builtin_expect (libgcc_s_handle == NULL, 0)) pthread_cancel_init (); - return libgcc_s_personality (version, actions, exception_class, - ue_header, context); + _Unwind_Reason_Code (*personality) + (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *, + struct _Unwind_Context *) = libgcc_s_personality; + PTR_DEMANGLE (personality); + return personality (version, actions, exception_class, ue_header, context); } _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop, void *stop_argument) { - if (__builtin_expect (libgcc_s_forcedunwind == NULL, 0)) + if (__builtin_expect (libgcc_s_handle == NULL, 0)) pthread_cancel_init (); - return libgcc_s_forcedunwind (exc, stop, stop_argument); + _Unwind_Reason_Code (*forcedunwind) + (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *) + = libgcc_s_forcedunwind; + PTR_DEMANGLE (forcedunwind); + return forcedunwind (exc, stop, stop_argument); } _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *context) { - if (__builtin_expect (libgcc_s_getcfa == NULL, 0)) + if (__builtin_expect (libgcc_s_handle == NULL, 0)) pthread_cancel_init (); - return libgcc_s_getcfa (context); + _Unwind_Word (*getcfa) (struct _Unwind_Context *) = libgcc_s_getcfa; + PTR_DEMANGLE (getcfa); + return getcfa (context); } diff --git a/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S index d8279173d7..c051192cee 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2005, 2007, 2008 +/* Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -36,6 +36,13 @@ mov #(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), tmp; \ extu.b tmp, tmp; \ xor tmp, reg +# define LOAD_FUTEX_WAIT_ABS(reg,tmp,tmp2) \ + mov #(FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG), tmp; \ + extu.b tmp, tmp; \ + mov #(FUTEX_CLOCK_REALTIME >> 8), tmp2; \ + swap.b tmp2, tmp2; \ + or tmp2, tmp; \ + xor tmp, reg # define LOAD_FUTEX_WAKE(reg,tmp,tmp2) \ mov #(FUTEX_WAKE | FUTEX_PRIVATE_FLAG), tmp; \ extu.b tmp, tmp; \ @@ -96,6 +103,22 @@ and tmp2, reg ; \ mov #FUTEX_WAIT, tmp ; \ or tmp, reg +# define LOAD_FUTEX_WAIT_ABS(reg,tmp,tmp2) \ + stc gbr, tmp ; \ + mov.w 99f, tmp2 ; \ + add tmp2, tmp ; \ + mov.l @tmp, tmp2 ; \ + bra 98f ; \ + mov #FUTEX_PRIVATE_FLAG, tmp ; \ +99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \ +98: extu.b tmp, tmp ; \ + xor tmp, reg ; \ + and tmp2, reg ; \ + mov #FUTEX_WAIT_BITSET, tmp ; \ + mov #(FUTEX_CLOCK_REALTIME >> 8), tmp2; \ + swap.b tmp2, tmp2; \ + or tmp2, tmp; \ + or tmp, reg # endif # define LOAD_FUTEX_WAKE(reg,tmp,tmp2) \ stc gbr, tmp ; \ @@ -193,12 +216,85 @@ __lll_lock_wait: cfi_endproc .size __lll_lock_wait,.-__lll_lock_wait + /* r5 (r8): futex + r7 (r11): flags + r6 (r9): timeout + r4 (r10): futex value + */ .globl __lll_timedlock_wait .type __lll_timedlock_wait,@function .hidden __lll_timedlock_wait .align 5 cfi_startproc __lll_timedlock_wait: + mov.l r12, @-r15 + cfi_adjust_cfa_offset(4) + cfi_rel_offset (r12, 0) + +# ifndef __ASSUME_FUTEX_CLOCK_REALTIME + mov.l .Lhave, r1 +# ifdef PIC + mova .Lgot, r0 + mov.l .Lgot, r12 + add r0, r12 + add r12, r1 +# endif + mov.l @r1, r0 + tst r0, r0 + bt .Lreltmo +# endif + + mov r4, r2 + mov r5, r4 + mov r7, r5 + mov r6, r7 + LOAD_FUTEX_WAIT_ABS (r5, r0, r1) + + mov #2, r6 + cmp/eq r6, r2 + bf/s 2f + mov r2, r6 + +1: + mov #2, r6 + mov #-1, r1 + mov #SYS_futex, r3 + extu.b r3, r3 + trapa #0x16 + SYSCALL_INST_PAD + mov r0, r6 + +2: + XCHG (r2, @r4, r3) /* NB: lock is implied */ + + tst r3, r3 + bt/s 3f + mov r6, r0 + + cmp/eq #-ETIMEDOUT, r0 + bt 4f + cmp/eq #-EINVAL, r0 + bf 1b +4: + neg r0, r3 +3: + mov r3, r0 + rts + mov.l @r15+, r12 + + .align 2 +# ifdef PIC +.Lgot: + .long _GLOBAL_OFFSET_TABLE_ +.Lhave: + .long __have_futex_clock_realtime@GOTOFF +# else +.Lhave: + .long __have_futex_clock_realtime +# endif + +# ifndef __ASSUME_FUTEX_CLOCK_REALTIME +.Lreltmo: /* Check for a valid timeout value. */ mov.l @(4,r6), r1 mov.l .L1g, r0 @@ -290,12 +386,15 @@ __lll_timedlock_wait: mov.l @r15+, r8 mov.l @r15+, r9 mov.l @r15+, r10 + mov.l @r15+, r11 rts - mov.l @r15+, r11 + mov.l @r15+, r12 3: + mov.l @r15+, r12 rts mov #EINVAL, r0 +# endif cfi_endproc .L1k: diff --git a/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h index e709667e54..853a2daf1b 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009 + 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 @@ -37,6 +38,9 @@ #define FUTEX_WAIT_BITSET 9 #define FUTEX_WAKE_BITSET 10 #define FUTEX_PRIVATE_FLAG 128 +#define FUTEX_CLOCK_REALTIME 256 + +#define FUTEX_BITSET_MATCH_ANY 0xffffffff #define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1) diff --git a/nscd/connections.c b/nscd/connections.c index dd934c1106..7e3a406185 100644 --- a/nscd/connections.c +++ b/nscd/connections.c @@ -1,5 +1,5 @@ /* Inner loops of cache daemon. - Copyright (C) 1998-2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1998-2007, 2008, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -647,6 +647,9 @@ cannot create read-only descriptor for \"%s\"; no mmap"), if (fd != -1) close (fd); } + else if (errno == EACCES) + error (EXIT_FAILURE, 0, _("cannot access '%s'"), + dbs[cnt].db_filename); } if (dbs[cnt].head == NULL) diff --git a/nscd/mem.c b/nscd/mem.c index e821729dab..7f3ea06f4a 100644 --- a/nscd/mem.c +++ b/nscd/mem.c @@ -1,5 +1,5 @@ /* Cache memory handling. - Copyright (C) 2004, 2005, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006, 2008, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2004. @@ -134,12 +134,11 @@ gc (struct database_dyn *db) stack_used = 0; size_t nmark = (db->head->first_free / BLOCK_ALIGN + BITS - 1) / BITS; size_t memory_needed = nmark * sizeof (BITMAP_T); - if (stack_used + memory_needed <= MAX_STACK_USE) + if (__builtin_expect (stack_used + memory_needed <= MAX_STACK_USE, 1)) { - mark = (BITMAP_T *) alloca (memory_needed); + mark = (BITMAP_T *) alloca_account (memory_needed, stack_used); mark_use_malloc = false; memset (mark, '\0', memory_needed); - stack_used += memory_needed; } else { @@ -153,19 +152,17 @@ gc (struct database_dyn *db) struct hashentry **he; struct hashentry **he_data; bool he_use_malloc; - if (stack_used + memory_needed <= MAX_STACK_USE) + if (__builtin_expect (stack_used + memory_needed <= MAX_STACK_USE, 1)) { - he = alloca (db->head->nentries * sizeof (struct hashentry *)); - he_data = alloca (db->head->nentries * sizeof (struct hashentry *)); + he = alloca_account (memory_needed, stack_used); he_use_malloc = false; - stack_used += memory_needed; } else { he = xmalloc (memory_needed); - he_data = &he[db->head->nentries * sizeof (struct hashentry *)]; he_use_malloc = true; } + he_data = &he[db->head->nentries]; size_t cnt = 0; for (size_t idx = 0; idx < db->head->module; ++idx) @@ -373,11 +370,9 @@ gc (struct database_dyn *db) ref_t disp = off_alloc - off_free; struct moveinfo *new_move; - if (stack_used + sizeof (*new_move) <= MAX_STACK_USE) - { - new_move = alloca (sizeof (*new_move)); - stack_used += sizeof (*new_move); - } + if (__builtin_expect (stack_used + sizeof (*new_move) <= MAX_STACK_USE, + 1)) + new_move = alloca_account (sizeof (*new_move), stack_used); else new_move = obstack_alloc (&ob, sizeof (*new_move)); new_move->from = db->data + off_alloc; diff --git a/nscd/nscd.c b/nscd/nscd.c index 08bf1f1260..1129cf8480 100644 --- a/nscd/nscd.c +++ b/nscd/nscd.c @@ -338,7 +338,10 @@ parse_opt (int key, char *arg, struct argp_state *state) break; if (cnt == lastdb) - return ARGP_ERR_UNKNOWN; + { + argp_error (state, _("'%s' is not a known database"), arg); + return EINVAL; + } size_t arg_len = strlen (arg) + 1; struct diff --git a/nss/getent.c b/nss/getent.c index 97c5875de7..7a3ad52175 100644 --- a/nss/getent.c +++ b/nss/getent.c @@ -448,8 +448,6 @@ print_networks (struct netent *net) putchar_unlocked (' '); fputs_unlocked (net->n_aliases[i], stdout); ++i; - if (net->n_aliases[i] != NULL) - putchar_unlocked (','); } putchar_unlocked ('\n'); } diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c index 3ba37c8941..66615da26c 100644 --- a/nss/nss_files/files-parse.c +++ b/nss/nss_files/files-parse.c @@ -1,5 +1,5 @@ /* Common code for file-based database parsers in nss_files module. - Copyright (C) 1996-2000, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1996-2000, 2003, 2004, 2009 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 @@ -127,10 +127,24 @@ nss_files_parse_hidden_def (parse_line) } \ } +/* Helper function. */ +static inline uint32_t +__attribute__ ((always_inline)) +strtou32 (const char *nptr, char **endptr, int base) +{ + unsigned long int val = strtoul (nptr, endptr, base); + + /* Match the 32-bit behavior on 64-bit platforms. */ + if (sizeof (long int) > 4 && val > 0xffffffff) + val = 0xffffffff; + + return val; +} + # define INT_FIELD(variable, terminator_p, swallow, base, convert) \ { \ char *endp; \ - variable = convert (strtoul (line, &endp, base)); \ + variable = convert (strtou32 (line, &endp, base)); \ if (endp == line) \ return 0; \ else if (terminator_p (*endp)) \ @@ -148,7 +162,7 @@ nss_files_parse_hidden_def (parse_line) if (*line == '\0') \ /* We expect some more input, so don't allow the string to end here. */ \ return 0; \ - variable = convert (strtoul (line, &endp, base)); \ + variable = convert (strtou32 (line, &endp, base)); \ if (endp == line) \ variable = default; \ if (terminator_p (*endp)) \ diff --git a/string/string.h b/string/string.h index 90c92d4527..849255f75c 100644 --- a/string/string.h +++ b/string/string.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-1993, 1995-2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 1991-1993,1995-2004,2007,2009 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 @@ -32,6 +32,11 @@ __BEGIN_DECLS #define __need_NULL #include <stddef.h> +/* Tell the caller that we provide correct C++ prototypes. */ +#if defined __cplusplus && __GNUC_PREREQ (4, 4) +# define __CORRECT_ISO_CPP_STRING_H_PROTO +#endif + __BEGIN_NAMESPACE_STD /* Copy N bytes of SRC to DEST. */ @@ -63,19 +68,57 @@ extern int memcmp (__const void *__s1, __const void *__s2, size_t __n) __THROW __attribute_pure__ __nonnull ((1, 2)); /* Search N bytes of S for C. */ +#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" +{ +extern void *memchr (void *__s, int __c, size_t __n) + __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1)); +extern __const void *memchr (__const void *__s, int __c, size_t __n) + __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1)); + +# ifdef __OPTIMIZE__ +__extern_always_inline void * +memchr (void *__s, int __c, size_t __n) __THROW +{ + return __builtin_memchr (__s, __c, __n); +} + +__extern_always_inline __const void * +memchr (__const void *__s, int __c, size_t __n) __THROW +{ + return __builtin_memchr (__s, __c, __n); +} +# endif +} +#else extern void *memchr (__const void *__s, int __c, size_t __n) __THROW __attribute_pure__ __nonnull ((1)); +#endif __END_NAMESPACE_STD #ifdef __USE_GNU /* Search in S for C. This is similar to `memchr' but there is no length limit. */ +# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" void *rawmemchr (void *__s, int __c) + __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1)); +extern "C++" __const void *rawmemchr (__const void *__s, int __c) + __THROW __asm ("rawmemchr") __attribute_pure__ __nonnull ((1)); +# else extern void *rawmemchr (__const void *__s, int __c) __THROW __attribute_pure__ __nonnull ((1)); +# endif /* Search N bytes of S for the final occurrence of C. */ +# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" void *memrchr (void *__s, int __c, size_t __n) + __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1)); +extern "C++" __const void *memrchr (__const void *__s, int __c, size_t __n) + __THROW __asm ("memrchr") __attribute_pure__ __nonnull ((1)); +# else extern void *memrchr (__const void *__s, int __c, size_t __n) __THROW __attribute_pure__ __nonnull ((1)); +# endif #endif @@ -164,18 +207,73 @@ extern char *strndup (__const char *__string, size_t __n) __BEGIN_NAMESPACE_STD /* Find the first occurrence of C in S. */ +#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" +{ +extern char *strchr (char *__s, int __c) + __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1)); +extern __const char *strchr (__const char *__s, int __c) + __THROW __asm ("strchr") __attribute_pure__ __nonnull ((1)); + +# ifdef __OPTIMIZE__ +__extern_always_inline char * +strchr (char *__s, int __c) __THROW +{ + return __builtin_strchr (__s, __c); +} + +__extern_always_inline __const char * +strchr (__const char *__s, int __c) __THROW +{ + return __builtin_strchr (__s, __c); +} +# endif +} +#else extern char *strchr (__const char *__s, int __c) __THROW __attribute_pure__ __nonnull ((1)); +#endif /* Find the last occurrence of C in S. */ +#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" +{ +extern char *strrchr (char *__s, int __c) + __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1)); +extern __const char *strrchr (__const char *__s, int __c) + __THROW __asm ("strrchr") __attribute_pure__ __nonnull ((1)); + +# ifdef __OPTIMIZE__ +__extern_always_inline char * +strrchr (char *__s, int __c) __THROW +{ + return __builtin_strrchr (__s, __c); +} + +__extern_always_inline __const char * +strrchr (__const char *__s, int __c) __THROW +{ + return __builtin_strrchr (__s, __c); +} +# endif +} +#else extern char *strrchr (__const char *__s, int __c) __THROW __attribute_pure__ __nonnull ((1)); +#endif __END_NAMESPACE_STD #ifdef __USE_GNU /* This function is similar to `strchr'. But it returns a pointer to the closing NUL byte in case C is not found in S. */ +# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" char *strchrnul (char *__s, int __c) + __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1)); +extern "C++" __const char *strchrnul (__const char *__s, int __c) + __THROW __asm ("strchrnul") __attribute_pure__ __nonnull ((1)); +# else extern char *strchrnul (__const char *__s, int __c) __THROW __attribute_pure__ __nonnull ((1)); +# endif #endif __BEGIN_NAMESPACE_STD @@ -188,11 +286,60 @@ extern size_t strcspn (__const char *__s, __const char *__reject) extern size_t strspn (__const char *__s, __const char *__accept) __THROW __attribute_pure__ __nonnull ((1, 2)); /* Find the first occurrence in S of any character in ACCEPT. */ +#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" +{ +extern char *strpbrk (char *__s, __const char *__accept) + __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2)); +extern __const char *strpbrk (__const char *__s, __const char *__accept) + __THROW __asm ("strpbrk") __attribute_pure__ __nonnull ((1, 2)); + +# ifdef __OPTIMIZE__ +__extern_always_inline char * +strpbrk (char *__s, __const char *__accept) __THROW +{ + return __builtin_strpbrk (__s, __accept); +} + +__extern_always_inline __const char * +strpbrk (__const char *__s, __const char *__accept) __THROW +{ + return __builtin_strpbrk (__s, __accept); +} +# endif +} +#else extern char *strpbrk (__const char *__s, __const char *__accept) __THROW __attribute_pure__ __nonnull ((1, 2)); +#endif /* Find the first occurrence of NEEDLE in HAYSTACK. */ +#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" +{ +extern char *strstr (char *__haystack, __const char *__needle) + __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2)); +extern __const char *strstr (__const char *__haystack, + __const char *__needle) + __THROW __asm ("strstr") __attribute_pure__ __nonnull ((1, 2)); + +# ifdef __OPTIMIZE__ +__extern_always_inline char * +strstr (char *__haystack, __const char *__needle) __THROW +{ + return __builtin_strstr (__haystack, __needle); +} + +__extern_always_inline __const char * +strstr (__const char *__haystack, __const char *__needle) __THROW +{ + return __builtin_strstr (__haystack, __needle); +} +# endif +} +#else extern char *strstr (__const char *__haystack, __const char *__needle) __THROW __attribute_pure__ __nonnull ((1, 2)); +#endif /* Divide S into tokens separated by characters in DELIM. */ @@ -214,8 +361,16 @@ extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim, #ifdef __USE_GNU /* Similar to `strstr' but this function ignores the case of both strings. */ +# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" char *strcasestr (char *__haystack, __const char *__needle) + __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2)); +extern "C++" __const char *strcasestr (__const char *__haystack, + __const char *__needle) + __THROW __asm ("strcasestr") __attribute_pure__ __nonnull ((1, 2)); +# else extern char *strcasestr (__const char *__haystack, __const char *__needle) __THROW __attribute_pure__ __nonnull ((1, 2)); +# endif #endif #ifdef __USE_GNU @@ -306,12 +461,60 @@ extern int bcmp (__const void *__s1, __const void *__s2, size_t __n) __THROW __attribute_pure__ __nonnull ((1, 2)); /* Find the first occurrence of C in S (same as strchr). */ +# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" +{ +extern char *index (char *__s, int __c) + __THROW __asm ("index") __attribute_pure__ __nonnull ((1)); +extern __const char *index (__const char *__s, int __c) + __THROW __asm ("index") __attribute_pure__ __nonnull ((1)); + +# if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRINGS_H_PROTO +__extern_always_inline char * +index (char *__s, int __c) __THROW +{ + return __builtin_index (__s, __c); +} + +__extern_always_inline __const char * +index (__const char *__s, int __c) __THROW +{ + return __builtin_index (__s, __c); +} +# endif +} +# else extern char *index (__const char *__s, int __c) __THROW __attribute_pure__ __nonnull ((1)); +# endif /* Find the last occurrence of C in S (same as strrchr). */ +# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" +{ +extern char *rindex (char *__s, int __c) + __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1)); +extern __const char *rindex (__const char *__s, int __c) + __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1)); + +# if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRINGS_H_PROTO +__extern_always_inline char * +rindex (char *__s, int __c) __THROW +{ + return __builtin_rindex (__s, __c); +} + +__extern_always_inline __const char * +rindex (__const char *__s, int __c) __THROW +{ + return __builtin_rindex (__s, __c); +} +#endif +} +# else extern char *rindex (__const char *__s, int __c) __THROW __attribute_pure__ __nonnull ((1)); +# endif /* Return the position of the first bit set in I, or 0 if none are set. The least-significant bit is position 1, the most-significant 32. */ @@ -390,7 +593,14 @@ extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1)); declare the function if the `basename' macro is available (defined in <libgen.h>) which makes the XPG version of this function available. */ +# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO +extern "C++" char *basename (char *__filename) + __THROW __asm ("basename") __nonnull ((1)); +extern "C++" __const char *basename (__const char *__filename) + __THROW __asm ("basename") __nonnull ((1)); +# else extern char *basename (__const char *__filename) __THROW __nonnull ((1)); +# endif # endif #endif diff --git a/string/strings.h b/string/strings.h index 3ba2b04c8e..0db756ae56 100644 --- a/string/strings.h +++ b/string/strings.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,96,97,99,2000,2001 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,96,97,99,2000,2001,2009 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,6 +28,11 @@ # define __need_size_t # include <stddef.h> +/* Tell the caller that we provide correct C++ prototypes. */ +# if defined __cplusplus && __GNUC_PREREQ (4, 4) +# define __CORRECT_ISO_CPP_STRINGS_H_PROTO +# endif + __BEGIN_DECLS /* Compare N bytes of S1 and S2 (same as memcmp). */ @@ -45,10 +50,60 @@ extern void bzero (void *__s, size_t __n) __THROW; extern int ffs (int __i) __THROW __attribute__ ((const)); /* Find the first occurrence of C in S (same as strchr). */ -extern char *index (__const char *__s, int __c) __THROW __attribute_pure__; +# ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO +extern "C++" +{ +extern char *index (char *__s, int __c) + __THROW __asm ("index") __attribute_pure__ __nonnull ((1)); +extern __const char *index (__const char *__s, int __c) + __THROW __asm ("index") __attribute_pure__ __nonnull ((1)); + +# if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRING_H_PROTO +__extern_always_inline char * +index (char *__s, int __c) __THROW +{ + return __builtin_index (__s, __c); +} + +__extern_always_inline __const char * +index (__const char *__s, int __c) __THROW +{ + return __builtin_index (__s, __c); +} +# endif +} +# else +extern char *index (__const char *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); +# endif /* Find the last occurrence of C in S (same as strrchr). */ -extern char *rindex (__const char *__s, int __c) __THROW __attribute_pure__; +# ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO +extern "C++" +{ +extern char *rindex (char *__s, int __c) + __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1)); +extern __const char *rindex (__const char *__s, int __c) + __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1)); + +# if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRING_H_PROTO +__extern_always_inline char * +rindex (char *__s, int __c) __THROW +{ + return __builtin_rindex (__s, __c); +} + +__extern_always_inline __const char * +rindex (__const char *__s, int __c) __THROW +{ + return __builtin_rindex (__s, __c); +} +#endif +} +# else +extern char *rindex (__const char *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); +# endif /* Compare S1 and S2, ignoring case. */ extern int strcasecmp (__const char *__s1, __const char *__s2) diff --git a/sysdeps/generic/dl-osinfo.h b/sysdeps/generic/dl-osinfo.h index 60b84a900d..4b880dae34 100644 --- a/sysdeps/generic/dl-osinfo.h +++ b/sysdeps/generic/dl-osinfo.h @@ -1,12 +1,48 @@ +/* Operating system specific code for generic dynamic loader functions. + Copyright (C) 2009 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + #include <stdint.h> static inline uintptr_t __attribute__ ((always_inline)) -_dl_setup_stack_chk_guard (void) +_dl_setup_stack_chk_guard (void *dl_random) +{ + uintptr_t ret; + if (dl_random == NULL) + { + ret = 0; + unsigned char *p = (unsigned char *) &ret; + p[sizeof (ret) - 1] = 255; + p[sizeof (ret) - 2] = '\n'; + p[0] = 0; + } + else + memcpy (&ret, dl_random, sizeof (ret)); + return ret; +} + +static inline uintptr_t __attribute__ ((always_inline)) +_dl_setup_pointer_guard (void *dl_random, uintptr_t stack_chk_guard) { - uintptr_t ret = 0; - unsigned char *p = (unsigned char *) &ret; - p[sizeof (ret) - 1] = 255; - p[sizeof (ret) - 2] = '\n'; - p[0] = 0; + uintptr_t ret; + if (dl_random == NULL) + ret = stack_chk_guard; + else + memcpy (&ret, (char *) dl_random + sizeof (ret), sizeof (ret)); return ret; } diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 4d857404a3..e00b173f49 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -1,5 +1,5 @@ /* Run-time dynamic linker data structures for loaded ELF shared objects. - Copyright (C) 1995-2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1995-2006, 2007, 2008, 2009 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 @@ -731,6 +731,9 @@ weak_extern (_dl_starting_up) extern int _dl_starting_up_internal attribute_hidden; #endif +/* Random data provided by the kernel. */ +extern void *_dl_random attribute_hidden; + /* OS-dependent function to open the zero-fill device. */ extern int _dl_sysdep_open_zero_fill (void); /* dl-sysdep.c */ diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps index 4efc714b29..5231789be1 100644 --- a/sysdeps/i386/fpu/libm-test-ulps +++ b/sysdeps/i386/fpu/libm-test-ulps @@ -453,6 +453,10 @@ Test "exp10 (3) == 1000": ildouble: 8 ldouble: 8 +# expm1 +Test "expm1 (1) == M_El - 1.0": +ildouble: 1 + # gamma Test "gamma (-0.5) == log(2*sqrt(pi))": double: 1 @@ -1134,6 +1138,9 @@ Function: "exp10": ildouble: 8 ldouble: 8 +Function: "expm1": +ildouble: 1 + Function: "gamma": double: 1 idouble: 1 diff --git a/sysdeps/i386/stackinfo.h b/sysdeps/i386/stackinfo.h index a9a6745aaf..2530ea7234 100644 --- a/sysdeps/i386/stackinfo.h +++ b/sysdeps/i386/stackinfo.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1999 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2009 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 @@ -25,4 +25,14 @@ /* On x86 the stack grows down. */ #define _STACK_GROWS_DOWN 1 +/* Access to the stack pointer. The macros are used in alloca_account + for which they need to act as barriers as well, hence the additional + (unnecessary) parameters. */ +#define stackinfo_get_sp() \ + ({ void *p__; asm volatile ("mov %%esp, %0" : "=r" (p__)); p__; }) +#define stackinfo_sub_sp(ptr) \ + ({ ptrdiff_t d__; \ + asm volatile ("sub %%esp, %0" : "=r" (d__) : "0" (ptr)); \ + d__; }) + #endif /* stackinfo.h */ diff --git a/sysdeps/powerpc/fpu/tst-setcontext-fpscr.c b/sysdeps/powerpc/fpu/tst-setcontext-fpscr.c index 973fb3f77a..a15fe86fb9 100644 --- a/sysdeps/powerpc/fpu/tst-setcontext-fpscr.c +++ b/sysdeps/powerpc/fpu/tst-setcontext-fpscr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001,2002,2004,2006,2007,2008 Free Software Foundation, Inc. +/* Copyright (C) 2001,2002,2004,2006-2008,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ryan S. Arnold <rsa@us.ibm.com> Sean Curry <spcurry@us.ibm.com> @@ -104,12 +104,16 @@ typedef unsigned int si_fpscr_t __attribute__ ((__mode__ (__SI__))); (__fpscr)=tmp.fpscr; \ tmp.fpscr; }) +/* We make sure to zero fp0 after we use it in order to prevent stale data + in an fp register from making a test-case pass erroneously. */ # define _SET_DI_FPSCR(__fpscr) { \ union { double d; di_fpscr_t fpscr; } \ tmp __attribute__ ((__aligned__(8))); \ tmp.fpscr = __fpscr; \ /* Set the entire 64-bit FPSCR. */ \ __asm__ ("lfd%U0 0,%0; mtfsf 255,0,1,0" : : "m" (tmp.d) : "fr0"); \ + tmp.d = 0; \ + __asm__("lfd%U0 0,%0" : : "m" (tmp.d) : "fr0"); \ } # define _GET_SI_FPSCR(__fpscr) ({ \ @@ -120,6 +124,8 @@ typedef unsigned int si_fpscr_t __attribute__ ((__mode__ (__SI__))); (__fpscr)=tmp.cw[1]; \ tmp.cw[0]; }) +/* We make sure to zero fp0 after we use it in order to prevent stale data + in an fp register from making a test-case pass erroneously. */ # define _SET_SI_FPSCR(__fpscr) { \ union { double d; si_fpscr_t fpscr[2]; } \ tmp __attribute__ ((__aligned__(8))); \ @@ -127,6 +133,8 @@ typedef unsigned int si_fpscr_t __attribute__ ((__mode__ (__SI__))); tmp.fpscr[0] = 0xFFF80000; \ tmp.fpscr[1] = __fpscr; \ __asm__ ("lfd%U0 0,%0; mtfsf 255,0" : : "m" (tmp.d) : "fr0"); \ + tmp.d = 0; \ + __asm__("lfd%U0 0,%0" : : "m" (tmp.d) : "fr0"); \ } void prime_special_regs(int which) diff --git a/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S b/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S index 7c6e27c209..f9f010fcac 100644 --- a/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S +++ b/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S @@ -1,5 +1,5 @@ /* longjmp for PowerPC. - Copyright (C) 1995-99, 2000, 2003-2005, 2006 Free Software Foundation, Inc. + Copyright (C) 1995-99, 2000, 2003-2006, 2009 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 @@ -64,7 +64,7 @@ ENTRY (BP_SYM (__longjmp)) andi. r6,r5,0xf lwz r0,((JB_VRSAVE)*4)(3) mtspr VRSAVE,r0 - beq+ aligned_restore_vmx + beq+ L(aligned_restore_vmx) addi r6,r5,16 lvsl v0,0,r5 lvx v1,0,r5 @@ -88,7 +88,7 @@ ENTRY (BP_SYM (__longjmp)) lvx v1,0,r5 vperm v31,v31,v1,v0 b L(no_vmx) -aligned_restore_vmx: +L(aligned_restore_vmx): addi r6,r5,16 lvx v20,0,r5 addi r5,r5,32 diff --git a/sysdeps/powerpc/powerpc64/__longjmp-common.S b/sysdeps/powerpc/powerpc64/__longjmp-common.S index 700a2a543c..19b2849c01 100644 --- a/sysdeps/powerpc/powerpc64/__longjmp-common.S +++ b/sysdeps/powerpc/powerpc64/__longjmp-common.S @@ -1,6 +1,5 @@ /* longjmp for PowerPC64. - Copyright (C) 1995, 1996,1997,1999,2000,2001,2002,2003,2004,2005,2006 - Free Software Foundation, Inc. + Copyright (C) 1995, 1996,1997,1999-2006,2009 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 @@ -58,7 +57,7 @@ ENTRY (BP_SYM (__longjmp)) andi. r6,r5,0xf lwz r0,((JB_VRSAVE)*8)(3) mtspr VRSAVE,r0 - beq+ aligned_restore_vmx + beq+ L(aligned_restore_vmx) addi r6,r5,16 lvsl v0,0,r5 lvx v1,0,r5 @@ -82,7 +81,7 @@ ENTRY (BP_SYM (__longjmp)) lvx v1,0,r5 vperm v31,v31,v1,v0 b L(no_vmx) -aligned_restore_vmx: +L(aligned_restore_vmx): addi r6,r5,16 lvx v20,0,r5 addi r5,r5,32 diff --git a/sysdeps/unix/sysv/linux/bits/shm.h b/sysdeps/unix/sysv/linux/bits/shm.h index 3f63152304..90ad0c718f 100644 --- a/sysdeps/unix/sysv/linux/bits/shm.h +++ b/sysdeps/unix/sysv/linux/bits/shm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1997,2000,2002,2004 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,2000,2002,2004,2009 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 @@ -30,6 +30,7 @@ #define SHM_RDONLY 010000 /* attach read-only else read-write */ #define SHM_RND 020000 /* round attach address to SHMLBA */ #define SHM_REMAP 040000 /* take-over region on attach */ +#define SHM_EXEC 0100000 /* execution access */ /* Commands for `shmctl'. */ #define SHM_LOCK 11 /* lock segment (root only) */ diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h index 275a0730c8..9fcfd47829 100644 --- a/sysdeps/unix/sysv/linux/dl-osinfo.h +++ b/sysdeps/unix/sysv/linux/dl-osinfo.h @@ -1,5 +1,5 @@ /* Operating system specific code for generic dynamic loader functions. Linux. - Copyright (C) 2000-2002,2004-2007,2008 Free Software Foundation, Inc. + Copyright (C) 2000-2002,2004-2008, 2009 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 @@ -63,48 +63,78 @@ dl_fatal (const char *str) } while (0) static inline uintptr_t __attribute__ ((always_inline)) -_dl_setup_stack_chk_guard (void) +_dl_setup_stack_chk_guard (void *dl_random) { uintptr_t ret; -#ifdef ENABLE_STACKGUARD_RANDOMIZE - int fd = __open ("/dev/urandom", O_RDONLY); - if (fd >= 0) +#ifndef __ASSUME_AT_RANDOM + if (__builtin_expect (dl_random == NULL, 0)) { - ssize_t reslen = __read (fd, &ret, sizeof (ret)); - __close (fd); - if (reslen == (ssize_t) sizeof (ret)) - return ret; - } -#endif - ret = 0; - unsigned char *p = (unsigned char *) &ret; - p[sizeof (ret) - 1] = 255; - p[sizeof (ret) - 2] = '\n'; +# ifdef ENABLE_STACKGUARD_RANDOMIZE + int fd = __open ("/dev/urandom", O_RDONLY); + if (fd >= 0) + { + ssize_t reslen = __read (fd, &ret, sizeof (ret)); + __close (fd); + if (reslen == (ssize_t) sizeof (ret)) + return ret; + } +# endif + ret = 0; + unsigned char *p = (unsigned char *) &ret; + p[sizeof (ret) - 1] = 255; + p[sizeof (ret) - 2] = '\n'; #ifdef HP_TIMING_NOW - hp_timing_t hpt; - HP_TIMING_NOW (hpt); - hpt = (hpt & 0xffff) << 8; - ret ^= hpt; + hp_timing_t hpt; + HP_TIMING_NOW (hpt); + hpt = (hpt & 0xffff) << 8; + ret ^= hpt; #endif - uintptr_t stk; - /* Avoid GCC being too smart. */ - asm ("" : "=r" (stk) : "r" (p)); - stk &= 0x7ffff0; + uintptr_t stk; + /* Avoid GCC being too smart. */ + asm ("" : "=r" (stk) : "r" (p)); + stk &= 0x7ffff0; #if __BYTE_ORDER == __LITTLE_ENDIAN - stk <<= (__WORDSIZE - 23); + stk <<= (__WORDSIZE - 23); #elif __WORDSIZE == 64 - stk <<= 31; + stk <<= 31; #endif - ret ^= stk; - /* Avoid GCC being too smart. */ - p = (unsigned char *) &errno; - asm ("" : "=r" (stk) : "r" (p)); - stk &= 0x7fff00; + ret ^= stk; + /* Avoid GCC being too smart. */ + p = (unsigned char *) &errno; + asm ("" : "=r" (stk) : "r" (p)); + stk &= 0x7fff00; #if __BYTE_ORDER == __LITTLE_ENDIAN - stk <<= (__WORDSIZE - 29); + stk <<= (__WORDSIZE - 29); #else - stk >>= 8; + stk >>= 8; +#endif + ret ^= stk; + } + else +#endif + /* We need in the moment only 8 bytes on 32-bit platforms and 16 + bytes on 64-bit platforms. Therefore we can use the data + directly and not use the kernel-provided data to seed a PRNG. */ + memcpy (&ret, dl_random, sizeof (ret)); + return ret; +} + +static inline uintptr_t __attribute__ ((always_inline)) +_dl_setup_pointer_guard (void *dl_random, uintptr_t stack_chk_guard) +{ + uintptr_t ret; +#ifndef __ASSUME_AT_RANDOM + if (dl_random == NULL) + { + ret = stack_chk_guard; +# ifndef HP_TIMING_NONAVAIL + hp_timing_t now; + HP_TIMING_NOW (now); + ret ^= now; +# endif + } + else #endif - ret ^= stk; + memcpy (&ret, (char *) dl_random + sizeof (ret), sizeof (ret)); return ret; } diff --git a/sysdeps/unix/sysv/linux/i386/sysconf.c b/sysdeps/unix/sysv/linux/i386/sysconf.c index 38bb5337ba..b1c93d7359 100644 --- a/sysdeps/unix/sysv/linux/i386/sysconf.c +++ b/sysdeps/unix/sysv/linux/i386/sysconf.c @@ -76,8 +76,10 @@ static const struct intel_02_cache_info { { 0x06, _SC_LEVEL1_ICACHE_SIZE, 8192, 4, 32 }, { 0x08, _SC_LEVEL1_ICACHE_SIZE, 16384, 4, 32 }, + { 0x09, _SC_LEVEL1_ICACHE_SIZE, 32768, 4, 32 }, { 0x0a, _SC_LEVEL1_DCACHE_SIZE, 8192, 2, 32 }, { 0x0c, _SC_LEVEL1_DCACHE_SIZE, 16384, 4, 32 }, + { 0x0d, _SC_LEVEL1_DCACHE_SIZE, 16384, 4, 64 }, { 0x22, _SC_LEVEL3_CACHE_SIZE, 524288, 4, 64 }, { 0x23, _SC_LEVEL3_CACHE_SIZE, 1048576, 8, 64 }, { 0x25, _SC_LEVEL3_CACHE_SIZE, 2097152, 8, 64 }, @@ -122,6 +124,18 @@ static const struct intel_02_cache_info { 0x85, _SC_LEVEL2_CACHE_SIZE, 2097152, 8, 32 }, { 0x86, _SC_LEVEL2_CACHE_SIZE, 524288, 4, 64 }, { 0x87, _SC_LEVEL2_CACHE_SIZE, 1048576, 8, 64 }, + { 0xd0, _SC_LEVEL3_CACHE_SIZE, 524288, 4, 64 }, + { 0xd1, _SC_LEVEL3_CACHE_SIZE, 1048576, 4, 64 }, + { 0xd2, _SC_LEVEL3_CACHE_SIZE, 2097152, 4, 64 }, + { 0xd6, _SC_LEVEL3_CACHE_SIZE, 1048576, 8, 64 }, + { 0xd7, _SC_LEVEL3_CACHE_SIZE, 2097152, 8, 64 }, + { 0xd8, _SC_LEVEL3_CACHE_SIZE, 4194304, 8, 64 }, + { 0xdc, _SC_LEVEL3_CACHE_SIZE, 2097152, 12, 64 }, + { 0xdd, _SC_LEVEL3_CACHE_SIZE, 4194304, 12, 64 }, + { 0xde, _SC_LEVEL3_CACHE_SIZE, 8388608, 12, 64 }, + { 0xe3, _SC_LEVEL3_CACHE_SIZE, 2097152, 16, 64 }, + { 0xe3, _SC_LEVEL3_CACHE_SIZE, 4194304, 16, 64 }, + { 0xe4, _SC_LEVEL3_CACHE_SIZE, 8388608, 16, 64 }, }; #define nintel_02_known (sizeof (intel_02_known) / sizeof (intel_02_known[0])) diff --git a/sysdeps/unix/sysv/linux/ia64/bits/shm.h b/sysdeps/unix/sysv/linux/ia64/bits/shm.h index 2dc58a679d..71b85295c5 100644 --- a/sysdeps/unix/sysv/linux/ia64/bits/shm.h +++ b/sysdeps/unix/sysv/linux/ia64/bits/shm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2002, 2005, 2009 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 @@ -30,6 +30,7 @@ #define SHM_RDONLY 010000 /* attach read-only else read-write */ #define SHM_RND 020000 /* round attach address to SHMLBA */ #define SHM_REMAP 040000 /* take-over region on attach */ +#define SHM_EXEC 0100000 /* execution access */ /* Commands for `shmctl'. */ #define SHM_LOCK 11 /* lock segment (root only) */ diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/shm.h b/sysdeps/unix/sysv/linux/powerpc/bits/shm.h index 6a35ff1d7c..023de7990d 100644 --- a/sysdeps/unix/sysv/linux/powerpc/bits/shm.h +++ b/sysdeps/unix/sysv/linux/powerpc/bits/shm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1996, 1997, 2000, 2002, 2004 +/* Copyright (C) 1995, 1996, 1997, 2000, 2002, 2004, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -28,9 +28,10 @@ #define SHM_W 0200 /* or S_IWUGO from <linux/stat.h> */ /* Flags for `shmat'. */ -#define SHM_RDONLY 010000 /* attach read-only else read-write */ -#define SHM_RND 020000 /* round attach address to SHMLBA */ -#define SHM_REMAP 040000 /* take-over region on attach */ +#define SHM_RDONLY 010000 /* attach read-only else read-write */ +#define SHM_RND 020000 /* round attach address to SHMLBA */ +#define SHM_REMAP 040000 /* take-over region on attach */ +#define SHM_EXEC 0100000 /* execution access */ /* Commands for `shmctl'. */ #define SHM_LOCK 11 /* lock segment (root only) */ diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S index 91ac4366c0..d83a0ef28d 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S @@ -1,5 +1,5 @@ /* Jump to a new context powerpc32 common. - Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2008, 2009 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 @@ -18,13 +18,13 @@ 02110-1301 USA. */ /* This is the common implementation of setcontext for powerpc32. - It not complete in itself should be included in to a framework that + It not complete in itself should be included in to a framework that defines: __CONTEXT_FUNC_NAME and if appropriate: __CONTEXT_ENABLE_FPRS __CONTEXT_ENABLE_VRS - Any archecture that implements the Vector unit is assumed to also + Any archecture that implements the Vector unit is assumed to also implement the floating unit. */ /* Stack frame offsets. */ @@ -202,7 +202,7 @@ ENTRY(__CONTEXT_FUNC_NAME) lfd fp0,_UC_FREGS+(0*8)(r31) # ifdef _ARCH_PWR6 /* Use the extended four-operand version of the mtfsf insn. */ - mtfsf 0xff,fp0,1,0 + mtfsf 0xff,fp31,1,0 # else /* Availability of DFP indicates a 64-bit FPSCR. */ andi. r6,r7,PPC_FEATURE_HAS_DFP @@ -304,4 +304,3 @@ ENTRY(__CONTEXT_FUNC_NAME) /* NOTREACHED */ END (__CONTEXT_FUNC_NAME) - diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S index 77c982242a..243a66a0d4 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S @@ -1,5 +1,5 @@ /* Save current context and jump to a new context. - Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2008, 2009 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 @@ -18,13 +18,13 @@ 02110-1301 USA. */ /* This is the common implementation of setcontext for powerpc32. - It not complete in itself should be included in to a framework that + It not complete in itself should be included in to a framework that defines: __CONTEXT_FUNC_NAME and if appropriate: __CONTEXT_ENABLE_FPRS __CONTEXT_ENABLE_VRS - Any archecture that implements the Vector unit is assumed to also + Any archecture that implements the Vector unit is assumed to also implement the floating unit. */ /* Stack frame offsets. */ @@ -51,7 +51,7 @@ ENTRY(__CONTEXT_FUNC_NAME) stw r0,_UC_GREGS+(PT_R0*4)(r3) mflr r0 stw r2,_UC_GREGS+(PT_R2*4)(r3) - stw r4,_UC_GREGS+(PT_R4*4)(r3) + stw r4,_UC_GREGS+(PT_R4*4)(r3) /* Set the callers LR_SAVE, and the ucontext LR and NIP to the callers return address. */ stw r0,_UC_GREGS+(PT_LNK*4)(r3) @@ -85,7 +85,7 @@ ENTRY(__CONTEXT_FUNC_NAME) stw r29,_UC_GREGS+(PT_R29*4)(r3) stw r30,_UC_GREGS+(PT_R30*4)(r3) stw r31,_UC_GREGS+(PT_R31*4)(r3) - + /* Save the value of R1. We had to push the stack before we had the address of uc_reg_space. So compute the address of the callers stack pointer and save it as R1. */ @@ -174,10 +174,10 @@ ENTRY(__CONTEXT_FUNC_NAME) la r10,(_UC_VREGS)(r3) la r9,(_UC_VREGS+16)(r3) - + /* beq L(no_vec)*/ beq 2f -/* address of the combined VSCR/VSAVE quadword. */ +/* address of the combined VSCR/VSAVE quadword. */ la r8,(_UC_VREGS+512)(r3) /* Save the vector registers */ @@ -194,7 +194,7 @@ ENTRY(__CONTEXT_FUNC_NAME) stvx v3,0,r9 addi r10,r10,32 addi r9,r9,32 - + stvx v0,0,r8 stvx v4,0,r10 @@ -266,7 +266,7 @@ ENTRY(__CONTEXT_FUNC_NAME) stvx v30,0,r10 stvx v31,0,r9 stw r0,0(r8) - + 2: /*L(no_vec):*/ # endif /* __CONTEXT_ENABLE_VRS */ #endif /* __CONTEXT_ENABLE_FPRS */ @@ -428,7 +428,7 @@ ENTRY(__CONTEXT_FUNC_NAME) lfd fp0,_UC_FREGS+(0*8)(r31) # ifdef _ARCH_PWR6 /* Use the extended four-operand version of the mtfsf insn. */ - mtfsf 0xff,fp0,1,0 + mtfsf 0xff,fp31,1,0 # else /* Availability of DFP indicates a 64-bit FPSCR. */ andi. r6,r7,PPC_FEATURE_HAS_DFP @@ -514,13 +514,13 @@ ENTRY(__CONTEXT_FUNC_NAME) lwz r31,_UC_GREGS+(PT_R31*4)(r31) bctr - + 3:/*L(error_exit):*/ lwz r0,_FRAME_LR_SAVE+16(r1) addi r1,r1,16 mtlr r0 blr - + 4:/*L(do_sigret):*/ addi r1,r4,-0xd0 li r0,SYS_ify(rt_sigreturn) @@ -528,4 +528,3 @@ ENTRY(__CONTEXT_FUNC_NAME) /* NOTREACHED */ END(__CONTEXT_FUNC_NAME) - diff --git a/sysdeps/unix/sysv/linux/s390/bits/shm.h b/sysdeps/unix/sysv/linux/s390/bits/shm.h index a6df6d779d..e31a29fcd7 100644 --- a/sysdeps/unix/sysv/linux/s390/bits/shm.h +++ b/sysdeps/unix/sysv/linux/s390/bits/shm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2002, 2004, 2009 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 @@ -31,6 +31,7 @@ #define SHM_RDONLY 010000 /* attach read-only else read-write */ #define SHM_RND 020000 /* round attach address to SHMLBA */ #define SHM_REMAP 040000 /* take-over region on attach */ +#define SHM_EXEC 0100000 /* execution access */ /* Commands for `shmctl'. */ #define SHM_LOCK 11 /* lock segment (root only) */ diff --git a/sysdeps/unix/sysv/linux/sh/Makefile b/sysdeps/unix/sysv/linux/sh/Makefile index c1b436a6fb..1ead8f2ae3 100644 --- a/sysdeps/unix/sysv/linux/sh/Makefile +++ b/sysdeps/unix/sysv/linux/sh/Makefile @@ -5,3 +5,8 @@ endif ifeq ($(subdir),stdlib) gen-as-const-headers += ucontext_i.sym endif + +ifeq ($(subdir),math) +# The libm.so link can't find __fpscr_values +libm.so-no-z-defs = yes +endif diff --git a/sysdeps/unix/sysv/linux/sh/bits/shm.h b/sysdeps/unix/sysv/linux/sh/bits/shm.h index 709aa3f976..6469784983 100644 --- a/sysdeps/unix/sysv/linux/sh/bits/shm.h +++ b/sysdeps/unix/sysv/linux/sh/bits/shm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1997,2000,2002,2004,2006 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,2000,2002,2004,2006,2009 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 @@ -30,6 +30,7 @@ #define SHM_RDONLY 010000 /* attach read-only else read-write */ #define SHM_RND 020000 /* round attach address to SHMLBA */ #define SHM_REMAP 040000 /* take-over region on attach */ +#define SHM_EXEC 0100000 /* execution access */ /* Commands for `shmctl'. */ #define SHM_LOCK 11 /* lock segment (root only) */ diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.h b/sysdeps/unix/sysv/linux/sh/sysdep.h index f0be37edc8..0fc2c4f1ee 100644 --- a/sysdeps/unix/sysv/linux/sh/sysdep.h +++ b/sysdeps/unix/sysv/linux/sh/sysdep.h @@ -1,5 +1,5 @@ /* Copyright (C) 1992,1993,1995,1996,1997,1998,1999,2000,2002,2003,2004, - 2005,2006 Free Software Foundation, Inc. + 2005,2006,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995. Changed by Kaz Kojima, <kkojima@rr.iij4u.or.jp>. @@ -339,7 +339,7 @@ asm volatile (SYSCALL_INST_STR##nr SYSCALL_INST_PAD \ : "=z" (resultvar) \ : "r" (r3) ASMFMT_##nr \ - : "memory"); \ + : "memory", "t"); \ \ (int) resultvar; }) @@ -353,7 +353,7 @@ asm volatile (SYSCALL_INST_STR##nr SYSCALL_INST_PAD \ : "=z" (resultvar) \ : "r" (r3) ASMFMT_##nr \ - : "memory"); \ + : "memory", "t"); \ \ (int) resultvar; }) diff --git a/sysdeps/unix/sysv/linux/sparc/bits/shm.h b/sysdeps/unix/sysv/linux/sparc/bits/shm.h index 273b67edb5..1ec5e91322 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/shm.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/shm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1996, 1997, 2000, 2002, 2004 +/* Copyright (C) 1995, 1996, 1997, 2000, 2002, 2004, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -32,6 +32,7 @@ #define SHM_RDONLY 010000 /* attach read-only else read-write */ #define SHM_RND 020000 /* round attach address to SHMLBA */ #define SHM_REMAP 040000 /* take-over region on attach */ +#define SHM_EXEC 0100000 /* execution access */ /* Commands for `shmctl'. */ #define SHM_LOCK 11 /* lock segment (root only) */ diff --git a/sysdeps/unix/sysv/linux/sys/inotify.h b/sysdeps/unix/sysv/linux/sys/inotify.h index 81e31fb646..8b3a85280f 100644 --- a/sysdeps/unix/sysv/linux/sys/inotify.h +++ b/sysdeps/unix/sysv/linux/sys/inotify.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006, 2008, 2009 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 @@ -98,7 +98,7 @@ extern int inotify_add_watch (int __fd, const char *__name, uint32_t __mask) __THROW; /* Remove the watch specified by WD from the inotify instance FD. */ -extern int inotify_rm_watch (int __fd, uint32_t __wd) __THROW; +extern int inotify_rm_watch (int __fd, int __wd) __THROW; __END_DECLS diff --git a/sysdeps/unix/sysv/linux/tst-clone.c b/sysdeps/unix/sysv/linux/tst-clone.c index 8e249c2f04..cbfa8917d6 100644 --- a/sysdeps/unix/sysv/linux/tst-clone.c +++ b/sysdeps/unix/sysv/linux/tst-clone.c @@ -1,5 +1,5 @@ /* Test for proper error/errno handling in clone. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009 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 @@ -36,9 +36,9 @@ do_test (void) int result; #ifdef __ia64__ - result = __clone2(child_fn, NULL, 0, 0, NULL, NULL, NULL); + result = __clone2 (child_fn, NULL, 0, 0, NULL, NULL, NULL); #else - result = clone(child_fn, NULL, (int) NULL, NULL); + result = clone (child_fn, NULL, 0, NULL); #endif if (errno != EINVAL || result != -1) diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/shm.h b/sysdeps/unix/sysv/linux/x86_64/bits/shm.h index def200c193..04f5cc5d65 100644 --- a/sysdeps/unix/sysv/linux/x86_64/bits/shm.h +++ b/sysdeps/unix/sysv/linux/x86_64/bits/shm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1996, 1997, 2000, 2002, 2004 +/* Copyright (C) 1995, 1996, 1997, 2000, 2002, 2004, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -31,6 +31,7 @@ #define SHM_RDONLY 010000 /* attach read-only else read-write */ #define SHM_RND 020000 /* round attach address to SHMLBA */ #define SHM_REMAP 040000 /* take-over region on attach */ +#define SHM_EXEC 0100000 /* execution access */ /* Commands for `shmctl'. */ #define SHM_LOCK 11 /* lock segment (root only) */ diff --git a/sysdeps/x86_64/cacheinfo.c b/sysdeps/x86_64/cacheinfo.c index 6a3ea0f1cb..a7e3fc7633 100644 --- a/sysdeps/x86_64/cacheinfo.c +++ b/sysdeps/x86_64/cacheinfo.c @@ -34,8 +34,10 @@ static const struct intel_02_cache_info { { 0x06, _SC_LEVEL1_ICACHE_SIZE, 8192, 4, 32 }, { 0x08, _SC_LEVEL1_ICACHE_SIZE, 16384, 4, 32 }, + { 0x09, _SC_LEVEL1_ICACHE_SIZE, 32768, 4, 32 }, { 0x0a, _SC_LEVEL1_DCACHE_SIZE, 8192, 2, 32 }, { 0x0c, _SC_LEVEL1_DCACHE_SIZE, 16384, 4, 32 }, + { 0x0d, _SC_LEVEL1_DCACHE_SIZE, 16384, 4, 64 }, { 0x22, _SC_LEVEL3_CACHE_SIZE, 524288, 4, 64 }, { 0x23, _SC_LEVEL3_CACHE_SIZE, 1048576, 8, 64 }, { 0x25, _SC_LEVEL3_CACHE_SIZE, 2097152, 8, 64 }, @@ -80,6 +82,18 @@ static const struct intel_02_cache_info { 0x85, _SC_LEVEL2_CACHE_SIZE, 2097152, 8, 32 }, { 0x86, _SC_LEVEL2_CACHE_SIZE, 524288, 4, 64 }, { 0x87, _SC_LEVEL2_CACHE_SIZE, 1048576, 8, 64 }, + { 0xd0, _SC_LEVEL3_CACHE_SIZE, 524288, 4, 64 }, + { 0xd1, _SC_LEVEL3_CACHE_SIZE, 1048576, 4, 64 }, + { 0xd2, _SC_LEVEL3_CACHE_SIZE, 2097152, 4, 64 }, + { 0xd6, _SC_LEVEL3_CACHE_SIZE, 1048576, 8, 64 }, + { 0xd7, _SC_LEVEL3_CACHE_SIZE, 2097152, 8, 64 }, + { 0xd8, _SC_LEVEL3_CACHE_SIZE, 4194304, 8, 64 }, + { 0xdc, _SC_LEVEL3_CACHE_SIZE, 2097152, 12, 64 }, + { 0xdd, _SC_LEVEL3_CACHE_SIZE, 4194304, 12, 64 }, + { 0xde, _SC_LEVEL3_CACHE_SIZE, 8388608, 12, 64 }, + { 0xe3, _SC_LEVEL3_CACHE_SIZE, 2097152, 16, 64 }, + { 0xe3, _SC_LEVEL3_CACHE_SIZE, 4194304, 16, 64 }, + { 0xe4, _SC_LEVEL3_CACHE_SIZE, 8388608, 16, 64 }, }; #define nintel_02_known (sizeof (intel_02_known) / sizeof (intel_02_known [0])) diff --git a/sysdeps/x86_64/stackinfo.h b/sysdeps/x86_64/stackinfo.h index 60668d10b1..b11849d9ab 100644 --- a/sysdeps/x86_64/stackinfo.h +++ b/sysdeps/x86_64/stackinfo.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2009 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 @@ -25,4 +25,14 @@ /* On x86_64 the stack grows down. */ #define _STACK_GROWS_DOWN 1 +/* Access to the stack pointer. The macros are used in alloca_account + for which they need to act as barriers as well, hence the additional + (unnecessary) parameters. */ +#define stackinfo_get_sp() \ + ({ void *p__; asm volatile ("mov %%rsp, %0" : "=r" (p__)); p__; }) +#define stackinfo_sub_sp(ptr) \ + ({ ptrdiff_t d__; \ + asm volatile ("sub %%rsp, %0" : "=r" (d__) : "0" (ptr)); \ + d__; }) + #endif /* stackinfo.h */ diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h index aaf278dd8d..a9067e583b 100644 --- a/wcsmbs/wchar.h +++ b/wcsmbs/wchar.h @@ -51,6 +51,11 @@ # define __need_wint_t # include <stddef.h> +/* Tell the caller that we provide correct C++ prototypes. */ +#if defined __cplusplus && __GNUC_PREREQ (4, 4) +# define __CORRECT_ISO_CPP_WCHAR_H_PROTO +#endif + /* We try to get wint_t from <stddef.h>, but not all GCC versions define it there. So define it ourselves if it remains undefined. */ # ifndef _WINT_T @@ -210,11 +215,25 @@ extern wchar_t *wcsdup (__const wchar_t *__s) __THROW __attribute_malloc__; __BEGIN_NAMESPACE_STD /* Find the first occurrence of WC in WCS. */ +#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO +extern "C++" wchar_t *wcschr (wchar_t *__wcs, wchar_t __wc) + __THROW __asm ("wcschr") __attribute_pure__; +extern "C++" __const wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc) + __THROW __asm ("wcschr") __attribute_pure__; +#else extern wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc) __THROW __attribute_pure__; +#endif /* Find the last occurrence of WC in WCS. */ +#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO +extern "C++" wchar_t *wcsrchr (wchar_t *__wcs, wchar_t __wc) + __THROW __asm ("wcsrchr") __attribute_pure__; +extern "C++" __const wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc) + __THROW __asm ("wcsrchr") __attribute_pure__; +#else extern wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc) __THROW __attribute_pure__; +#endif __END_NAMESPACE_STD #ifdef __USE_GNU @@ -234,11 +253,27 @@ extern size_t wcscspn (__const wchar_t *__wcs, __const wchar_t *__reject) extern size_t wcsspn (__const wchar_t *__wcs, __const wchar_t *__accept) __THROW __attribute_pure__; /* Find the first occurrence in WCS of any character in ACCEPT. */ +#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO +extern "C++" wchar_t *wcspbrk (wchar_t *__wcs, __const wchar_t *__accept) + __THROW __asm ("wcspbrk") __attribute_pure__; +extern "C++" __const wchar_t *wcspbrk (__const wchar_t *__wcs, + __const wchar_t *__accept) + __THROW __asm ("wcspbrk") __attribute_pure__; +#else extern wchar_t *wcspbrk (__const wchar_t *__wcs, __const wchar_t *__accept) __THROW __attribute_pure__; +#endif /* Find the first occurrence of NEEDLE in HAYSTACK. */ +#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO +extern "C++" wchar_t *wcsstr (wchar_t *__haystack, __const wchar_t *__needle) + __THROW __asm ("wcsstr") __attribute_pure__; +extern "C++" __const wchar_t *wcsstr (__const wchar_t *__haystack, + __const wchar_t *__needle) + __THROW __asm ("wcsstr") __attribute_pure__; +#else extern wchar_t *wcsstr (__const wchar_t *__haystack, __const wchar_t *__needle) __THROW __attribute_pure__; +#endif /* Divide WCS into tokens separated by characters in DELIM. */ extern wchar_t *wcstok (wchar_t *__restrict __s, @@ -251,8 +286,16 @@ __END_NAMESPACE_STD #ifdef __USE_XOPEN /* Another name for `wcsstr' from XPG4. */ +# ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO +extern "C++" wchar_t *wcswcs (wchar_t *__haystack, __const wchar_t *__needle) + __THROW __asm ("wcswcs") __attribute_pure__; +extern "C++" __const wchar_t *wcswcs (__const wchar_t *__haystack, + __const wchar_t *__needle) + __THROW __asm ("wcswcs") __attribute_pure__; +# else extern wchar_t *wcswcs (__const wchar_t *__haystack, __const wchar_t *__needle) __THROW __attribute_pure__; +# endif #endif #ifdef __USE_GNU @@ -264,8 +307,16 @@ extern size_t wcsnlen (__const wchar_t *__s, size_t __maxlen) __BEGIN_NAMESPACE_STD /* Search N wide characters of S for C. */ +#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO +extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n) + __THROW __asm ("wmemchr") __attribute_pure__; +extern "C++" __const wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c, + size_t __n) + __THROW __asm ("wmemchr") __attribute_pure__; +#else extern wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c, size_t __n) __THROW __attribute_pure__; +#endif /* Compare N wide characters of S1 and S2. */ extern int wmemcmp (__const wchar_t *__restrict __s1, |