From 11bf311edc76f5ddc469a8c396e313e82d76be15 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 11 Jan 2007 21:51:07 +0000 Subject: [BZ #2510, BZ #2830, BZ #3137, BZ #3313, BZ #3426, BZ #3465, BZ #3480, BZ #3483, BZ #3493, BZ #3514, BZ #3515, BZ #3664, BZ #3673, BZ #3674] 2007-01-11 Jakub Jelinek * sysdeps/i386/soft-fp/sfp-machine.h: Remove. * sysdeps/x86_64/soft-fp/sfp-machine.h: Likewise. 2007-01-10 Ulrich Drepper * io/fts.c: Make sure fts_cur is always valid after return from fts_read. Patch by Miloslav Trmac . 2006-10-27 Richard Sandiford * elf/elf.h (R_MIPS_GLOB_DAT): Define. (R_MIPS_NUM): Bump by 1. 2007-01-03 Jakub Jelinek * posix/execvp.c: Include alloca.h. (allocate_scripts_argv): Renamed to... (scripts_argv): ... this. Don't allocate buffer here nor count arguments. (execvp): Use alloca if possible. * posix/Makefile: Add rules to build and run tst-vfork3 test. * posix/tst-vfork3.c: New test. * stdlib/Makefile (tst-strtod3-ENV): Define. 2007-01-02 Ulrich Drepper * posix/getconf.c: Update copyright year. * nss/getent.c: Likewise. * iconv/iconvconfig.c: Likewise. * iconv/iconv_prog.c: Likewise. * elf/ldconfig.c: Likewise. * catgets/gencat.c: Likewise. * csu/version.c: Likewise. * elf/ldd.bash.in: Likewise. * elf/sprof.c (print_version): Likewise. * locale/programs/locale.c: Likewise. * locale/programs/localedef.c: Likewise. * nscd/nscd.c (print_version): Likewise. * debug/xtrace.sh: Likewise. * malloc/memusage.sh: Likewise. * malloc/mtrace.pl: Likewise. * debug/catchsegv.sh: Likewise. 2006-12-24 Ulrich Drepper * malloc/malloc.c (sYSMALLOc): Remove some unnecessary alignment attempts. 2006-12-23 Ulrich Drepper * posix/wordexp.c: Remove some unnecessary tests. 2006-12-20 SUGIOKA Toshinobu * sysdeps/unix/sysv/linux/sh/bits/shm.h: New file. * nss/getXXbyYY_r.c: Include atomic.h. (INTERNAL (REENTRANT_NAME)): Write startp after start_fct, add atomic_write_barrier () in between. 2006-11-28 Jakub Jelinek * elf/dl-support.c: Include dl-procinfo.h. * sysdeps/powerpc/dl-procinfo.h (PPC_PLATFORM_POWER4, PPC_PLATFORM_PPC970, PPC_PLATFORM_POWER5, PPC_PLATFORM_POWER5_PLUS, PPC_PLATFORM_POWER6, PPC_PLATFORM_CELL_BE, PPC_PLATFORM_POWER6X): Define. (_dl_string_platform): Use PPC_PLATFORM_* macros instead of hardcoded constants. * sysdeps/powerpc/dl-procinfo.c (_dl_powerpc_platform): Use PPC_PLATFORM_* macros for array designators. 2006-11-11 Steven Munroe * sysdeps/powerpc/dl-procinfo.c (_dl_powerpc_cap_flags): Add 3 new cap names to the beginning. (_dl_powerpc_platforms): Add "power6x". * sysdeps/powerpc/dl-procinfo.h (_DL_HWCAP_FIRST): Decrease. (HWCAP_IMPORTANT): Add PPC_FEATURE_HAS_DFP. (_DL_PLATFORMS_COUNT): Increase. (_dl_string_platform): Handle power6x case. * sysdeps/powerpc/sysdep.h (PPC_FEATURE_PA6T, PPC_FEATURE_HAS_DFP, PPC_FEATURE_POWER6_EXT): Define. (PPC_FEATURE_POWER5, PPC_FEATURE_POWER5_PLUS): Correct Comment. [-2^31 .. 2^31) range. * sysdeps/unix/sysv/linux/bits/statvfs.h: Define ST_RELATIME. * sysdeps/unix/sysv/linux/internal_statvfs.c (__statvfs_getflags): Handle relatime mount option. 2006-12-13 Jakub Jelinek * sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S: Include kernel-features.h. 2006-12-11 Ulrich Drepper * stdlib/strtod_l.c (____STRTOF_INTERNAL): Parse thousand separators also if no non-zero digits found. * stdlib/Makefile (tests): Add tst-strtod3. [BZ #3664] * stdlib/strtod_l.c (____STRTOF_INTERNAL): Fix test to recognize empty parsed strings. * stdlib/Makefile (tests): Add tst-strtod2. * stdlib/tst-strtod2.c: New file. [BZ #3673] * stdlib/strtod_l.c (____STRTOF_INTERNAL): Fix exp_limit computation. * stdlib/Makefile (tests): Add tst-atof2. * stdlib/tst-atof2.c: New file. [BZ #3674] * stdlib/strtod_l.c (____STRTOF_INTERNAL): Adjust exponent value correctly if removing trailing zero of hex-float. * stdlib/Makefile (tests): Add tst-atof1. * stdlib/tst-atof1.c: New file. * misc/mntent_r.c (__hasmntopt): Check p[optlen] even when p == rest. Start searching for next comma at p rather than rest. * misc/Makefile (tests): Add tst-mntent2. * misc/tst-mntent2.c: New test. 2006-12-08 Ulrich Drepper * malloc/memusage.c: Handle realloc with new size of zero and non-NULL pointer correctly. (me): Really write first record twice. (struct entry): Make format bi-arch safe. (dest): Write out more realloc statistics. * malloc/memusagestat.c (struct entry): Make format bi-arch safe. 2006-12-05 Jakub Jelinek * nis/nis_subr.c (nis_getnames): Revert last change. 2006-12-03 Kaz Kojima * sysdeps/unix/sysv/linux/sh/sys/io.h: Removed. 2006-11-30 H.J. Lu * sysdeps/i386/i686/memcmp.S: Use jump table as the base of jump table entries. 2006-11-30 Jan Kratochvil * sysdeps/unix/sysv/linux/i386/clone.S: Provide CFI for the outermost `clone' function to ensure proper unwinding stop of gdb. * sysdeps/unix/sysv/linux/x86_64/clone.S: Likewise. 2006-12-01 Ulrich Drepper * nscd/nscd.init: Remove obsolete and commented-out -S option handling. 2006-11-23 Jakub Jelinek [BZ #3514] * manual/string.texi (strncmp): Fix pastos from wcscmp description. [BZ #3515] * manual/string.texi (strtok): Remove duplicate paragraph. 2006-12-01 Jan Kratochvil * sysdeps/unix/sysv/linux/x86_64/sigaction.c: Fix compatibility with libgcc not supporting `rflags' unwinding (register # >= 17). 2006-11-30 Jakub Jelinek * sunrpc/svc_run.c (svc_run): Set my_pollfd to new_pollfd if realloc succeeded. 2006-11-29 Daniel Jacobowitz Jakub Jelinek Jan Kratochvil * sysdeps/unix/sysv/linux/x86_64/sigaction.c (restore_rt): Add correct unwind information. * sysdeps/unix/sysv/linux/x86_64/Makefile: Provide symbols for 'restore_rt' even in the 'signal' directory. * sysdeps/unix/sysv/linux/x86_64/ucontext_i.sym: Extend the regs list. malloc crashed. Don't allocate memory unnecessarily in each loop. 2006-10-21 Jakub Jelinek * resolv/mapv4v6addr.h (map_v4v6_address): Fix last change. 2006-11-20 Ulrich Drepper * resolv/mapv4v6addr.h (map_v4v6_address): Optimize a bit. 2006-11-18 Bruno Haible * sysdeps/unix/sysv/linux/i386/getgroups.c (__getgroups): Invoke __sysconf only after having tried to call getgroups32. 2006-11-19 Ulrich Drepper * nss/nss_files/files-hosts.c (LINE_PARSER): Support IPv6-style addresses for IPv4 queries if they can be mapped. 2006-11-16 Jakub Jelinek * sysdeps/x86_64/fpu/s_copysignf.S (__copysignf): Switch to .text. * sysdeps/x86_64/fpu/s_copysign.S (__copysign): Likewise. (signmask): Add .size directive. (othermask): Add .type directive. 2006-11-14 Ulrich Drepper * po/nl.po: Update from translation team. * timezone/zdump.c: Redo fix for BZ #3137. 2006-11-14 Jakub Jelinek * nss/nss_files/files-alias.c (get_next_alias): Set line back to first_unused after parsing :include: file. * timezone/africa: Update from tzdata2006o. * timezone/antarctica: Likewise. * timezone/asia: Likewise. * timezone/australasia: Likewise. * timezone/backward: Likewise. * timezone/europe: Likewise. * timezone/iso3166.tab: Likewise. * timezone/northamerica: Likewise. * timezone/southamerica: Likewise. * timezone/zone.tab: Likewise. * time/tzfile.c (__tzfile_read): Extend to handle new file format on machines with 64-bit time_t. * timezone/checktab.awk: Update from tzcode2006o. * timezone/ialloc.c: Likewise. * timezone/private.h: Likewise. * timezone/scheck.c: Likewise. * timezone/tzfile.h: Likewise. * timezone/tzselect.ksh: Likewise. * timezone/zdump.c: Likewise. * timezone/zic.c: Likewise. [BZ #3483] * elf/ldconfig.c (main): Call setlocale and textdomain. Patch mostly by Benno Schulenberg . [BZ #3480] * manual/argp.texi: Fix typos. * manual/charset.texi: Likewise. * manual/errno.texi: Likewise. * manual/filesys.texi: Likewise. * manual/lang.texi: Likewise. * manual/maint.texi: Likewise. * manual/memory.texi: Likewise. * manual/message.texi: Likewise. * manual/resource.texi: Likewise. * manual/search.texi: Likewise. * manual/signal.texi: Likewise. * manual/startup.texi: Likewise. * manual/stdio.texi: Likewise. * manual/sysinfo.texi: Likewise. * manual/syslog.texi: Likewise. * manual/time.texi: Likewise. Patch by Ralf Wildenhues . [BZ #3465] * sunrpc/clnt_raw.c: Minimal message improvements. * sunrpc/pm_getmaps.c: Likewise. * nis/nss_nisplus/nisplus-publickey.c: Likewise. * nis/nis_print_group_entry.c: Likewise. * locale/programs/repertoire.c: Likewise. * locale/programs/charmap.c: Likewise. * malloc/memusage.sh: Likewise. * elf/dl-deps.c: Likewise. * locale/programs/ld-collate.c: Likewise. * libio/vswprintf.c: Likewise. * malloc/memusagestat.c: Likewise. * sunrpc/auth_unix.c: Likewise. * sunrpc/rpc_main.c: Likewise. * nscd/cache.c: Likewise. * locale/programs/repertoire.c: Unify output messages. * locale/programs/charmap.c: Likewise. * locale/programs/ld-ctype.c: Likewise. * locale/programs/ld-monetary.c: Likewise. * locale/programs/ld-numeric.c: Likewise. * locale/programs/ld-time.c: Likewise. * elf/ldconfig.c: Likewise. * nscd/selinux.c: Likewise. * elf/cache.c: Likewise. Patch mostly by Benno Schulenberg . 2006-11-10 Jakub Jelinek * string/strxfrm_l.c (STRXFRM): Fix trailing \1 optimization if N is one bigger than return value. * string/tst-strxfrm2.c (do_test): Also test strxfrm with l1 + 1 and l1 last arguments, if buf is defined, verify the return value equals to strlen (buf) and verify no byte beyond passed length is modified. 2006-11-10 Ulrich Drepper * po/sv.po: Update from translation team. * sysdeps/gnu/siglist.c (__old_sys_siglist, __old_sys_sigabbrev): Use __new_sys_siglist instead of _sys_siglist_internal as second macro argument. (_old_sys_siglist): Use declare_symbol_alias macro instead of strong_alias. 2006-11-09 Ulrich Drepper [BZ #3493] * posix/unistd.h (sysconf): Remove const attribute. * sysdeps/posix/getaddrinfo.c (getaddrinfo): Fix test for temporary or deprecated addresses. Patch by Sridhar Samudrala . * string/Makefile (tests): Add tst-strxfrm2. * string/tst-strxfrm2.c: New file. 2006-10-09 Jakub Jelinek * elf/dl-debug.c (_dl_debug_initialize): Check r->r_map for 0 rather than r->r_brk. * string/strxfrm_l.c (STRXFRM): Do the trailing \1 removal optimization even if needed > n. 2006-11-07 Jakub Jelinek * include/libc-symbols.h (declare_symbol): Rename to... (declare_symbol_alias): ... this. Add ORIGINAL argument, imply strong_alias (ORIGINAL, SYMBOL) in asm to make sure it preceedes .size directive. * sysdeps/gnu/errlist-compat.awk: Adjust for declare_symbol_alias changes. * sysdeps/gnu/siglist.c: Likewise. 2006-11-03 Steven Munroe * sysdeps/powerpc/fpu/bits/mathinline.h [__LIBC_INTERNAL_MATH_INLINES]: Moved to ... * sysdeps/powerpc/fpu/math_private.h: ...here. New file. 2006-11-05 Ulrich Drepper * sysdeps/unix/sysv/linux/i386/sysconf.c (intel_check_word): Update handling of cache descriptor 0x49 for new models. * sysdeps/unix/sysv/linux/x86_64/sysconf.c (intel_check_word): Likewise. 2006-11-02 Ulrich Drepper * configure.in: Work around ld --help change and avoid -z relro test completely if the architecture doesn't care about security. 2006-11-01 Ulrich Drepper * po/sv.po: Update from translation team. 2006-10-31 Ulrich Drepper * stdlib/atexit.c (atexit): Don't mark as hidden when used to generate compatibility version. 2006-10-29 Ulrich Drepper * configure.in: Relax -z relro requirement a bit. * po/sv.po: Update from translation team. 2006-10-29 Jakub Jelinek * elf/dl-sym.c (do_sym): Use RTLD_SINGLE_THREAD_P. * elf/dl-runtime.c (_dl_fixup, _dl_profile_fixup): Likewise. * elf/dl-close.c (_dl_close_worker): Likewise. * elf/dl-open.c (_dl_open_worker): Likewise. * sysdeps/generic/sysdep-cancel.h (RTLD_SINGLE_THREAD_P): Define. * configure.in: Require assembler support for visibility, compiler support for visibility and aliases, linker support for various -z options. * Makeconfig: Remove conditional code which now is unnecessary. * config.h.in: Likewise. * config.make.in: Likewise. * dlfcn/Makefile: Likewise. * elf/Makefile: Likewise. * elf/dl-load.c: Likewise. * elf/rtld.c: Likewise. * include/libc-symbols.h: Likewise. * include/stdio.h: Likewise. * io/Makefile: Likewise. * io/fstat.c: Likewise. * io/fstat64.c: Likewise. * io/fstatat.c: Likewise. * io/fstatat64.c: Likewise. * io/lstat.c: Likewise. * io/lstat64.c: Likewise. * io/mknod.c: Likewise. * io/mknodat.c: Likewise. * io/stat.c: Likewise. * io/stat64.c: Likewise. * libio/stdio.c: Likewise. * nscd/Makefile: Likewise. * stdlib/Makefile: Likewise. * stdlib/atexit.c: Likewise. * sysdeps/generic/ldsodefs.h: Likewise. * sysdeps/i386/dl-machine.h: Likewise. * sysdeps/i386/sysdep.h: Likewise. * sysdeps/i386/i686/memcmp.S: Likewise. * sysdeps/powerpc/powerpc32/sysdep.h: Likewise. * sysdeps/unix/sysv/linux/i386/sigaction.c: Likewise. * sysdeps/unix/sysv/linux/x86_64/sigaction.c: Likewise. * Makerules: USE_TLS support is now default. * tls.make.c: Likewise. * csu/Versions: Likewise. * csu/libc-start.c: Likewise. * csu/libc-tls.c: Likewise. * csu/version.c: Likewise. * dlfcn/dlinfo.c: Likewise. * elf/dl-addr.c: Likewise. * elf/dl-cache.c: Likewise. * elf/dl-close.c: Likewise. * elf/dl-iteratephdr.c: Likewise. * elf/dl-load.c: Likewise. * elf/dl-lookup.c: Likewise. * elf/dl-object.c: Likewise. * elf/dl-open.c: Likewise. * elf/dl-reloc.c: Likewise. * elf/dl-support.c: Likewise. * elf/dl-sym.c: Likewise. * elf/dl-sysdep.c: Likewise. * elf/dl-tls.c: Likewise. * elf/ldconfig.c: Likewise. * elf/rtld.c: Likewise. * elf/tst-tls-dlinfo.c: Likewise. * elf/tst-tls1.c: Likewise. * elf/tst-tls10.h: Likewise. * elf/tst-tls14.c: Likewise. * elf/tst-tls2.c: Likewise. * elf/tst-tls3.c: Likewise. * elf/tst-tls4.c: Likewise. * elf/tst-tls5.c: Likewise. * elf/tst-tls6.c: Likewise. * elf/tst-tls7.c: Likewise. * elf/tst-tls8.c: Likewise. * elf/tst-tls9.c: Likewise. * elf/tst-tlsmod1.c: Likewise. * elf/tst-tlsmod13.c: Likewise. * elf/tst-tlsmod13a.c: Likewise. * elf/tst-tlsmod14a.c: Likewise. * elf/tst-tlsmod2.c: Likewise. * elf/tst-tlsmod3.c: Likewise. * elf/tst-tlsmod4.c: Likewise. * elf/tst-tlsmod5.c: Likewise. * elf/tst-tlsmod6.c: Likewise. * include/errno.h: Likewise. * include/link.h: Likewise. * include/tls.h: Likewise. * locale/global-locale.c: Likewise. * locale/localeinfo.h: Likewise. * malloc/arena.c: Likewise. * malloc/hooks.c: Likewise. * malloc/malloc.c: Likewise. * resolv/Versions: Likewise. * sysdeps/alpha/dl-machine.h: Likewise. * sysdeps/alpha/libc-tls.c: Likewise. * sysdeps/generic/ldsodefs.h: Likewise. * sysdeps/generic/tls.h: Likewise. * sysdeps/i386/dl-machine.h: Likewise. * sysdeps/ia64/dl-machine.h: Likewise. * sysdeps/ia64/libc-tls.c: Likewise. * sysdeps/mach/hurd/fork.c: Likewise. * sysdeps/mach/hurd/i386/tls.h: Likewise. * sysdeps/powerpc/powerpc32/dl-machine.c: Likwise. * sysdeps/powerpc/powerpc32/dl-machine.h: Likewise. * sysdeps/powerpc/powerpc64/dl-machine.h: Likewise. * sysdeps/s390/libc-tls.c: Likewise. * sysdeps/s390/s390-32/dl-machine.h: Likewise. * sysdeps/s390/s390-64/dl-machine.h: Likewise. * sysdeps/sh/dl-machine.h: Likewise. * sysdeps/sparc/sparc32/dl-machine.h: Likewise. * sysdeps/sparc/sparc64/dl-machine.h: Likewise. * sysdeps/x86_64/dl-machine.h: Likewise. [BZ #3426] * stdlib/stdlib.h: Adjust comment for canonicalize_file_name to reality. 2006-10-27 Jakub Jelinek * elf/dl-lookup.c (_dl_debug_bindings): Remove unused symbol_scope argument. (_dl_lookup_symbol_x): Adjust caller. * sysdeps/generic/ldsodefs.h (struct link_namespaces): Remove _ns_global_scope. * elf/rtld.c (dl_main): Don't initialize _ns_global_scope. * elf/dl-libc.c: Revert l_scope name changes. * elf/dl-load.c: Likewise. * elf/dl-object.c: Likewise. * elf/rtld.c: Likewise. * elf/dl-close.c (_dl_close): Likewise. * elf/dl-open.c (dl_open_worker): Likewise. If not SINGLE_THREAD_P, always use __rtld_mrlock_{change,done}. Always free old scope list here if not l_scope_mem. * elf/dl-runtime.c (_dl_fixup, _dl_profile_fixup): Revert l_scope name change. Never free scope list here. Just __rtld_mrlock_lock before the lookup and __rtld_mrlock_unlock it after the lookup. * elf/dl-sym.c: Likewise. * include/link.h (struct r_scoperec): Remove. (struct link_map): Replace l_scoperec with l_scope, l_scoperec_mem with l_scope_mem and l_scoperec_lock with l_scope_lock. 2006-10-25 Ulrich Drepper * sysdeps/gnu/netinet/tcp.h: Define TCP_CONGESTION. 2006-10-18 Ulrich Drepper * configure.in: Disable building profile libraries by default. 2006-10-18 Ulrich Drepper * elf/dl-lookup.c (_dl_lookup_symbol_x): Add warning to _dl_lookup_symbol_x code. 2006-10-17 Jakub Jelinek * elf/dl-runtime.c: Include sysdep-cancel.h. (_dl_fixup, _dl_profile_fixup): Use __rtld_mrlock_* and scoperec->nusers only if !SINGLE_THREAD_P. Use atomic_* instead of catomic_* macros. * elf/dl-sym.c: Include sysdep-cancel.h. (do_sym): Use __rtld_mrlock_* and scoperec->nusers only if !SINGLE_THREAD_P. Use atomic_* instead of catomic_* macros. * elf/dl-close.c: Include sysdep-cancel.h. (_dl_close): Use __rtld_mrlock_* and scoperec->nusers only if !SINGLE_THREAD_P. Use atomic_* instead of catomic_* macros. * elf/dl-open.c: Include sysdep-cancel.h. (dl_open_worker): Use __rtld_mrlock_* and scoperec->nusers only if !SINGLE_THREAD_P. Use atomic_* instead of catomic_* macros. 2006-10-17 Jakub Jelinek [BZ #3313] * malloc/malloc.c (malloc_consolidate): Set maxfb to address of last fastbin rather than end of fastbin array. 2006-10-18 Ulrich Drepper * sysdeps/i386/i486/bits/atomic.h (catomic_decrement): Use correct body macro. * sysdeps/x86_64/bits/atomic.h (__arch_c_compare_and_exchange_val_64_acq): Add missing casts. (catomic_decrement): Use correct body macro. 2006-10-17 Jakub Jelinek * include/atomic.h: Add a unique prefix to all local variables in macros. * csu/tst-atomic.c (do_test): Test also catomic_* macros. 2006-10-14 Ulrich Drepper * resolv/arpa/nameser.h: Document that ns_t_a6 is deprecated. [BZ #3313] * malloc/malloc.c (malloc_consolidate): Don't use get_fast_max to determine highest fast bin to consolidate, always look into all of them. (do_check_malloc_state): Only require for empty bins for large sizes in main arena. * libio/stdio.h: Add more __wur attributes. 2006-11-12 Andreas Jaeger [BZ #2510] * manual/search.texi (Hash Search Function): Clarify. (Array Search Function): Clarify. 2006-11-12 Joseph Myers [BZ #2830] * math/atest-exp.c (main): Cast hex value to mp_limb_t before shifting. * math/atest-exp2.c (read_mpn_hex): Likewise. * math/atest-sincos.c (main): Likewise. * sysdeps/unix/sysv/linux/syscalls.list: Add epoll_pwait. * sysdeps/unix/sysv/linux/sys/epoll.h: Declare epoll_pwait. * sysdeps/unix/sysv/linux/Versions (libc): Add epoll_pwait for version GLIBC_2.6. * Versions.def: Add GLIBC_2.6 for libc. * sysdeps/i386/i486/bits/atomic.h: Add catomic_* support. 2006-10-11 Jakub Jelinek * malloc/malloc.c (_int_malloc): Remove unused any_larger variable. * nis/nis_defaults.c (__nis_default_access): Don't call getenv twice. * nis/nis_subr.c (nis_getnames): Use __secure_getenv instead of getenv. * sysdeps/generic/unsecvars.h: Add NIS_PATH. 2006-10-11 Ulrich Drepper * include/atomic.c: Define catomic_* operations. * sysdeps/x86_64/bits/atomic.h: Likewise. Fix a few minor problems. * stdlib/cxa_finalize.c: Use catomic_* operations instead of atomic_*. * malloc/memusage.c: Likewise. * gmon/mcount.c: Likewise. * elf/dl-close.c: Likewise. * elf/dl-open.c: Likewise. * elf/dl-profile.c: Likewise. * elf/dl-sym.c: Likewise. * elf/dl-runtime.c: Likewise. * elf/dl-fptr.c: Likewise. * resolv/res_libc.c: Likewise. 2006-10-10 Roland McGrath * sysdeps/mach/hurd/utimes.c: Use a union to avoid an improper cast. * sysdeps/mach/hurd/futimes.c: Likewise. * sysdeps/mach/hurd/lutimes.c: Likewise. 2006-10-09 Ulrich Drepper Jakub Jelinek Implement reference counting of scope records. * elf/dl-close.c (_dl_close): Remove all scopes from removed objects from the list in objects which remain. Always allocate new scope record. * elf/dl-open.c (dl_open_worker): When growing array for scopes, don't resize, allocate a new one. * elf/dl-runtime.c: Update reference counters before using a scope array. * elf/dl-sym.c: Likewise. * elf/dl-libc.c: Adjust for l_scope name change. * elf/dl-load.c: Likewise. * elf/dl-object.c: Likewise. * elf/rtld.c: Likewise. * include/link.h: Include . Define struct r_scoperec. Replace r_scope with pointer to r_scoperec structure. Add l_scoperec_lock. * sysdeps/generic/ldsodefs.h: Include . * sysdeps/generic/rtld-lowlevel.h: New file. * include/atomic.h: Rename atomic_and to atomic_and_val and atomic_or to atomic_or_val. Define new macros atomic_and and atomic_or which do not return values. * sysdeps/x86_64/bits/atomic.h: Define atomic_and and atomic_or. Various cleanups. * sysdeps/i386/i486/bits/atomic.h: Likewise. * po/sv.po: Update from translation team. 2006-10-07 Ulrich Drepper * Versions.def: Add GLIBC_2.6 to libpthread. * include/shlib-compat.h (SHLIB_COMPAT): Expand parameters before use. (versioned_symbol): Likewise. (compat_symbol): Likewise. * po/tr.po: Update from translation team. * nis/Banner: Removed. It's been integral part forever and the author info is incomplete anyway. * libio/Banner: Likewise. 2006-10-06 Ulrich Drepper * version.h (VERSION): Bump to 2.5.90 for new development tree. --- nptl/ChangeLog | 253 +++++++++------------ nptl/Makefile | 10 +- nptl/allocatestack.c | 59 +---- nptl/descr.h | 3 +- nptl/init.c | 6 +- nptl/pthreadP.h | 4 +- nptl/pthread_attr_setstack.c | 15 +- nptl/pthread_attr_setstacksize.c | 14 +- nptl/pthread_barrier_wait.c | 77 +++++++ nptl/pthread_cond_broadcast.c | 86 +++++++ nptl/pthread_cond_signal.c | 61 +++++ nptl/pthread_cond_timedwait.c | 214 +++++++++++++++++ nptl/pthread_cond_wait.c | 191 ++++++++++++++++ nptl/pthread_getattr_np.c | 10 +- nptl/pthread_getcpuclockid.c | 57 +++++ nptl/pthread_mutex_lock.c | 4 +- nptl/pthread_mutex_timedlock.c | 8 +- nptl/pthread_mutex_trylock.c | 8 +- nptl/pthread_once.c | 54 +++++ nptl/pthread_rwlock_rdlock.c | 95 ++++++++ nptl/pthread_rwlock_timedrdlock.c | 137 +++++++++++ nptl/pthread_rwlock_timedwrlock.c | 127 +++++++++++ nptl/pthread_rwlock_unlock.c | 57 +++++ nptl/pthread_rwlock_wrlock.c | 87 +++++++ nptl/pthread_spin_destroy.c | 29 +++ nptl/pthread_spin_init.c | 28 +++ nptl/pthread_spin_unlock.c | 30 +++ nptl/sysdeps/alpha/tls.h | 28 +-- nptl/sysdeps/i386/tls.h | 26 +-- nptl/sysdeps/ia64/pthread_spin_unlock.c | 4 +- nptl/sysdeps/ia64/tls.h | 28 +-- nptl/sysdeps/powerpc/tls.h | 28 +-- nptl/sysdeps/pthread/pthread_barrier_wait.c | 77 ------- nptl/sysdeps/pthread/pthread_cond_broadcast.c | 86 ------- nptl/sysdeps/pthread/pthread_cond_signal.c | 61 ----- nptl/sysdeps/pthread/pthread_cond_timedwait.c | 214 ----------------- nptl/sysdeps/pthread/pthread_cond_wait.c | 191 ---------------- nptl/sysdeps/pthread/pthread_getcpuclockid.c | 57 ----- nptl/sysdeps/pthread/pthread_once.c | 54 ----- nptl/sysdeps/pthread/pthread_rwlock_rdlock.c | 95 -------- nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c | 137 ----------- nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c | 127 ----------- nptl/sysdeps/pthread/pthread_rwlock_unlock.c | 57 ----- nptl/sysdeps/pthread/pthread_rwlock_wrlock.c | 87 ------- nptl/sysdeps/pthread/pthread_spin_destroy.c | 29 --- nptl/sysdeps/pthread/pthread_spin_init.c | 28 --- nptl/sysdeps/pthread/pthread_spin_unlock.c | 30 --- nptl/sysdeps/s390/tls.h | 29 +-- nptl/sysdeps/sh/tls.h | 28 +-- nptl/sysdeps/sparc/tls.h | 34 +-- .../sysdeps/unix/sysv/linux/alpha/bits/local_lim.h | 3 + .../sysdeps/unix/sysv/linux/alpha/bits/semaphore.h | 3 - nptl/sysdeps/unix/sysv/linux/bits/local_lim.h | 3 + nptl/sysdeps/unix/sysv/linux/fork.c | 9 +- nptl/sysdeps/unix/sysv/linux/i386/bits/semaphore.h | 3 - .../unix/sysv/linux/i386/i486/sem_timedwait.S | 11 +- nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h | 10 + nptl/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h | 3 + nptl/sysdeps/unix/sysv/linux/ia64/bits/semaphore.h | 3 - nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c | 22 +- nptl/sysdeps/unix/sysv/linux/powerpc/Versions | 4 + .../unix/sysv/linux/powerpc/bits/local_lim.h | 93 ++++++++ .../unix/sysv/linux/powerpc/bits/semaphore.h | 3 - .../sysv/linux/powerpc/pthread_attr_setstack.c | 2 + .../sysv/linux/powerpc/pthread_attr_setstacksize.c | 8 + nptl/sysdeps/unix/sysv/linux/rtld-lowlevel.h | 2 +- nptl/sysdeps/unix/sysv/linux/s390/bits/semaphore.h | 3 - .../unix/sysv/linux/s390/s390-32/sysdep-cancel.h | 21 +- .../unix/sysv/linux/s390/s390-64/sysdep-cancel.h | 21 +- nptl/sysdeps/unix/sysv/linux/sh/bits/semaphore.h | 3 - .../sysdeps/unix/sysv/linux/sparc/bits/local_lim.h | 3 + .../sysdeps/unix/sysv/linux/sparc/bits/semaphore.h | 3 - .../sparc/sparc32/sparcv9/pthread_barrier_wait.c | 2 +- .../unix/sysv/linux/x86_64/bits/semaphore.h | 3 - nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S | 4 +- nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h | 28 ++- .../sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S | 10 +- nptl/sysdeps/x86_64/tls.h | 26 +-- nptl/tst-cancel-wrappers.sh | 3 +- nptl/tst-cancel4.c | 44 +--- nptl/tst-robust9.c | 94 -------- nptl/tst-robustpi9.c | 2 - nptl/tst-sem10.c | 88 ------- nptl/tst-tls5.h | 2 +- 84 files changed, 1703 insertions(+), 2098 deletions(-) create mode 100644 nptl/pthread_barrier_wait.c create mode 100644 nptl/pthread_cond_broadcast.c create mode 100644 nptl/pthread_cond_signal.c create mode 100644 nptl/pthread_cond_timedwait.c create mode 100644 nptl/pthread_cond_wait.c create mode 100644 nptl/pthread_getcpuclockid.c create mode 100644 nptl/pthread_once.c create mode 100644 nptl/pthread_rwlock_rdlock.c create mode 100644 nptl/pthread_rwlock_timedrdlock.c create mode 100644 nptl/pthread_rwlock_timedwrlock.c create mode 100644 nptl/pthread_rwlock_unlock.c create mode 100644 nptl/pthread_rwlock_wrlock.c create mode 100644 nptl/pthread_spin_destroy.c create mode 100644 nptl/pthread_spin_init.c create mode 100644 nptl/pthread_spin_unlock.c delete mode 100644 nptl/sysdeps/pthread/pthread_barrier_wait.c delete mode 100644 nptl/sysdeps/pthread/pthread_cond_broadcast.c delete mode 100644 nptl/sysdeps/pthread/pthread_cond_signal.c delete mode 100644 nptl/sysdeps/pthread/pthread_cond_timedwait.c delete mode 100644 nptl/sysdeps/pthread/pthread_cond_wait.c delete mode 100644 nptl/sysdeps/pthread/pthread_getcpuclockid.c delete mode 100644 nptl/sysdeps/pthread/pthread_once.c delete mode 100644 nptl/sysdeps/pthread/pthread_rwlock_rdlock.c delete mode 100644 nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c delete mode 100644 nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c delete mode 100644 nptl/sysdeps/pthread/pthread_rwlock_unlock.c delete mode 100644 nptl/sysdeps/pthread/pthread_rwlock_wrlock.c delete mode 100644 nptl/sysdeps/pthread/pthread_spin_destroy.c delete mode 100644 nptl/sysdeps/pthread/pthread_spin_init.c delete mode 100644 nptl/sysdeps/pthread/pthread_spin_unlock.c create mode 100644 nptl/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h create mode 100644 nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstack.c create mode 100644 nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c delete mode 100644 nptl/tst-robust9.c delete mode 100644 nptl/tst-robustpi9.c delete mode 100644 nptl/tst-sem10.c (limited to 'nptl') diff --git a/nptl/ChangeLog b/nptl/ChangeLog index 47ea82f..0b1d630 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,107 +1,41 @@ -2007-07-27 Jakub Jelinek +2007-01-10 Ulrich Drepper - * sysdeps/sparc/tls.h (tcbhead_t): Move gscope_flag to the end - of the structure for sparc32. + * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Cleanups. Define + FUTEX_CMP_REQUEUE and lll_futex_requeue. -2007-07-26 Aurelien Jarno - - * sysdeps/sparc/tls.h (tcbhead_t): Add gscope_flag. - -2007-06-22 Jakub Jelinek - - * pthread_getattr_np.c (pthread_getattr_np): Clear cpuset and - cpusetsize if pthread_getaffinity_np failed with ENOSYS. - -2007-05-28 Jakub Jelinek +2006-12-28 David S. Miller - * sysdeps/i386/tls.h (THREAD_GSCOPE_RESET_FLAG): Use explicit - insn suffix. - (THREAD_GSCOPE_GET_FLAG): Remove. - * sysdeps/x86_64/tls.h (THREAD_GSCOPE_GET_FLAG): Remove. - * allocatestack.c (__wait_lookup_done): Revert 2007-05-24 - changes. - * sysdeps/powerpc/tls.h (tcbhead_t): Remove gscope_flag. - (THREAD_GSCOPE_GET_FLAG): Remove. - (THREAD_GSCOPE_RESET_FLAG): Use THREAD_SELF->header.gscope_flag - instead of THREAD_GSCOPE_GET_FLAG. - (THREAD_GSCOPE_SET_FLAG): Likewise. Add atomic_write_barrier after - it. - * sysdeps/s390/tls.h (THREAD_GSCOPE_FLAG_UNUSED, - THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT, - THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG, - THREAD_GSCOPE_WAIT): Define. - * sysdeps/sparc/tls.h (THREAD_GSCOPE_FLAG_UNUSED, - THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT, - THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG, - THREAD_GSCOPE_WAIT): Define. - * sysdeps/sh/tls.h (THREAD_GSCOPE_FLAG_UNUSED, - THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT, - THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG, - THREAD_GSCOPE_WAIT): Define. - * sysdeps/ia64/tls.h (THREAD_GSCOPE_FLAG_UNUSED, - THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT, - THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG, - THREAD_GSCOPE_WAIT): Define. - -2007-05-24 Richard Henderson - - * descr.h (struct pthread): Add header.gscope_flag. - * sysdeps/alpha/tls.h (THREAD_GSCOPE_FLAG_UNUSED, - THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT, - THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG, - THREAD_GSCOPE_WAIT): Define. - -2007-05-26 Ulrich Drepper - - * allocatestack.c: Revert last change. - * init.c: Likewise. - * sysdeps/i386/tls.h: Likewise. - * sysdeps/x86_64/tls.h: Likewise. + * shlib-versions: Fix sparc64 linux target specification. -2007-05-24 Jakub Jelinek +2007-01-10 Jakub Jelinek - * sysdeps/powerpc/tls.h (tcbhead_t): Add gscope_flag. - (THREAD_GSCOPE_FLAG_UNUSED, THREAD_GSCOPE_FLAG_USED, - THREAD_GSCOPE_FLAG_WAIT): Define. - (THREAD_GSCOPE_GET_FLAG, THREAD_GSCOPE_SET_FLAG, - THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_WAIT): Define. - * sysdeps/i386/tls.h (THREAD_GSCOPE_WAIT): Don't use - PTR_DEMANGLE. - (THREAD_GSCOPE_GET_FLAG): Define. - * sysdeps/x86_64/tls.h (THREAD_GSCOPE_GET_FLAG): Define. - * allocatestack.c (__wait_lookup_done): Use THREAD_GSCOPE_GET_FLAG - instead of ->header.gscope_flag directly. + * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c: + Adjust include path for pthread_barrier_wait.c move. -2007-05-21 Ulrich Drepper +2006-12-21 Jakub Jelinek - * sysdeps/pthread/pthread-functions.h (struct pthread_functions): - Remove ptr_wait_lookup_done again. - * init.c (pthread_functions): Don't add .ptr_wait_lookup_done here. - (__pthread_initialize_minimal_internal): Initialize - _dl_wait_lookup_done pointer in _rtld_global directly. - * sysdeps/unix/sysv/linux/libc_pthread_init.c (__libc_pthread_init): - Remove code to code _dl_wait_lookup_done. - * sysdeps/x86_64/tls.h (THREAD_GSCOPE_WAIT): The pointer is not - encrypted for now. + * sysdeps/unix/sysv/linux/pthread_kill.c (pthread_kill): Make sure + tid isn't reread from pd->tid in between ESRCH test and the syscall. -2007-05-19 Ulrich Drepper +2006-12-06 Jakub Jelinek - * allocatestack.c (__wait_lookup_done): New function. - * sysdeps/pthread/pthread-functions.h (struct pthread_functions): - Add ptr_wait_lookup_done. - * init.c (pthread_functions): Initialize .ptr_wait_lookup_done. - * pthreadP.h: Declare __wait_lookup_done. - * sysdeps/i386/tls.h (tcbhead_t): Add gscope_flag. - Define macros to implement reference handling of global scope. - * sysdeps/x86_64/tls.h: Likewise. - * sysdeps/unix/sysv/linux/libc_pthread_init.c (__libc_pthread_init): - Initialize GL(dl_wait_lookup_done). + * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h (PSEUDO): Handle + 6 argument cancellable syscalls. + (STM_6, LM_6, LR7_0, LR7_1, LR7_2, LR7_3, LR7_4, LR7_5, LR7_6): Define. + * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h (PSEUDO): Handle + 6 argument cancellable syscalls. + (STM_6, LM_6, LR7_0, LR7_1, LR7_2, LR7_3, LR7_4, LR7_5, LR7_6): Define. 2006-12-09 Ulrich Drepper * sysdeps/unix/sysv/linux/rtld-lowlevel.h (__rtld_mrlock_initialize): Add missing closing parenthesis. +2006-10-30 Jakub Jelinek + + * sysdeps/ia64/pthread_spin_unlock.c (pthread_spin_unlock): Use + __sync_lock_release instead of __sync_lock_release_si. + 2006-10-29 Jakub Jelinek * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (RTLD_SINGLE_THREAD_P): @@ -118,6 +52,50 @@ * sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h: Likewise. * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h: Likewise. +2006-10-27 Ulrich Drepper + + * sysdeps/pthread/pthread_barrier_wait.c: Move to... + * pthread_barrier_wait.c: ...here. + * sysdeps/pthread/pthread_cond_broadcast.c: Move to... + * pthread_cond_broadcast.c: ...here. + * sysdeps/pthread/pthread_cond_signal.c: Move to... + * pthread_cond_signal.c: ...here. + * sysdeps/pthread/pthread_cond_timedwait.c: Move to... + * pthread_cond_timedwait.c: ...here. + * sysdeps/pthread/pthread_cond_wait.c: Move to... + * pthread_cond_wait.c: ...here. + * sysdeps/pthread/pthread_once.c: Move to... + * pthread_once.c: ...here. + * sysdeps/pthread/pthread_rwlock_rdlock.c: Move to... + * pthread_rwlock_rdlock.c: ...here. + * sysdeps/pthread/pthread_rwlock_timedrdlock.c: Move to... + * pthread_rwlock_timedrdlock.c: ...here. + * sysdeps/pthread/pthread_rwlock_timedwrlock.c: Move to... + * pthread_rwlock_timedwrlock.c: ...here. + * sysdeps/pthread/pthread_rwlock_unlock.c: Move to... + * pthread_rwlock_unlock.c: ...here. + * sysdeps/pthread/pthread_rwlock_wrlock.c: Move to... + * pthread_rwlock_wrlock.c: ...here. + * sysdeps/pthread/pthread_spin_destroy.c: Move to... + * pthread_spin_destroy.c: ...here. + * sysdeps/pthread/pthread_spin_init.c: Move to... + * pthread_spin_init.c: ...here. + * sysdeps/pthread/pthread_spin_unlock.c: Move to... + * pthread_spin_unlock.c: ...here. + * sysdeps/pthread/pthread_getcpuclockid.c: Move to... + * pthread_getcpuclockid.c: ...here. + + * init.c: USE_TLS support is now always enabled. + * tst-tls5.h: Likewise. + * sysdeps/alpha/tls.h: Likewise. + * sysdeps/i386/tls.h: Likewise. + * sysdeps/ia64/tls.h: Likewise. + * sysdeps/powerpc/tls.h: Likewise. + * sysdeps/s390/tls.h: Likewise. + * sysdeps/sh/tls.h: Likewise. + * sysdeps/sparc/tls.h: Likewise. + * sysdeps/x86_64/tls.h: Likewise. + 2006-10-27 Jakub Jelinek * sysdeps/unix/sysv/linux/rtld-lowlevel.h (__rtld_mrlock_lock, @@ -147,74 +125,59 @@ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h (SINGLE_THREAD_P): Likewise. -2006-10-09 Ulrich Drepper +2006-10-26 Jakub Jelinek - * sysdeps/unix/sysv/linux/rtld-lowlevel.h: New file.. - -2007-05-25 Ulrich Drepper + * pthread_attr_setstacksize.c (NEW_VERNUM): Define to GLIBC_2_3_3 + by default rather than 2_3_3. - * Makefile (tests): Add tst-sem10. - * tst-sem10.c: New file. - -2007-05-25 Ulrich Drepper - Jakub Jelinek +2006-10-17 Jakub Jelinek - * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S (sem_timedwait): - Move __pthread_enable_asynccancel right before futex syscall. - * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S (sem_timedwait): - Likewise. - -2007-05-21 Jakub Jelinek - - * tst-robust9.c (do_test): Don't fail if ENABLE_PI and - pthread_mutex_init failed with ENOTSUP. - -2007-05-17 Ulrich Drepper - - [BZ #4512] - * pthread_mutex_lock.c: Preserve FUTEX_WAITERS bit when dead owner - is detected. - * pthread_mutex_timedlock.c: Likewise. - * pthread_mutex_trylock.c: Likewise. - Patch in part by Atsushi Nemoto . - - * Makefile (tests): Add tst-robust9 and tst-robustpi9. - * tst-robust9.c: New file. - * tst-robustpi9.c: New file. - -2007-05-07 Ulrich Drepper - - * sysdeps/unix/sysv/linux/lowlevelrobustlock.c - (__lll_robust_lock_wait): Fix race caused by reloading of futex value. - (__lll_robust_timedlock_wait): Likewise. - Reported by Alexey Kuznetsov . - -2007-05-06 Mike Frysinger + * sysdeps/unix/sysv/linux/rtld-lowlevel.h (__rtld_mrlock_lock, + __rtld_mrlock_unlock, __rtld_mrlock_change, __rtld_mrlock_done): Use + atomic_* instead of catomic_* macros. - [BZ #4465] - * tst-cancel-wrappers.sh: Set C["fdatasync"] to 1. - * tst-cancel4.c (tf_fdatasync): New test. +2006-10-12 Ulrich Drepper -2007-02-25 Ulrich Drepper + [BZ #3285] + * sysdeps/unix/sysv/linux/bits/local_lim.h: Add SEM_VALUE_MAX. + * sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h: Likewise. + * sysdeps/unix/sysv/linux/sparc/bits/local_lim.h: Likewise. + * sysdeps/unix/sysv/linux/alpha/bits/local_lim.h: Likewise. + * sysdeps/unix/sysv/linux/ia64/bits/local_lim.h: Likewise. + * sysdeps/unix/sysv/linux/i386/bits/semaphore.h: Remove SEM_VALUE_MAX. + * sysdeps/unix/sysv/linux/powerpc/bits/semaphore.h: Likewise. + * sysdeps/unix/sysv/linux/x86_64/bits/semaphore.h: Likewise. + * sysdeps/unix/sysv/linux/sparc/bits/semaphore.h: Likewise. + * sysdeps/unix/sysv/linux/alpha/bits/semaphore.h: Likewise. + * sysdeps/unix/sysv/linux/sh/bits/semaphore.h: Likewise. + * sysdeps/unix/sysv/linux/ia64/bits/semaphore.h: Likewise. + * sysdeps/unix/sysv/linux/s390/bits/semaphore.h: Likewise. - * sysdeps/unix/sysv/linux/fork.c (__libc_fork): Reset refcntr in - new thread, don't just decrement it. - Patch by Suzuki K P . +2006-10-11 Ulrich Drepper -2007-02-09 Jakub Jelinek + * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: Add support for + cancelable syscalls with six parameters. - * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S - (__lll_mutex_timedlock_wait): Use correct pointer when we don't - call into the kernel to delay. + * sysdeps/unix/sysv/linux/rtld-lowlevel.h: Use catomic_* + operations instead of atomic_*. -2006-12-28 David S. Miller +2006-10-09 Ulrich Drepper - * shlib-versions: Fix sparc64 linux target specification. + * sysdeps/unix/sysv/linux/rtld-lowlevel.h: New file.. -2006-12-21 Jakub Jelinek +2006-10-07 Ulrich Drepper - * sysdeps/unix/sysv/linux/pthread_kill.c (pthread_kill): Make sure - tid isn't reread from pd->tid in between ESRCH test and the syscall. + * sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h: New file. + * sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstack.c: New file. + * sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c: + New file. + * pthread_attr_setstack.c: Allow overwriting the version number of the + new symbol. + * pthread_attr_setstacksize.c: Likewise. + (__old_pthread_attr_setstacksize): If STACKSIZE_ADJUST is defined use + it. + * sysdeps/unix/sysv/linux/powerpc/Versions (libpthread): Add + pthread_attr_setstack and pthread_attr_setstacksize to GLIBC_2.6. 2006-09-24 Ulrich Drepper diff --git a/nptl/Makefile b/nptl/Makefile index 61cd257..9393cab 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc. +# Copyright (C) 2002,2003,2004,2005,2006 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 @@ -209,16 +209,16 @@ tests = tst-typesizes \ tst-cond14 tst-cond15 tst-cond16 tst-cond17 tst-cond18 tst-cond19 \ tst-cond20 tst-cond21 tst-cond22 \ tst-robust1 tst-robust2 tst-robust3 tst-robust4 tst-robust5 \ - tst-robust6 tst-robust7 tst-robust8 tst-robust9 \ - tst-robustpi1 tst-robustpi2 tst-robustpi3 tst-robustpi4 tst-robustpi5 \ - tst-robustpi6 tst-robustpi7 tst-robustpi8 tst-robustpi9 \ + tst-robust6 tst-robust7 tst-robust8 \ + tst-robustpi1 tst-robustpi2 tst-robustpi3 tst-robustpi4 \ + tst-robustpi5 tst-robustpi6 tst-robustpi7 tst-robustpi8 \ tst-rwlock1 tst-rwlock2 tst-rwlock3 tst-rwlock4 tst-rwlock5 \ tst-rwlock6 tst-rwlock7 tst-rwlock8 tst-rwlock9 tst-rwlock10 \ tst-rwlock11 tst-rwlock12 tst-rwlock13 tst-rwlock14 \ tst-once1 tst-once2 tst-once3 tst-once4 \ tst-key1 tst-key2 tst-key3 tst-key4 \ tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 \ - tst-sem8 tst-sem9 tst-sem10 \ + tst-sem8 tst-sem9 \ tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 \ tst-align tst-align2 tst-align3 \ tst-basic1 tst-basic2 tst-basic3 tst-basic4 tst-basic5 tst-basic6 \ diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 736c63d..c05cd47 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -982,60 +982,3 @@ __pthread_init_static_tls (struct link_map *map) lll_unlock (stack_cache_lock); } - - -void -attribute_hidden -__wait_lookup_done (void) -{ - lll_lock (stack_cache_lock); - - struct pthread *self = THREAD_SELF; - - /* Iterate over the list with system-allocated threads first. */ - list_t *runp; - list_for_each (runp, &stack_used) - { - struct pthread *t = list_entry (runp, struct pthread, list); - if (t == self || t->header.gscope_flag == THREAD_GSCOPE_FLAG_UNUSED) - continue; - - int *const gscope_flagp = &t->header.gscope_flag; - - /* We have to wait until this thread is done with the global - scope. First tell the thread that we are waiting and - possibly have to be woken. */ - if (atomic_compare_and_exchange_bool_acq (gscope_flagp, - THREAD_GSCOPE_FLAG_WAIT, - THREAD_GSCOPE_FLAG_USED)) - continue; - - do - lll_futex_wait (gscope_flagp, THREAD_GSCOPE_FLAG_WAIT); - while (*gscope_flagp == THREAD_GSCOPE_FLAG_WAIT); - } - - /* Now the list with threads using user-allocated stacks. */ - list_for_each (runp, &__stack_user) - { - struct pthread *t = list_entry (runp, struct pthread, list); - if (t == self || t->header.gscope_flag == THREAD_GSCOPE_FLAG_UNUSED) - continue; - - int *const gscope_flagp = &t->header.gscope_flag; - - /* We have to wait until this thread is done with the global - scope. First tell the thread that we are waiting and - possibly have to be woken. */ - if (atomic_compare_and_exchange_bool_acq (gscope_flagp, - THREAD_GSCOPE_FLAG_WAIT, - THREAD_GSCOPE_FLAG_USED)) - continue; - - do - lll_futex_wait (gscope_flagp, THREAD_GSCOPE_FLAG_WAIT); - while (*gscope_flagp == THREAD_GSCOPE_FLAG_WAIT); - } - - lll_unlock (stack_cache_lock); -} diff --git a/nptl/descr.h b/nptl/descr.h index 241ba52..321ce85 100644 --- a/nptl/descr.h +++ b/nptl/descr.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -131,7 +131,6 @@ struct pthread struct { int multiple_threads; - int gscope_flag; } header; #endif diff --git a/nptl/init.c b/nptl/init.c index 7144abd..dddc975 100644 --- a/nptl/init.c +++ b/nptl/init.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -73,7 +73,7 @@ int __set_robust_list_avail; static const char nptl_version[] __attribute_used__ = VERSION; -#if defined USE_TLS && !defined SHARED +#ifndef SHARED extern void __libc_setup_tls (size_t tcbsize, size_t tcbalign); #endif @@ -386,8 +386,6 @@ __pthread_initialize_minimal_internal (void) GL(dl_init_static_tls) = &__pthread_init_static_tls; - GL(dl_wait_lookup_done) = &__wait_lookup_done; - /* Register the fork generation counter with the libc. */ #ifndef TLS_MULTIPLE_THREADS_IN_TCB __libc_multiple_threads_ptr = diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 21ce6fe..f9634ab 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, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -545,8 +545,6 @@ extern int __nptl_setxid (struct xid_command *cmdp) attribute_hidden; extern void __free_stack_cache (void) attribute_hidden; -extern void __wait_lookup_done (void) attribute_hidden; - #ifdef SHARED # define PTHREAD_STATIC_FN_REQUIRE(name) #else diff --git a/nptl/pthread_attr_setstack.c b/nptl/pthread_attr_setstack.c index 622e4a2..be79e32 100644 --- a/nptl/pthread_attr_setstack.c +++ b/nptl/pthread_attr_setstack.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -23,6 +23,11 @@ #include "pthreadP.h" +#ifndef NEW_VERNUM +# define NEW_VERNUM GLIBC_2_3_3 +#endif + + int __pthread_attr_setstack (attr, stackaddr, stacksize) pthread_attr_t *attr; @@ -54,9 +59,9 @@ strong_alias (__pthread_attr_setstack, pthread_attr_setstack) #else # include versioned_symbol (libpthread, __pthread_attr_setstack, pthread_attr_setstack, - GLIBC_2_3_3); + NEW_VERNUM); -# if SHLIB_COMPAT(libpthread, GLIBC_2_2, GLIBC_2_3_3) +# if SHLIB_COMPAT(libpthread, GLIBC_2_2, NEW_VERNUM) int __old_pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr, @@ -71,9 +76,9 @@ __old_pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr, if (stacksize < 16384) return EINVAL; -# ifdef EXTRA_PARAM_CHECKS +# ifdef EXTRA_PARAM_CHECKS EXTRA_PARAM_CHECKS; -# endif +# endif iattr->stacksize = stacksize; iattr->stackaddr = (char *) stackaddr + stacksize; diff --git a/nptl/pthread_attr_setstacksize.c b/nptl/pthread_attr_setstacksize.c index f84a9f6..0974538 100644 --- a/nptl/pthread_attr_setstacksize.c +++ b/nptl/pthread_attr_setstacksize.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -22,6 +22,10 @@ #include #include "pthreadP.h" +#ifndef NEW_VERNUM +# define NEW_VERNUM GLIBC_2_3_3 +#endif + int __pthread_attr_setstacksize (attr, stacksize) @@ -47,9 +51,9 @@ strong_alias (__pthread_attr_setstacksize, pthread_attr_setstacksize) #else # include versioned_symbol (libpthread, __pthread_attr_setstacksize, - pthread_attr_setstacksize, GLIBC_2_3_3); + pthread_attr_setstacksize, NEW_VERNUM); -# if SHLIB_COMPAT(libpthread, GLIBC_2_1, GLIBC_2_3_3) +# if SHLIB_COMPAT(libpthread, GLIBC_2_1, NEW_VERNUM) int __old_pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize) @@ -63,6 +67,10 @@ __old_pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize) if (stacksize < 16384) return EINVAL; +# ifdef STACKSIZE_ADJUST + STACKSIZE_ADJUST; +# endif + iattr->stacksize = stacksize; return 0; diff --git a/nptl/pthread_barrier_wait.c b/nptl/pthread_barrier_wait.c new file mode 100644 index 0000000..c6b563f --- /dev/null +++ b/nptl/pthread_barrier_wait.c @@ -0,0 +1,77 @@ +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky , 2003. + + 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 +#include +#include +#include + + +/* Wait on barrier. */ +int +pthread_barrier_wait (barrier) + pthread_barrier_t *barrier; +{ + struct pthread_barrier *ibarrier = (struct pthread_barrier *) barrier; + int result = 0; + + /* Make sure we are alone. */ + lll_lock (ibarrier->lock); + + /* One more arrival. */ + --ibarrier->left; + + /* Are these all? */ + if (ibarrier->left == 0) + { + /* Yes. Increment the event counter to avoid invalid wake-ups and + tell the current waiters that it is their turn. */ + ++ibarrier->curr_event; + + /* Wake up everybody. */ + lll_futex_wake (&ibarrier->curr_event, INT_MAX); + + /* This is the thread which finished the serialization. */ + result = PTHREAD_BARRIER_SERIAL_THREAD; + } + else + { + /* The number of the event we are waiting for. The barrier's event + number must be bumped before we continue. */ + unsigned int event = ibarrier->curr_event; + + /* Before suspending, make the barrier available to others. */ + lll_unlock (ibarrier->lock); + + /* Wait for the event counter of the barrier to change. */ + do + lll_futex_wait (&ibarrier->curr_event, event); + while (event == ibarrier->curr_event); + } + + /* Make sure the init_count is stored locally or in a register. */ + unsigned int init_count = ibarrier->init_count; + + /* If this was the last woken thread, unlock. */ + if (atomic_increment_val (&ibarrier->left) == init_count) + /* We are done. */ + lll_unlock (ibarrier->lock); + + return result; +} diff --git a/nptl/pthread_cond_broadcast.c b/nptl/pthread_cond_broadcast.c new file mode 100644 index 0000000..2b8b546 --- /dev/null +++ b/nptl/pthread_cond_broadcast.c @@ -0,0 +1,86 @@ +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky , 2003. + + 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 +#include +#include +#include +#include +#include + +#include +#include + + +int +__pthread_cond_broadcast (cond) + pthread_cond_t *cond; +{ + /* Make sure we are alone. */ + lll_mutex_lock (cond->__data.__lock); + + /* Are there any waiters to be woken? */ + if (cond->__data.__total_seq > cond->__data.__wakeup_seq) + { + /* Yes. Mark them all as woken. */ + cond->__data.__wakeup_seq = cond->__data.__total_seq; + cond->__data.__woken_seq = cond->__data.__total_seq; + cond->__data.__futex = (unsigned int) cond->__data.__total_seq * 2; + int futex_val = cond->__data.__futex; + /* Signal that a broadcast happened. */ + ++cond->__data.__broadcast_seq; + + /* We are done. */ + lll_mutex_unlock (cond->__data.__lock); + + /* Do not use requeue for pshared condvars. */ + if (cond->__data.__mutex == (void *) ~0l) + goto wake_all; + + /* Wake everybody. */ + pthread_mutex_t *mut = (pthread_mutex_t *) cond->__data.__mutex; + + /* XXX: Kernel so far doesn't support requeue to PI futex. */ + if (__builtin_expect (mut->__data.__kind & PTHREAD_MUTEX_PRIO_INHERIT_NP, + 0)) + goto wake_all; + + /* lll_futex_requeue returns 0 for success and non-zero + for errors. */ + if (__builtin_expect (lll_futex_requeue (&cond->__data.__futex, 1, + INT_MAX, &mut->__data.__lock, + futex_val), 0)) + { + /* The requeue functionality is not available. */ + wake_all: + lll_futex_wake (&cond->__data.__futex, INT_MAX); + } + + /* That's all. */ + return 0; + } + + /* We are done. */ + lll_mutex_unlock (cond->__data.__lock); + + return 0; +} + +versioned_symbol (libpthread, __pthread_cond_broadcast, pthread_cond_broadcast, + GLIBC_2_3_2); diff --git a/nptl/pthread_cond_signal.c b/nptl/pthread_cond_signal.c new file mode 100644 index 0000000..5a9bbca --- /dev/null +++ b/nptl/pthread_cond_signal.c @@ -0,0 +1,61 @@ +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky , 2003. + + 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 +#include +#include +#include +#include +#include + +#include +#include + + +int +__pthread_cond_signal (cond) + pthread_cond_t *cond; +{ + /* Make sure we are alone. */ + lll_mutex_lock (cond->__data.__lock); + + /* Are there any waiters to be woken? */ + if (cond->__data.__total_seq > cond->__data.__wakeup_seq) + { + /* Yes. Mark one of them as woken. */ + ++cond->__data.__wakeup_seq; + ++cond->__data.__futex; + + /* Wake one. */ + if (! __builtin_expect (lll_futex_wake_unlock (&cond->__data.__futex, 1, + 1, &cond->__data.__lock), + 0)) + return 0; + + lll_futex_wake (&cond->__data.__futex, 1); + } + + /* We are done. */ + lll_mutex_unlock (cond->__data.__lock); + + return 0; +} + +versioned_symbol (libpthread, __pthread_cond_signal, pthread_cond_signal, + GLIBC_2_3_2); diff --git a/nptl/pthread_cond_timedwait.c b/nptl/pthread_cond_timedwait.c new file mode 100644 index 0000000..fdbf43e --- /dev/null +++ b/nptl/pthread_cond_timedwait.c @@ -0,0 +1,214 @@ +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky , 2003. + + 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 +#include +#include +#include +#include +#include + +#include + + +/* Cleanup handler, defined in pthread_cond_wait.c. */ +extern void __condvar_cleanup (void *arg) + __attribute__ ((visibility ("hidden"))); + +struct _condvar_cleanup_buffer +{ + int oldtype; + pthread_cond_t *cond; + pthread_mutex_t *mutex; + unsigned int bc_seq; +}; + +int +__pthread_cond_timedwait (cond, mutex, abstime) + pthread_cond_t *cond; + pthread_mutex_t *mutex; + const struct timespec *abstime; +{ + struct _pthread_cleanup_buffer buffer; + struct _condvar_cleanup_buffer cbuffer; + int result = 0; + + /* Catch invalid parameters. */ + if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) + return EINVAL; + + /* Make sure we are along. */ + lll_mutex_lock (cond->__data.__lock); + + /* Now we can release the mutex. */ + int err = __pthread_mutex_unlock_usercnt (mutex, 0); + if (err) + { + lll_mutex_unlock (cond->__data.__lock); + return err; + } + + /* We have one new user of the condvar. */ + ++cond->__data.__total_seq; + ++cond->__data.__futex; + cond->__data.__nwaiters += 1 << COND_CLOCK_BITS; + + /* Remember the mutex we are using here. If there is already a + different address store this is a bad user bug. Do not store + anything for pshared condvars. */ + if (cond->__data.__mutex != (void *) ~0l) + cond->__data.__mutex = mutex; + + /* Prepare structure passed to cancellation handler. */ + cbuffer.cond = cond; + cbuffer.mutex = mutex; + + /* Before we block we enable cancellation. Therefore we have to + install a cancellation handler. */ + __pthread_cleanup_push (&buffer, __condvar_cleanup, &cbuffer); + + /* The current values of the wakeup counter. The "woken" counter + must exceed this value. */ + unsigned long long int val; + unsigned long long int seq; + val = seq = cond->__data.__wakeup_seq; + /* Remember the broadcast counter. */ + cbuffer.bc_seq = cond->__data.__broadcast_seq; + + while (1) + { + struct timespec rt; + { +#ifdef __NR_clock_gettime + INTERNAL_SYSCALL_DECL (err); + int ret; + ret = INTERNAL_SYSCALL (clock_gettime, err, 2, + (cond->__data.__nwaiters + & ((1 << COND_CLOCK_BITS) - 1)), + &rt); +# ifndef __ASSUME_POSIX_TIMERS + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (ret, err), 0)) + { + struct timeval tv; + (void) gettimeofday (&tv, NULL); + + /* Convert the absolute timeout value to a relative timeout. */ + rt.tv_sec = abstime->tv_sec - tv.tv_sec; + rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000; + } + else +# endif + { + /* Convert the absolute timeout value to a relative timeout. */ + rt.tv_sec = abstime->tv_sec - rt.tv_sec; + rt.tv_nsec = abstime->tv_nsec - rt.tv_nsec; + } +#else + /* Get the current time. So far we support only one clock. */ + struct timeval tv; + (void) gettimeofday (&tv, NULL); + + /* Convert the absolute timeout value to a relative timeout. */ + rt.tv_sec = abstime->tv_sec - tv.tv_sec; + rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000; +#endif + } + if (rt.tv_nsec < 0) + { + rt.tv_nsec += 1000000000; + --rt.tv_sec; + } + /* Did we already time out? */ + if (__builtin_expect (rt.tv_sec < 0, 0)) + { + if (cbuffer.bc_seq != cond->__data.__broadcast_seq) + goto bc_out; + + goto timeout; + } + + unsigned int futex_val = cond->__data.__futex; + + /* Prepare to wait. Release the condvar futex. */ + lll_mutex_unlock (cond->__data.__lock); + + /* Enable asynchronous cancellation. Required by the standard. */ + cbuffer.oldtype = __pthread_enable_asynccancel (); + + /* Wait until woken by signal or broadcast. */ + err = lll_futex_timed_wait (&cond->__data.__futex, + futex_val, &rt); + + /* Disable asynchronous cancellation. */ + __pthread_disable_asynccancel (cbuffer.oldtype); + + /* We are going to look at shared data again, so get the lock. */ + lll_mutex_lock(cond->__data.__lock); + + /* If a broadcast happened, we are done. */ + if (cbuffer.bc_seq != cond->__data.__broadcast_seq) + goto bc_out; + + /* Check whether we are eligible for wakeup. */ + val = cond->__data.__wakeup_seq; + if (val != seq && cond->__data.__woken_seq != val) + break; + + /* Not woken yet. Maybe the time expired? */ + if (__builtin_expect (err == -ETIMEDOUT, 0)) + { + timeout: + /* Yep. Adjust the counters. */ + ++cond->__data.__wakeup_seq; + ++cond->__data.__futex; + + /* The error value. */ + result = ETIMEDOUT; + break; + } + } + + /* Another thread woken up. */ + ++cond->__data.__woken_seq; + + bc_out: + + cond->__data.__nwaiters -= 1 << COND_CLOCK_BITS; + + /* If pthread_cond_destroy was called on this variable already, + notify the pthread_cond_destroy caller all waiters have left + and it can be successfully destroyed. */ + if (cond->__data.__total_seq == -1ULL + && cond->__data.__nwaiters < (1 << COND_CLOCK_BITS)) + lll_futex_wake (&cond->__data.__nwaiters, 1); + + /* We are done with the condvar. */ + lll_mutex_unlock (cond->__data.__lock); + + /* The cancellation handling is back to normal, remove the handler. */ + __pthread_cleanup_pop (&buffer, 0); + + /* Get the mutex before returning. */ + err = __pthread_mutex_cond_lock (mutex); + + return err ?: result; +} + +versioned_symbol (libpthread, __pthread_cond_timedwait, pthread_cond_timedwait, + GLIBC_2_3_2); diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c new file mode 100644 index 0000000..f5f5cec --- /dev/null +++ b/nptl/pthread_cond_wait.c @@ -0,0 +1,191 @@ +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky , 2003. + + 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 +#include +#include +#include +#include +#include + +#include + + +struct _condvar_cleanup_buffer +{ + int oldtype; + pthread_cond_t *cond; + pthread_mutex_t *mutex; + unsigned int bc_seq; +}; + + +void +__attribute__ ((visibility ("hidden"))) +__condvar_cleanup (void *arg) +{ + struct _condvar_cleanup_buffer *cbuffer = + (struct _condvar_cleanup_buffer *) arg; + unsigned int destroying; + + /* We are going to modify shared data. */ + lll_mutex_lock (cbuffer->cond->__data.__lock); + + if (cbuffer->bc_seq == cbuffer->cond->__data.__broadcast_seq) + { + /* This thread is not waiting anymore. Adjust the sequence counters + appropriately. We do not increment WAKEUP_SEQ if this would + bump it over the value of TOTAL_SEQ. This can happen if a thread + was woken and then canceled. */ + if (cbuffer->cond->__data.__wakeup_seq + < cbuffer->cond->__data.__total_seq) + { + ++cbuffer->cond->__data.__wakeup_seq; + ++cbuffer->cond->__data.__futex; + } + ++cbuffer->cond->__data.__woken_seq; + } + + cbuffer->cond->__data.__nwaiters -= 1 << COND_CLOCK_BITS; + + /* If pthread_cond_destroy was called on this variable already, + notify the pthread_cond_destroy caller all waiters have left + and it can be successfully destroyed. */ + destroying = 0; + if (cbuffer->cond->__data.__total_seq == -1ULL + && cbuffer->cond->__data.__nwaiters < (1 << COND_CLOCK_BITS)) + { + lll_futex_wake (&cbuffer->cond->__data.__nwaiters, 1); + destroying = 1; + } + + /* We are done. */ + lll_mutex_unlock (cbuffer->cond->__data.__lock); + + /* Wake everybody to make sure no condvar signal gets lost. */ + if (! destroying) + lll_futex_wake (&cbuffer->cond->__data.__futex, INT_MAX); + + /* Get the mutex before returning unless asynchronous cancellation + is in effect. */ + __pthread_mutex_cond_lock (cbuffer->mutex); +} + + +int +__pthread_cond_wait (cond, mutex) + pthread_cond_t *cond; + pthread_mutex_t *mutex; +{ + struct _pthread_cleanup_buffer buffer; + struct _condvar_cleanup_buffer cbuffer; + int err; + + /* Make sure we are along. */ + lll_mutex_lock (cond->__data.__lock); + + /* Now we can release the mutex. */ + err = __pthread_mutex_unlock_usercnt (mutex, 0); + if (__builtin_expect (err, 0)) + { + lll_mutex_unlock (cond->__data.__lock); + return err; + } + + /* We have one new user of the condvar. */ + ++cond->__data.__total_seq; + ++cond->__data.__futex; + cond->__data.__nwaiters += 1 << COND_CLOCK_BITS; + + /* Remember the mutex we are using here. If there is already a + different address store this is a bad user bug. Do not store + anything for pshared condvars. */ + if (cond->__data.__mutex != (void *) ~0l) + cond->__data.__mutex = mutex; + + /* Prepare structure passed to cancellation handler. */ + cbuffer.cond = cond; + cbuffer.mutex = mutex; + + /* Before we block we enable cancellation. Therefore we have to + install a cancellation handler. */ + __pthread_cleanup_push (&buffer, __condvar_cleanup, &cbuffer); + + /* The current values of the wakeup counter. The "woken" counter + must exceed this value. */ + unsigned long long int val; + unsigned long long int seq; + val = seq = cond->__data.__wakeup_seq; + /* Remember the broadcast counter. */ + cbuffer.bc_seq = cond->__data.__broadcast_seq; + + do + { + unsigned int futex_val = cond->__data.__futex; + + /* Prepare to wait. Release the condvar futex. */ + lll_mutex_unlock (cond->__data.__lock); + + /* Enable asynchronous cancellation. Required by the standard. */ + cbuffer.oldtype = __pthread_enable_asynccancel (); + + /* Wait until woken by signal or broadcast. */ + lll_futex_wait (&cond->__data.__futex, futex_val); + + /* Disable asynchronous cancellation. */ + __pthread_disable_asynccancel (cbuffer.oldtype); + + /* We are going to look at shared data again, so get the lock. */ + lll_mutex_lock (cond->__data.__lock); + + /* If a broadcast happened, we are done. */ + if (cbuffer.bc_seq != cond->__data.__broadcast_seq) + goto bc_out; + + /* Check whether we are eligible for wakeup. */ + val = cond->__data.__wakeup_seq; + } + while (val == seq || cond->__data.__woken_seq == val); + + /* Another thread woken up. */ + ++cond->__data.__woken_seq; + + bc_out: + + cond->__data.__nwaiters -= 1 << COND_CLOCK_BITS; + + /* If pthread_cond_destroy was called on this varaible already, + notify the pthread_cond_destroy caller all waiters have left + and it can be successfully destroyed. */ + if (cond->__data.__total_seq == -1ULL + && cond->__data.__nwaiters < (1 << COND_CLOCK_BITS)) + lll_futex_wake (&cond->__data.__nwaiters, 1); + + /* We are done with the condvar. */ + lll_mutex_unlock (cond->__data.__lock); + + /* The cancellation handling is back to normal, remove the handler. */ + __pthread_cleanup_pop (&buffer, 0); + + /* Get the mutex before returning. */ + return __pthread_mutex_cond_lock (mutex); +} + +versioned_symbol (libpthread, __pthread_cond_wait, pthread_cond_wait, + GLIBC_2_3_2); diff --git a/nptl/pthread_getattr_np.c b/nptl/pthread_getattr_np.c index f6cd889..4bdc7b5 100644 --- a/nptl/pthread_getattr_np.c +++ b/nptl/pthread_getattr_np.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -168,12 +168,8 @@ pthread_getattr_np (thread_id, attr) { free (cpuset); if (ret == ENOSYS) - { - /* There is no such functionality. */ - ret = 0; - iattr->cpuset = NULL; - iattr->cpusetsize = 0; - } + /* There is no such functionality. */ + ret = 0; } } diff --git a/nptl/pthread_getcpuclockid.c b/nptl/pthread_getcpuclockid.c new file mode 100644 index 0000000..8506f94 --- /dev/null +++ b/nptl/pthread_getcpuclockid.c @@ -0,0 +1,57 @@ +/* Copyright (C) 2000, 2001, 2002, 2003 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; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#include + + +int +pthread_getcpuclockid (threadid, clockid) + pthread_t threadid; + clockid_t *clockid; +{ + struct pthread *pd = (struct pthread *) threadid; + + /* Make sure the descriptor is valid. */ + if (INVALID_TD_P (pd)) + /* Not a valid thread handle. */ + return ESRCH; + +#ifdef CLOCK_THREAD_CPUTIME_ID + /* We need to store the thread ID in the CLOCKID variable together + with a number identifying the clock. We reserve the low 3 bits + for the clock ID and the rest for the thread ID. This is + problematic if the thread ID is too large. But 29 bits should be + fine. + + If some day more clock IDs are needed the ID part can be + enlarged. The IDs are entirely internal. */ + if (pd->tid >= 1 << (8 * sizeof (*clockid) - CLOCK_IDFIELD_SIZE)) + return ERANGE; + + /* Store the number. */ + *clockid = CLOCK_THREAD_CPUTIME_ID | (pd->tid << CLOCK_IDFIELD_SIZE); + + return 0; +#else + /* We don't have a timer for that. */ + return ENOENT; +#endif +} diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c index 1c3ee4f..52cc47f 100644 --- a/nptl/pthread_mutex_lock.c +++ b/nptl/pthread_mutex_lock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -127,8 +127,6 @@ __pthread_mutex_lock (mutex) int newval = id; #ifdef NO_INCR newval |= FUTEX_WAITERS; -#else - newval |= (oldval & FUTEX_WAITERS); #endif newval diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c index 8fd681c..c8e6b85 100644 --- a/nptl/pthread_mutex_timedlock.c +++ b/nptl/pthread_mutex_timedlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -119,11 +119,9 @@ pthread_mutex_timedlock (mutex, abstime) if ((oldval & FUTEX_OWNER_DIED) != 0) { /* The previous owner died. Try locking the mutex. */ - int newval = id | (oldval & FUTEX_WAITERS); - - newval + int newval = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock, - newval, oldval); + id, oldval); if (newval != oldval) { oldval = newval; diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c index 66aca8e..94d5192 100644 --- a/nptl/pthread_mutex_trylock.c +++ b/nptl/pthread_mutex_trylock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -91,11 +91,9 @@ __pthread_mutex_trylock (mutex) if ((oldval & FUTEX_OWNER_DIED) != 0) { /* The previous owner died. Try locking the mutex. */ - int newval = id | (oldval & FUTEX_WAITERS); - - newval + int newval = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock, - newval, oldval); + id, oldval); if (newval != oldval) { diff --git a/nptl/pthread_once.c b/nptl/pthread_once.c new file mode 100644 index 0000000..9b2cef8 --- /dev/null +++ b/nptl/pthread_once.c @@ -0,0 +1,54 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2002. + + 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 "pthreadP.h" +#include + + + +static lll_lock_t once_lock = LLL_LOCK_INITIALIZER; + + +int +__pthread_once (once_control, init_routine) + pthread_once_t *once_control; + void (*init_routine) (void); +{ + /* XXX Depending on whether the LOCK_IN_ONCE_T is defined use a + global lock variable or one which is part of the pthread_once_t + object. */ + if (*once_control == PTHREAD_ONCE_INIT) + { + lll_lock (once_lock); + + /* XXX This implementation is not complete. It doesn't take + cancelation and fork into account. */ + if (*once_control == PTHREAD_ONCE_INIT) + { + init_routine (); + + *once_control = !PTHREAD_ONCE_INIT; + } + + lll_unlock (once_lock); + } + + return 0; +} +strong_alias (__pthread_once, pthread_once) diff --git a/nptl/pthread_rwlock_rdlock.c b/nptl/pthread_rwlock_rdlock.c new file mode 100644 index 0000000..e225d70 --- /dev/null +++ b/nptl/pthread_rwlock_rdlock.c @@ -0,0 +1,95 @@ +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky , 2003. + + 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 +#include +#include +#include +#include + + +/* Acquire read lock for RWLOCK. */ +int +__pthread_rwlock_rdlock (rwlock) + pthread_rwlock_t *rwlock; +{ + int result = 0; + + /* Make sure we are along. */ + lll_mutex_lock (rwlock->__data.__lock); + + while (1) + { + /* Get the rwlock if there is no writer... */ + if (rwlock->__data.__writer == 0 + /* ...and if either no writer is waiting or we prefer readers. */ + && (!rwlock->__data.__nr_writers_queued + || rwlock->__data.__flags == 0)) + { + /* Increment the reader counter. Avoid overflow. */ + if (__builtin_expect (++rwlock->__data.__nr_readers == 0, 0)) + { + /* Overflow on number of readers. */ + --rwlock->__data.__nr_readers; + result = EAGAIN; + } + + break; + } + + /* Make sure we are not holding the rwlock as a writer. This is + a deadlock situation we recognize and report. */ + if (__builtin_expect (rwlock->__data.__writer + == THREAD_GETMEM (THREAD_SELF, tid), 0)) + { + result = EDEADLK; + break; + } + + /* Remember that we are a reader. */ + if (__builtin_expect (++rwlock->__data.__nr_readers_queued == 0, 0)) + { + /* Overflow on number of queued readers. */ + --rwlock->__data.__nr_readers_queued; + result = EAGAIN; + break; + } + + int waitval = rwlock->__data.__readers_wakeup; + + /* Free the lock. */ + lll_mutex_unlock (rwlock->__data.__lock); + + /* Wait for the writer to finish. */ + lll_futex_wait (&rwlock->__data.__readers_wakeup, waitval); + + /* Get the lock. */ + lll_mutex_lock (rwlock->__data.__lock); + + --rwlock->__data.__nr_readers_queued; + } + + /* We are done, free the lock. */ + lll_mutex_unlock (rwlock->__data.__lock); + + return result; +} + +weak_alias (__pthread_rwlock_rdlock, pthread_rwlock_rdlock) +strong_alias (__pthread_rwlock_rdlock, __pthread_rwlock_rdlock_internal) diff --git a/nptl/pthread_rwlock_timedrdlock.c b/nptl/pthread_rwlock_timedrdlock.c new file mode 100644 index 0000000..80ea83a --- /dev/null +++ b/nptl/pthread_rwlock_timedrdlock.c @@ -0,0 +1,137 @@ +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky , 2003. + + 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 +#include +#include +#include +#include + + +/* Try to acquire read lock for RWLOCK or return after specfied time. */ +int +pthread_rwlock_timedrdlock (rwlock, abstime) + pthread_rwlock_t *rwlock; + const struct timespec *abstime; +{ + int result = 0; + + /* Make sure we are along. */ + lll_mutex_lock(rwlock->__data.__lock); + + while (1) + { + int err; + + /* Get the rwlock if there is no writer... */ + if (rwlock->__data.__writer == 0 + /* ...and if either no writer is waiting or we prefer readers. */ + && (!rwlock->__data.__nr_writers_queued + || rwlock->__data.__flags == 0)) + { + /* Increment the reader counter. Avoid overflow. */ + if (++rwlock->__data.__nr_readers == 0) + { + /* Overflow on number of readers. */ + --rwlock->__data.__nr_readers; + result = EAGAIN; + } + + break; + } + + /* Make sure we are not holding the rwlock as a writer. This is + a deadlock situation we recognize and report. */ + if (__builtin_expect (rwlock->__data.__writer + == THREAD_GETMEM (THREAD_SELF, tid), 0)) + { + result = EDEADLK; + break; + } + + /* Make sure the passed in timeout value is valid. Ideally this + test would be executed once. But since it must not be + performed if we would not block at all simply moving the test + to the front is no option. Replicating all the code is + costly while this test is not. */ + if (__builtin_expect (abstime->tv_nsec >= 1000000000 + || abstime->tv_nsec < 0, 0)) + { + result = EINVAL; + break; + } + + /* Get the current time. So far we support only one clock. */ + struct timeval tv; + (void) gettimeofday (&tv, NULL); + + /* Convert the absolute timeout value to a relative timeout. */ + struct timespec rt; + rt.tv_sec = abstime->tv_sec - tv.tv_sec; + rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000; + if (rt.tv_nsec < 0) + { + rt.tv_nsec += 1000000000; + --rt.tv_sec; + } + /* Did we already time out? */ + if (rt.tv_sec < 0) + { + /* Yep, return with an appropriate error. */ + result = ETIMEDOUT; + break; + } + + /* Remember that we are a reader. */ + if (++rwlock->__data.__nr_readers_queued == 0) + { + /* Overflow on number of queued readers. */ + --rwlock->__data.__nr_readers_queued; + result = EAGAIN; + break; + } + + int waitval = rwlock->__data.__readers_wakeup; + + /* Free the lock. */ + lll_mutex_unlock (rwlock->__data.__lock); + + /* Wait for the writer to finish. */ + err = lll_futex_timed_wait (&rwlock->__data.__readers_wakeup, + waitval, &rt); + + /* Get the lock. */ + lll_mutex_lock (rwlock->__data.__lock); + + --rwlock->__data.__nr_readers_queued; + + /* Did the futex call time out? */ + if (err == -ETIMEDOUT) + { + /* Yep, report it. */ + result = ETIMEDOUT; + break; + } + } + + /* We are done, free the lock. */ + lll_mutex_unlock (rwlock->__data.__lock); + + return result; +} diff --git a/nptl/pthread_rwlock_timedwrlock.c b/nptl/pthread_rwlock_timedwrlock.c new file mode 100644 index 0000000..97c0598 --- /dev/null +++ b/nptl/pthread_rwlock_timedwrlock.c @@ -0,0 +1,127 @@ +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky , 2003. + + 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 +#include +#include +#include +#include + + +/* Try to acquire write lock for RWLOCK or return after specfied time. */ +int +pthread_rwlock_timedwrlock (rwlock, abstime) + pthread_rwlock_t *rwlock; + const struct timespec *abstime; +{ + int result = 0; + + /* Make sure we are along. */ + lll_mutex_lock (rwlock->__data.__lock); + + while (1) + { + int err; + + /* Get the rwlock if there is no writer and no reader. */ + if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0) + { + /* Mark self as writer. */ + rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid); + break; + } + + /* Make sure we are not holding the rwlock as a writer. This is + a deadlock situation we recognize and report. */ + if (__builtin_expect (rwlock->__data.__writer + == THREAD_GETMEM (THREAD_SELF, tid), 0)) + { + result = EDEADLK; + break; + } + + /* Make sure the passed in timeout value is valid. Ideally this + test would be executed once. But since it must not be + performed if we would not block at all simply moving the test + to the front is no option. Replicating all the code is + costly while this test is not. */ + if (__builtin_expect (abstime->tv_nsec >= 1000000000 + || abstime->tv_nsec < 0, 0)) + { + result = EINVAL; + break; + } + + /* Get the current time. So far we support only one clock. */ + struct timeval tv; + (void) gettimeofday (&tv, NULL); + + /* Convert the absolute timeout value to a relative timeout. */ + struct timespec rt; + rt.tv_sec = abstime->tv_sec - tv.tv_sec; + rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000; + if (rt.tv_nsec < 0) + { + rt.tv_nsec += 1000000000; + --rt.tv_sec; + } + /* Did we already time out? */ + if (rt.tv_sec < 0) + { + result = ETIMEDOUT; + break; + } + + /* Remember that we are a writer. */ + if (++rwlock->__data.__nr_writers_queued == 0) + { + /* Overflow on number of queued writers. */ + --rwlock->__data.__nr_writers_queued; + result = EAGAIN; + break; + } + + int waitval = rwlock->__data.__writer_wakeup; + + /* Free the lock. */ + lll_mutex_unlock (rwlock->__data.__lock); + + /* Wait for the writer or reader(s) to finish. */ + err = lll_futex_timed_wait (&rwlock->__data.__writer_wakeup, + waitval, &rt); + + /* Get the lock. */ + lll_mutex_lock (rwlock->__data.__lock); + + /* To start over again, remove the thread from the writer list. */ + --rwlock->__data.__nr_writers_queued; + + /* Did the futex call time out? */ + if (err == -ETIMEDOUT) + { + result = ETIMEDOUT; + break; + } + } + + /* We are done, free the lock. */ + lll_mutex_unlock (rwlock->__data.__lock); + + return result; +} diff --git a/nptl/pthread_rwlock_unlock.c b/nptl/pthread_rwlock_unlock.c new file mode 100644 index 0000000..9cae8b6 --- /dev/null +++ b/nptl/pthread_rwlock_unlock.c @@ -0,0 +1,57 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky , 2003. + + 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 +#include +#include +#include +#include + +/* Unlock RWLOCK. */ +int +__pthread_rwlock_unlock (pthread_rwlock_t *rwlock) +{ + lll_mutex_lock (rwlock->__data.__lock); + if (rwlock->__data.__writer) + rwlock->__data.__writer = 0; + else + --rwlock->__data.__nr_readers; + if (rwlock->__data.__nr_readers == 0) + { + if (rwlock->__data.__nr_writers_queued) + { + ++rwlock->__data.__writer_wakeup; + lll_mutex_unlock (rwlock->__data.__lock); + lll_futex_wake (&rwlock->__data.__writer_wakeup, 1); + return 0; + } + else if (rwlock->__data.__nr_readers_queued) + { + ++rwlock->__data.__readers_wakeup; + lll_mutex_unlock (rwlock->__data.__lock); + lll_futex_wake (&rwlock->__data.__readers_wakeup, INT_MAX); + return 0; + } + } + lll_mutex_unlock (rwlock->__data.__lock); + return 0; +} + +weak_alias (__pthread_rwlock_unlock, pthread_rwlock_unlock) +strong_alias (__pthread_rwlock_unlock, __pthread_rwlock_unlock_internal) diff --git a/nptl/pthread_rwlock_wrlock.c b/nptl/pthread_rwlock_wrlock.c new file mode 100644 index 0000000..822aeed --- /dev/null +++ b/nptl/pthread_rwlock_wrlock.c @@ -0,0 +1,87 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky , 2003. + + 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 +#include +#include +#include +#include + + +/* Acquire write lock for RWLOCK. */ +int +__pthread_rwlock_wrlock (rwlock) + pthread_rwlock_t *rwlock; +{ + int result = 0; + + /* Make sure we are along. */ + lll_mutex_lock (rwlock->__data.__lock); + + while (1) + { + /* Get the rwlock if there is no writer and no reader. */ + if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0) + { + /* Mark self as writer. */ + rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid); + break; + } + + /* Make sure we are not holding the rwlock as a writer. This is + a deadlock situation we recognize and report. */ + if (__builtin_expect (rwlock->__data.__writer + == THREAD_GETMEM (THREAD_SELF, tid), 0)) + { + result = EDEADLK; + break; + } + + /* Remember that we are a writer. */ + if (++rwlock->__data.__nr_writers_queued == 0) + { + /* Overflow on number of queued writers. */ + --rwlock->__data.__nr_writers_queued; + result = EAGAIN; + break; + } + + int waitval = rwlock->__data.__writer_wakeup; + + /* Free the lock. */ + lll_mutex_unlock (rwlock->__data.__lock); + + /* Wait for the writer or reader(s) to finish. */ + lll_futex_wait (&rwlock->__data.__writer_wakeup, waitval); + + /* Get the lock. */ + lll_mutex_lock (rwlock->__data.__lock); + + /* To start over again, remove the thread from the writer list. */ + --rwlock->__data.__nr_writers_queued; + } + + /* We are done, free the lock. */ + lll_mutex_unlock (rwlock->__data.__lock); + + return result; +} + +weak_alias (__pthread_rwlock_wrlock, pthread_rwlock_wrlock) +strong_alias (__pthread_rwlock_wrlock, __pthread_rwlock_wrlock_internal) diff --git a/nptl/pthread_spin_destroy.c b/nptl/pthread_spin_destroy.c new file mode 100644 index 0000000..4d0109c --- /dev/null +++ b/nptl/pthread_spin_destroy.c @@ -0,0 +1,29 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2002. + + 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 "pthreadP.h" + + +int +pthread_spin_destroy (lock) + pthread_spinlock_t *lock; +{ + /* Nothing to do. */ + return 0; +} diff --git a/nptl/pthread_spin_init.c b/nptl/pthread_spin_init.c new file mode 100644 index 0000000..c227508 --- /dev/null +++ b/nptl/pthread_spin_init.c @@ -0,0 +1,28 @@ +/* pthread_spin_init -- initialize a spin lock. Generic version. + Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Paul Mackerras , 2003. + + 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 "pthreadP.h" + +int +pthread_spin_init (pthread_spinlock_t *lock, int pshared) +{ + *lock = 0; + return 0; +} diff --git a/nptl/pthread_spin_unlock.c b/nptl/pthread_spin_unlock.c new file mode 100644 index 0000000..f97cadf --- /dev/null +++ b/nptl/pthread_spin_unlock.c @@ -0,0 +1,30 @@ +/* pthread_spin_unlock -- unlock a spin lock. Generic version. + Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Paul Mackerras , 2003. + + 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 "pthreadP.h" +#include + +int +pthread_spin_unlock (pthread_spinlock_t *lock) +{ + atomic_full_barrier (); + *lock = 0; + return 0; +} diff --git a/nptl/sysdeps/alpha/tls.h b/nptl/sysdeps/alpha/tls.h index 07db159..be2430f 100644 --- a/nptl/sysdeps/alpha/tls.h +++ b/nptl/sysdeps/alpha/tls.h @@ -1,5 +1,5 @@ /* Definition for thread-local data handling. NPTL/Alpha version. - Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2005, 2006 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 @@ -48,9 +48,6 @@ typedef union dtv # error "TLS support is required." #endif -/* Signal that TLS support is available. */ -# define USE_TLS 1 - #ifndef __ASSEMBLER__ /* Get system call information. */ @@ -124,29 +121,6 @@ typedef struct #define THREAD_SETMEM_NC(descr, member, idx, value) \ descr->member[idx] = (value) -/* Get and set the global scope generation counter in struct pthread. */ -#define THREAD_GSCOPE_FLAG_UNUSED 0 -#define THREAD_GSCOPE_FLAG_USED 1 -#define THREAD_GSCOPE_FLAG_WAIT 2 -#define THREAD_GSCOPE_RESET_FLAG() \ - do \ - { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ - THREAD_GSCOPE_FLAG_UNUSED); \ - if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ - } \ - while (0) -#define THREAD_GSCOPE_SET_FLAG() \ - do \ - { \ - THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \ - atomic_write_barrier (); \ - } \ - while (0) -#define THREAD_GSCOPE_WAIT() \ - GL(dl_wait_lookup_done) () - #endif /* __ASSEMBLER__ */ #endif /* tls.h */ diff --git a/nptl/sysdeps/i386/tls.h b/nptl/sysdeps/i386/tls.h index b3d9142..d5b3797 100644 --- a/nptl/sysdeps/i386/tls.h +++ b/nptl/sysdeps/i386/tls.h @@ -1,5 +1,5 @@ /* Definition for thread-local data handling. nptl/i386 version. - Copyright (C) 2002,2003,2004,2005,2007 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006 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 @@ -51,7 +51,6 @@ typedef struct uintptr_t sysinfo; uintptr_t stack_guard; uintptr_t pointer_guard; - int gscope_flag; } tcbhead_t; # define TLS_MULTIPLE_THREADS_IN_TCB 1 @@ -66,9 +65,6 @@ typedef struct # error "TLS support is required." #endif -/* Signal that TLS support is available. */ -#define USE_TLS 1 - /* Alignment requirement for the stack. For IA-32 this is governed by the SSE memory functions. */ #define STACK_ALIGN 16 @@ -435,26 +431,6 @@ union user_desc_init = THREAD_GETMEM (THREAD_SELF, header.pointer_guard)) -/* Get and set the global scope generation counter in the TCB head. */ -#define THREAD_GSCOPE_FLAG_UNUSED 0 -#define THREAD_GSCOPE_FLAG_USED 1 -#define THREAD_GSCOPE_FLAG_WAIT 2 -#define THREAD_GSCOPE_RESET_FLAG() \ - do \ - { int __res; \ - asm volatile ("xchgl %0, %%gs:%P1" \ - : "=r" (__res) \ - : "i" (offsetof (struct pthread, header.gscope_flag)), \ - "0" (THREAD_GSCOPE_FLAG_UNUSED)); \ - if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ - } \ - while (0) -#define THREAD_GSCOPE_SET_FLAG() \ - THREAD_SETMEM (THREAD_SELF, header.gscope_flag, THREAD_GSCOPE_FLAG_USED) -#define THREAD_GSCOPE_WAIT() \ - GL(dl_wait_lookup_done) () - #endif /* __ASSEMBLER__ */ #endif /* tls.h */ diff --git a/nptl/sysdeps/ia64/pthread_spin_unlock.c b/nptl/sysdeps/ia64/pthread_spin_unlock.c index 6232764..50d9c5f 100644 --- a/nptl/sysdeps/ia64/pthread_spin_unlock.c +++ b/nptl/sysdeps/ia64/pthread_spin_unlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2003. @@ -23,6 +23,6 @@ int pthread_spin_unlock (pthread_spinlock_t *lock) { - __sync_lock_release_si ((int *) lock); + __sync_lock_release ((int *) lock); return 0; } diff --git a/nptl/sysdeps/ia64/tls.h b/nptl/sysdeps/ia64/tls.h index a43f096..22a8b08 100644 --- a/nptl/sysdeps/ia64/tls.h +++ b/nptl/sysdeps/ia64/tls.h @@ -1,5 +1,5 @@ /* Definition for thread-local data handling. nptl/IA-64 version. - Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2006 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 @@ -61,9 +61,6 @@ register struct pthread *__thread_self __asm__("r13"); # error "TLS support is required." #endif -/* Signal that TLS support is available. */ -#define USE_TLS 1 - /* Alignment requirement for the stack. */ #define STACK_ALIGN 16 @@ -166,29 +163,6 @@ register struct pthread *__thread_self __asm__("r13"); (((uintptr_t *) ((char *) (descr) + TLS_PRE_TCB_SIZE))[-2] \ = THREAD_GET_POINTER_GUARD ()) -/* Get and set the global scope generation counter in struct pthread. */ -#define THREAD_GSCOPE_FLAG_UNUSED 0 -#define THREAD_GSCOPE_FLAG_USED 1 -#define THREAD_GSCOPE_FLAG_WAIT 2 -#define THREAD_GSCOPE_RESET_FLAG() \ - do \ - { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ - THREAD_GSCOPE_FLAG_UNUSED); \ - if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ - } \ - while (0) -#define THREAD_GSCOPE_SET_FLAG() \ - do \ - { \ - THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \ - atomic_write_barrier (); \ - } \ - while (0) -#define THREAD_GSCOPE_WAIT() \ - GL(dl_wait_lookup_done) () - #endif /* __ASSEMBLER__ */ #endif /* tls.h */ diff --git a/nptl/sysdeps/powerpc/tls.h b/nptl/sysdeps/powerpc/tls.h index ad5698c..ddaafe2 100644 --- a/nptl/sysdeps/powerpc/tls.h +++ b/nptl/sysdeps/powerpc/tls.h @@ -1,5 +1,5 @@ /* Definition for thread-local data handling. NPTL/PowerPC version. - Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2005, 2006 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 @@ -48,9 +48,6 @@ typedef union dtv # error "TLS support is required." #endif -/* Signal that TLS support is available. */ -# define USE_TLS 1 - #ifndef __ASSEMBLER__ /* Get system call information. */ @@ -183,29 +180,6 @@ register void *__thread_register __asm__ ("r13"); different value to mean unset l_tls_offset. */ # define NO_TLS_OFFSET -1 -/* Get and set the global scope generation counter in struct pthread. */ -#define THREAD_GSCOPE_FLAG_UNUSED 0 -#define THREAD_GSCOPE_FLAG_USED 1 -#define THREAD_GSCOPE_FLAG_WAIT 2 -#define THREAD_GSCOPE_RESET_FLAG() \ - do \ - { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ - THREAD_GSCOPE_FLAG_UNUSED); \ - if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ - } \ - while (0) -#define THREAD_GSCOPE_SET_FLAG() \ - do \ - { \ - THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \ - atomic_write_barrier (); \ - } \ - while (0) -#define THREAD_GSCOPE_WAIT() \ - GL(dl_wait_lookup_done) () - #endif /* __ASSEMBLER__ */ #endif /* tls.h */ diff --git a/nptl/sysdeps/pthread/pthread_barrier_wait.c b/nptl/sysdeps/pthread/pthread_barrier_wait.c deleted file mode 100644 index c6b563f..0000000 --- a/nptl/sysdeps/pthread/pthread_barrier_wait.c +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Martin Schwidefsky , 2003. - - 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 -#include -#include -#include - - -/* Wait on barrier. */ -int -pthread_barrier_wait (barrier) - pthread_barrier_t *barrier; -{ - struct pthread_barrier *ibarrier = (struct pthread_barrier *) barrier; - int result = 0; - - /* Make sure we are alone. */ - lll_lock (ibarrier->lock); - - /* One more arrival. */ - --ibarrier->left; - - /* Are these all? */ - if (ibarrier->left == 0) - { - /* Yes. Increment the event counter to avoid invalid wake-ups and - tell the current waiters that it is their turn. */ - ++ibarrier->curr_event; - - /* Wake up everybody. */ - lll_futex_wake (&ibarrier->curr_event, INT_MAX); - - /* This is the thread which finished the serialization. */ - result = PTHREAD_BARRIER_SERIAL_THREAD; - } - else - { - /* The number of the event we are waiting for. The barrier's event - number must be bumped before we continue. */ - unsigned int event = ibarrier->curr_event; - - /* Before suspending, make the barrier available to others. */ - lll_unlock (ibarrier->lock); - - /* Wait for the event counter of the barrier to change. */ - do - lll_futex_wait (&ibarrier->curr_event, event); - while (event == ibarrier->curr_event); - } - - /* Make sure the init_count is stored locally or in a register. */ - unsigned int init_count = ibarrier->init_count; - - /* If this was the last woken thread, unlock. */ - if (atomic_increment_val (&ibarrier->left) == init_count) - /* We are done. */ - lll_unlock (ibarrier->lock); - - return result; -} diff --git a/nptl/sysdeps/pthread/pthread_cond_broadcast.c b/nptl/sysdeps/pthread/pthread_cond_broadcast.c deleted file mode 100644 index 2b8b546..0000000 --- a/nptl/sysdeps/pthread/pthread_cond_broadcast.c +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Martin Schwidefsky , 2003. - - 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 -#include -#include -#include -#include -#include - -#include -#include - - -int -__pthread_cond_broadcast (cond) - pthread_cond_t *cond; -{ - /* Make sure we are alone. */ - lll_mutex_lock (cond->__data.__lock); - - /* Are there any waiters to be woken? */ - if (cond->__data.__total_seq > cond->__data.__wakeup_seq) - { - /* Yes. Mark them all as woken. */ - cond->__data.__wakeup_seq = cond->__data.__total_seq; - cond->__data.__woken_seq = cond->__data.__total_seq; - cond->__data.__futex = (unsigned int) cond->__data.__total_seq * 2; - int futex_val = cond->__data.__futex; - /* Signal that a broadcast happened. */ - ++cond->__data.__broadcast_seq; - - /* We are done. */ - lll_mutex_unlock (cond->__data.__lock); - - /* Do not use requeue for pshared condvars. */ - if (cond->__data.__mutex == (void *) ~0l) - goto wake_all; - - /* Wake everybody. */ - pthread_mutex_t *mut = (pthread_mutex_t *) cond->__data.__mutex; - - /* XXX: Kernel so far doesn't support requeue to PI futex. */ - if (__builtin_expect (mut->__data.__kind & PTHREAD_MUTEX_PRIO_INHERIT_NP, - 0)) - goto wake_all; - - /* lll_futex_requeue returns 0 for success and non-zero - for errors. */ - if (__builtin_expect (lll_futex_requeue (&cond->__data.__futex, 1, - INT_MAX, &mut->__data.__lock, - futex_val), 0)) - { - /* The requeue functionality is not available. */ - wake_all: - lll_futex_wake (&cond->__data.__futex, INT_MAX); - } - - /* That's all. */ - return 0; - } - - /* We are done. */ - lll_mutex_unlock (cond->__data.__lock); - - return 0; -} - -versioned_symbol (libpthread, __pthread_cond_broadcast, pthread_cond_broadcast, - GLIBC_2_3_2); diff --git a/nptl/sysdeps/pthread/pthread_cond_signal.c b/nptl/sysdeps/pthread/pthread_cond_signal.c deleted file mode 100644 index 5a9bbca..0000000 --- a/nptl/sysdeps/pthread/pthread_cond_signal.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Martin Schwidefsky , 2003. - - 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 -#include -#include -#include -#include -#include - -#include -#include - - -int -__pthread_cond_signal (cond) - pthread_cond_t *cond; -{ - /* Make sure we are alone. */ - lll_mutex_lock (cond->__data.__lock); - - /* Are there any waiters to be woken? */ - if (cond->__data.__total_seq > cond->__data.__wakeup_seq) - { - /* Yes. Mark one of them as woken. */ - ++cond->__data.__wakeup_seq; - ++cond->__data.__futex; - - /* Wake one. */ - if (! __builtin_expect (lll_futex_wake_unlock (&cond->__data.__futex, 1, - 1, &cond->__data.__lock), - 0)) - return 0; - - lll_futex_wake (&cond->__data.__futex, 1); - } - - /* We are done. */ - lll_mutex_unlock (cond->__data.__lock); - - return 0; -} - -versioned_symbol (libpthread, __pthread_cond_signal, pthread_cond_signal, - GLIBC_2_3_2); diff --git a/nptl/sysdeps/pthread/pthread_cond_timedwait.c b/nptl/sysdeps/pthread/pthread_cond_timedwait.c deleted file mode 100644 index fdbf43e..0000000 --- a/nptl/sysdeps/pthread/pthread_cond_timedwait.c +++ /dev/null @@ -1,214 +0,0 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Martin Schwidefsky , 2003. - - 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 -#include -#include -#include -#include -#include - -#include - - -/* Cleanup handler, defined in pthread_cond_wait.c. */ -extern void __condvar_cleanup (void *arg) - __attribute__ ((visibility ("hidden"))); - -struct _condvar_cleanup_buffer -{ - int oldtype; - pthread_cond_t *cond; - pthread_mutex_t *mutex; - unsigned int bc_seq; -}; - -int -__pthread_cond_timedwait (cond, mutex, abstime) - pthread_cond_t *cond; - pthread_mutex_t *mutex; - const struct timespec *abstime; -{ - struct _pthread_cleanup_buffer buffer; - struct _condvar_cleanup_buffer cbuffer; - int result = 0; - - /* Catch invalid parameters. */ - if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) - return EINVAL; - - /* Make sure we are along. */ - lll_mutex_lock (cond->__data.__lock); - - /* Now we can release the mutex. */ - int err = __pthread_mutex_unlock_usercnt (mutex, 0); - if (err) - { - lll_mutex_unlock (cond->__data.__lock); - return err; - } - - /* We have one new user of the condvar. */ - ++cond->__data.__total_seq; - ++cond->__data.__futex; - cond->__data.__nwaiters += 1 << COND_CLOCK_BITS; - - /* Remember the mutex we are using here. If there is already a - different address store this is a bad user bug. Do not store - anything for pshared condvars. */ - if (cond->__data.__mutex != (void *) ~0l) - cond->__data.__mutex = mutex; - - /* Prepare structure passed to cancellation handler. */ - cbuffer.cond = cond; - cbuffer.mutex = mutex; - - /* Before we block we enable cancellation. Therefore we have to - install a cancellation handler. */ - __pthread_cleanup_push (&buffer, __condvar_cleanup, &cbuffer); - - /* The current values of the wakeup counter. The "woken" counter - must exceed this value. */ - unsigned long long int val; - unsigned long long int seq; - val = seq = cond->__data.__wakeup_seq; - /* Remember the broadcast counter. */ - cbuffer.bc_seq = cond->__data.__broadcast_seq; - - while (1) - { - struct timespec rt; - { -#ifdef __NR_clock_gettime - INTERNAL_SYSCALL_DECL (err); - int ret; - ret = INTERNAL_SYSCALL (clock_gettime, err, 2, - (cond->__data.__nwaiters - & ((1 << COND_CLOCK_BITS) - 1)), - &rt); -# ifndef __ASSUME_POSIX_TIMERS - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (ret, err), 0)) - { - struct timeval tv; - (void) gettimeofday (&tv, NULL); - - /* Convert the absolute timeout value to a relative timeout. */ - rt.tv_sec = abstime->tv_sec - tv.tv_sec; - rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000; - } - else -# endif - { - /* Convert the absolute timeout value to a relative timeout. */ - rt.tv_sec = abstime->tv_sec - rt.tv_sec; - rt.tv_nsec = abstime->tv_nsec - rt.tv_nsec; - } -#else - /* Get the current time. So far we support only one clock. */ - struct timeval tv; - (void) gettimeofday (&tv, NULL); - - /* Convert the absolute timeout value to a relative timeout. */ - rt.tv_sec = abstime->tv_sec - tv.tv_sec; - rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000; -#endif - } - if (rt.tv_nsec < 0) - { - rt.tv_nsec += 1000000000; - --rt.tv_sec; - } - /* Did we already time out? */ - if (__builtin_expect (rt.tv_sec < 0, 0)) - { - if (cbuffer.bc_seq != cond->__data.__broadcast_seq) - goto bc_out; - - goto timeout; - } - - unsigned int futex_val = cond->__data.__futex; - - /* Prepare to wait. Release the condvar futex. */ - lll_mutex_unlock (cond->__data.__lock); - - /* Enable asynchronous cancellation. Required by the standard. */ - cbuffer.oldtype = __pthread_enable_asynccancel (); - - /* Wait until woken by signal or broadcast. */ - err = lll_futex_timed_wait (&cond->__data.__futex, - futex_val, &rt); - - /* Disable asynchronous cancellation. */ - __pthread_disable_asynccancel (cbuffer.oldtype); - - /* We are going to look at shared data again, so get the lock. */ - lll_mutex_lock(cond->__data.__lock); - - /* If a broadcast happened, we are done. */ - if (cbuffer.bc_seq != cond->__data.__broadcast_seq) - goto bc_out; - - /* Check whether we are eligible for wakeup. */ - val = cond->__data.__wakeup_seq; - if (val != seq && cond->__data.__woken_seq != val) - break; - - /* Not woken yet. Maybe the time expired? */ - if (__builtin_expect (err == -ETIMEDOUT, 0)) - { - timeout: - /* Yep. Adjust the counters. */ - ++cond->__data.__wakeup_seq; - ++cond->__data.__futex; - - /* The error value. */ - result = ETIMEDOUT; - break; - } - } - - /* Another thread woken up. */ - ++cond->__data.__woken_seq; - - bc_out: - - cond->__data.__nwaiters -= 1 << COND_CLOCK_BITS; - - /* If pthread_cond_destroy was called on this variable already, - notify the pthread_cond_destroy caller all waiters have left - and it can be successfully destroyed. */ - if (cond->__data.__total_seq == -1ULL - && cond->__data.__nwaiters < (1 << COND_CLOCK_BITS)) - lll_futex_wake (&cond->__data.__nwaiters, 1); - - /* We are done with the condvar. */ - lll_mutex_unlock (cond->__data.__lock); - - /* The cancellation handling is back to normal, remove the handler. */ - __pthread_cleanup_pop (&buffer, 0); - - /* Get the mutex before returning. */ - err = __pthread_mutex_cond_lock (mutex); - - return err ?: result; -} - -versioned_symbol (libpthread, __pthread_cond_timedwait, pthread_cond_timedwait, - GLIBC_2_3_2); diff --git a/nptl/sysdeps/pthread/pthread_cond_wait.c b/nptl/sysdeps/pthread/pthread_cond_wait.c deleted file mode 100644 index f5f5cec..0000000 --- a/nptl/sysdeps/pthread/pthread_cond_wait.c +++ /dev/null @@ -1,191 +0,0 @@ -/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Martin Schwidefsky , 2003. - - 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 -#include -#include -#include -#include -#include - -#include - - -struct _condvar_cleanup_buffer -{ - int oldtype; - pthread_cond_t *cond; - pthread_mutex_t *mutex; - unsigned int bc_seq; -}; - - -void -__attribute__ ((visibility ("hidden"))) -__condvar_cleanup (void *arg) -{ - struct _condvar_cleanup_buffer *cbuffer = - (struct _condvar_cleanup_buffer *) arg; - unsigned int destroying; - - /* We are going to modify shared data. */ - lll_mutex_lock (cbuffer->cond->__data.__lock); - - if (cbuffer->bc_seq == cbuffer->cond->__data.__broadcast_seq) - { - /* This thread is not waiting anymore. Adjust the sequence counters - appropriately. We do not increment WAKEUP_SEQ if this would - bump it over the value of TOTAL_SEQ. This can happen if a thread - was woken and then canceled. */ - if (cbuffer->cond->__data.__wakeup_seq - < cbuffer->cond->__data.__total_seq) - { - ++cbuffer->cond->__data.__wakeup_seq; - ++cbuffer->cond->__data.__futex; - } - ++cbuffer->cond->__data.__woken_seq; - } - - cbuffer->cond->__data.__nwaiters -= 1 << COND_CLOCK_BITS; - - /* If pthread_cond_destroy was called on this variable already, - notify the pthread_cond_destroy caller all waiters have left - and it can be successfully destroyed. */ - destroying = 0; - if (cbuffer->cond->__data.__total_seq == -1ULL - && cbuffer->cond->__data.__nwaiters < (1 << COND_CLOCK_BITS)) - { - lll_futex_wake (&cbuffer->cond->__data.__nwaiters, 1); - destroying = 1; - } - - /* We are done. */ - lll_mutex_unlock (cbuffer->cond->__data.__lock); - - /* Wake everybody to make sure no condvar signal gets lost. */ - if (! destroying) - lll_futex_wake (&cbuffer->cond->__data.__futex, INT_MAX); - - /* Get the mutex before returning unless asynchronous cancellation - is in effect. */ - __pthread_mutex_cond_lock (cbuffer->mutex); -} - - -int -__pthread_cond_wait (cond, mutex) - pthread_cond_t *cond; - pthread_mutex_t *mutex; -{ - struct _pthread_cleanup_buffer buffer; - struct _condvar_cleanup_buffer cbuffer; - int err; - - /* Make sure we are along. */ - lll_mutex_lock (cond->__data.__lock); - - /* Now we can release the mutex. */ - err = __pthread_mutex_unlock_usercnt (mutex, 0); - if (__builtin_expect (err, 0)) - { - lll_mutex_unlock (cond->__data.__lock); - return err; - } - - /* We have one new user of the condvar. */ - ++cond->__data.__total_seq; - ++cond->__data.__futex; - cond->__data.__nwaiters += 1 << COND_CLOCK_BITS; - - /* Remember the mutex we are using here. If there is already a - different address store this is a bad user bug. Do not store - anything for pshared condvars. */ - if (cond->__data.__mutex != (void *) ~0l) - cond->__data.__mutex = mutex; - - /* Prepare structure passed to cancellation handler. */ - cbuffer.cond = cond; - cbuffer.mutex = mutex; - - /* Before we block we enable cancellation. Therefore we have to - install a cancellation handler. */ - __pthread_cleanup_push (&buffer, __condvar_cleanup, &cbuffer); - - /* The current values of the wakeup counter. The "woken" counter - must exceed this value. */ - unsigned long long int val; - unsigned long long int seq; - val = seq = cond->__data.__wakeup_seq; - /* Remember the broadcast counter. */ - cbuffer.bc_seq = cond->__data.__broadcast_seq; - - do - { - unsigned int futex_val = cond->__data.__futex; - - /* Prepare to wait. Release the condvar futex. */ - lll_mutex_unlock (cond->__data.__lock); - - /* Enable asynchronous cancellation. Required by the standard. */ - cbuffer.oldtype = __pthread_enable_asynccancel (); - - /* Wait until woken by signal or broadcast. */ - lll_futex_wait (&cond->__data.__futex, futex_val); - - /* Disable asynchronous cancellation. */ - __pthread_disable_asynccancel (cbuffer.oldtype); - - /* We are going to look at shared data again, so get the lock. */ - lll_mutex_lock (cond->__data.__lock); - - /* If a broadcast happened, we are done. */ - if (cbuffer.bc_seq != cond->__data.__broadcast_seq) - goto bc_out; - - /* Check whether we are eligible for wakeup. */ - val = cond->__data.__wakeup_seq; - } - while (val == seq || cond->__data.__woken_seq == val); - - /* Another thread woken up. */ - ++cond->__data.__woken_seq; - - bc_out: - - cond->__data.__nwaiters -= 1 << COND_CLOCK_BITS; - - /* If pthread_cond_destroy was called on this varaible already, - notify the pthread_cond_destroy caller all waiters have left - and it can be successfully destroyed. */ - if (cond->__data.__total_seq == -1ULL - && cond->__data.__nwaiters < (1 << COND_CLOCK_BITS)) - lll_futex_wake (&cond->__data.__nwaiters, 1); - - /* We are done with the condvar. */ - lll_mutex_unlock (cond->__data.__lock); - - /* The cancellation handling is back to normal, remove the handler. */ - __pthread_cleanup_pop (&buffer, 0); - - /* Get the mutex before returning. */ - return __pthread_mutex_cond_lock (mutex); -} - -versioned_symbol (libpthread, __pthread_cond_wait, pthread_cond_wait, - GLIBC_2_3_2); diff --git a/nptl/sysdeps/pthread/pthread_getcpuclockid.c b/nptl/sysdeps/pthread/pthread_getcpuclockid.c deleted file mode 100644 index 8506f94..0000000 --- a/nptl/sysdeps/pthread/pthread_getcpuclockid.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2000, 2001, 2002, 2003 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; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#include -#include -#include -#include - - -int -pthread_getcpuclockid (threadid, clockid) - pthread_t threadid; - clockid_t *clockid; -{ - struct pthread *pd = (struct pthread *) threadid; - - /* Make sure the descriptor is valid. */ - if (INVALID_TD_P (pd)) - /* Not a valid thread handle. */ - return ESRCH; - -#ifdef CLOCK_THREAD_CPUTIME_ID - /* We need to store the thread ID in the CLOCKID variable together - with a number identifying the clock. We reserve the low 3 bits - for the clock ID and the rest for the thread ID. This is - problematic if the thread ID is too large. But 29 bits should be - fine. - - If some day more clock IDs are needed the ID part can be - enlarged. The IDs are entirely internal. */ - if (pd->tid >= 1 << (8 * sizeof (*clockid) - CLOCK_IDFIELD_SIZE)) - return ERANGE; - - /* Store the number. */ - *clockid = CLOCK_THREAD_CPUTIME_ID | (pd->tid << CLOCK_IDFIELD_SIZE); - - return 0; -#else - /* We don't have a timer for that. */ - return ENOENT; -#endif -} diff --git a/nptl/sysdeps/pthread/pthread_once.c b/nptl/sysdeps/pthread/pthread_once.c deleted file mode 100644 index 9b2cef8..0000000 --- a/nptl/sysdeps/pthread/pthread_once.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2002. - - 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 "pthreadP.h" -#include - - - -static lll_lock_t once_lock = LLL_LOCK_INITIALIZER; - - -int -__pthread_once (once_control, init_routine) - pthread_once_t *once_control; - void (*init_routine) (void); -{ - /* XXX Depending on whether the LOCK_IN_ONCE_T is defined use a - global lock variable or one which is part of the pthread_once_t - object. */ - if (*once_control == PTHREAD_ONCE_INIT) - { - lll_lock (once_lock); - - /* XXX This implementation is not complete. It doesn't take - cancelation and fork into account. */ - if (*once_control == PTHREAD_ONCE_INIT) - { - init_routine (); - - *once_control = !PTHREAD_ONCE_INIT; - } - - lll_unlock (once_lock); - } - - return 0; -} -strong_alias (__pthread_once, pthread_once) diff --git a/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c b/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c deleted file mode 100644 index e225d70..0000000 --- a/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Martin Schwidefsky , 2003. - - 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 -#include -#include -#include -#include - - -/* Acquire read lock for RWLOCK. */ -int -__pthread_rwlock_rdlock (rwlock) - pthread_rwlock_t *rwlock; -{ - int result = 0; - - /* Make sure we are along. */ - lll_mutex_lock (rwlock->__data.__lock); - - while (1) - { - /* Get the rwlock if there is no writer... */ - if (rwlock->__data.__writer == 0 - /* ...and if either no writer is waiting or we prefer readers. */ - && (!rwlock->__data.__nr_writers_queued - || rwlock->__data.__flags == 0)) - { - /* Increment the reader counter. Avoid overflow. */ - if (__builtin_expect (++rwlock->__data.__nr_readers == 0, 0)) - { - /* Overflow on number of readers. */ - --rwlock->__data.__nr_readers; - result = EAGAIN; - } - - break; - } - - /* Make sure we are not holding the rwlock as a writer. This is - a deadlock situation we recognize and report. */ - if (__builtin_expect (rwlock->__data.__writer - == THREAD_GETMEM (THREAD_SELF, tid), 0)) - { - result = EDEADLK; - break; - } - - /* Remember that we are a reader. */ - if (__builtin_expect (++rwlock->__data.__nr_readers_queued == 0, 0)) - { - /* Overflow on number of queued readers. */ - --rwlock->__data.__nr_readers_queued; - result = EAGAIN; - break; - } - - int waitval = rwlock->__data.__readers_wakeup; - - /* Free the lock. */ - lll_mutex_unlock (rwlock->__data.__lock); - - /* Wait for the writer to finish. */ - lll_futex_wait (&rwlock->__data.__readers_wakeup, waitval); - - /* Get the lock. */ - lll_mutex_lock (rwlock->__data.__lock); - - --rwlock->__data.__nr_readers_queued; - } - - /* We are done, free the lock. */ - lll_mutex_unlock (rwlock->__data.__lock); - - return result; -} - -weak_alias (__pthread_rwlock_rdlock, pthread_rwlock_rdlock) -strong_alias (__pthread_rwlock_rdlock, __pthread_rwlock_rdlock_internal) diff --git a/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c b/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c deleted file mode 100644 index 80ea83a..0000000 --- a/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c +++ /dev/null @@ -1,137 +0,0 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Martin Schwidefsky , 2003. - - 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 -#include -#include -#include -#include - - -/* Try to acquire read lock for RWLOCK or return after specfied time. */ -int -pthread_rwlock_timedrdlock (rwlock, abstime) - pthread_rwlock_t *rwlock; - const struct timespec *abstime; -{ - int result = 0; - - /* Make sure we are along. */ - lll_mutex_lock(rwlock->__data.__lock); - - while (1) - { - int err; - - /* Get the rwlock if there is no writer... */ - if (rwlock->__data.__writer == 0 - /* ...and if either no writer is waiting or we prefer readers. */ - && (!rwlock->__data.__nr_writers_queued - || rwlock->__data.__flags == 0)) - { - /* Increment the reader counter. Avoid overflow. */ - if (++rwlock->__data.__nr_readers == 0) - { - /* Overflow on number of readers. */ - --rwlock->__data.__nr_readers; - result = EAGAIN; - } - - break; - } - - /* Make sure we are not holding the rwlock as a writer. This is - a deadlock situation we recognize and report. */ - if (__builtin_expect (rwlock->__data.__writer - == THREAD_GETMEM (THREAD_SELF, tid), 0)) - { - result = EDEADLK; - break; - } - - /* Make sure the passed in timeout value is valid. Ideally this - test would be executed once. But since it must not be - performed if we would not block at all simply moving the test - to the front is no option. Replicating all the code is - costly while this test is not. */ - if (__builtin_expect (abstime->tv_nsec >= 1000000000 - || abstime->tv_nsec < 0, 0)) - { - result = EINVAL; - break; - } - - /* Get the current time. So far we support only one clock. */ - struct timeval tv; - (void) gettimeofday (&tv, NULL); - - /* Convert the absolute timeout value to a relative timeout. */ - struct timespec rt; - rt.tv_sec = abstime->tv_sec - tv.tv_sec; - rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000; - if (rt.tv_nsec < 0) - { - rt.tv_nsec += 1000000000; - --rt.tv_sec; - } - /* Did we already time out? */ - if (rt.tv_sec < 0) - { - /* Yep, return with an appropriate error. */ - result = ETIMEDOUT; - break; - } - - /* Remember that we are a reader. */ - if (++rwlock->__data.__nr_readers_queued == 0) - { - /* Overflow on number of queued readers. */ - --rwlock->__data.__nr_readers_queued; - result = EAGAIN; - break; - } - - int waitval = rwlock->__data.__readers_wakeup; - - /* Free the lock. */ - lll_mutex_unlock (rwlock->__data.__lock); - - /* Wait for the writer to finish. */ - err = lll_futex_timed_wait (&rwlock->__data.__readers_wakeup, - waitval, &rt); - - /* Get the lock. */ - lll_mutex_lock (rwlock->__data.__lock); - - --rwlock->__data.__nr_readers_queued; - - /* Did the futex call time out? */ - if (err == -ETIMEDOUT) - { - /* Yep, report it. */ - result = ETIMEDOUT; - break; - } - } - - /* We are done, free the lock. */ - lll_mutex_unlock (rwlock->__data.__lock); - - return result; -} diff --git a/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c b/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c deleted file mode 100644 index 97c0598..0000000 --- a/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c +++ /dev/null @@ -1,127 +0,0 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Martin Schwidefsky , 2003. - - 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 -#include -#include -#include -#include - - -/* Try to acquire write lock for RWLOCK or return after specfied time. */ -int -pthread_rwlock_timedwrlock (rwlock, abstime) - pthread_rwlock_t *rwlock; - const struct timespec *abstime; -{ - int result = 0; - - /* Make sure we are along. */ - lll_mutex_lock (rwlock->__data.__lock); - - while (1) - { - int err; - - /* Get the rwlock if there is no writer and no reader. */ - if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0) - { - /* Mark self as writer. */ - rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid); - break; - } - - /* Make sure we are not holding the rwlock as a writer. This is - a deadlock situation we recognize and report. */ - if (__builtin_expect (rwlock->__data.__writer - == THREAD_GETMEM (THREAD_SELF, tid), 0)) - { - result = EDEADLK; - break; - } - - /* Make sure the passed in timeout value is valid. Ideally this - test would be executed once. But since it must not be - performed if we would not block at all simply moving the test - to the front is no option. Replicating all the code is - costly while this test is not. */ - if (__builtin_expect (abstime->tv_nsec >= 1000000000 - || abstime->tv_nsec < 0, 0)) - { - result = EINVAL; - break; - } - - /* Get the current time. So far we support only one clock. */ - struct timeval tv; - (void) gettimeofday (&tv, NULL); - - /* Convert the absolute timeout value to a relative timeout. */ - struct timespec rt; - rt.tv_sec = abstime->tv_sec - tv.tv_sec; - rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000; - if (rt.tv_nsec < 0) - { - rt.tv_nsec += 1000000000; - --rt.tv_sec; - } - /* Did we already time out? */ - if (rt.tv_sec < 0) - { - result = ETIMEDOUT; - break; - } - - /* Remember that we are a writer. */ - if (++rwlock->__data.__nr_writers_queued == 0) - { - /* Overflow on number of queued writers. */ - --rwlock->__data.__nr_writers_queued; - result = EAGAIN; - break; - } - - int waitval = rwlock->__data.__writer_wakeup; - - /* Free the lock. */ - lll_mutex_unlock (rwlock->__data.__lock); - - /* Wait for the writer or reader(s) to finish. */ - err = lll_futex_timed_wait (&rwlock->__data.__writer_wakeup, - waitval, &rt); - - /* Get the lock. */ - lll_mutex_lock (rwlock->__data.__lock); - - /* To start over again, remove the thread from the writer list. */ - --rwlock->__data.__nr_writers_queued; - - /* Did the futex call time out? */ - if (err == -ETIMEDOUT) - { - result = ETIMEDOUT; - break; - } - } - - /* We are done, free the lock. */ - lll_mutex_unlock (rwlock->__data.__lock); - - return result; -} diff --git a/nptl/sysdeps/pthread/pthread_rwlock_unlock.c b/nptl/sysdeps/pthread/pthread_rwlock_unlock.c deleted file mode 100644 index 9cae8b6..0000000 --- a/nptl/sysdeps/pthread/pthread_rwlock_unlock.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Martin Schwidefsky , 2003. - - 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 -#include -#include -#include -#include - -/* Unlock RWLOCK. */ -int -__pthread_rwlock_unlock (pthread_rwlock_t *rwlock) -{ - lll_mutex_lock (rwlock->__data.__lock); - if (rwlock->__data.__writer) - rwlock->__data.__writer = 0; - else - --rwlock->__data.__nr_readers; - if (rwlock->__data.__nr_readers == 0) - { - if (rwlock->__data.__nr_writers_queued) - { - ++rwlock->__data.__writer_wakeup; - lll_mutex_unlock (rwlock->__data.__lock); - lll_futex_wake (&rwlock->__data.__writer_wakeup, 1); - return 0; - } - else if (rwlock->__data.__nr_readers_queued) - { - ++rwlock->__data.__readers_wakeup; - lll_mutex_unlock (rwlock->__data.__lock); - lll_futex_wake (&rwlock->__data.__readers_wakeup, INT_MAX); - return 0; - } - } - lll_mutex_unlock (rwlock->__data.__lock); - return 0; -} - -weak_alias (__pthread_rwlock_unlock, pthread_rwlock_unlock) -strong_alias (__pthread_rwlock_unlock, __pthread_rwlock_unlock_internal) diff --git a/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c b/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c deleted file mode 100644 index 822aeed..0000000 --- a/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright (C) 2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Martin Schwidefsky , 2003. - - 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 -#include -#include -#include -#include - - -/* Acquire write lock for RWLOCK. */ -int -__pthread_rwlock_wrlock (rwlock) - pthread_rwlock_t *rwlock; -{ - int result = 0; - - /* Make sure we are along. */ - lll_mutex_lock (rwlock->__data.__lock); - - while (1) - { - /* Get the rwlock if there is no writer and no reader. */ - if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0) - { - /* Mark self as writer. */ - rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid); - break; - } - - /* Make sure we are not holding the rwlock as a writer. This is - a deadlock situation we recognize and report. */ - if (__builtin_expect (rwlock->__data.__writer - == THREAD_GETMEM (THREAD_SELF, tid), 0)) - { - result = EDEADLK; - break; - } - - /* Remember that we are a writer. */ - if (++rwlock->__data.__nr_writers_queued == 0) - { - /* Overflow on number of queued writers. */ - --rwlock->__data.__nr_writers_queued; - result = EAGAIN; - break; - } - - int waitval = rwlock->__data.__writer_wakeup; - - /* Free the lock. */ - lll_mutex_unlock (rwlock->__data.__lock); - - /* Wait for the writer or reader(s) to finish. */ - lll_futex_wait (&rwlock->__data.__writer_wakeup, waitval); - - /* Get the lock. */ - lll_mutex_lock (rwlock->__data.__lock); - - /* To start over again, remove the thread from the writer list. */ - --rwlock->__data.__nr_writers_queued; - } - - /* We are done, free the lock. */ - lll_mutex_unlock (rwlock->__data.__lock); - - return result; -} - -weak_alias (__pthread_rwlock_wrlock, pthread_rwlock_wrlock) -strong_alias (__pthread_rwlock_wrlock, __pthread_rwlock_wrlock_internal) diff --git a/nptl/sysdeps/pthread/pthread_spin_destroy.c b/nptl/sysdeps/pthread/pthread_spin_destroy.c deleted file mode 100644 index 4d0109c..0000000 --- a/nptl/sysdeps/pthread/pthread_spin_destroy.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2002. - - 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 "pthreadP.h" - - -int -pthread_spin_destroy (lock) - pthread_spinlock_t *lock; -{ - /* Nothing to do. */ - return 0; -} diff --git a/nptl/sysdeps/pthread/pthread_spin_init.c b/nptl/sysdeps/pthread/pthread_spin_init.c deleted file mode 100644 index c227508..0000000 --- a/nptl/sysdeps/pthread/pthread_spin_init.c +++ /dev/null @@ -1,28 +0,0 @@ -/* pthread_spin_init -- initialize a spin lock. Generic version. - Copyright (C) 2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Paul Mackerras , 2003. - - 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 "pthreadP.h" - -int -pthread_spin_init (pthread_spinlock_t *lock, int pshared) -{ - *lock = 0; - return 0; -} diff --git a/nptl/sysdeps/pthread/pthread_spin_unlock.c b/nptl/sysdeps/pthread/pthread_spin_unlock.c deleted file mode 100644 index f97cadf..0000000 --- a/nptl/sysdeps/pthread/pthread_spin_unlock.c +++ /dev/null @@ -1,30 +0,0 @@ -/* pthread_spin_unlock -- unlock a spin lock. Generic version. - Copyright (C) 2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Paul Mackerras , 2003. - - 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 "pthreadP.h" -#include - -int -pthread_spin_unlock (pthread_spinlock_t *lock) -{ - atomic_full_barrier (); - *lock = 0; - return 0; -} diff --git a/nptl/sysdeps/s390/tls.h b/nptl/sysdeps/s390/tls.h index 8e8f86d..6f6f17b 100644 --- a/nptl/sysdeps/s390/tls.h +++ b/nptl/sysdeps/s390/tls.h @@ -1,5 +1,5 @@ /* Definition for thread-local data handling. NPTL/s390 version. - Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2006 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 +50,6 @@ typedef struct int multiple_threads; uintptr_t sysinfo; uintptr_t stack_guard; - int gscope_flag; } tcbhead_t; # ifndef __s390x__ @@ -67,9 +66,6 @@ typedef struct # error "TLS support is required." #endif -/* Signal that TLS support is available. */ -#define USE_TLS 1 - /* Alignment requirement for the stack. For IA-32 this is governed by the SSE memory functions. */ #define STACK_ALIGN 16 @@ -172,29 +168,6 @@ typedef struct #define THREAD_SET_POINTER_GUARD(value) #define THREAD_COPY_POINTER_GUARD(descr) -/* Get and set the global scope generation counter in struct pthread. */ -#define THREAD_GSCOPE_FLAG_UNUSED 0 -#define THREAD_GSCOPE_FLAG_USED 1 -#define THREAD_GSCOPE_FLAG_WAIT 2 -#define THREAD_GSCOPE_RESET_FLAG() \ - do \ - { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ - THREAD_GSCOPE_FLAG_UNUSED); \ - if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ - } \ - while (0) -#define THREAD_GSCOPE_SET_FLAG() \ - do \ - { \ - THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \ - atomic_write_barrier (); \ - } \ - while (0) -#define THREAD_GSCOPE_WAIT() \ - GL(dl_wait_lookup_done) () - #endif /* __ASSEMBLER__ */ #endif /* tls.h */ diff --git a/nptl/sysdeps/sh/tls.h b/nptl/sysdeps/sh/tls.h index 2873fe7..d9aa107 100644 --- a/nptl/sysdeps/sh/tls.h +++ b/nptl/sysdeps/sh/tls.h @@ -1,5 +1,5 @@ /* Definition for thread-local data handling. NPTL/SH version. - Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2005, 2006 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 @@ -56,9 +56,6 @@ typedef struct # error "TLS support is required." #endif -/* Signal that TLS support is available. */ -# define USE_TLS 1 - #ifndef __ASSEMBLER__ /* Get system call information. */ @@ -153,29 +150,6 @@ typedef struct __asm __volatile ("stc gbr,%0" : "=r" (__tcbp)); \ ((tcbhead_t *) (descr + 1))->pointer_guard = __tcbp->pointer_guard;}) -/* Get and set the global scope generation counter in struct pthread. */ -#define THREAD_GSCOPE_FLAG_UNUSED 0 -#define THREAD_GSCOPE_FLAG_USED 1 -#define THREAD_GSCOPE_FLAG_WAIT 2 -#define THREAD_GSCOPE_RESET_FLAG() \ - do \ - { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ - THREAD_GSCOPE_FLAG_UNUSED); \ - if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ - } \ - while (0) -#define THREAD_GSCOPE_SET_FLAG() \ - do \ - { \ - THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \ - atomic_write_barrier (); \ - } \ - while (0) -#define THREAD_GSCOPE_WAIT() \ - GL(dl_wait_lookup_done) () - #endif /* __ASSEMBLER__ */ #endif /* tls.h */ diff --git a/nptl/sysdeps/sparc/tls.h b/nptl/sysdeps/sparc/tls.h index 90a3e0b..4fbe426 100644 --- a/nptl/sysdeps/sparc/tls.h +++ b/nptl/sysdeps/sparc/tls.h @@ -1,5 +1,5 @@ /* Definitions for thread-local data handling. NPTL/sparc version. - Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2005, 2006 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 @@ -46,15 +46,9 @@ typedef struct dtv_t *dtv; void *self; int multiple_threads; -#if __WORDSIZE == 64 - int gscope_flag; -#endif uintptr_t sysinfo; uintptr_t stack_guard; uintptr_t pointer_guard; -#if __WORDSIZE != 64 - int gscope_flag; -#endif } tcbhead_t; #else /* __ASSEMBLER__ */ @@ -66,9 +60,6 @@ typedef struct # error "TLS support is required." #endif -/* Signal that TLS support is available. */ -#define USE_TLS 1 - #ifndef __ASSEMBLER__ /* Get system call information. */ # include @@ -150,29 +141,6 @@ register struct pthread *__thread_self __asm__("%g7"); # define THREAD_COPY_POINTER_GUARD(descr) \ ((descr)->header.pointer_guard = THREAD_GET_POINTER_GUARD ()) -/* Get and set the global scope generation counter in struct pthread. */ -#define THREAD_GSCOPE_FLAG_UNUSED 0 -#define THREAD_GSCOPE_FLAG_USED 1 -#define THREAD_GSCOPE_FLAG_WAIT 2 -#define THREAD_GSCOPE_RESET_FLAG() \ - do \ - { int __res \ - = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ - THREAD_GSCOPE_FLAG_UNUSED); \ - if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ - } \ - while (0) -#define THREAD_GSCOPE_SET_FLAG() \ - do \ - { \ - THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \ - atomic_write_barrier (); \ - } \ - while (0) -#define THREAD_GSCOPE_WAIT() \ - GL(dl_wait_lookup_done) () - #endif /* !ASSEMBLER */ #endif /* tls.h */ diff --git a/nptl/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h b/nptl/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h index e071878..9b27b1f 100644 --- a/nptl/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h +++ b/nptl/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h @@ -87,3 +87,6 @@ /* Maximum message queue priority level. */ #define MQ_PRIO_MAX 32768 + +/* Maximum value the semaphore can have. */ +#define SEM_VALUE_MAX (2147483647) diff --git a/nptl/sysdeps/unix/sysv/linux/alpha/bits/semaphore.h b/nptl/sysdeps/unix/sysv/linux/alpha/bits/semaphore.h index 6dadfda..be4469c 100644 --- a/nptl/sysdeps/unix/sysv/linux/alpha/bits/semaphore.h +++ b/nptl/sysdeps/unix/sysv/linux/alpha/bits/semaphore.h @@ -26,9 +26,6 @@ /* Value returned if `sem_open' failed. */ #define SEM_FAILED ((sem_t *) 0) -/* Maximum value the semaphore can have. */ -#define SEM_VALUE_MAX (2147483647) - typedef union { diff --git a/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h b/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h index b639ba4..4b7b297 100644 --- a/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h +++ b/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h @@ -87,3 +87,6 @@ /* Maximum message queue priority level. */ #define MQ_PRIO_MAX 32768 + +/* Maximum value the semaphore can have. */ +#define SEM_VALUE_MAX (2147483647) diff --git a/nptl/sysdeps/unix/sysv/linux/fork.c b/nptl/sysdeps/unix/sysv/linux/fork.c index 98bb237..8409744 100644 --- a/nptl/sysdeps/unix/sysv/linux/fork.c +++ b/nptl/sysdeps/unix/sysv/linux/fork.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -167,11 +167,8 @@ __libc_fork (void) allp->handler->child_handler (); /* Note that we do not have to wake any possible waiter. - This is the only thread in the new process. The count - may have been bumped up by other threads doing a fork. - We reset it to 1, to avoid waiting for non-existing - thread(s) to release the count. */ - allp->handler->refcntr = 1; + This is the only thread in the new process. */ + --allp->handler->refcntr; /* XXX We could at this point look through the object pool and mark all objects not on the __fork_handlers list as diff --git a/nptl/sysdeps/unix/sysv/linux/i386/bits/semaphore.h b/nptl/sysdeps/unix/sysv/linux/i386/bits/semaphore.h index e6c5d84..934493c 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/bits/semaphore.h +++ b/nptl/sysdeps/unix/sysv/linux/i386/bits/semaphore.h @@ -28,9 +28,6 @@ /* Value returned if `sem_open' failed. */ #define SEM_FAILED ((sem_t *) 0) -/* Maximum value the semaphore can have. */ -#define SEM_VALUE_MAX (2147483647) - typedef union { diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S index bf70e17..aa1f9f4 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -79,7 +79,10 @@ sem_timedwait: jae 6f cfi_offset(3, -16) /* %ebx */ -7: xorl %ecx, %ecx +7: call __pthread_enable_asynccancel + movl %eax, 8(%esp) + + xorl %ecx, %ecx movl %esp, %ebx movl %ecx, %edx movl $SYS_gettimeofday, %eax @@ -102,10 +105,6 @@ sem_timedwait: movl %ecx, (%esp) /* Store relative timeout. */ movl %edx, 4(%esp) - - call __pthread_enable_asynccancel - movl %eax, 8(%esp) - movl 28(%esp), %ebx xorl %ecx, %ecx movl %esp, %esi diff --git a/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h index d60dcd33..1cd4b9b 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h +++ b/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h @@ -58,6 +58,7 @@ # define SAVE_OLDTYPE_3 SAVE_OLDTYPE_2 # define SAVE_OLDTYPE_4 SAVE_OLDTYPE_2 # define SAVE_OLDTYPE_5 SAVE_OLDTYPE_2 +# define SAVE_OLDTYPE_6 SAVE_OLDTYPE_2 # define PUSHCARGS_0 /* No arguments to push. */ # define DOCARGS_0 /* No arguments to frob. */ @@ -101,6 +102,14 @@ # define _POPCARGS_5 _POPCARGS_4; popl %edi; \ cfi_adjust_cfa_offset (-4); cfi_restore (edi); +# define PUSHCARGS_6 _PUSHCARGS_6 +# define DOCARGS_6 _DOARGS_6 (44) +# define POPCARGS_6 _POPCARGS_6 +# define _PUSHCARGS_6 pushl %ebp; cfi_adjust_cfa_offset (4); \ + cfi_rel_offset (ebp, 0); _PUSHCARGS_5 +# define _POPCARGS_6 _POPCARGS_5; popl %ebp; \ + cfi_adjust_cfa_offset (-4); cfi_restore (ebp); + # ifdef IS_IN_libpthread # define CENABLE call __pthread_enable_asynccancel; # define CDISABLE call __pthread_disable_asynccancel @@ -122,6 +131,7 @@ # define POPSTATE_3 POPSTATE_2 # define POPSTATE_4 POPSTATE_3 # define POPSTATE_5 POPSTATE_4 +# define POPSTATE_6 POPSTATE_5 # ifndef __ASSEMBLER__ # define SINGLE_THREAD_P \ diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h b/nptl/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h index f837250..83db31e 100644 --- a/nptl/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h +++ b/nptl/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h @@ -87,3 +87,6 @@ /* Maximum message queue priority level. */ #define MQ_PRIO_MAX 32768 + +/* Maximum value the semaphore can have. */ +#define SEM_VALUE_MAX (2147483647) diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/bits/semaphore.h b/nptl/sysdeps/unix/sysv/linux/ia64/bits/semaphore.h index 2329e98..0684aeb 100644 --- a/nptl/sysdeps/unix/sysv/linux/ia64/bits/semaphore.h +++ b/nptl/sysdeps/unix/sysv/linux/ia64/bits/semaphore.h @@ -28,9 +28,6 @@ /* Value returned if `sem_open' failed. */ #define SEM_FAILED ((sem_t *) 0) -/* Maximum value the semaphore can have. */ -#define SEM_VALUE_MAX (2147483647) - typedef union { diff --git a/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c b/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c index 30ef991..3e88ee1 100644 --- a/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c +++ b/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2006. @@ -30,10 +30,6 @@ __lll_robust_lock_wait (int *futex) int oldval = *futex; int tid = THREAD_GETMEM (THREAD_SELF, tid); - /* If the futex changed meanwhile try locking again. */ - if (oldval == 0) - goto try; - do { if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0)) @@ -45,9 +41,6 @@ __lll_robust_lock_wait (int *futex) continue; lll_futex_wait (futex, newval); - - try: - ; } while ((oldval = atomic_compare_and_exchange_val_acq (futex, tid | FUTEX_WAITERS, @@ -64,11 +57,6 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime) return EINVAL; int tid = THREAD_GETMEM (THREAD_SELF, tid); - int oldval = *futex; - - /* If the futex changed meanwhile try locking again. */ - if (oldval == 0) - goto try; do { @@ -92,6 +80,7 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime) return ETIMEDOUT; /* Wait. */ + int oldval = *futex; if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0)) return oldval; @@ -101,13 +90,8 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime) continue; lll_futex_timed_wait (futex, newval, &rt); - - try: - ; } - while ((oldval = atomic_compare_and_exchange_val_acq (futex, - tid | FUTEX_WAITERS, - 0)) != 0); + while (atomic_compare_and_exchange_bool_acq (futex, tid | FUTEX_WAITERS, 0)); return 0; } diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/Versions b/nptl/sysdeps/unix/sysv/linux/powerpc/Versions index 9977847..6b5a036 100644 --- a/nptl/sysdeps/unix/sysv/linux/powerpc/Versions +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/Versions @@ -2,4 +2,8 @@ libpthread { GLIBC_2.3.4 { longjmp; siglongjmp; } + GLIBC_2.6 { + # Changed PTHREAD_STACK_MIN. + pthread_attr_setstack; pthread_attr_setstacksize; + } } diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h new file mode 100644 index 0000000..02e2d17 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h @@ -0,0 +1,93 @@ +/* Minimum guaranteed maximum values for system limits. Linux/PPC version. + Copyright (C) 1993-1998,2000,2002-2004,2006 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; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* The kernel header pollutes the namespace with the NR_OPEN symbol + and defines LINK_MAX although filesystems have different maxima. A + similar thing is true for OPEN_MAX: the limit can be changed at + runtime and therefore the macro must not be defined. Remove this + after including the header if necessary. */ +#ifndef NR_OPEN +# define __undef_NR_OPEN +#endif +#ifndef LINK_MAX +# define __undef_LINK_MAX +#endif +#ifndef OPEN_MAX +# define __undef_OPEN_MAX +#endif + +/* The kernel sources contain a file with all the needed information. */ +#include + +/* Have to remove NR_OPEN? */ +#ifdef __undef_NR_OPEN +# undef NR_OPEN +# undef __undef_NR_OPEN +#endif +/* Have to remove LINK_MAX? */ +#ifdef __undef_LINK_MAX +# undef LINK_MAX +# undef __undef_LINK_MAX +#endif +/* Have to remove OPEN_MAX? */ +#ifdef __undef_OPEN_MAX +# undef OPEN_MAX +# undef __undef_OPEN_MAX +#endif + +/* The number of data keys per process. */ +#define _POSIX_THREAD_KEYS_MAX 128 +/* This is the value this implementation supports. */ +#define PTHREAD_KEYS_MAX 1024 + +/* Controlling the iterations of destructors for thread-specific data. */ +#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 +/* Number of iterations this implementation does. */ +#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS + +/* The number of threads per process. */ +#define _POSIX_THREAD_THREADS_MAX 64 +/* We have no predefined limit on the number of threads. */ +#undef PTHREAD_THREADS_MAX + +/* Maximum amount by which a process can descrease its asynchronous I/O + priority level. */ +#define AIO_PRIO_DELTA_MAX 20 + +/* Minimum size for a thread. At least two pages for systems with 64k + pages. */ +#define PTHREAD_STACK_MIN 131072 + +/* Maximum number of timer expiration overruns. */ +#define DELAYTIMER_MAX 2147483647 + +/* Maximum tty name length. */ +#define TTY_NAME_MAX 32 + +/* Maximum login name length. This is arbitrary. */ +#define LOGIN_NAME_MAX 256 + +/* Maximum host name length. */ +#define HOST_NAME_MAX 64 + +/* Maximum message queue priority level. */ +#define MQ_PRIO_MAX 32768 + +/* Maximum value the semaphore can have. */ +#define SEM_VALUE_MAX (2147483647) diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/semaphore.h b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/semaphore.h index 8123b41..c7f121b 100644 --- a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/semaphore.h +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/semaphore.h @@ -33,9 +33,6 @@ /* Value returned if `sem_open' failed. */ #define SEM_FAILED ((sem_t *) 0) -/* Maximum value the semaphore can have. */ -#define SEM_VALUE_MAX (2147483647) - typedef union { diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstack.c b/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstack.c new file mode 100644 index 0000000..2cb0a13 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstack.c @@ -0,0 +1,2 @@ +#define NEW_VERNUM GLIBC_2_6 +#include diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c b/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c new file mode 100644 index 0000000..9472dd1 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c @@ -0,0 +1,8 @@ +#define NEW_VERNUM GLIBC_2_6 +#define STACKSIZE_ADJUST \ + do { \ + size_t ps = __getpagesize (); \ + if (stacksize < 2 * ps) \ + stacksize = 2 * ps; \ + } while (0) +#include diff --git a/nptl/sysdeps/unix/sysv/linux/rtld-lowlevel.h b/nptl/sysdeps/unix/sysv/linux/rtld-lowlevel.h index 39db5a3..6b3d368 100644 --- a/nptl/sysdeps/unix/sysv/linux/rtld-lowlevel.h +++ b/nptl/sysdeps/unix/sysv/linux/rtld-lowlevel.h @@ -1,5 +1,5 @@ /* Defintions for lowlevel handling in ld.so. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2006 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 diff --git a/nptl/sysdeps/unix/sysv/linux/s390/bits/semaphore.h b/nptl/sysdeps/unix/sysv/linux/s390/bits/semaphore.h index ead2663..111462f 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/bits/semaphore.h +++ b/nptl/sysdeps/unix/sysv/linux/s390/bits/semaphore.h @@ -32,9 +32,6 @@ /* Value returned if `sem_open' failed. */ #define SEM_FAILED ((sem_t *) 0) -/* Maximum value the semaphore can have. */ -#define SEM_VALUE_MAX (2147483647) - typedef union { diff --git a/nptl/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h index 17ab562..6b02402 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h +++ b/nptl/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h @@ -45,7 +45,13 @@ L(pseudo_cancel): \ bas %r14,0(%r1,%r13); \ lr %r0,%r2; \ LM_##args \ - DO_CALL(syscall_name, args); \ + .if SYS_ify (syscall_name) < 256; \ + svc SYS_ify (syscall_name); \ + .else; \ + lhi %r1,SYS_ify (syscall_name); \ + svc 0; \ + .endif; \ + LR7_##args \ l %r1,2f-0b(%r13); \ lr %r12,%r2; \ lr %r2,%r0; \ @@ -89,6 +95,7 @@ L(pseudo_end): #define STM_3 stm %r2,%r4,8(%r15); #define STM_4 stm %r2,%r5,8(%r15); #define STM_5 stm %r2,%r5,8(%r15); +#define STM_6 stm %r2,%r7,8(%r15); #define LM_0 /* Nothing */ #define LM_1 l %r2,8+96(%r15); @@ -96,6 +103,18 @@ L(pseudo_end): #define LM_3 lm %r2,%r4,8+96(%r15); #define LM_4 lm %r2,%r5,8+96(%r15); #define LM_5 lm %r2,%r5,8+96(%r15); +#define LM_6 lm %r2,%r5,8+96(%r15); \ + cfi_offset (%r7, -68); \ + l %r7,96+96(%r15); + +#define LR7_0 /* Nothing */ +#define LR7_1 /* Nothing */ +#define LR7_2 /* Nothing */ +#define LR7_3 /* Nothing */ +#define LR7_4 /* Nothing */ +#define LR7_5 /* Nothing */ +#define LR7_6 l %r7,28+96(%r15); \ + cfi_restore (%r7); # ifndef __ASSEMBLER__ # define SINGLE_THREAD_P \ diff --git a/nptl/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h index 77ce742..70d5a86 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h +++ b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h @@ -42,7 +42,13 @@ L(pseudo_cancel): \ brasl %r14,CENABLE; \ lgr %r0,%r2; \ LM_##args \ - DO_CALL(syscall_name, args); \ + .if SYS_ify (syscall_name) < 256; \ + svc SYS_ify (syscall_name); \ + .else; \ + lghi %r1,SYS_ify (syscall_name); \ + svc 0; \ + .endif; \ + LR7_##args \ lgr %r13,%r2; \ lgr %r2,%r0; \ brasl %r14,CDISABLE; \ @@ -85,6 +91,7 @@ L(pseudo_end): #define STM_3 stmg %r2,%r4,16(%r15); #define STM_4 stmg %r2,%r5,16(%r15); #define STM_5 stmg %r2,%r5,16(%r15); +#define STM_6 stmg %r2,%r7,16(%r15); #define LM_0 /* Nothing */ #define LM_1 lg %r2,16+160(%r15); @@ -92,6 +99,18 @@ L(pseudo_end): #define LM_3 lmg %r2,%r4,16+160(%r15); #define LM_4 lmg %r2,%r5,16+160(%r15); #define LM_5 lmg %r2,%r5,16+160(%r15); +#define LM_6 lmg %r2,%r5,16+160(%r15); \ + cfi_offset (%r7, -104); \ + lg %r7,160+160(%r15); + +#define LR7_0 /* Nothing */ +#define LR7_1 /* Nothing */ +#define LR7_2 /* Nothing */ +#define LR7_3 /* Nothing */ +#define LR7_4 /* Nothing */ +#define LR7_5 /* Nothing */ +#define LR7_6 lg %r7,56+160(%r15); \ + cfi_restore (%r7); # if defined IS_IN_libpthread || !defined NOT_IN_libc # ifndef __ASSEMBLER__ diff --git a/nptl/sysdeps/unix/sysv/linux/sh/bits/semaphore.h b/nptl/sysdeps/unix/sysv/linux/sh/bits/semaphore.h index e6c5d84..934493c 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/bits/semaphore.h +++ b/nptl/sysdeps/unix/sysv/linux/sh/bits/semaphore.h @@ -28,9 +28,6 @@ /* Value returned if `sem_open' failed. */ #define SEM_FAILED ((sem_t *) 0) -/* Maximum value the semaphore can have. */ -#define SEM_VALUE_MAX (2147483647) - typedef union { diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h b/nptl/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h index e082ea8..2576f12 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h +++ b/nptl/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h @@ -87,3 +87,6 @@ /* Maximum message queue priority level. */ #define MQ_PRIO_MAX 32768 + +/* Maximum value the semaphore can have. */ +#define SEM_VALUE_MAX (2147483647) diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/bits/semaphore.h b/nptl/sysdeps/unix/sysv/linux/sparc/bits/semaphore.h index 7f3a328..8fd7d34 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/bits/semaphore.h +++ b/nptl/sysdeps/unix/sysv/linux/sparc/bits/semaphore.h @@ -33,9 +33,6 @@ /* Value returned if `sem_open' failed. */ #define SEM_FAILED ((sem_t *) 0) -/* Maximum value the semaphore can have. */ -#define SEM_VALUE_MAX (2147483647) - typedef union { diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c index 7613863..55d20eb 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c +++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c @@ -1 +1 @@ -#include "../../../../../../pthread/pthread_barrier_wait.c" +#include "../../../../../../../pthread_barrier_wait.c" diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/bits/semaphore.h b/nptl/sysdeps/unix/sysv/linux/x86_64/bits/semaphore.h index 57edbbb..e973bc5 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/bits/semaphore.h +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/bits/semaphore.h @@ -33,9 +33,6 @@ /* Value returned if `sem_open' failed. */ #define SEM_FAILED ((sem_t *) 0) -/* Maximum value the semaphore can have. */ -#define SEM_VALUE_MAX (2147483647) - typedef union { diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S index 394dec8..90f10e6 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -164,7 +164,7 @@ __lll_mutex_timedlock_wait: 8: /* NB: %edx == 2 */ xorl %eax, %eax LOCK - cmpxchgl %edx, (%r12) + cmpxchgl %edx, (%rdi) jnz 7f 6: addq $16, %rsp diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h index 97085bf..4030bb7 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -35,6 +35,7 @@ #define SYS_futex 202 #define FUTEX_WAIT 0 #define FUTEX_WAKE 1 +#define FUTEX_CMP_REQUEUE 4 #define FUTEX_LOCK_PI 6 #define FUTEX_UNLOCK_PI 7 #define FUTEX_TRYLOCK_PI 8 @@ -150,7 +151,7 @@ LLL_STUB_UNWIND_INFO_END #define lll_futex_wait(futex, val) \ ({ \ int __status; \ - register __typeof (val) _val asm ("edx") = (val); \ + register __typeof (val) _val __asm ("edx") = (val); \ __asm __volatile ("xorq %%r10, %%r10\n\t" \ "syscall" \ : "=a" (__status) \ @@ -163,22 +164,22 @@ LLL_STUB_UNWIND_INFO_END #define lll_futex_timed_wait(futex, val, timeout) \ ({ \ - register const struct timespec *__to __asm__ ("r10") = timeout; \ + register const struct timespec *__to __asm ("r10") = timeout; \ int __status; \ - register __typeof (val) _val asm ("edx") = (val); \ + register __typeof (val) _val __asm ("edx") = (val); \ __asm __volatile ("syscall" \ : "=a" (__status) \ : "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAIT), \ "d" (_val), "r" (__to) \ : "memory", "cc", "r11", "cx"); \ - __status; \ + -__status; \ }) #define lll_futex_wake(futex, nr) \ do { \ int __ignore; \ - register __typeof (nr) _nr asm ("edx") = (nr); \ + register __typeof (nr) _nr __asm ("edx") = (nr); \ __asm __volatile ("syscall" \ : "=a" (__ignore) \ : "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAKE), \ @@ -423,6 +424,21 @@ extern int __lll_mutex_unlock_wait (int *__futex) attribute_hidden; : "cx", "r11", "cc", "memory"); }) +/* Returns non-zero if error happened, zero if success. */ +#define lll_futex_requeue(ftx, nr_wake, nr_move, mutex, val) \ + ({ int __res; \ + register int __nr_move __asm ("r10") = nr_move; \ + register void *__mutex __asm ("r8") = mutex; \ + register int __val __asm ("r9") = val; \ + __asm __volatile ("syscall" \ + : "=a" (__res) \ + : "0" (__NR_futex), "D" ((void *) ftx), \ + "S" (FUTEX_CMP_REQUEUE), "d" (nr_wake), \ + "r" (__nr_move), "r" (__mutex), "r" (__val) \ + : "cx", "r11", "cc", "memory"); \ + __res < 0; }) + + #define lll_mutex_islocked(futex) \ (futex != LLL_MUTEX_LOCK_INITIALIZER) diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S index 51136cf..c44d3f5 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -79,7 +79,10 @@ sem_timedwait: cfi_offset(14, -24) /* %r14 */ jae 6f -7: xorl %esi, %esi +7: call __pthread_enable_asynccancel + movl %eax, 16(%rsp) + + xorl %esi, %esi movq %rsp, %rdi movq $VSYSCALL_ADDR_vgettimeofday, %rax callq *%rax @@ -102,9 +105,6 @@ sem_timedwait: movq %rdi, (%rsp) /* Store relative timeout. */ movq %rsi, 8(%rsp) - call __pthread_enable_asynccancel - movl %eax, 16(%rsp) - movq %rsp, %r10 movq %r12, %rdi xorl %esi, %esi diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h index b6385b1..7618573 100644 --- a/nptl/sysdeps/x86_64/tls.h +++ b/nptl/sysdeps/x86_64/tls.h @@ -1,5 +1,5 @@ /* Definition for thread-local data handling. nptl/x86_64 version. - Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006 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 @@ -47,7 +47,6 @@ typedef struct dtv_t *dtv; void *self; /* Pointer to the thread descriptor. */ int multiple_threads; - int gscope_flag; uintptr_t sysinfo; uintptr_t stack_guard; uintptr_t pointer_guard; @@ -63,9 +62,6 @@ typedef struct # error "TLS support is required." #endif -/* Signal that TLS support is available. */ -#define USE_TLS 1 - /* Alignment requirement for the stack. */ #define STACK_ALIGN 16 @@ -340,26 +336,6 @@ typedef struct = THREAD_GETMEM (THREAD_SELF, header.pointer_guard)) -/* Get and set the global scope generation counter in the TCB head. */ -#define THREAD_GSCOPE_FLAG_UNUSED 0 -#define THREAD_GSCOPE_FLAG_USED 1 -#define THREAD_GSCOPE_FLAG_WAIT 2 -#define THREAD_GSCOPE_RESET_FLAG() \ - do \ - { int __res; \ - asm volatile ("xchgl %0, %%fs:%P1" \ - : "=r" (__res) \ - : "i" (offsetof (struct pthread, header.gscope_flag)), \ - "0" (THREAD_GSCOPE_FLAG_UNUSED)); \ - if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ - } \ - while (0) -#define THREAD_GSCOPE_SET_FLAG() \ - THREAD_SETMEM (THREAD_SELF, header.gscope_flag, THREAD_GSCOPE_FLAG_USED) -#define THREAD_GSCOPE_WAIT() \ - GL(dl_wait_lookup_done) () - #endif /* __ASSEMBLER__ */ #endif /* tls.h */ diff --git a/nptl/tst-cancel-wrappers.sh b/nptl/tst-cancel-wrappers.sh index 61b9fb5..d6f16d1 100644 --- a/nptl/tst-cancel-wrappers.sh +++ b/nptl/tst-cancel-wrappers.sh @@ -1,6 +1,6 @@ #! /bin/sh # Test whether all cancelable functions are cancelable. -# Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003 Free Software Foundation, Inc. # This file is part of the GNU C Library. # Contributed by Jakub Jelinek , 2002. @@ -26,7 +26,6 @@ C["close"]=1 C["connect"]=1 C["creat"]=1 C["fcntl"]=1 -C["fdatasync"]=1 C["fsync"]=1 C["msgrcv"]=1 C["msgsnd"]=1 diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c index 45df6ce..73cfa44 100644 --- a/nptl/tst-cancel4.c +++ b/nptl/tst-cancel4.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -1571,47 +1571,6 @@ tf_fsync (void *arg) static void * -tf_fdatasync (void *arg) -{ - if (arg == NULL) - // XXX If somebody can provide a portable test case in which fdatasync() - // blocks we can enable this test to run in both rounds. - abort (); - - tempfd = open ("Makefile", O_RDONLY); - if (tempfd == -1) - { - printf ("%s: cannot open Makefile\n", __FUNCTION__); - exit (1); - } - - int r = pthread_barrier_wait (&b2); - if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: barrier_wait failed\n", __FUNCTION__); - exit (1); - } - - r = pthread_barrier_wait (&b2); - if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) - { - printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); - exit (1); - } - - pthread_cleanup_push (cl, NULL); - - fdatasync (tempfd); - - pthread_cleanup_pop (0); - - printf ("%s: fdatasync returned\n", __FUNCTION__); - - exit (1); -} - - -static void * tf_msync (void *arg) { if (arg == NULL) @@ -2119,7 +2078,6 @@ static struct ADD_TEST (pread, 2, 1), ADD_TEST (pwrite, 2, 1), ADD_TEST (fsync, 2, 1), - ADD_TEST (fdatasync, 2, 1), ADD_TEST (msync, 2, 1), ADD_TEST (sendto, 2, 1), ADD_TEST (sendmsg, 2, 1), diff --git a/nptl/tst-robust9.c b/nptl/tst-robust9.c deleted file mode 100644 index 1d6ba17..0000000 --- a/nptl/tst-robust9.c +++ /dev/null @@ -1,94 +0,0 @@ -#include -#include -#include -#include -#include -#include - - -static pthread_mutex_t m; - -static void * -tf (void *data) -{ - int err = pthread_mutex_lock (&m); - if (err == EOWNERDEAD) - { - err = pthread_mutex_consistent_np (&m); - if (err) - { - puts ("pthread_mutex_consistent_np"); - exit (1); - } - } - else if (err) - { - puts ("pthread_mutex_lock"); - exit (1); - } - printf ("thread%ld got the lock.\n", (long int) data); - sleep (1); - /* exit without unlock */ - return NULL; -} - -static int -do_test (void) -{ - int err, i; - pthread_t t[3]; - pthread_mutexattr_t ma; - - pthread_mutexattr_init (&ma); - err = pthread_mutexattr_setrobust_np (&ma, PTHREAD_MUTEX_ROBUST_NP); - if (err) - { - puts ("pthread_mutexattr_setrobust_np"); - return 1; - } -#ifdef ENABLE_PI - if (pthread_mutexattr_setprotocol (&ma, PTHREAD_PRIO_INHERIT) != 0) - { - puts ("pthread_mutexattr_setprotocol failed"); - return 1; - } -#endif - err = pthread_mutex_init (&m, &ma); -#ifdef ENABLE_PI - if (err == ENOTSUP) - { - puts ("PI robust mutexes not supported"); - return 0; - } -#endif - if (err) - { - puts ("pthread_mutex_init"); - return 1; - } - - for (i = 0; i < sizeof (t) / sizeof (t[0]); i++) - { - err = pthread_create (&t[i], NULL, tf, (void *) (long int) i); - if (err) - { - puts ("pthread_create"); - return 1; - } - } - - for (i = 0; i < sizeof (t) / sizeof (t[0]); i++) - { - err = pthread_join (t[i], NULL); - if (err) - { - puts ("pthread_join"); - return 1; - } - } - return 0; -} - -#define TIMEOUT 5 -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" diff --git a/nptl/tst-robustpi9.c b/nptl/tst-robustpi9.c deleted file mode 100644 index d059aa7..0000000 --- a/nptl/tst-robustpi9.c +++ /dev/null @@ -1,2 +0,0 @@ -#define ENABLE_PI 1 -#include "tst-robust9.c" diff --git a/nptl/tst-sem10.c b/nptl/tst-sem10.c deleted file mode 100644 index 9f6e870..0000000 --- a/nptl/tst-sem10.c +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (C) 2007 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek , 2007. - - 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 -#include -#include -#include -#include -#include -#include - - -static int -do_test (void) -{ - sem_t s; - if (sem_init (&s, 0, 0) == -1) - { - puts ("sem_init failed"); - return 1; - } - - struct timeval tv; - if (gettimeofday (&tv, NULL) != 0) - { - puts ("gettimeofday failed"); - return 1; - } - - struct timespec ts; - TIMEVAL_TO_TIMESPEC (&tv, &ts); - - /* Set ts to yesterday. */ - ts.tv_sec -= 86400; - - int type_before; - if (pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &type_before) != 0) - { - puts ("first pthread_setcanceltype failed"); - return 1; - } - - errno = 0; - if (TEMP_FAILURE_RETRY (sem_timedwait (&s, &ts)) != -1) - { - puts ("sem_timedwait succeeded"); - return 1; - } - if (errno != ETIMEDOUT) - { - printf ("sem_timedwait return errno = %d instead of ETIMEDOUT\n", - errno); - return 1; - } - - int type_after; - if (pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &type_after) != 0) - { - puts ("second pthread_setcanceltype failed"); - return 1; - } - if (type_after != PTHREAD_CANCEL_DEFERRED) - { - puts ("sem_timedwait changed cancellation type"); - return 1; - } - - return 0; -} - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" diff --git a/nptl/tst-tls5.h b/nptl/tst-tls5.h index b7c14eb..9a76ab7 100644 --- a/nptl/tst-tls5.h +++ b/nptl/tst-tls5.h @@ -2,7 +2,7 @@ #include #include -#if USE_TLS && HAVE___THREAD +#if HAVE___THREAD struct tls_obj { -- cgit v1.1