diff options
Diffstat (limited to 'nptl')
133 files changed, 1013 insertions, 3046 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog index 0a463b2164..88c3210a69 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,186 +1,10 @@ -2007-07-06 Kaz Kojima <kkojima@rr.iij4u.or.jp> - - * sysdeps/sh/tls.h: Include stdlib.h, list.h, sysdep.h and - kernel-features.h. - -2007-05-16 Roland McGrath <roland@redhat.com> - - * init.c (__nptl_initial_report_events): New variable. - (__pthread_initialize_minimal_internal): Initialize pd->report_events - to that. - 2007-06-22 Jakub Jelinek <jakub@redhat.com> * pthread_getattr_np.c (pthread_getattr_np): Clear cpuset and cpusetsize if pthread_getaffinity_np failed with ENOSYS. -2007-06-19 Ulrich Drepper <drepper@redhat.com> - - * sysdeps/unix/sysv/linux/rtld-lowlevel.h: Remove mrlock - implementation. - -2007-06-18 Ulrich Drepper <drepper@redhat.com> - - * pthreadP.h: Define PTHREAD_MUTEX_TYPE. - * phtread_mutex_lock.c: Use PTHREAD_MUTEX_TYPE. - * pthread_mutex_timedlock.c: Likewise. - * pthread_mutex_trylock.c: Likewise. - * pthread_mutex_unlock.c: Likewise. - -2007-06-17 Andreas Schwab <schwab@suse.de> - - * sysdeps/pthread/pt-initfini.c: Tell gcc about the nonstandard - sections. - -2007-06-17 Ulrich Drepper <drepper@redhat.com> - - * allocatestack.c (allocate_stack): Make code compile if - __ASSUME_PRIVATE_FUTEX is set. - -2007-06-17 Kaz Kojima <kkojima@rr.iij4u.or.jp> - - * sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S: - (__pthread_rwlock_rdlock): Don't use non SH-3/4 instruction. - * sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S: - (__pthread_rwlock_wrlock): Likewise. - * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S: - (pthread_rwlock_timedrdlock): Likewise. - * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S: - (pthread_rwlock_timedwrlock): Likewise. - * sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S: - (__pthread_rwlock_unlock): Likewise. - -2007-06-10 Kaz Kojima <kkojima@rr.iij4u.or.jp> - - * sysdeps/sh/tcb-offsets.sym: Add PRIVATE_FUTEX. - * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Include endian.h. - Split __flags into __flags, __shared, __pad1 and __pad2. - * sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S: Use private - futexes if they are available. - * sysdeps/unix/sysv/linux/sh/lowlevellock.S: Adjust so that change - in libc-lowlevellock.S allow using private futexes. - * sysdeps/unix/sysv/linux/sh/lowlevellock.h: Define - FUTEX_PRIVATE_FLAG. Add additional parameter to lll_futex_wait, - lll_futex_timed_wait and lll_futex_wake. Change lll_futex_wait - to call lll_futex_timed_wait. Add lll_private_futex_wait, - lll_private_futex_timed_wait and lll_private_futex_wake. - (lll_robust_mutex_unlock): Fix typo. - * sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S: Use private - field in futex command setup. - * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Use - COND_NWAITERS_SHIFT instead of COND_CLOCK_BITS. - * sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S: Likewise. - * sysdeps/unix/sysv/linux/sh/pthread_once.S: Use private futexes - if they are available. Remove clear_once_control. - * sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S: Use private - futexes if they are available. - * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S: Likewise. - * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S: Likewise. - * sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S: Likewise. - * sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S: Likewise. - * sysdeps/unix/sysv/linux/sh/sem_post.S: Add private futex support. - Wake only when there are waiters. - * sysdeps/unix/sysv/linux/sh/sem_wait.S: Add private futex - support. Indicate that there are waiters. Remove unnecessary - extra cancellation test. - * sysdeps/unix/sysv/linux/sh/sem_timedwait.S: Likewise. Removed - left-over duplication of __sem_wait_cleanup. - -2007-06-07 Ulrich Drepper <drepper@redhat.com> - - * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Add additional - parameter to lll_futex_wait, lll_futex_timed_wait, and - lll_futex_wake. Change lll_futex_wait to call lll_futex_timed_wait. - Add lll_private_futex_wait, lll_private_futex_timed_wait, and - lll_private_futex_wake. - * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Likewise. - * allocatestack.c: Adjust use of lll_futex_* macros. - * init.c: Likewise. - * lowlevellock.h: Likewise. - * pthread_barrier_wait.c: Likewise. - * pthread_cond_broadcast.c: Likewise. - * pthread_cond_destroy.c: Likewise. - * pthread_cond_signal.c: Likewise. - * pthread_cond_timedwait.c: Likewise. - * pthread_cond_wait.c: Likewise. - * pthread_create.c: Likewise. - * pthread_mutex_lock.c: Likewise. - * pthread_mutex_setprioceiling.c: Likewise. - * pthread_mutex_timedlock.c: Likewise. - * pthread_mutex_unlock.c: Likewise. - * pthread_rwlock_timedrdlock.c: Likewise. - * pthread_rwlock_timedwrlock.c: Likewise. - * pthread_rwlock_unlock.c: Likewise. - * sysdeps/alpha/tls.h: Likewise. - * sysdeps/i386/tls.h: Likewise. - * sysdeps/ia64/tls.h: Likewise. - * sysdeps/powerpc/tls.h: Likewise. - * sysdeps/pthread/aio_misc.h: Likewise. - * sysdeps/pthread/gai_misc.h: Likewise. - * sysdeps/s390/tls.h: Likewise. - * sysdeps/sh/tls.h: Likewise. - * sysdeps/sparc/tls.h: Likewise. - * sysdeps/unix/sysv/linux/fork.c: Likewise. - * sysdeps/unix/sysv/linux/lowlevellock.c: Likewise. - * sysdeps/unix/sysv/linux/lowlevelrobustlock.c: Likewise. - * sysdeps/unix/sysv/linux/rtld-lowlevel.h: Likewise. - * sysdeps/unix/sysv/linux/sem_post.c: Likewise. - * sysdeps/unix/sysv/linux/sem_timedwait.c: Likewise. - * sysdeps/unix/sysv/linux/sem_wait.c: Likewise. - * sysdeps/unix/sysv/linux/unregister-atfork.c: Likewise. - * sysdeps/unix/sysv/linux/sparc/pthread_once.c: Likewise. - * sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_wait.c: - Likewise. - * sysdeps/unix/sysv/linux/sparc/sparc32/sem_post.c: Likewise. - * sysdeps/x86_64/tls.h: Likewise. - -2007-05-29 Ulrich Drepper <drepper@redhat.com> - - * pthread_getattr_np.c: No need to install a cancellation handler, - this is no cancellation point. - * pthread_getschedparam.c: Likewise. - * pthread_setschedparam.c: Likewise. - * pthread_setschedprio.c: Likewise. - * sysdeps/unix/sysv/linux/lowlevellock.c: Remove all traces of - lll_unlock_wake_cb. - * sysdeps/unix/sysv/linux/alpha/lowlevellock.h: Likewise. - * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Likewise. - * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Likewise. - * sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Likewise. - * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise. - * sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise. - * sysdeps/unix/sysv/linux/sh/lowlevellock.S: Likewise. - * sysdeps/unix/sysv/linux/sh/lowlevellock.h: Likewise. - * sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Likewise. - * sysdeps/unix/sysv/linux/sparc/sparc32/lowlevellock.c: Likewise. - * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Likewise. - * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise. - - * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Checking - whether there are more than one thread makes no sense here since - we only call the slow path if the locks are taken. - * sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S: Likewise. - - * sysdeps/unix/sysv/linux/internaltypes.h: Introduce - COND_NWAITERS_SHIFT. - * pthread_cond_destroy.c: Use COND_NWAITERS_SHIFT instead of - COND_CLOCK_BITS. - * pthread_cond_init.c: Likewise. - * pthread_cond_timedwait.c: Likewise. - * pthread_cond_wait.c: Likewise. - * pthread_condattr_getclock.c: Likewise. - * pthread_condattr_setclock.c: Likewise. - * sysdeps/unix/sysv/linux/lowlevelcond.sym: Likewise. - * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise. - * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise. - * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise. - * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise. - 2007-05-28 Jakub Jelinek <jakub@redhat.com> - * sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c: Include - unistd.h. - * sysdeps/i386/tls.h (THREAD_GSCOPE_RESET_FLAG): Use explicit insn suffix. (THREAD_GSCOPE_GET_FLAG): Remove. @@ -218,127 +42,15 @@ THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG, THREAD_GSCOPE_WAIT): Define. -2007-05-27 Ulrich Drepper <drepper@redhat.com> - - * init.c: Make it compile with older kernel headers. - - * tst-initializers1.c: Show through exit code which test failed. - - * pthread_rwlock_init.c: Also initialize __shared field. - * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Split __flags - element in rwlock structure into four byte elements. One of them is - the new __shared element. - * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h [__WORDSIZE=32]: - Likewise. - [__WORDSIZE=64]: Renamed __pad1 element int rwlock structure to - __shared, adjust names of other padding elements. - * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise. - * sysdeps/pthread/pthread.h: Adjust rwlock initializers. - * sysdeps/unix/sysv/linux/lowlevelrwlock.sym: Add PSHARED. - * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Define - FUTEX_PRIVATE_FLAG. - * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: Change main - futex to use private operations if possible. - * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S: - Likewise. - * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S: - Likewise. - * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S: Likewise. - * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: Likewise. - * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Likewise. - * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S: - Likewise. - * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S: - Likewise. - * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S: Likewise. - * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: Likewise. - 2007-05-26 Ulrich Drepper <drepper@redhat.com> - * pthreadP.h (PTHREAD_RWLOCK_PREFER_READER_P): Define. - * pthread_rwlock_rdlock.c: Use PTHREAD_RWLOCK_PREFER_READER_P. - * pthread_rwlock_timedrdlock.c: Likewise. - * pthread_rwlock_tryrdlock.c: Likewise. - - * sysdeps/unix/sysv/linux/x86_64/sem_trywait.S (sem_trywait): Tiny - optimization. - - * sysdeps/unix/sysv/linux/sem_wait.c: Add missing break. - * sysdeps/unix/sysv/linux/sem_timedwait.c: Removed left-over - duplication of __sem_wait_cleanup. - * allocatestack.c: Revert last change. * init.c: Likewise. * sysdeps/i386/tls.h: Likewise. * sysdeps/x86_64/tls.h: Likewise. - * descr.h [TLS_DTV_AT_TP] (struct pthread): Add private_futex field to - header structure. - * sysdeps/powerpc/tcb-offsets.sym: Add PRIVATE_FUTEX_OFFSET. - - * sysdeps/unix/sysv/linux/internaltypes.h (struct pthread_barrier): - Add private field. - * sysdeps/unix/sysv/linux/lowlevelbarrier.sym: Add PRIVATE definition. - * pthread_barrier_init.c: Set private flag if pshared and private - futexes are supported. - * sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S: Use - private field in futex command setup. - * sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S: Likewise. - -2007-05-25 Ulrich Drepper <drepper@redhat.com> - - * sysdeps/unix/sysv/linux/i386/i486/sem_post.S: Add private futex - support. - * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: Likewise. - * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S: Likewise. - * sysdeps/unix/sysv/linux/x86_64/sem_post.S: Likewise. - * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Likewise. - * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Likewise. - - * semaphoreP.h: Declare __old_sem_init and __old_sem_wait. - * sem_init.c (__new_sem_init): Rewrite to initialize all three - fields in the structure. - (__old_sem_init): New function. - * sem_open.c: Initialize all fields of the structure. - * sem_getvalue.c: Adjust for renamed element. - * sysdeps/unix/sysv/linux/Makefile [subdir=nptl] - (gen-as-const-headers): Add structsem.sym. - * sysdeps/unix/sysv/linux/structsem.sym: New file. - * sysdeps/unix/sysv/linux/internaltypes.h: Rename struct sem to - struct new_sem. Add struct old_sem. - * sysdeps/unix/sysv/linux/sem_post.c: Wake only when there are waiters. - * sysdeps/unix/sysv/linux/i386/i486/sem_post.S: Likewise. - * sysdeps/unix/sysv/linux/x86_64/sem_post.S: Likewise. - * sysdeps/unix/sysv/linux/sem_wait.c: Indicate that there are waiters. - * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S: Likewise. - * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Likewise. - * sysdeps/unix/sysv/linux/sem_timedwait.c: Likewise. - * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: Likewise. - * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Likewise. - * Makefile (tests): Add tst-sem10, tst-sem11, tst-sem12. - * tst-sem10.c: New file. - * tst-sem11.c: New file. - * tst-sem12.c: New file. - * tst-typesizes.c: Test struct new_sem and struct old_sem instead - of struct sem. - -2007-05-25 Ulrich Drepper <drepper@redhat.com> - Jakub Jelinek <jakub@redhat.com> - - * 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-24 Jakub Jelinek <jakub@redhat.com> - * sysdeps/i386/tls.h (THREAD_SET_PRIVATE_FUTEX, - THREAD_COPY_PRIVATE_FUTEX): Define. - * sysdeps/x86_64/tls.h (THREAD_SET_PRIVATE_FUTEX, - THREAD_COPY_PRIVATE_FUTEX): Define. - * allocatestack.c (allocate_stack): Use THREAD_COPY_PRIVATE_FUTEX. - * init.c (__pthread_initialize_minimal_internal): Use - THREAD_SET_PRIVATE_FUTEX. - * sysdeps/powerpc/tls.h (tcbhead_t): Add gscope_flag. (THREAD_GSCOPE_FLAG_UNUSED, THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT): Define. @@ -351,29 +63,6 @@ * allocatestack.c (__wait_lookup_done): Use THREAD_GSCOPE_GET_FLAG instead of ->header.gscope_flag directly. -2007-05-23 Ulrich Drepper <drepper@redhat.com> - - * init.c (__pthread_initialize_minimal_internal): Check whether - private futexes are available. - * allocatestack.c (allocate_stack): Copy private_futex field from - current thread into the new stack. - * sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S: Use private - futexes if they are available. - * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Likewise - * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Adjust so that change - in libc-lowlevellock.S allow using private futexes. - * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Likewise. - * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Define - FUTEX_PRIVATE_FLAG. - * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Likewise. - * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Use private futexes - if they are available. - * sysdeps/unix/sysv/linux/i386/pthread_once.S: Likewise. - * sysdeps/x86_64/tcb-offsets.sym: Add PRIVATE_FUTEX. - * sysdeps/i386/tcb-offsets.sym: Likewise. - * sysdeps/x86_64/tls.h (tcbhead_t): Add private_futex field. - * sysdeps/i386/tls.h (tcbhead_t): Likewise. - 2007-05-21 Ulrich Drepper <drepper@redhat.com> * sysdeps/pthread/pthread-functions.h (struct pthread_functions): @@ -386,11 +75,6 @@ * sysdeps/x86_64/tls.h (THREAD_GSCOPE_WAIT): The pointer is not encrypted for now. -2007-05-21 Jakub Jelinek <jakub@redhat.com> - - * tst-robust9.c (do_test): Don't fail if ENABLE_PI and - pthread_mutex_init failed with ENOTSUP. - 2007-05-19 Ulrich Drepper <drepper@redhat.com> * allocatestack.c (__wait_lookup_done): New function. @@ -404,6 +88,24 @@ * sysdeps/unix/sysv/linux/libc_pthread_init.c (__libc_pthread_init): Initialize GL(dl_wait_lookup_done). +2007-05-25 Ulrich Drepper <drepper@redhat.com> + + * Makefile (tests): Add tst-sem10. + * tst-sem10.c: New file. + +2007-05-25 Ulrich Drepper <drepper@redhat.com> + Jakub Jelinek <jakub@redhat.com> + + * 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 <jakub@redhat.com> + + * tst-robust9.c (do_test): Don't fail if ENABLE_PI and + pthread_mutex_init failed with ENOTSUP. + 2007-05-17 Ulrich Drepper <drepper@redhat.com> [BZ #4512] @@ -417,9 +119,6 @@ * tst-robust9.c: New file. * tst-robustpi9.c: New file. - * sysdeps/unix/sysv/linux/sem_wait.c (__new_sem_wait): Remove - unnecessary extra cancellation test. - 2007-05-14 Ulrich Drepper <drepper@redhat.com> * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Remove unnecessary diff --git a/nptl/Makefile b/nptl/Makefile index a9eac89e41..61cd25756c 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -218,7 +218,7 @@ tests = tst-typesizes \ 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-sem11 tst-sem12 \ + tst-sem8 tst-sem9 tst-sem10 \ 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 145fe0a35f..e556dbac08 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -376,12 +376,6 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1; #endif -#ifndef __ASSUME_PRIVATE_FUTEX - /* The thread must know when private futexes are supported. */ - pd->header.private_futex = THREAD_GETMEM (THREAD_SELF, - header.private_futex); -#endif - #ifdef NEED_DL_SYSINFO /* Copy the sysinfo value from the parent. */ THREAD_SYSINFO(pd) = THREAD_SELF_SYSINFO; @@ -516,12 +510,6 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1; #endif -#ifndef __ASSUME_PRIVATE_FUTEX - /* The thread must know when private futexes are supported. */ - pd->header.private_futex = THREAD_GETMEM (THREAD_SELF, - header.private_futex); -#endif - #ifdef NEED_DL_SYSINFO /* Copy the sysinfo value from the parent. */ THREAD_SYSINFO(pd) = THREAD_SELF_SYSINFO; @@ -951,7 +939,7 @@ __nptl_setxid (struct xid_command *cmdp) int cur = cmdp->cntr; while (cur != 0) { - lll_private_futex_wait (&cmdp->cntr, cur); + lll_futex_wait (&cmdp->cntr, cur); cur = cmdp->cntr; } @@ -1037,7 +1025,7 @@ __wait_lookup_done (void) continue; do - lll_private_futex_wait (gscope_flagp, THREAD_GSCOPE_FLAG_WAIT); + lll_futex_wait (gscope_flagp, THREAD_GSCOPE_FLAG_WAIT); while (*gscope_flagp == THREAD_GSCOPE_FLAG_WAIT); } @@ -1059,7 +1047,7 @@ __wait_lookup_done (void) continue; do - lll_private_futex_wait (gscope_flagp, THREAD_GSCOPE_FLAG_WAIT); + lll_futex_wait (gscope_flagp, THREAD_GSCOPE_FLAG_WAIT); while (*gscope_flagp == THREAD_GSCOPE_FLAG_WAIT); } diff --git a/nptl/descr.h b/nptl/descr.h index 3a3361d9e3..74d8c44140 100644 --- a/nptl/descr.h +++ b/nptl/descr.h @@ -37,7 +37,6 @@ #endif #define __need_res_state #include <resolv.h> -#include <kernel-features.h> #ifndef TCB_ALIGNMENT # define TCB_ALIGNMENT sizeof (double) @@ -133,9 +132,6 @@ struct pthread { int multiple_threads; int gscope_flag; -# ifndef __ASSUME_PRIVATE_FUTEX - int private_futex; -# endif } header; #endif diff --git a/nptl/init.c b/nptl/init.c index a1aec6b8f7..4449a9dbc0 100644 --- a/nptl/init.c +++ b/nptl/init.c @@ -35,6 +35,27 @@ #include <lowlevellock.h> +#ifndef __NR_set_tid_address +/* XXX For the time being... Once we can rely on the kernel headers + having the definition remove these lines. */ +#if defined __s390__ +# define __NR_set_tid_address 252 +#elif defined __ia64__ +# define __NR_set_tid_address 1233 +#elif defined __i386__ +# define __NR_set_tid_address 258 +#elif defined __x86_64__ +# define __NR_set_tid_address 218 +#elif defined __powerpc__ +# define __NR_set_tid_address 232 +#elif defined __sparc__ +# define __NR_set_tid_address 166 +#else +# error "define __NR_set_tid_address" +#endif +#endif + + /* Size and alignment of static TLS block. */ size_t __static_tls_size; size_t __static_tls_align_m1; @@ -216,7 +237,7 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx) __xidcmd->id[1], __xidcmd->id[2]); if (atomic_decrement_val (&__xidcmd->cntr) == 0) - lll_private_futex_wake (&__xidcmd->cntr, 1); + lll_futex_wake (&__xidcmd->cntr, 1); /* Reset the SETXID flag. */ struct pthread *self = THREAD_SELF; @@ -225,7 +246,7 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx) /* And release the futex. */ self->setxid_futex = 1; - lll_private_futex_wake (&self->setxid_futex, 1); + lll_futex_wake (&self->setxid_futex, 1); } @@ -234,9 +255,6 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx) extern void **__libc_dl_error_tsd (void) __attribute__ ((const)); -/* This can be set by the debugger before initialization is complete. */ -static bool __nptl_initial_report_events; - void __pthread_initialize_minimal_internal (void) { @@ -279,18 +297,6 @@ __pthread_initialize_minimal_internal (void) #endif set_robust_list_not_avail (); -#ifndef __ASSUME_PRIVATE_FUTEX - /* Private futexes are always used (at least internally) so that - doing the test once this early is beneficial. */ - { - int word; - word = INTERNAL_SYSCALL (futex, err, 3, &word, - FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1); - if (!INTERNAL_SYSCALL_ERROR_P (word, err)) - THREAD_SETMEM (pd, header.private_futex, FUTEX_PRIVATE_FLAG); - } -#endif - /* Set initial thread's stack block from 0 up to __libc_stack_end. It will be bigger than it actually is, but for unwind.c/pt-longjmp.c purposes this is good enough. */ @@ -300,9 +306,6 @@ __pthread_initialize_minimal_internal (void) INIT_LIST_HEAD (&__stack_user); list_add (&pd->list, &__stack_user); - /* Before initializing __stack_user, the debugger could not find us and - had to set __nptl_initial_report_events. Propagate its setting. */ - THREAD_SETMEM (pd, report_events, __nptl_initial_report_events); /* Install the cancellation signal handler. If for some reason we cannot install the handler we do not abort. Maybe we should, but diff --git a/nptl/lowlevellock.h b/nptl/lowlevellock.h index 0600e1794d..338da39990 100644 --- a/nptl/lowlevellock.h +++ b/nptl/lowlevellock.h @@ -1,5 +1,5 @@ /* Low level locking macros used in NPTL implementation. Stub version. - Copyright (C) 2002, 2007 Free Software Foundation, Inc. + Copyright (C) 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -21,6 +21,16 @@ #include <atomic.h> +/* Implement generic mutex. Basic futex syscall support is required: + + lll_futex_wait(futex, value) - call sys_futex with FUTEX_WAIT + and third parameter VALUE + + lll_futex_wake(futex, value) - call sys_futex with FUTEX_WAKE + and third parameter VALUE +*/ + + /* Mutex lock counter: bit 31 clear means unlocked; bit 31 set means locked. @@ -56,9 +66,7 @@ __generic_mutex_lock (int *mutex) if (v >= 0) continue; - lll_futex_wait (mutex, v, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wait (mutex, v); } } @@ -74,9 +82,7 @@ __generic_mutex_unlock (int *mutex) /* There are other threads waiting for this mutex, wake one of them up. */ - lll_futex_wake (mutex, 1, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wake (mutex, 1); } diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 85fb9b8e48..21ce6fe0b7 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -97,9 +97,6 @@ enum = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ADAPTIVE_NP }; -#define PTHREAD_MUTEX_TYPE(m) \ - ((m)->__data.__kind) - /* Ceiling in __data.__lock. __data.__lock is signed, so don't use the MSB bit in there, but in the mask also include that bit, so that the compiler can optimize & PTHREAD_MUTEX_PRIO_CEILING_MASK @@ -121,11 +118,6 @@ enum | PTHREAD_MUTEXATTR_PROTOCOL_MASK | PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) -/* Check whether rwlock prefers readers. */ -#define PTHREAD_RWLOCK_PREFER_READER_P(rwlock) \ - ((rwlock)->__data.__flags == 0) - - /* Bits used in robust mutex implementation. */ #define FUTEX_WAITERS 0x80000000 #define FUTEX_OWNER_DIED 0x40000000 diff --git a/nptl/pthread_barrier_init.c b/nptl/pthread_barrier_init.c index 8dfc444965..19e82fa38d 100644 --- a/nptl/pthread_barrier_init.c +++ b/nptl/pthread_barrier_init.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -20,13 +20,6 @@ #include <errno.h> #include "pthreadP.h" #include <lowlevellock.h> -#include <kernel-features.h> - - -static const struct pthread_barrierattr default_attr = - { - .pshared = PTHREAD_PROCESS_PRIVATE - }; int @@ -40,15 +33,17 @@ pthread_barrier_init (barrier, attr, count) if (__builtin_expect (count == 0, 0)) return EINVAL; - struct pthread_barrierattr *iattr - = (attr != NULL - ? iattr = (struct pthread_barrierattr *) attr - : &default_attr); + if (attr != NULL) + { + struct pthread_barrierattr *iattr; - if (iattr->pshared != PTHREAD_PROCESS_PRIVATE - && __builtin_expect (iattr->pshared != PTHREAD_PROCESS_SHARED, 0)) - /* Invalid attribute. */ - return EINVAL; + iattr = (struct pthread_barrierattr *) attr; + + if (iattr->pshared != PTHREAD_PROCESS_PRIVATE + && __builtin_expect (iattr->pshared != PTHREAD_PROCESS_SHARED, 0)) + /* Invalid attribute. */ + return EINVAL; + } ibarrier = (struct pthread_barrier *) barrier; @@ -58,14 +53,5 @@ pthread_barrier_init (barrier, attr, count) ibarrier->init_count = count; ibarrier->curr_event = 0; -#ifdef __ASSUME_PRIVATE_FUTEX - ibarrier->private = (iattr->pshared != PTHREAD_PROCESS_PRIVATE - ? 0 : FUTEX_PRIVATE_FLAG); -#else - ibarrier->private = (iattr->pshared != PTHREAD_PROCESS_PRIVATE - ? 0 : THREAD_GETMEM (THREAD_SELF, - header.private_futex)); -#endif - return 0; } diff --git a/nptl/pthread_barrier_wait.c b/nptl/pthread_barrier_wait.c index e96a3e5473..c6b563f242 100644 --- a/nptl/pthread_barrier_wait.c +++ b/nptl/pthread_barrier_wait.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -45,9 +45,7 @@ pthread_barrier_wait (barrier) ++ibarrier->curr_event; /* Wake up everybody. */ - lll_futex_wake (&ibarrier->curr_event, INT_MAX, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wake (&ibarrier->curr_event, INT_MAX); /* This is the thread which finished the serialization. */ result = PTHREAD_BARRIER_SERIAL_THREAD; @@ -63,9 +61,7 @@ pthread_barrier_wait (barrier) /* Wait for the event counter of the barrier to change. */ do - lll_futex_wait (&ibarrier->curr_event, event, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wait (&ibarrier->curr_event, event); while (event == ibarrier->curr_event); } diff --git a/nptl/pthread_cond_broadcast.c b/nptl/pthread_cond_broadcast.c index aec33f3bd8..2b8b5460f4 100644 --- a/nptl/pthread_cond_broadcast.c +++ b/nptl/pthread_cond_broadcast.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -69,9 +69,7 @@ __pthread_cond_broadcast (cond) { /* The requeue functionality is not available. */ wake_all: - lll_futex_wake (&cond->__data.__futex, INT_MAX, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wake (&cond->__data.__futex, INT_MAX); } /* That's all. */ diff --git a/nptl/pthread_cond_destroy.c b/nptl/pthread_cond_destroy.c index 8574b6118f..3e4ec8d0e4 100644 --- a/nptl/pthread_cond_destroy.c +++ b/nptl/pthread_cond_destroy.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -45,7 +45,7 @@ __pthread_cond_destroy (cond) pthread_cond_destroy needs to wait for them. */ unsigned int nwaiters = cond->__data.__nwaiters; - if (nwaiters >= (1 << COND_NWAITERS_SHIFT)) + if (nwaiters >= (1 << COND_CLOCK_BITS)) { /* Wake everybody on the associated mutex in case there are threads that have been requeued to it. @@ -59,24 +59,20 @@ __pthread_cond_destroy (cond) && cond->__data.__mutex != (void *) ~0l) { pthread_mutex_t *mut = (pthread_mutex_t *) cond->__data.__mutex; - lll_futex_wake (&mut->__data.__lock, INT_MAX, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wake (&mut->__data.__lock, INT_MAX); } do { lll_mutex_unlock (cond->__data.__lock); - lll_futex_wait (&cond->__data.__nwaiters, nwaiters, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wait (&cond->__data.__nwaiters, nwaiters); lll_mutex_lock (cond->__data.__lock); nwaiters = cond->__data.__nwaiters; } - while (nwaiters >= (1 << COND_NWAITERS_SHIFT)); + while (nwaiters >= (1 << COND_CLOCK_BITS)); } return 0; diff --git a/nptl/pthread_cond_init.c b/nptl/pthread_cond_init.c index 7c6d4c18f1..5e2e6704a9 100644 --- a/nptl/pthread_cond_init.c +++ b/nptl/pthread_cond_init.c @@ -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 <drepper@redhat.com>, 2002. @@ -31,8 +31,8 @@ __pthread_cond_init (cond, cond_attr) cond->__data.__lock = LLL_MUTEX_LOCK_INITIALIZER; cond->__data.__futex = 0; cond->__data.__nwaiters = (icond_attr != NULL - && ((icond_attr->value - & (COND_NWAITERS_SHIFT << 1)) >> 1)); + && ((icond_attr->value & (COND_CLOCK_BITS << 1)) + >> 1)); cond->__data.__total_seq = 0; cond->__data.__wakeup_seq = 0; cond->__data.__woken_seq = 0; diff --git a/nptl/pthread_cond_signal.c b/nptl/pthread_cond_signal.c index a4faf41854..5a9bbcad91 100644 --- a/nptl/pthread_cond_signal.c +++ b/nptl/pthread_cond_signal.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -44,15 +44,11 @@ __pthread_cond_signal (cond) /* Wake one. */ if (! __builtin_expect (lll_futex_wake_unlock (&cond->__data.__futex, 1, - 1, &cond->__data.__lock, - // XYZ check mutex flag - LLL_SHARED), + 1, &cond->__data.__lock), 0)) return 0; - lll_futex_wake (&cond->__data.__futex, 1, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wake (&cond->__data.__futex, 1); } /* We are done. */ diff --git a/nptl/pthread_cond_timedwait.c b/nptl/pthread_cond_timedwait.c index d1c29d2377..fdbf43eae8 100644 --- a/nptl/pthread_cond_timedwait.c +++ b/nptl/pthread_cond_timedwait.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -67,7 +67,7 @@ __pthread_cond_timedwait (cond, mutex, abstime) /* We have one new user of the condvar. */ ++cond->__data.__total_seq; ++cond->__data.__futex; - cond->__data.__nwaiters += 1 << COND_NWAITERS_SHIFT; + 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 @@ -100,7 +100,7 @@ __pthread_cond_timedwait (cond, mutex, abstime) int ret; ret = INTERNAL_SYSCALL (clock_gettime, err, 2, (cond->__data.__nwaiters - & ((1 << COND_NWAITERS_SHIFT) - 1)), + & ((1 << COND_CLOCK_BITS) - 1)), &rt); # ifndef __ASSUME_POSIX_TIMERS if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (ret, err), 0)) @@ -153,9 +153,7 @@ __pthread_cond_timedwait (cond, mutex, abstime) /* Wait until woken by signal or broadcast. */ err = lll_futex_timed_wait (&cond->__data.__futex, - futex_val, &rt, - // XYZ check mutex flag - LLL_SHARED); + futex_val, &rt); /* Disable asynchronous cancellation. */ __pthread_disable_asynccancel (cbuffer.oldtype); @@ -191,16 +189,14 @@ __pthread_cond_timedwait (cond, mutex, abstime) bc_out: - cond->__data.__nwaiters -= 1 << COND_NWAITERS_SHIFT; + 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_NWAITERS_SHIFT)) - lll_futex_wake (&cond->__data.__nwaiters, 1, - // XYZ check mutex flag - LLL_SHARED); + && 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); diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c index e524aa6c94..f5f5cec5a8 100644 --- a/nptl/pthread_cond_wait.c +++ b/nptl/pthread_cond_wait.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -62,18 +62,16 @@ __condvar_cleanup (void *arg) ++cbuffer->cond->__data.__woken_seq; } - cbuffer->cond->__data.__nwaiters -= 1 << COND_NWAITERS_SHIFT; + 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_NWAITERS_SHIFT)) + && cbuffer->cond->__data.__nwaiters < (1 << COND_CLOCK_BITS)) { - lll_futex_wake (&cbuffer->cond->__data.__nwaiters, 1, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wake (&cbuffer->cond->__data.__nwaiters, 1); destroying = 1; } @@ -82,9 +80,7 @@ __condvar_cleanup (void *arg) /* Wake everybody to make sure no condvar signal gets lost. */ if (! destroying) - lll_futex_wake (&cbuffer->cond->__data.__futex, INT_MAX, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wake (&cbuffer->cond->__data.__futex, INT_MAX); /* Get the mutex before returning unless asynchronous cancellation is in effect. */ @@ -115,7 +111,7 @@ __pthread_cond_wait (cond, mutex) /* We have one new user of the condvar. */ ++cond->__data.__total_seq; ++cond->__data.__futex; - cond->__data.__nwaiters += 1 << COND_NWAITERS_SHIFT; + 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 @@ -150,9 +146,7 @@ __pthread_cond_wait (cond, mutex) cbuffer.oldtype = __pthread_enable_asynccancel (); /* Wait until woken by signal or broadcast. */ - lll_futex_wait (&cond->__data.__futex, futex_val, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wait (&cond->__data.__futex, futex_val); /* Disable asynchronous cancellation. */ __pthread_disable_asynccancel (cbuffer.oldtype); @@ -174,16 +168,14 @@ __pthread_cond_wait (cond, mutex) bc_out: - cond->__data.__nwaiters -= 1 << COND_NWAITERS_SHIFT; + 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_NWAITERS_SHIFT)) - lll_futex_wake (&cond->__data.__nwaiters, 1, - // XYZ check mutex flag - LLL_SHARED); + && 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); diff --git a/nptl/pthread_condattr_getclock.c b/nptl/pthread_condattr_getclock.c index 3eedeb17ef..84de918a54 100644 --- a/nptl/pthread_condattr_getclock.c +++ b/nptl/pthread_condattr_getclock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2003. @@ -26,6 +26,6 @@ pthread_condattr_getclock (attr, clock_id) clockid_t *clock_id; { *clock_id = (((((const struct pthread_condattr *) attr)->value) >> 1) - & ((1 << COND_NWAITERS_SHIFT) - 1)); + & ((1 << COND_CLOCK_BITS) - 1)); return 0; } diff --git a/nptl/pthread_condattr_setclock.c b/nptl/pthread_condattr_setclock.c index 9c03bce9fc..04e246b74d 100644 --- a/nptl/pthread_condattr_setclock.c +++ b/nptl/pthread_condattr_setclock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2003. @@ -62,12 +62,11 @@ pthread_condattr_setclock (attr, clock_id) return EINVAL; /* Make sure the value fits in the bits we reserved. */ - assert (clock_id < (1 << COND_NWAITERS_SHIFT)); + assert (clock_id < (1 << COND_CLOCK_BITS)); int *valuep = &((struct pthread_condattr *) attr)->value; - *valuep = ((*valuep & ~(1 << (COND_NWAITERS_SHIFT + 1)) & ~1) - | (clock_id << 1)); + *valuep = (*valuep & ~(1 << (COND_CLOCK_BITS + 1)) & ~1) | (clock_id << 1); return 0; } diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index b1f852dc95..79729ced03 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.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 <drepper@redhat.com>, 2002. @@ -385,7 +385,7 @@ start_thread (void *arg) /* Some other thread might call any of the setXid functions and expect us to reply. In this case wait until we did that. */ do - lll_private_futex_wait (&pd->setxid_futex, 0); + lll_futex_wait (&pd->setxid_futex, 0); while (pd->cancelhandling & SETXID_BITMASK); /* Reset the value so that the stack can be reused. */ diff --git a/nptl/pthread_getattr_np.c b/nptl/pthread_getattr_np.c index 87cf56482f..f6cd8899d8 100644 --- a/nptl/pthread_getattr_np.c +++ b/nptl/pthread_getattr_np.c @@ -39,6 +39,10 @@ pthread_getattr_np (thread_id, attr) struct pthread_attr *iattr = (struct pthread_attr *) attr; int ret = 0; + /* We have to handle cancellation in the following code since we are + locking another threads desriptor. */ + pthread_cleanup_push ((void (*) (void *)) lll_unlock_wake_cb, &thread->lock); + lll_lock (thread->lock); /* The thread library is responsible for keeping the values in the @@ -175,5 +179,7 @@ pthread_getattr_np (thread_id, attr) lll_unlock (thread->lock); + pthread_cleanup_pop (0); + return ret; } diff --git a/nptl/pthread_getschedparam.c b/nptl/pthread_getschedparam.c index 5e8713016e..434d867779 100644 --- a/nptl/pthread_getschedparam.c +++ b/nptl/pthread_getschedparam.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -38,6 +38,10 @@ __pthread_getschedparam (threadid, policy, param) int result = 0; + /* We have to handle cancellation in the following code since we are + locking another threads descriptor. */ + pthread_cleanup_push ((void (*) (void *)) lll_unlock_wake_cb, &pd->lock); + lll_lock (pd->lock); /* The library is responsible for maintaining the values at all @@ -70,6 +74,8 @@ __pthread_getschedparam (threadid, policy, param) lll_unlock (pd->lock); + pthread_cleanup_pop (0); + return result; } strong_alias (__pthread_getschedparam, pthread_getschedparam) diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c index d0d6805aea..1c3ee4fe25 100644 --- a/nptl/pthread_mutex_lock.c +++ b/nptl/pthread_mutex_lock.c @@ -43,8 +43,7 @@ __pthread_mutex_lock (mutex) pid_t id = THREAD_GETMEM (THREAD_SELF, tid); int retval = 0; - switch (__builtin_expect (PTHREAD_MUTEX_TYPE (mutex), - PTHREAD_MUTEX_TIMED_NP)) + switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP)) { /* Recursive mutex. */ case PTHREAD_MUTEX_RECURSIVE_NP: @@ -409,9 +408,7 @@ __pthread_mutex_lock (mutex) break; if (oldval != ceilval) - lll_futex_wait (&mutex->__data.__lock, ceilval | 2, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wait (&mutex->__data.__lock, ceilval | 2); } while (atomic_compare_and_exchange_val_acq (&mutex->__data.__lock, ceilval | 2, ceilval) diff --git a/nptl/pthread_mutex_setprioceiling.c b/nptl/pthread_mutex_setprioceiling.c index 301fb63d21..cd13d1c14c 100644 --- a/nptl/pthread_mutex_setprioceiling.c +++ b/nptl/pthread_mutex_setprioceiling.c @@ -1,5 +1,5 @@ /* Set current priority ceiling of pthread_mutex_t. - 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 <jakub@redhat.com>, 2006. @@ -80,9 +80,7 @@ pthread_mutex_setprioceiling (mutex, prioceiling, old_ceiling) break; if (oldval != ceilval) - lll_futex_wait (&mutex->__data.__lock, ceilval | 2, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wait (&mutex->__data.__lock, ceilval | 2); } while (atomic_compare_and_exchange_val_acq (&mutex->__data.__lock, ceilval | 2, ceilval) @@ -112,9 +110,7 @@ pthread_mutex_setprioceiling (mutex, prioceiling, old_ceiling) | (prioceiling << PTHREAD_MUTEX_PRIO_CEILING_SHIFT); atomic_full_barrier (); - lll_futex_wake (&mutex->__data.__lock, INT_MAX, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wake (&mutex->__data.__lock, INT_MAX); return 0; } diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c index 825a9849b8..8fd681c6ef 100644 --- a/nptl/pthread_mutex_timedlock.c +++ b/nptl/pthread_mutex_timedlock.c @@ -37,8 +37,7 @@ pthread_mutex_timedlock (mutex, abstime) /* We must not check ABSTIME here. If the thread does not block abstime must not be checked for a valid value. */ - switch (__builtin_expect (PTHREAD_MUTEX_TYPE (mutex), - PTHREAD_MUTEX_TIMED_NP)) + switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP)) { /* Recursive mutex. */ case PTHREAD_MUTEX_RECURSIVE_NP: @@ -442,9 +441,7 @@ pthread_mutex_timedlock (mutex, abstime) } lll_futex_timed_wait (&mutex->__data.__lock, - ceilval | 2, &rt, - // XYZ check mutex flag - LLL_SHARED); + ceilval | 2, &rt); } } while (atomic_compare_and_exchange_val_acq (&mutex->__data.__lock, diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c index 9a97a6cf81..9db904c60b 100644 --- a/nptl/pthread_mutex_trylock.c +++ b/nptl/pthread_mutex_trylock.c @@ -31,8 +31,7 @@ __pthread_mutex_trylock (mutex) int oldval; pid_t id = THREAD_GETMEM (THREAD_SELF, tid); - switch (__builtin_expect (PTHREAD_MUTEX_TYPE (mutex), - PTHREAD_MUTEX_TIMED_NP)) + switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP)) { /* Recursive mutex. */ case PTHREAD_MUTEX_RECURSIVE_NP: diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c index 642e3a4442..33919d60af 100644 --- a/nptl/pthread_mutex_unlock.c +++ b/nptl/pthread_mutex_unlock.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 <drepper@redhat.com>, 2002. @@ -31,8 +31,7 @@ __pthread_mutex_unlock_usercnt (mutex, decr) { int newowner = 0; - switch (__builtin_expect (PTHREAD_MUTEX_TYPE (mutex), - PTHREAD_MUTEX_TIMED_NP)) + switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP)) { case PTHREAD_MUTEX_RECURSIVE_NP: /* Recursive mutex. */ @@ -241,9 +240,7 @@ __pthread_mutex_unlock_usercnt (mutex, decr) newval, oldval)); if ((oldval & ~PTHREAD_MUTEX_PRIO_CEILING_MASK) > 1) - lll_futex_wake (&mutex->__data.__lock, 1, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wake (&mutex->__data.__lock, 1); int oldprio = newval >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT; return __pthread_tpp_change_priority (oldprio, -1); diff --git a/nptl/pthread_rwlock_init.c b/nptl/pthread_rwlock_init.c index 27f25ac2ab..f664dd8104 100644 --- a/nptl/pthread_rwlock_init.c +++ b/nptl/pthread_rwlock_init.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -18,7 +18,6 @@ 02111-1307 USA. */ #include "pthreadP.h" -#include <kernel-features.h> static const struct pthread_rwlockattr default_attr = @@ -38,44 +37,14 @@ __pthread_rwlock_init (rwlock, attr) iattr = ((const struct pthread_rwlockattr *) attr) ?: &default_attr; rwlock->__data.__lock = 0; + rwlock->__data.__flags + = iattr->lockkind == PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP; rwlock->__data.__nr_readers = 0; + rwlock->__data.__writer = 0; rwlock->__data.__readers_wakeup = 0; rwlock->__data.__writer_wakeup = 0; rwlock->__data.__nr_readers_queued = 0; rwlock->__data.__nr_writers_queued = 0; - rwlock->__data.__writer = 0; - - rwlock->__data.__flags - = iattr->lockkind == PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP; - - /* The __SHARED field is computed to minimize the work that needs to - be done while handling the futex. There are two inputs: the - availability of private futexes and whether the rwlock is shared - or private. Unfortunately the value of a private rwlock is - fixed: it must be zero. The PRIVATE_FUTEX flag has the value - 0x80 in case private futexes are available and zero otherwise. - This leads to the following table: - - | pshared | result - | shared private | shared private | - ------------+-----------------+-----------------+ - !avail 0 | 0 0 | 0 0 | - avail 0x80 | 0x80 0 | 0 0x80 | - - If the pshared value is in locking functions XORed with avail - we get the expected result. */ -#ifdef __ASSUME_PRIVATE_FUTEX - rwlock->__data.__shared = (iattr->pshared == PTHREAD_PROCESS_PRIVATE - ? 0 : FUTEX_PRIVATE_FLAG); -#else - rwlock->__data.__shared = (iattr->pshared == PTHREAD_PROCESS_PRIVATE - ? 0 - : THREAD_GETMEM (THREAD_SELF, - header.private_futex)); -#endif - - rwlock->__data.__pad1 = 0; - rwlock->__data.__pad2 = 0; return 0; } diff --git a/nptl/pthread_rwlock_rdlock.c b/nptl/pthread_rwlock_rdlock.c index 6764c1e9ad..e225d7030d 100644 --- a/nptl/pthread_rwlock_rdlock.c +++ b/nptl/pthread_rwlock_rdlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -40,7 +40,7 @@ __pthread_rwlock_rdlock (rwlock) if (rwlock->__data.__writer == 0 /* ...and if either no writer is waiting or we prefer readers. */ && (!rwlock->__data.__nr_writers_queued - || PTHREAD_RWLOCK_PREFER_READER_P (rwlock))) + || rwlock->__data.__flags == 0)) { /* Increment the reader counter. Avoid overflow. */ if (__builtin_expect (++rwlock->__data.__nr_readers == 0, 0)) diff --git a/nptl/pthread_rwlock_timedrdlock.c b/nptl/pthread_rwlock_timedrdlock.c index 654d628b2f..80ea83a3dd 100644 --- a/nptl/pthread_rwlock_timedrdlock.c +++ b/nptl/pthread_rwlock_timedrdlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -43,7 +43,7 @@ pthread_rwlock_timedrdlock (rwlock, abstime) if (rwlock->__data.__writer == 0 /* ...and if either no writer is waiting or we prefer readers. */ && (!rwlock->__data.__nr_writers_queued - || PTHREAD_RWLOCK_PREFER_READER_P (rwlock))) + || rwlock->__data.__flags == 0)) { /* Increment the reader counter. Avoid overflow. */ if (++rwlock->__data.__nr_readers == 0) @@ -114,9 +114,7 @@ pthread_rwlock_timedrdlock (rwlock, abstime) /* Wait for the writer to finish. */ err = lll_futex_timed_wait (&rwlock->__data.__readers_wakeup, - waitval, &rt, - // XYZ check mutex flag - LLL_SHARED); + waitval, &rt); /* Get the lock. */ lll_mutex_lock (rwlock->__data.__lock); diff --git a/nptl/pthread_rwlock_timedwrlock.c b/nptl/pthread_rwlock_timedwrlock.c index 354beb0846..97c0598f96 100644 --- a/nptl/pthread_rwlock_timedwrlock.c +++ b/nptl/pthread_rwlock_timedwrlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -104,9 +104,7 @@ pthread_rwlock_timedwrlock (rwlock, abstime) /* Wait for the writer or reader(s) to finish. */ err = lll_futex_timed_wait (&rwlock->__data.__writer_wakeup, - waitval, &rt, - // XYZ check mutex flag - LLL_SHARED); + waitval, &rt); /* Get the lock. */ lll_mutex_lock (rwlock->__data.__lock); diff --git a/nptl/pthread_rwlock_tryrdlock.c b/nptl/pthread_rwlock_tryrdlock.c index df8863bcf8..446af05969 100644 --- a/nptl/pthread_rwlock_tryrdlock.c +++ b/nptl/pthread_rwlock_tryrdlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -32,7 +32,7 @@ __pthread_rwlock_tryrdlock (rwlock) if (rwlock->__data.__writer == 0 && (rwlock->__data.__nr_writers_queued == 0 - || PTHREAD_RWLOCK_PREFER_READER_P (rwlock))) + || rwlock->__data.__flags == 0)) { if (__builtin_expect (++rwlock->__data.__nr_readers == 0, 0)) { diff --git a/nptl/pthread_rwlock_unlock.c b/nptl/pthread_rwlock_unlock.c index 87a77a94ab..9cae8b6c22 100644 --- a/nptl/pthread_rwlock_unlock.c +++ b/nptl/pthread_rwlock_unlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -38,18 +38,14 @@ __pthread_rwlock_unlock (pthread_rwlock_t *rwlock) { ++rwlock->__data.__writer_wakeup; lll_mutex_unlock (rwlock->__data.__lock); - lll_futex_wake (&rwlock->__data.__writer_wakeup, 1, - // XYZ check mutex flag - LLL_SHARED); + 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, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wake (&rwlock->__data.__readers_wakeup, INT_MAX); return 0; } } diff --git a/nptl/pthread_setschedparam.c b/nptl/pthread_setschedparam.c index 8129dec82c..30ac6b3e89 100644 --- a/nptl/pthread_setschedparam.c +++ b/nptl/pthread_setschedparam.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 <drepper@redhat.com>, 2002. @@ -39,6 +39,10 @@ __pthread_setschedparam (threadid, policy, param) int result = 0; + /* We have to handle cancellation in the following code since we are + locking another threads desriptor. */ + pthread_cleanup_push ((void (*) (void *)) lll_unlock_wake_cb, &pd->lock); + lll_lock (pd->lock); struct sched_param p; @@ -69,6 +73,8 @@ __pthread_setschedparam (threadid, policy, param) lll_unlock (pd->lock); + pthread_cleanup_pop (0); + return result; } strong_alias (__pthread_setschedparam, pthread_setschedparam) diff --git a/nptl/pthread_setschedprio.c b/nptl/pthread_setschedprio.c index 59462ec2a1..4a71f6c7b3 100644 --- a/nptl/pthread_setschedprio.c +++ b/nptl/pthread_setschedprio.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -41,6 +41,10 @@ pthread_setschedprio (threadid, prio) struct sched_param param; param.sched_priority = prio; + /* We have to handle cancellation in the following code since we are + locking another threads desriptor. */ + pthread_cleanup_push ((void (*) (void *)) lll_unlock_wake_cb, &pd->lock); + lll_lock (pd->lock); /* If the thread should have higher priority because of some @@ -62,5 +66,7 @@ pthread_setschedprio (threadid, prio) lll_unlock (pd->lock); + pthread_cleanup_pop (0); + return result; } diff --git a/nptl/sem_getvalue.c b/nptl/sem_getvalue.c index 3b17e59629..6bc7ea82b4 100644 --- a/nptl/sem_getvalue.c +++ b/nptl/sem_getvalue.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -27,11 +27,11 @@ __new_sem_getvalue (sem, sval) sem_t *sem; int *sval; { - struct new_sem *isem = (struct new_sem *) sem; + struct sem *isem = (struct sem *) sem; /* XXX Check for valid SEM parameter. */ - *sval = isem->value; + *sval = isem->count; return 0; } diff --git a/nptl/sem_init.c b/nptl/sem_init.c index e29d900588..8709911ac3 100644 --- a/nptl/sem_init.c +++ b/nptl/sem_init.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -22,7 +22,6 @@ #include <lowlevellock.h> #include <shlib-compat.h> #include "semaphoreP.h" -#include <kernel-features.h> int @@ -39,50 +38,18 @@ __new_sem_init (sem, pshared, value) } /* Map to the internal type. */ - struct new_sem *isem = (struct new_sem *) sem; + struct sem *isem = (struct sem *) sem; - /* Use the values the user provided. */ - isem->value = value; -#ifdef __ASSUME_PRIVATE_FUTEX - isem->private = pshared ? 0 : FUTEX_PRIVATE_FLAG; -#else - isem->private = pshared ? 0 : THREAD_GETMEM (THREAD_SELF, - header.private_futex); -#endif + /* Use the value the user provided. */ + isem->count = value; - isem->nwaiters = 0; + /* We can completely ignore the PSHARED parameter since inter-process + use needs no special preparation. */ return 0; } versioned_symbol (libpthread, __new_sem_init, sem_init, GLIBC_2_1); - - - #if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1) -int -attribute_compat_text_section -__old_sem_init (sem, pshared, value) - sem_t *sem; - int pshared; - unsigned int value; -{ - /* Parameter sanity check. */ - if (__builtin_expect (value > SEM_VALUE_MAX, 0)) - { - __set_errno (EINVAL); - return -1; - } - - /* Map to the internal type. */ - struct old_sem *isem = (struct old_sem *) sem; - - /* Use the value the user provided. */ - isem->value = value; - - /* We cannot store the PSHARED attribute. So we always use the - operations needed for shared semaphores. */ - - return 0; -} +strong_alias (__new_sem_init, __old_sem_init) compat_symbol (libpthread, __old_sem_init, sem_init, GLIBC_2_0); #endif diff --git a/nptl/sem_open.c b/nptl/sem_open.c index 27d308e920..66bcb13aec 100644 --- a/nptl/sem_open.c +++ b/nptl/sem_open.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2006, 2007 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 <drepper@redhat.com>, 2002. @@ -304,14 +304,12 @@ sem_open (const char *name, int oflag, ...) /* Create the initial file content. */ sem_t initsem; - struct new_sem *iinitsem = (struct new_sem *) &initsem; - iinitsem->value = value; - iinitsem->private = 0; - iinitsem->nwaiters = 0; + struct sem *iinitsem = (struct sem *) &initsem; + iinitsem->count = value; /* Initialize the remaining bytes as well. */ - memset ((char *) &initsem + sizeof (struct new_sem), '\0', - sizeof (sem_t) - sizeof (struct new_sem)); + memset ((char *) &initsem + sizeof (struct sem), '\0', + sizeof (sem_t) - sizeof (struct sem)); tmpfname = (char *) alloca (mountpoint.dirlen + 6 + 1); char *xxxxxx = __mempcpy (tmpfname, mountpoint.dir, mountpoint.dirlen); diff --git a/nptl/semaphoreP.h b/nptl/semaphoreP.h index 9659059900..754609a1a8 100644 --- a/nptl/semaphoreP.h +++ b/nptl/semaphoreP.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2006, 2007 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 <drepper@redhat.com>, 2002. @@ -60,10 +60,8 @@ extern int __sem_search (const void *a, const void *b) attribute_hidden; /* Prototypes of functions with multiple interfaces. */ extern int __new_sem_init (sem_t *sem, int pshared, unsigned int value); -extern int __old_sem_init (sem_t *sem, int pshared, unsigned int value); extern int __new_sem_destroy (sem_t *sem); extern int __new_sem_post (sem_t *sem); extern int __new_sem_wait (sem_t *sem); -extern int __old_sem_wait (sem_t *sem); extern int __new_sem_trywait (sem_t *sem); extern int __new_sem_getvalue (sem_t *sem, int *sval); diff --git a/nptl/sysdeps/alpha/tls.h b/nptl/sysdeps/alpha/tls.h index 388a399c73..64ddcd5c01 100644 --- a/nptl/sysdeps/alpha/tls.h +++ b/nptl/sysdeps/alpha/tls.h @@ -131,7 +131,7 @@ typedef struct = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ + lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ } \ while (0) #define THREAD_GSCOPE_SET_FLAG() \ diff --git a/nptl/sysdeps/i386/tcb-offsets.sym b/nptl/sysdeps/i386/tcb-offsets.sym index 69f9deb368..7c8d9a5ca5 100644 --- a/nptl/sysdeps/i386/tcb-offsets.sym +++ b/nptl/sysdeps/i386/tcb-offsets.sym @@ -12,6 +12,3 @@ CLEANUP offsetof (struct pthread, cleanup) CLEANUP_PREV offsetof (struct _pthread_cleanup_buffer, __prev) MUTEX_FUTEX offsetof (pthread_mutex_t, __data.__lock) POINTER_GUARD offsetof (tcbhead_t, pointer_guard) -#ifndef __ASSUME_PRIVATE_FUTEX -PRIVATE_FUTEX offsetof (tcbhead_t, private_futex) -#endif diff --git a/nptl/sysdeps/i386/tls.h b/nptl/sysdeps/i386/tls.h index 1ffd4cf494..b97729ce4b 100644 --- a/nptl/sysdeps/i386/tls.h +++ b/nptl/sysdeps/i386/tls.h @@ -27,8 +27,6 @@ # include <stdint.h> # include <stdlib.h> # include <list.h> -# include <sysdep.h> -# include <kernel-features.h> /* Type for the dtv. */ @@ -54,9 +52,6 @@ typedef struct uintptr_t stack_guard; uintptr_t pointer_guard; int gscope_flag; -#ifndef __ASSUME_PRIVATE_FUTEX - int private_futex; -#endif } tcbhead_t; # define TLS_MULTIPLE_THREADS_IN_TCB 1 @@ -449,7 +444,7 @@ union user_desc_init : "i" (offsetof (struct pthread, header.gscope_flag)), \ "0" (THREAD_GSCOPE_FLAG_UNUSED)); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ + lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ } \ while (0) #define THREAD_GSCOPE_SET_FLAG() \ diff --git a/nptl/sysdeps/ia64/tls.h b/nptl/sysdeps/ia64/tls.h index a5b7b76e2a..a144c28b09 100644 --- a/nptl/sysdeps/ia64/tls.h +++ b/nptl/sysdeps/ia64/tls.h @@ -173,7 +173,7 @@ register struct pthread *__thread_self __asm__("r13"); = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ + lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ } \ while (0) #define THREAD_GSCOPE_SET_FLAG() \ diff --git a/nptl/sysdeps/powerpc/tcb-offsets.sym b/nptl/sysdeps/powerpc/tcb-offsets.sym index eda43dce8e..4a8671e802 100644 --- a/nptl/sysdeps/powerpc/tcb-offsets.sym +++ b/nptl/sysdeps/powerpc/tcb-offsets.sym @@ -15,4 +15,3 @@ MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads) PID thread_offsetof (pid) TID thread_offsetof (tid) POINTER_GUARD (offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t)) -PRIVATE_FUTEX_OFFSET thread_offsetof (header.private_futex) diff --git a/nptl/sysdeps/powerpc/tls.h b/nptl/sysdeps/powerpc/tls.h index 06c60e8ba2..bd9c99e06e 100644 --- a/nptl/sysdeps/powerpc/tls.h +++ b/nptl/sysdeps/powerpc/tls.h @@ -190,7 +190,7 @@ register void *__thread_register __asm__ ("r13"); = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ + lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ } \ while (0) #define THREAD_GSCOPE_SET_FLAG() \ diff --git a/nptl/sysdeps/pthread/aio_misc.h b/nptl/sysdeps/pthread/aio_misc.h index 25ab74e272..c5a11f4550 100644 --- a/nptl/sysdeps/pthread/aio_misc.h +++ b/nptl/sysdeps/pthread/aio_misc.h @@ -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. The GNU C Library is free software; you can redistribute it and/or @@ -30,7 +30,7 @@ #define AIO_MISC_NOTIFY(waitlist) \ do { \ if (*waitlist->counterp > 0 && --*waitlist->counterp == 0) \ - lll_private_futex_wake (waitlist->counterp, 1); \ + lll_futex_wake (waitlist->counterp, 1); \ } while (0) #define AIO_MISC_WAIT(result, futex, timeout, cancel) \ @@ -49,8 +49,7 @@ int status; \ do \ { \ - status = lll_private_futex_timed_wait (futexaddr, oldval, \ - timeout); \ + status = lll_futex_timed_wait (futexaddr, oldval, timeout); \ if (status != -EWOULDBLOCK) \ break; \ \ diff --git a/nptl/sysdeps/pthread/gai_misc.h b/nptl/sysdeps/pthread/gai_misc.h index 5f6990040a..9f6a73dad1 100644 --- a/nptl/sysdeps/pthread/gai_misc.h +++ b/nptl/sysdeps/pthread/gai_misc.h @@ -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. The GNU C Library is free software; you can redistribute it and/or @@ -31,7 +31,7 @@ #define GAI_MISC_NOTIFY(waitlist) \ do { \ if (*waitlist->counterp > 0 && --*waitlist->counterp == 0) \ - lll_private_futex_wake (waitlist->counterp, 1); \ + lll_futex_wake (waitlist->counterp, 1); \ } while (0) #define GAI_MISC_WAIT(result, futex, timeout, cancel) \ @@ -50,8 +50,7 @@ int status; \ do \ { \ - status = lll_private_futex_timed_wait (futexaddr, oldval, \ - timeout); \ + status = lll_futex_timed_wait (futexaddr, oldval, timeout); \ if (status != -EWOULDBLOCK) \ break; \ \ diff --git a/nptl/sysdeps/pthread/pt-initfini.c b/nptl/sysdeps/pthread/pt-initfini.c index 9c00dc0b7d..1e35edd3eb 100644 --- a/nptl/sysdeps/pthread/pt-initfini.c +++ b/nptl/sysdeps/pthread/pt-initfini.c @@ -72,7 +72,7 @@ call_initialize_minimal (void) } SECTION (".init"); -extern void __attribute__ ((section (".init"))) _init (void); +extern void _init (void); void _init (void) { @@ -93,7 +93,7 @@ asm ("\n/*@_init_EPILOG_ENDS*/"); asm ("\n/*@_fini_PROLOG_BEGINS*/"); SECTION (".fini"); -extern void __attribute__ ((section (".fini"))) _fini (void); +extern void _fini (void); void _fini (void) { diff --git a/nptl/sysdeps/pthread/pthread-functions.h b/nptl/sysdeps/pthread/pthread-functions.h index 0c404fcbb3..a13b937032 100644 --- a/nptl/sysdeps/pthread/pthread-functions.h +++ b/nptl/sysdeps/pthread/pthread-functions.h @@ -97,6 +97,7 @@ struct pthread_functions void (*ptr__nptl_deallocate_tsd) (void); int (*ptr__nptl_setxid) (struct xid_command *); void (*ptr_freeres) (void); + void (*ptr_wait_lookup_done) (int); }; /* Variable in libc.so. */ diff --git a/nptl/sysdeps/pthread/pthread.h b/nptl/sysdeps/pthread/pthread.h index d175f312ee..4dc0b2272b 100644 --- a/nptl/sysdeps/pthread/pthread.h +++ b/nptl/sysdeps/pthread/pthread.h @@ -21,7 +21,6 @@ #define _PTHREAD_H 1 #include <features.h> -#include <endian.h> #include <sched.h> #include <time.h> @@ -121,23 +120,21 @@ enum }; /* Read-write lock initializers. */ -# define PTHREAD_RWLOCK_INITIALIZER \ +# if __WORDSIZE == 64 +# define PTHREAD_RWLOCK_INITIALIZER \ { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } +# else +# define PTHREAD_RWLOCK_INITIALIZER \ + { { 0, 0, 0, 0, 0, 0, 0, 0 } } +# endif # ifdef __USE_GNU # if __WORDSIZE == 64 # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \ { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } } # else -# if __BYTE_ORDER == __LITTLE_ENDIAN -# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \ - { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, \ - 0, 0, 0, 0 } } -# else -# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \ - { { 0, 0, 0, 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\ - 0 } } -# endif +# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \ + { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, 0 } } # endif # endif #endif /* Unix98 or XOpen2K */ diff --git a/nptl/sysdeps/s390/tls.h b/nptl/sysdeps/s390/tls.h index f10db8f227..251dfd4a46 100644 --- a/nptl/sysdeps/s390/tls.h +++ b/nptl/sysdeps/s390/tls.h @@ -27,7 +27,6 @@ # include <stdint.h> # include <stdlib.h> # include <list.h> -# include <kernel-features.h> /* Type for the dtv. */ @@ -52,9 +51,6 @@ typedef struct uintptr_t sysinfo; uintptr_t stack_guard; int gscope_flag; -#ifndef __ASSUME_PRIVATE_FUTEX - int private_futex; -#endif } tcbhead_t; # ifndef __s390x__ @@ -183,7 +179,7 @@ typedef struct = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ + lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ } \ while (0) #define THREAD_GSCOPE_SET_FLAG() \ diff --git a/nptl/sysdeps/sh/tcb-offsets.sym b/nptl/sysdeps/sh/tcb-offsets.sym index 753b72b2dd..4ad866335b 100644 --- a/nptl/sysdeps/sh/tcb-offsets.sym +++ b/nptl/sysdeps/sh/tcb-offsets.sym @@ -10,6 +10,3 @@ MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads) TLS_PRE_TCB_SIZE sizeof (struct pthread) MUTEX_FUTEX offsetof (pthread_mutex_t, __data.__lock) POINTER_GUARD offsetof (tcbhead_t, pointer_guard) -#ifndef __ASSUME_PRIVATE_FUTEX -PRIVATE_FUTEX offsetof (struct pthread, header.private_futex) -#endif diff --git a/nptl/sysdeps/sh/tls.h b/nptl/sysdeps/sh/tls.h index e07e29f786..6d6eff665f 100644 --- a/nptl/sysdeps/sh/tls.h +++ b/nptl/sysdeps/sh/tls.h @@ -26,10 +26,6 @@ # include <stdbool.h> # include <stddef.h> # include <stdint.h> -# include <stdlib.h> -# include <list.h> -# include <sysdep.h> -# include <kernel-features.h> /* Type for the dtv. */ typedef union dtv @@ -164,7 +160,7 @@ typedef struct = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ + lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ } \ while (0) #define THREAD_GSCOPE_SET_FLAG() \ diff --git a/nptl/sysdeps/sparc/tls.h b/nptl/sysdeps/sparc/tls.h index 788c974c1c..60e52fd4ea 100644 --- a/nptl/sysdeps/sparc/tls.h +++ b/nptl/sysdeps/sparc/tls.h @@ -151,7 +151,7 @@ register struct pthread *__thread_self __asm__("%g7"); = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ THREAD_GSCOPE_FLAG_UNUSED); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ + lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ } \ while (0) #define THREAD_GSCOPE_SET_FLAG() \ diff --git a/nptl/sysdeps/unix/sysv/linux/Makefile b/nptl/sysdeps/unix/sysv/linux/Makefile index ad5ae6ad12..cfcdb6d97f 100644 --- a/nptl/sysdeps/unix/sysv/linux/Makefile +++ b/nptl/sysdeps/unix/sysv/linux/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. # Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -25,8 +25,7 @@ libpthread-sysdep_routines += pt-fork pthread_mutex_cond_lock gen-as-const-headers += lowlevelcond.sym lowlevelrwlock.sym \ lowlevelbarrier.sym unwindbuf.sym \ - lowlevelrobustlock.sym pthread-pi-defines.sym \ - structsem.sym + lowlevelrobustlock.sym pthread-pi-defines.sym endif ifeq ($(subdir),posix) diff --git a/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h index 04ac006400..58b4806eb2 100644 --- a/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 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 @@ -237,6 +237,8 @@ typedef int lll_lock_t; #define LLL_LOCK_INITIALIZER (0) #define LLL_LOCK_INITIALIZER_LOCKED (1) +extern int lll_unlock_wake_cb (int *__futex) attribute_hidden; + /* The states of a lock are: 0 - untaken 1 - taken by one user diff --git a/nptl/sysdeps/unix/sysv/linux/fork.c b/nptl/sysdeps/unix/sysv/linux/fork.c index c6dadb5683..98bb237c06 100644 --- a/nptl/sysdeps/unix/sysv/linux/fork.c +++ b/nptl/sysdeps/unix/sysv/linux/fork.c @@ -203,7 +203,7 @@ __libc_fork (void) if (atomic_decrement_and_test (&allp->handler->refcntr) && allp->handler->need_signal) - lll_private_futex_wake (allp->handler->refcntr, 1); + lll_futex_wake (allp->handler->refcntr, 1); allp = allp->next; } diff --git a/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h index 9e3e016fb8..f53d0e5a72 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.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. The GNU C Library is free software; you can redistribute it and/or @@ -128,10 +128,7 @@ typedef union unsigned int __nr_writers_queued; /* FLAGS must stay at this position in the structure to maintain binary compatibility. */ - unsigned char __flags; - unsigned char __shared; - unsigned char __pad1; - unsigned char __pad2; + unsigned int __flags; int __writer; } __data; char __size[__SIZEOF_PTHREAD_RWLOCK_T]; diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S index 830f628578..88885b735d 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S @@ -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 <drepper@redhat.com>, 2002. @@ -17,19 +17,14 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <kernel-features.h> - -/* All locks in libc are private. Use the kernel feature if possible. */ -#define FUTEX_PRIVATE_FLAG 128 -#ifdef __ASSUME_PRIVATE_FUTEX -# define FUTEX_WAIT (0 | FUTEX_PRIVATE_FLAG) -# define FUTEX_WAKE (1 | FUTEX_PRIVATE_FLAG) -#else -# define LOAD_FUTEX_WAIT(reg) \ - movl %gs:PRIVATE_FUTEX, reg -# define LOAD_FUTEX_WAKE(reg) \ - movl %gs:PRIVATE_FUTEX, reg ; \ - orl $FUTEX_WAKE, reg +/* In libc.so we do not unconditionally use the lock prefix. Only if + the application is using threads. */ +#ifndef UP +# define LOCK \ + cmpl $0, %gs:MULTIPLE_THREADS_OFFSET; \ + je 0f; \ + lock; \ +0: #endif #include "lowlevellock.S" diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S index cfcc7dafc4..e2da5b04cf 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S @@ -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 <drepper@redhat.com>, 2002. @@ -32,22 +32,8 @@ #define SYS_gettimeofday __NR_gettimeofday #define SYS_futex 240 -#ifndef FUTEX_WAIT -# define FUTEX_WAIT 0 -# define FUTEX_WAKE 1 -#endif - -#ifndef LOAD_FUTEX_WAIT -# if FUTEX_WAIT == 0 -# define LOAD_FUTEX_WAIT(reg) \ - xorl reg, reg -# else -# define LOAD_FUTEX_WAIT(reg) \ - movl $FUTEX_WAIT, reg -# endif -# define LOAD_FUTEX_WAKE(reg) \ - movl $FUTEX_WAKE, reg -#endif +#define FUTEX_WAIT 0 +#define FUTEX_WAKE 1 .globl __lll_mutex_lock_wait @@ -69,7 +55,7 @@ __lll_mutex_lock_wait: movl $2, %edx movl %ecx, %ebx xorl %esi, %esi /* No timeout. */ - LOAD_FUTEX_WAIT (%ecx) + xorl %ecx, %ecx /* movl $FUTEX_WAIT, %ecx */ cmpl %edx, %eax /* NB: %edx == 2 */ jne 2f @@ -165,7 +151,7 @@ __lll_mutex_timedlock_wait: /* Futex call. */ movl %esp, %esi - LOAD_FUTEX_WAIT (%ecx) + xorl %ecx, %ecx /* movl $FUTEX_WAIT, %ecx */ movl $SYS_futex, %eax ENTER_KERNEL movl %eax, %ecx @@ -219,6 +205,35 @@ __lll_mutex_timedlock_wait: #endif +#ifdef NOT_IN_libc + .globl lll_unlock_wake_cb + .type lll_unlock_wake_cb,@function + .hidden lll_unlock_wake_cb + .align 16 +lll_unlock_wake_cb: + pushl %ebx + pushl %ecx + pushl %edx + + movl 20(%esp), %ebx + LOCK + subl $1, (%ebx) + je 1f + + movl $FUTEX_WAKE, %ecx + movl $1, %edx /* Wake one thread. */ + movl $SYS_futex, %eax + movl $0, (%ebx) + ENTER_KERNEL + +1: popl %edx + popl %ecx + popl %ebx + ret + .size lll_unlock_wake_cb,.-lll_unlock_wake_cb +#endif + + .globl __lll_mutex_unlock_wake .type __lll_mutex_unlock_wake,@function .hidden __lll_mutex_unlock_wake @@ -237,7 +252,7 @@ __lll_mutex_unlock_wake: movl %eax, %ebx movl $0, (%eax) - LOAD_FUTEX_WAKE (%ecx) + movl $FUTEX_WAKE, %ecx movl $1, %edx /* Wake one thread. */ movl $SYS_futex, %eax ENTER_KERNEL @@ -299,8 +314,6 @@ __lll_timedwait_tid: jz 4f movl %esp, %esi - /* XXX The kernel so far uses global futex for the wakeup at - all times. */ xorl %ecx, %ecx /* movl $FUTEX_WAIT, %ecx */ movl %ebp, %ebx movl $SYS_futex, %eax diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S index 29857195f0..fe7a8b9c66 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -69,13 +69,7 @@ pthread_barrier_wait: /* Wait for the remaining threads. The call will return immediately if the CURR_EVENT memory has meanwhile been changed. */ -7: -#if FUTEX_WAIT == 0 - movl PRIVATE(%ebx), %ecx -#else - movl $FUTEX_WAIT, %ecx - orl PRIVATE(%ebx), %ecx -#endif +7: xorl %ecx, %ecx /* movl $FUTEX_WAIT, %ecx */ xorl %esi, %esi 8: movl $SYS_futex, %eax ENTER_KERNEL @@ -126,7 +120,6 @@ pthread_barrier_wait: so 0x7fffffff is the highest value. */ movl $0x7fffffff, %edx movl $FUTEX_WAKE, %ecx - orl PRIVATE(%ebx), %ecx movl $SYS_futex, %eax ENTER_KERNEL diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S index 93f4d56b32..f481a8e43c 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S @@ -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 <drepper@redhat.com>, 2002. @@ -87,7 +87,7 @@ __pthread_cond_timedwait: addl $1, total_seq(%ebx) adcl $0, total_seq+4(%ebx) addl $1, cond_futex(%ebx) - addl $(1 << nwaiters_shift), cond_nwaiters(%ebx) + addl $(1 << clock_bits), cond_nwaiters(%ebx) #define FRAME_SIZE 24 subl $FRAME_SIZE, %esp @@ -106,7 +106,7 @@ __pthread_cond_timedwait: #ifdef __NR_clock_gettime /* Get the clock number. */ movl cond_nwaiters(%ebx), %ebx - andl $((1 << nwaiters_shift) - 1), %ebx + andl $((1 << clock_bits) - 1), %ebx /* Only clocks 0 and 1 are allowed so far. Both are handled in the kernel. */ leal 4(%esp), %ecx @@ -228,7 +228,7 @@ __pthread_cond_timedwait: 14: addl $1, woken_seq(%ebx) adcl $0, woken_seq+4(%ebx) -24: subl $(1 << nwaiters_shift), cond_nwaiters(%ebx) +24: subl $(1 << clock_bits), cond_nwaiters(%ebx) /* Wake up a thread which wants to destroy the condvar object. */ movl total_seq(%ebx), %eax @@ -236,7 +236,7 @@ __pthread_cond_timedwait: cmpl $0xffffffff, %eax jne 25f movl cond_nwaiters(%ebx), %eax - andl $~((1 << nwaiters_shift) - 1), %eax + andl $~((1 << clock_bits) - 1), %eax jne 25f addl $cond_nwaiters, %ebx @@ -424,7 +424,7 @@ __condvar_tw_cleanup: 7: addl $1, woken_seq(%ebx) adcl $0, woken_seq+4(%ebx) -3: subl $(1 << nwaiters_shift), cond_nwaiters(%ebx) +3: subl $(1 << clock_bits), cond_nwaiters(%ebx) /* Wake up a thread which wants to destroy the condvar object. */ xorl %edi, %edi @@ -433,7 +433,7 @@ __condvar_tw_cleanup: cmpl $0xffffffff, %eax jne 4f movl cond_nwaiters(%ebx), %eax - andl $~((1 << nwaiters_shift) - 1), %eax + andl $~((1 << clock_bits) - 1), %eax jne 4f addl $cond_nwaiters, %ebx diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S index c92cfbc718..f16c7d9198 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S @@ -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 <drepper@redhat.com>, 2002. @@ -80,7 +80,7 @@ __pthread_cond_wait: addl $1, total_seq(%ebx) adcl $0, total_seq+4(%ebx) addl $1, cond_futex(%ebx) - addl $(1 << nwaiters_shift), cond_nwaiters(%ebx) + addl $(1 << clock_bits), cond_nwaiters(%ebx) #define FRAME_SIZE 16 subl $FRAME_SIZE, %esp @@ -157,7 +157,7 @@ __pthread_cond_wait: adcl $0, woken_seq+4(%ebx) /* Unlock */ -16: subl $(1 << nwaiters_shift), cond_nwaiters(%ebx) +16: subl $(1 << clock_bits), cond_nwaiters(%ebx) /* Wake up a thread which wants to destroy the condvar object. */ movl total_seq(%ebx), %eax @@ -165,7 +165,7 @@ __pthread_cond_wait: cmpl $0xffffffff, %eax jne 17f movl cond_nwaiters(%ebx), %eax - andl $~((1 << nwaiters_shift) - 1), %eax + andl $~((1 << clock_bits) - 1), %eax jne 17f addl $cond_nwaiters, %ebx @@ -315,7 +315,7 @@ __condvar_w_cleanup: 7: addl $1, woken_seq(%ebx) adcl $0, woken_seq+4(%ebx) -3: subl $(1 << nwaiters_shift), cond_nwaiters(%ebx) +3: subl $(1 << clock_bits), cond_nwaiters(%ebx) /* Wake up a thread which wants to destroy the condvar object. */ xorl %edi, %edi @@ -324,7 +324,7 @@ __condvar_w_cleanup: cmpl $0xffffffff, %eax jne 4f movl cond_nwaiters(%ebx), %eax - andl $~((1 << nwaiters_shift) - 1), %eax + andl $~((1 << clock_bits) - 1), %eax jne 4f addl $cond_nwaiters, %ebx diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S index c61c697985..db0639d21c 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S @@ -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 <drepper@redhat.com>, 2002. @@ -61,7 +61,7 @@ __pthread_rwlock_rdlock: jne 14f cmpl $0, WRITERS_QUEUED(%ebx) je 5f - cmpb $0, FLAGS(%ebx) + cmpl $0, FLAGS(%ebx) je 5f 3: addl $1, READERS_QUEUED(%ebx) @@ -77,18 +77,8 @@ __pthread_rwlock_rdlock: #endif jne 10f -11: -#if __ASSUME_PRIVATE_FUTEX - movzbl PSHARED(%ebx), %ecx - xorl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %ecx -#else - movzbl PSHARED(%ebx), %ecx -# if FUTEX_WAIT != 0 - orl $FUTEX_WAIT, %ecx -# endif - xorl %gs:PRIVATE_FUTEX, %ecx -#endif - addl $READERS_WAKEUP, %ebx +11: addl $READERS_WAKEUP, %ebx + movl %esi, %ecx /* movl $FUTEX_WAIT, %ecx */ movl $SYS_futex, %eax ENTER_KERNEL diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S index c6a584fed0..eb5665b432 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S @@ -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 <drepper@redhat.com>, 2002. @@ -65,7 +65,7 @@ pthread_rwlock_timedrdlock: jne 14f cmpl $0, WRITERS_QUEUED(%ebp) je 5f - cmpb $0, FLAGS(%ebp) + cmpl $0, FLAGS(%ebp) je 5f /* Check the value of the timeout parameter. */ @@ -108,18 +108,8 @@ pthread_rwlock_timedrdlock: /* Futex call. */ movl %ecx, (%esp) /* Store relative timeout. */ movl %edx, 4(%esp) - movl %esi, %edx -#if __ASSUME_PRIVATE_FUTEX - movzbl PSHARED(%ebp), %ecx - xorl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %ecx -#else - movzbl PSHARED(%ebp), %ecx -# if FUTEX_WAIT != 0 - orl $FUTEX_WAIT, %ecx -# endif - xorl %gs:PRIVATE_FUTEX, %ecx -#endif + xorl %ecx, %ecx /* movl $FUTEX_WAIT, %ecx */ movl %esp, %esi leal READERS_WAKEUP(%ebp), %ebx movl $SYS_futex, %eax diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S index 5e9faf93fb..d9db77ba05 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S @@ -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 <drepper@redhat.com>, 2002. @@ -106,18 +106,8 @@ pthread_rwlock_timedwrlock: /* Futex call. */ movl %ecx, (%esp) /* Store relative timeout. */ movl %edx, 4(%esp) - movl %esi, %edx -#if __ASSUME_PRIVATE_FUTEX - movzbl PSHARED(%ebp), %ecx - xorl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %ecx -#else - movzbl PSHARED(%ebp), %ecx -# if FUTEX_WAIT != 0 - orl $FUTEX_WAIT, %ecx -# endif - xorl %gs:PRIVATE_FUTEX, %ecx -#endif + xorl %ecx, %ecx /* movl $FUTEX_WAIT, %ecx */ movl %esp, %esi leal WRITERS_WAKEUP(%ebp), %ebx movl $SYS_futex, %eax diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S index 35c40c2c1c..64aac3255a 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S @@ -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 <drepper@redhat.com>, 2002. @@ -61,8 +61,9 @@ __pthread_rwlock_unlock: 5: movl $0, WRITER(%edi) - movl $1, %edx + movl $1, %ecx leal WRITERS_WAKEUP(%edi), %ebx + movl %ecx, %edx cmpl $0, WRITERS_QUEUED(%edi) jne 0f @@ -82,16 +83,7 @@ __pthread_rwlock_unlock: #endif jne 7f -8: -#if __ASSUME_PRIVATE_FUTEX - movzbl PSHARED(%edi), %ecx - xorl $FUTEX_PRIVATE_FLAG|FUTEX_WAKE, %ecx -#else - movzbl PSHARED(%edi), %ecx - orl $FUTEX_WAKE, %ecx - xorl %gs:PRIVATE_FUTEX, %ecx -#endif - movl $SYS_futex, %eax +8: movl $SYS_futex, %eax ENTER_KERNEL xorl %eax, %eax diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S index 88044c040b..ea9cc170db 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S @@ -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 <drepper@redhat.com>, 2002. @@ -75,18 +75,8 @@ __pthread_rwlock_wrlock: #endif jne 10f -11: -#if __ASSUME_PRIVATE_FUTEX - movzbl PSHARED(%ebx), %ecx - xorl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %ecx -#else - movzbl PSHARED(%ebx), %ecx -# if FUTEX_WAIT != 0 - orl $FUTEX_WAIT, %ecx -# endif - xorl %gs:PRIVATE_FUTEX, %ecx -#endif - addl $WRITERS_WAKEUP, %ebx +11: addl $WRITERS_WAKEUP, %ebx + movl %esi, %ecx /* movl $FUTEX_WAIT, %ecx */ movl $SYS_futex, %eax ENTER_KERNEL diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_post.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_post.S index 280dc2fe27..71e96d2228 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_post.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_post.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 <drepper@redhat.com>, 2002. @@ -20,7 +20,6 @@ #include <sysdep.h> #include <shlib-compat.h> #include <pthread-errnos.h> -#include <structsem.h> #ifndef UP # define LOCK lock @@ -41,27 +40,19 @@ __new_sem_post: pushl %ebx movl 8(%esp), %ebx - + movl $1, %edx LOCK -#if VALUE == 0 - addl $1, (%ebx) -#else - addl $1, VALUE(%ebx) -#endif + xaddl %edx, (%ebx) - cmpl $0, NWAITERS(%ebx) - je 2f - - movl $FUTEX_WAKE, %ecx - orl PRIVATE(%ebx), %ecx - movl $1, %edx movl $SYS_futex, %eax + movl $FUTEX_WAKE, %ecx + addl $1, %edx ENTER_KERNEL testl %eax, %eax js 1f -2: xorl %eax, %eax + xorl %eax, %eax popl %ebx ret 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 57b5b58186..bf70e17fca 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S @@ -20,7 +20,6 @@ #include <sysdep.h> #include <shlib-compat.h> #include <pthread-errnos.h> -#include <structsem.h> #ifndef UP # define LOCK lock @@ -30,12 +29,7 @@ #define SYS_gettimeofday __NR_gettimeofday #define SYS_futex 240 -#define FUTEX_WAIT 0 - - -#if VALUE != 0 -# error "code needs to be rewritten for VALUE != 0" -#endif +#define FUTEX_WAKE 1 .text @@ -43,8 +37,14 @@ .globl sem_timedwait .type sem_timedwait,@function .align 16 + cfi_startproc sem_timedwait: -.LSTARTCODE: + /* First check for cancellation. */ + movl %gs:CANCELHANDLING, %eax + andl $0xfffffff9, %eax + cmpl $8, %eax + je 10f + movl 4(%esp), %ecx movl (%ecx), %eax @@ -61,24 +61,24 @@ sem_timedwait: /* Check whether the timeout value is valid. */ 1: pushl %esi -.Lpush_esi: + cfi_adjust_cfa_offset(4) pushl %edi -.Lpush_edi: + cfi_adjust_cfa_offset(4) pushl %ebx -.Lpush_ebx: + cfi_adjust_cfa_offset(4) subl $12, %esp -.Lsub_esp: + cfi_adjust_cfa_offset(12) movl 32(%esp), %edi + cfi_offset(7, -12) /* %edi */ /* Check for invalid nanosecond field. */ cmpl $1000000000, 4(%edi) movl $EINVAL, %esi + cfi_offset(6, -8) /* %esi */ jae 6f - LOCK - incl NWAITERS(%ecx) - + cfi_offset(3, -16) /* %ebx */ 7: xorl %ecx, %ecx movl %esp, %ebx movl %ecx, %edx @@ -103,26 +103,19 @@ sem_timedwait: movl %ecx, (%esp) /* Store relative timeout. */ movl %edx, 4(%esp) -.LcleanupSTART: call __pthread_enable_asynccancel movl %eax, 8(%esp) - movl 28(%esp), %ebx /* Load semaphore address. */ -#if FUTEX_WAIT == 0 - movl PRIVATE(%ebx), %ecx -#else - movl $FUTEX_WAIT, %ecx - orl PRIVATE(%ebx), %ecx -#endif + movl 28(%esp), %ebx + xorl %ecx, %ecx movl %esp, %esi - xorl %edx, %edx movl $SYS_futex, %eax + xorl %edx, %edx ENTER_KERNEL movl %eax, %esi movl 8(%esp), %eax call __pthread_disable_asynccancel -.LcleanupEND: testl %esi, %esi je 9f @@ -138,22 +131,24 @@ sem_timedwait: cmpxchgl %ecx, (%ebx) jne 8b - xorl %eax, %eax - -10: LOCK - decl NWAITERS(%ebx) - addl $12, %esp -.Ladd_esp: + cfi_adjust_cfa_offset(-12) + xorl %eax, %eax popl %ebx -.Lpop_ebx: + cfi_adjust_cfa_offset(-4) + cfi_restore(3) popl %edi -.Lpop_edi: + cfi_adjust_cfa_offset(-4) + cfi_restore(7) popl %esi -.Lpop_esi: + cfi_adjust_cfa_offset(-4) + cfi_restore(6) ret -.Lafter_ret: + cfi_adjust_cfa_offset(24) + cfi_offset(6, -8) /* %esi */ + cfi_offset(7, -12) /* %edi */ + cfi_offset(3, -16) /* %ebx */ 3: negl %esi 6: #ifdef PIC @@ -177,163 +172,25 @@ sem_timedwait: movl %esi, (%eax) #endif - movl 28(%esp), %ebx /* Load semaphore address. */ + addl $12, %esp + cfi_adjust_cfa_offset(-12) orl $-1, %eax - jmp 10b - .size sem_timedwait,.-sem_timedwait - + popl %ebx + cfi_adjust_cfa_offset(-4) + cfi_restore(3) + popl %edi + cfi_adjust_cfa_offset(-4) + cfi_restore(7) + popl %esi + cfi_adjust_cfa_offset(-4) + cfi_restore(6) + ret - .type sem_wait_cleanup,@function -sem_wait_cleanup: +10: /* Canceled. */ + movl $0xffffffff, %gs:RESULT LOCK - decl NWAITERS(%ebx) - movl %eax, (%esp) -.LcallUR: - call _Unwind_Resume@PLT - hlt -.LENDCODE: - .size sem_wait_cleanup,.-sem_wait_cleanup - - - .section .gcc_except_table,"a",@progbits -.LexceptSTART: - .byte 0xff # @LPStart format (omit) - .byte 0xff # @TType format (omit) - .byte 0x01 # call-site format - # DW_EH_PE_uleb128 - .uleb128 .Lcstend-.Lcstbegin -.Lcstbegin: - .uleb128 .LcleanupSTART-.LSTARTCODE - .uleb128 .LcleanupEND-.LcleanupSTART - .uleb128 sem_wait_cleanup-.LSTARTCODE - .uleb128 0 - .uleb128 .LcallUR-.LSTARTCODE - .uleb128 .LENDCODE-.LcallUR - .uleb128 0 - .uleb128 0 -.Lcstend: - - - .section .eh_frame,"a",@progbits -.LSTARTFRAME: - .long .LENDCIE-.LSTARTCIE # Length of the CIE. -.LSTARTCIE: - .long 0 # CIE ID. - .byte 1 # Version number. -#ifdef SHARED - .string "zPLR" # NUL-terminated augmentation - # string. -#else - .string "zPL" # NUL-terminated augmentation - # string. -#endif - .uleb128 1 # Code alignment factor. - .sleb128 -4 # Data alignment factor. - .byte 8 # Return address register - # column. -#ifdef SHARED - .uleb128 7 # Augmentation value length. - .byte 0x9b # Personality: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4 - # + DW_EH_PE_indirect - .long DW.ref.__gcc_personality_v0-. - .byte 0x1b # LSDA Encoding: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4. - .byte 0x1b # FDE Encoding: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4. -#else - .uleb128 6 # Augmentation value length. - .byte 0x0 # Personality: absolute - .long __gcc_personality_v0 - .byte 0x0 # LSDA Encoding: absolute -#endif - .byte 0x0c # DW_CFA_def_cfa - .uleb128 4 - .uleb128 4 - .byte 0x88 # DW_CFA_offset, column 0x10 - .uleb128 1 - .align 4 -.LENDCIE: - - .long .LENDFDE-.LSTARTFDE # Length of the FDE. -.LSTARTFDE: - .long .LSTARTFDE-.LSTARTFRAME # CIE pointer. -#ifdef SHARED - .long .LSTARTCODE-. # PC-relative start address - # of the code. -#else - .long .LSTARTCODE # Start address of the code. -#endif - .long .LENDCODE-.LSTARTCODE # Length of the code. - .uleb128 4 # Augmentation size -#ifdef SHARED - .long .LexceptSTART-. -#else - .long .LexceptSTART -#endif - - .byte 4 # DW_CFA_advance_loc4 - .long .Lpush_esi-.LSTARTCODE - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 8 - .byte 0x86 # DW_CFA_offset %esi - .uleb128 2 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpush_edi-.Lpush_esi - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 12 - .byte 0x87 # DW_CFA_offset %edi - .uleb128 3 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpush_ebx-.Lpush_edi - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 16 - .byte 0x83 # DW_CFA_offset %ebx - .uleb128 4 - .byte 4 # DW_CFA_advance_loc4 - .long .Lsub_esp-.Lpush_ebx - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 28 - .byte 4 # DW_CFA_advance_loc4 - .long .Ladd_esp-.Lsub_esp - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 16 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpop_ebx-.Ladd_esp - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 12 - .byte 0xc3 # DW_CFA_restore %ebx - .byte 4 # DW_CFA_advance_loc4 - .long .Lpop_edi-.Lpop_ebx - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 8 - .byte 0xc7 # DW_CFA_restore %edi - .byte 4 # DW_CFA_advance_loc4 - .long .Lpop_esi-.Lpop_edi - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 4 - .byte 0xc6 # DW_CFA_restore %esi - .byte 4 # DW_CFA_advance_loc4 - .long .Lafter_ret-.Lpop_esi - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 28 - .byte 0x86 # DW_CFA_offset %esi - .uleb128 2 - .byte 0x87 # DW_CFA_offset %edi - .uleb128 3 - .byte 0x83 # DW_CFA_offset %ebx - .uleb128 4 - .align 4 -.LENDFDE: - - -#ifdef SHARED - .hidden DW.ref.__gcc_personality_v0 - .weak DW.ref.__gcc_personality_v0 - .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits - .align 4 - .type DW.ref.__gcc_personality_v0, @object - .size DW.ref.__gcc_personality_v0, 4 -DW.ref.__gcc_personality_v0: - .long __gcc_personality_v0 -#endif + orl $0x10, %gs:CANCELHANDLING + movl %gs:CLEANUP_JMP_BUF, %eax + jmp HIDDEN_JUMPTARGET (__pthread_unwind) + cfi_endproc + .size sem_timedwait,.-sem_timedwait diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_wait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_wait.S index d0eef75144..b1296275d0 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_wait.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_wait.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 <drepper@redhat.com>, 2002. @@ -20,7 +20,6 @@ #include <sysdep.h> #include <shlib-compat.h> #include <pthread-errnos.h> -#include <structsem.h> #ifndef UP # define LOCK lock @@ -29,261 +28,22 @@ #endif #define SYS_futex 240 -#define FUTEX_WAIT 0 +#define FUTEX_WAKE 1 -#if VALUE != 0 -# error "code needs to be rewritten for VALUE != 0" -#endif - .text .globl __new_sem_wait .type __new_sem_wait,@function .align 16 + cfi_startproc __new_sem_wait: -.LSTARTCODE: - pushl %ebx -.Lpush_ebx: - pushl %esi -.Lpush_esi: - subl $4, %esp -.Lsub_esp: - - movl 16(%esp), %ebx - - movl (%ebx), %eax -2: testl %eax, %eax - je 1f - - leal -1(%eax), %edx - LOCK - cmpxchgl %edx, (%ebx) - jne 2b -7: xorl %eax, %eax - -9: movl 4(%esp), %esi - movl 8(%esp), %ebx - addl $12, %esp -.Ladd_esp: - ret - -.Lafter_ret: -1: LOCK - incl NWAITERS(%ebx) - -.LcleanupSTART: -6: call __pthread_enable_asynccancel - movl %eax, (%esp) - -#if FUTEX_WAIT == 0 - movl PRIVATE(%ebx), %ecx -#else - movl $FUTEX_WAIT, %ecx - orl PRIVATE(%ebx), %ecx -#endif - xorl %esi, %esi - xorl %edx, %edx - movl $SYS_futex, %eax - ENTER_KERNEL - movl %eax, %esi - - movl (%esp), %eax - call __pthread_disable_asynccancel -.LcleanupEND: - - testl %esi, %esi - je 3f - cmpl $-EWOULDBLOCK, %esi - jne 4f - -3: - movl (%ebx), %eax -5: testl %eax, %eax - je 6b - - leal -1(%eax), %edx - LOCK - cmpxchgl %edx, (%ebx) - jne 5b - - LOCK - decl NWAITERS(%ebx) - jmp 7b - -4: LOCK - decl NWAITERS(%ebx) - - negl %esi -#ifdef PIC - call __i686.get_pc_thunk.bx -#else - movl $8f, %ebx -8: -#endif - addl $_GLOBAL_OFFSET_TABLE_, %ebx -#if USE___THREAD -# ifdef NO_TLS_DIRECT_SEG_REFS - movl errno@gotntpoff(%ebx), %edx - addl %gs:0, %edx - movl %esi, (%edx) -# else - movl errno@gotntpoff(%ebx), %edx - movl %esi, %gs:(%edx) -# endif -#else - call __errno_location@plt - movl %esi, (%eax) -#endif - orl $-1, %eax - - jmp 9b - .size __new_sem_wait,.-__new_sem_wait - versioned_symbol(libpthread, __new_sem_wait, sem_wait, GLIBC_2_1) - - - .type sem_wait_cleanup,@function -sem_wait_cleanup: - LOCK - decl NWAITERS(%ebx) - movl %eax, (%esp) -.LcallUR: - call _Unwind_Resume@PLT - hlt -.LENDCODE: - .size sem_wait_cleanup,.-sem_wait_cleanup - - - .section .gcc_except_table,"a",@progbits -.LexceptSTART: - .byte 0xff # @LPStart format (omit) - .byte 0xff # @TType format (omit) - .byte 0x01 # call-site format - # DW_EH_PE_uleb128 - .uleb128 .Lcstend-.Lcstbegin -.Lcstbegin: - .uleb128 .LcleanupSTART-.LSTARTCODE - .uleb128 .LcleanupEND-.LcleanupSTART - .uleb128 sem_wait_cleanup-.LSTARTCODE - .uleb128 0 - .uleb128 .LcallUR-.LSTARTCODE - .uleb128 .LENDCODE-.LcallUR - .uleb128 0 - .uleb128 0 -.Lcstend: - - - .section .eh_frame,"a",@progbits -.LSTARTFRAME: - .long .LENDCIE-.LSTARTCIE # Length of the CIE. -.LSTARTCIE: - .long 0 # CIE ID. - .byte 1 # Version number. -#ifdef SHARED - .string "zPLR" # NUL-terminated augmentation - # string. -#else - .string "zPL" # NUL-terminated augmentation - # string. -#endif - .uleb128 1 # Code alignment factor. - .sleb128 -4 # Data alignment factor. - .byte 8 # Return address register - # column. -#ifdef SHARED - .uleb128 7 # Augmentation value length. - .byte 0x9b # Personality: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4 - # + DW_EH_PE_indirect - .long DW.ref.__gcc_personality_v0-. - .byte 0x1b # LSDA Encoding: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4. - .byte 0x1b # FDE Encoding: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4. -#else - .uleb128 6 # Augmentation value length. - .byte 0x0 # Personality: absolute - .long __gcc_personality_v0 - .byte 0x0 # LSDA Encoding: absolute -#endif - .byte 0x0c # DW_CFA_def_cfa - .uleb128 4 - .uleb128 4 - .byte 0x88 # DW_CFA_offset, column 0x10 - .uleb128 1 - .align 4 -.LENDCIE: - - .long .LENDFDE-.LSTARTFDE # Length of the FDE. -.LSTARTFDE: - .long .LSTARTFDE-.LSTARTFRAME # CIE pointer. -#ifdef SHARED - .long .LSTARTCODE-. # PC-relative start address - # of the code. -#else - .long .LSTARTCODE # Start address of the code. -#endif - .long .LENDCODE-.LSTARTCODE # Length of the code. - .uleb128 4 # Augmentation size -#ifdef SHARED - .long .LexceptSTART-. -#else - .long .LexceptSTART -#endif + /* First check for cancellation. */ + movl %gs:CANCELHANDLING, %eax + andl $0xfffffff9, %eax + cmpl $8, %eax + je 5f - .byte 4 # DW_CFA_advance_loc4 - .long .Lpush_ebx-.LSTARTCODE - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 8 - .byte 0x83 # DW_CFA_offset %ebx - .uleb128 2 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpush_esi-.Lpush_ebx - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 12 - .byte 0x86 # DW_CFA_offset %esi - .uleb128 3 - .byte 4 # DW_CFA_advance_loc4 - .long .Lsub_esp-.Lpush_esi - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 16 - .byte 4 # DW_CFA_advance_loc4 - .long .Ladd_esp-.Lsub_esp - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 4 - .byte 0xc3 # DW_CFA_restore %ebx - .byte 0xc6 # DW_CFA_restore %esi - .byte 4 # DW_CFA_advance_loc4 - .long .Lafter_ret-.Ladd_esp - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 16 - .byte 0x83 # DW_CFA_offset %ebx - .uleb128 2 - .byte 0x86 # DW_CFA_offset %esi - .uleb128 3 - .align 4 -.LENDFDE: - - -#ifdef SHARED - .hidden DW.ref.__gcc_personality_v0 - .weak DW.ref.__gcc_personality_v0 - .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits - .align 4 - .type DW.ref.__gcc_personality_v0, @object - .size DW.ref.__gcc_personality_v0, 4 -DW.ref.__gcc_personality_v0: - .long __gcc_personality_v0 -#endif - - -#if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1) - .section ".text.compat", "ax" - .global __old_sem_wait - .type __old_sem_wait,@function - .align 16 - cfi_startproc -__old_sem_wait: pushl %ebx cfi_adjust_cfa_offset(4) pushl %esi @@ -292,9 +52,9 @@ __old_sem_wait: cfi_adjust_cfa_offset(4) movl 16(%esp), %ebx - cfi_offset(ebx, -8) + cfi_offset(3, -8) /* %ebx */ - cfi_offset(esi, -12) + cfi_offset(6, -12) /* %esi */ 3: movl (%ebx), %eax 2: testl %eax, %eax je 1f @@ -305,17 +65,17 @@ __old_sem_wait: jne 2b xorl %eax, %eax -5: movl 4(%esp), %esi + movl 4(%esp), %esi + cfi_restore(6) movl 8(%esp), %ebx + cfi_restore(3) addl $12, %esp - cfi_restore(ebx) - cfi_restore(esi) cfi_adjust_cfa_offset(-12) ret cfi_adjust_cfa_offset(12) - cfi_offset(ebx, -8) - cfi_offset(esi, -12) + cfi_offset(3, -8) /* %ebx */ + cfi_offset(6, -12) /* %esi */ 1: call __pthread_enable_asynccancel movl %eax, (%esp) @@ -355,8 +115,25 @@ __old_sem_wait: movl %esi, (%eax) #endif orl $-1, %eax - jmp 5b + movl 4(%esp), %esi + cfi_restore(6) + movl 8(%esp), %ebx + cfi_restore(3) + addl $12, %esp + cfi_adjust_cfa_offset(-12) + ret + +5: /* Canceled. */ + movl $0xffffffff, %gs:RESULT + LOCK + orl $0x10, %gs:CANCELHANDLING + movl %gs:CLEANUP_JMP_BUF, %eax + jmp HIDDEN_JUMPTARGET (__pthread_unwind) cfi_endproc - .size __old_sem_wait,.-__old_sem_wait + .size __new_sem_wait,.-__new_sem_wait + versioned_symbol(libpthread, __new_sem_wait, sem_wait, GLIBC_2_1) +#if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1) + .global __old_sem_wait +__old_sem_wait = __new_sem_wait compat_symbol(libpthread, __old_sem_wait, sem_wait, GLIBC_2_0) #endif diff --git a/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h index 474b39ae18..21de09fe91 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h @@ -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 <drepper@redhat.com>, 2002. @@ -23,8 +23,6 @@ #include <time.h> #include <sys/param.h> #include <bits/pthreadtypes.h> -#include <kernel-features.h> -#include <tcb-offsets.h> #ifndef LOCK_INSTR # ifdef UP @@ -40,14 +38,6 @@ #define FUTEX_LOCK_PI 6 #define FUTEX_UNLOCK_PI 7 #define FUTEX_TRYLOCK_PI 8 -#define FUTEX_PRIVATE_FLAG 128 - - -/* Values for 'private' parameter of locking macros. Yes, the - definition seems to be backwards. But it is not. The bit will be - reversed before passing to the system call. */ -#define LLL_PRIVATE 0 -#define LLL_SHARED FUTEX_PRIVATE_FLAG /* Initializer for compatibility lock. */ @@ -154,11 +144,7 @@ LLL_STUB_UNWIND_INFO_START \ LLL_STUB_UNWIND_INFO_END -#define lll_futex_wait(futex, val, private) \ - lll_futex_timed_wait (futex, val, NULL, private) - - -#define lll_futex_timed_wait(futex, val, timeout, private) \ +#define lll_futex_wait(futex, val) \ ({ \ int __status; \ register __typeof (val) _val asm ("edx") = (val); \ @@ -166,7 +152,7 @@ LLL_STUB_UNWIND_INFO_END LLL_ENTER_KERNEL \ LLL_EBX_LOAD \ : "=a" (__status) \ - : "0" (SYS_futex), LLL_EBX_REG (futex), "S" (timeout), \ + : "0" (SYS_futex), LLL_EBX_REG (futex), "S" (0), \ "c" (FUTEX_WAIT), "d" (_val), \ "i" (offsetof (tcbhead_t, sysinfo)) \ : "memory"); \ @@ -174,27 +160,7 @@ LLL_STUB_UNWIND_INFO_END }) -#define lll_futex_wake(futex, nr, private) \ - do { \ - int __ignore; \ - register __typeof (nr) _nr asm ("edx") = (nr); \ - __asm __volatile (LLL_EBX_LOAD \ - LLL_ENTER_KERNEL \ - LLL_EBX_LOAD \ - : "=a" (__ignore) \ - : "0" (SYS_futex), LLL_EBX_REG (futex), \ - "c" (FUTEX_WAKE), "d" (_nr), \ - "i" (0) /* phony, to align next arg's number */, \ - "i" (offsetof (tcbhead_t, sysinfo))); \ - } while (0) - - -#define lll_private_futex_wait(futex, val) \ - lll_private_futex_timed_wait (futex, val, NULL) - - -#ifdef __ASSUME_PRIVATE_FUTEX -# define lll_private_futex_timed_wait(futex, val, timeout) \ +#define lll_futex_timed_wait(futex, val, timeout) \ ({ \ int __status; \ register __typeof (val) _val asm ("edx") = (val); \ @@ -203,14 +169,14 @@ LLL_STUB_UNWIND_INFO_END LLL_EBX_LOAD \ : "=a" (__status) \ : "0" (SYS_futex), LLL_EBX_REG (futex), "S" (timeout), \ - "c" (FUTEX_WAIT | FUTEX_PRIVATE_FLAG)), "d" (_val), \ + "c" (FUTEX_WAIT), "d" (_val), \ "i" (offsetof (tcbhead_t, sysinfo)) \ : "memory"); \ __status; \ }) -# define lll_private_futex_wake(futex, nr) \ +#define lll_futex_wake(futex, nr) \ do { \ int __ignore; \ register __typeof (nr) _nr asm ("edx") = (nr); \ @@ -219,45 +185,10 @@ LLL_STUB_UNWIND_INFO_END LLL_EBX_LOAD \ : "=a" (__ignore) \ : "0" (SYS_futex), LLL_EBX_REG (futex), \ - "c" (FUTEX_WAKE | FUTEX_PRIVATE_FLAG), "d" (_nr), \ + "c" (FUTEX_WAKE), "d" (_nr), \ "i" (0) /* phony, to align next arg's number */, \ "i" (offsetof (tcbhead_t, sysinfo))); \ } while (0) -#else -# define lll_private_futex_timed_wait(futex, val, timeout) \ - ({ \ - int __status; \ - int __ignore; \ - register __typeof (val) _val asm ("edx") = (val); \ - __asm __volatile ("movl %%gs:%P7, %%ecx\n\t" \ - LLL_EBX_LOAD \ - LLL_ENTER_KERNEL \ - LLL_EBX_LOAD \ - : "=a" (__status), "=c" (__ignore) \ - : LLL_EBX_REG (futex), "0" (SYS_futex), "S" (timeout), \ - "d" (_val), "i" (offsetof (tcbhead_t, sysinfo)), \ - "i" (PRIVATE_FUTEX) \ - : "memory"); \ - __status; \ - }) - - -# define lll_private_futex_wake(futex, nr) \ - do { \ - int __ignore; \ - int __ignore2; \ - register __typeof (nr) _nr asm ("edx") = (nr); \ - __asm __volatile ("orl %%gs:%P7, %%ecx\n\t" \ - LLL_EBX_LOAD \ - LLL_ENTER_KERNEL \ - LLL_EBX_LOAD \ - : "=a" (__ignore), "=c" (__ignore2) \ - : LLL_EBX_REG (futex), "0" (SYS_futex), \ - "1" (FUTEX_WAKE), "d" (_nr), \ - "i" (offsetof (tcbhead_t, sysinfo)), \ - "i" (PRIVATE_FUTEX)); \ - } while (0) -#endif /* Does not preserve %eax and %ecx. */ @@ -483,6 +414,21 @@ extern int __lll_mutex_unlock_wake (int *__futex) "i" (offsetof (tcbhead_t, sysinfo))); }) +#define lll_futex_wake(futex, nr) \ + do { \ + int __ignore; \ + register __typeof (nr) _nr asm ("edx") = (nr); \ + __asm __volatile (LLL_EBX_LOAD \ + LLL_ENTER_KERNEL \ + LLL_EBX_LOAD \ + : "=a" (__ignore) \ + : "0" (SYS_futex), LLL_EBX_REG (futex), \ + "c" (FUTEX_WAKE), "d" (_nr), \ + "i" (0) /* phony, to align next arg's number */, \ + "i" (offsetof (tcbhead_t, sysinfo))); \ + } while (0) + + #define lll_mutex_islocked(futex) \ (futex != 0) @@ -502,6 +448,7 @@ extern int __lll_lock_wait (int val, int *__futex) __attribute ((regparm (2))) attribute_hidden; extern int __lll_unlock_wake (int *__futex) __attribute ((regparm (1))) attribute_hidden; +extern int lll_unlock_wake_cb (int *__futex) attribute_hidden; /* The states of a lock are: diff --git a/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S index 8ff0dad27f..312933c5e4 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S @@ -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 <drepper@redhat.com>, 2002. @@ -19,8 +19,6 @@ #include <unwindbuf.h> #include <sysdep.h> -#include <kernel-features.h> - #ifndef UP # define LOCK lock @@ -28,10 +26,8 @@ # define LOCK #endif -#define SYS_futex 240 -#define FUTEX_WAIT 0 -#define FUTEX_WAKE 1 -#define FUTEX_PRIVATE_FLAG 128 +#define SYS_futex 240 +#define FUTEX_WAKE 1 .comm __fork_generation, 4, 4 @@ -94,16 +90,7 @@ __pthread_once: jnz 3f /* Different for generation -> run initializer. */ /* Somebody else got here first. Wait. */ -#ifdef __ASSUME_PRIVATE_FUTEX - movl $FUTEX_WAIT|FUTEX_PRIVATE_FLAG, %ecx -#else -# if FUTEX_WAIT == 0 - movl %gs:PRIVATE_FUTEX, %ecx -# else - movl $FUTEX_WAIT, %ecx - orl %gs:PRIVATE_FUTEX, %ecx -# endif -#endif + movl %esi, %ecx /* movl $FUTEX_WAIT, %ecx */ movl $SYS_futex, %eax ENTER_KERNEL jmp 6b @@ -144,12 +131,7 @@ __pthread_once: /* Wake up all other threads. */ movl $0x7fffffff, %edx -#ifdef __ASSUME_PRIVATE_FUTEX - movl $FUTEX_WAKE|FUTEX_PRIVATE_FLAG, %ecx -#else movl $FUTEX_WAKE, %ecx - orl %gs:PRIVATE_FUTEX, %ecx -#endif movl $SYS_futex, %eax ENTER_KERNEL @@ -170,12 +152,7 @@ __pthread_once: movl $0, (%ebx) movl $0x7fffffff, %edx -#ifdef __ASSUME_PRIVATE_FUTEX - movl $FUTEX_WAKE|FUTEX_PRIVATE_FLAG, %ecx -#else movl $FUTEX_WAKE, %ecx - orl %gs:PRIVATE_FUTEX, %ecx -#endif movl $SYS_futex, %eax ENTER_KERNEL diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h index 17093471d3..8df997a262 100644 --- a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. @@ -226,6 +226,8 @@ extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *) /* Type for lock object. */ typedef int lll_lock_t; +extern int lll_unlock_wake_cb (int *__futex) attribute_hidden; + /* Initializers for lock. */ #define LLL_LOCK_INITIALIZER (0) #define LLL_LOCK_INITIALIZER_LOCKED (1) diff --git a/nptl/sysdeps/unix/sysv/linux/internaltypes.h b/nptl/sysdeps/unix/sysv/linux/internaltypes.h index add20b6f72..1dec19e57d 100644 --- a/nptl/sysdeps/unix/sysv/linux/internaltypes.h +++ b/nptl/sysdeps/unix/sysv/linux/internaltypes.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -76,11 +76,9 @@ struct pthread_condattr /* The __NWAITERS field is used as a counter and to house the number - of bits for other purposes. COND_CLOCK_BITS is the number - of bits needed to represent the ID of the clock. COND_NWAITERS_SHIFT - is the number of bits reserved for other purposes like the clock. */ -#define COND_CLOCK_BITS 1 -#define COND_NWAITERS_SHIFT 1 + of bits which represent the clock. COND_CLOCK_BITS is the number + of bits reserved for the clock. */ +#define COND_CLOCK_BITS 1 /* Read-write lock variable attribute data structure. */ @@ -98,7 +96,6 @@ struct pthread_barrier int lock; unsigned int left; unsigned int init_count; - int private; }; @@ -140,16 +137,9 @@ struct pthread_key_struct /* Semaphore variable structure. */ -struct new_sem +struct sem { - unsigned int value; - int private; - unsigned long int nwaiters; -}; - -struct old_sem -{ - unsigned int value; + unsigned int count; }; diff --git a/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c b/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c index 4b614bd1a6..92a188a2f3 100644 --- a/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c +++ b/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c @@ -26,7 +26,6 @@ #include <pthreadP.h> #include <bits/libc-lock.h> #include <sysdep.h> -#include <ldsodefs.h> #ifdef TLS_MULTIPLE_THREADS_IN_TCB diff --git a/nptl/sysdeps/unix/sysv/linux/lowlevelbarrier.sym b/nptl/sysdeps/unix/sysv/linux/lowlevelbarrier.sym index cfe22b0892..36e28eb2a6 100644 --- a/nptl/sysdeps/unix/sysv/linux/lowlevelbarrier.sym +++ b/nptl/sysdeps/unix/sysv/linux/lowlevelbarrier.sym @@ -9,4 +9,3 @@ CURR_EVENT offsetof (struct pthread_barrier, curr_event) MUTEX offsetof (struct pthread_barrier, lock) LEFT offsetof (struct pthread_barrier, left) INIT_COUNT offsetof (struct pthread_barrier, init_count) -PRIVATE offsetof (struct pthread_barrier, private) diff --git a/nptl/sysdeps/unix/sysv/linux/lowlevelcond.sym b/nptl/sysdeps/unix/sysv/linux/lowlevelcond.sym index 18e1adad43..c5e7978069 100644 --- a/nptl/sysdeps/unix/sysv/linux/lowlevelcond.sym +++ b/nptl/sysdeps/unix/sysv/linux/lowlevelcond.sym @@ -13,4 +13,4 @@ wakeup_seq offsetof (pthread_cond_t, __data.__wakeup_seq) woken_seq offsetof (pthread_cond_t, __data.__woken_seq) dep_mutex offsetof (pthread_cond_t, __data.__mutex) broadcast_seq offsetof (pthread_cond_t, __data.__broadcast_seq) -nwaiters_shift COND_NWAITERS_SHIFT +clock_bits COND_CLOCK_BITS diff --git a/nptl/sysdeps/unix/sysv/linux/lowlevellock.c b/nptl/sysdeps/unix/sysv/linux/lowlevellock.c index ab7f605f0c..932e27300f 100644 --- a/nptl/sysdeps/unix/sysv/linux/lowlevellock.c +++ b/nptl/sysdeps/unix/sysv/linux/lowlevellock.c @@ -1,5 +1,5 @@ /* low level locking for pthread library. Generic futex-using version. - Copyright (C) 2003, 2007 Free Software Foundation, Inc. + Copyright (C) 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Paul Mackerras <paulus@au.ibm.com>, 2003. @@ -31,9 +31,7 @@ __lll_lock_wait (int *futex) { int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1); if (oldval != 0) - lll_futex_wait (futex, 2, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wait (futex, 2); } while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0); } @@ -70,9 +68,7 @@ __lll_timedlock_wait (int *futex, const struct timespec *abstime) /* Wait. */ int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1); if (oldval != 0) - lll_futex_timed_wait (futex, 2, &rt, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_timed_wait (futex, 2, &rt); } while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0); @@ -80,9 +76,21 @@ __lll_timedlock_wait (int *futex, const struct timespec *abstime) } -/* This function doesn't get included in libc.so */ +/* These don't get included in libc.so */ #ifdef IS_IN_libpthread int +lll_unlock_wake_cb (int *futex) +{ + int val = atomic_exchange_rel (futex, 0); + + if (__builtin_expect (val > 1, 0)) + lll_futex_wake (futex, 1); + + return 0; +} + + +int __lll_timedwait_tid (int *tidp, const struct timespec *abstime) { int tid; @@ -112,12 +120,12 @@ __lll_timedwait_tid (int *tidp, const struct timespec *abstime) if (rt.tv_sec < 0) return ETIMEDOUT; - /* Wait until thread terminates. The kernel so far does not use - the private futex operations for this. */ - if (lll_futex_timed_wait (tidp, tid, &rt, LLL_SHARED) == -ETIMEDOUT) + /* Wait until thread terminates. */ + if (lll_futex_timed_wait (tidp, tid, &rt) == -ETIMEDOUT) return ETIMEDOUT; } return 0; } + #endif diff --git a/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c b/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c index 54cee0859b..30ef991bd0 100644 --- a/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c +++ b/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c @@ -44,9 +44,7 @@ __lll_robust_lock_wait (int *futex) && atomic_compare_and_exchange_bool_acq (futex, newval, oldval)) continue; - lll_futex_wait (futex, newval, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wait (futex, newval); try: ; @@ -102,9 +100,7 @@ __lll_robust_timedlock_wait (int *futex, const struct timespec *abstime) && atomic_compare_and_exchange_bool_acq (futex, newval, oldval)) continue; - lll_futex_timed_wait (futex, newval, &rt, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_timed_wait (futex, newval, &rt); try: ; diff --git a/nptl/sysdeps/unix/sysv/linux/lowlevelrwlock.sym b/nptl/sysdeps/unix/sysv/linux/lowlevelrwlock.sym index f50b25bfb8..e82c878d39 100644 --- a/nptl/sysdeps/unix/sysv/linux/lowlevelrwlock.sym +++ b/nptl/sysdeps/unix/sysv/linux/lowlevelrwlock.sym @@ -1,7 +1,6 @@ #include <stddef.h> #include <stdio.h> #include <bits/pthreadtypes.h> -#include <bits/wordsize.h> -- @@ -13,4 +12,3 @@ READERS_QUEUED offsetof (pthread_rwlock_t, __data.__nr_readers_queued) WRITERS_QUEUED offsetof (pthread_rwlock_t, __data.__nr_writers_queued) FLAGS offsetof (pthread_rwlock_t, __data.__flags) WRITER offsetof (pthread_rwlock_t, __data.__writer) -PSHARED offsetof (pthread_rwlock_t, __data.__shared) diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h index c0b59c336f..a7150f6aef 100644 --- a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h @@ -1,5 +1,5 @@ /* Machine-specific pthread type layouts. PowerPC 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. Contributed by Paul Mackerras <paulus@au.ibm.com>, 2003. @@ -160,9 +160,9 @@ typedef union unsigned int __nr_readers_queued; unsigned int __nr_writers_queued; int __writer; - int __shared; - unsigned long int __pad1; + int __pad1; unsigned long int __pad2; + unsigned long int __pad3; /* FLAGS must stay at this position in the structure to maintain binary compatibility. */ unsigned int __flags; @@ -176,12 +176,9 @@ typedef union unsigned int __writer_wakeup; unsigned int __nr_readers_queued; unsigned int __nr_writers_queued; - unsigned char __pad1; - unsigned char __pad2; - unsigned char __shared; /* FLAGS must stay at this position in the structure to maintain binary compatibility. */ - unsigned char __flags; + unsigned int __flags; int __writer; } __data; # endif diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h index 20547f94f2..239f4ddf55 100644 --- a/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h @@ -37,8 +37,6 @@ #define FUTEX_LOCK_PI 6 #define FUTEX_UNLOCK_PI 7 #define FUTEX_TRYLOCK_PI 8 -#define FUTEX_PRIVATE_FLAG 128 - /* Initializer for compatibility lock. */ #define LLL_MUTEX_LOCK_INITIALIZER (0) @@ -263,6 +261,8 @@ typedef int lll_lock_t; #define LLL_LOCK_INITIALIZER (0) #define LLL_LOCK_INITIALIZER_LOCKED (1) +extern int lll_unlock_wake_cb (int *__futex) attribute_hidden; + /* The states of a lock are: 0 - untaken 1 - taken by one user diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c b/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c index 6fedac1b33..9472dd17ef 100644 --- a/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c +++ b/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c @@ -1,4 +1,3 @@ -#include <unistd.h> /* For __getpagesize. */ #define NEW_VERNUM GLIBC_2_6 #define STACKSIZE_ADJUST \ do { \ diff --git a/nptl/sysdeps/unix/sysv/linux/rtld-lowlevel.h b/nptl/sysdeps/unix/sysv/linux/rtld-lowlevel.h index 1aeff8fb39..6b3d3682da 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 @@ -24,6 +24,115 @@ #include <lowlevellock.h> +/* Special multi-reader lock used in ld.so. */ +#define __RTLD_MRLOCK_WRITER 1 +#define __RTLD_MRLOCK_RWAIT 2 +#define __RTLD_MRLOCK_WWAIT 4 +#define __RTLD_MRLOCK_RBITS \ + ~(__RTLD_MRLOCK_WRITER | __RTLD_MRLOCK_RWAIT | __RTLD_MRLOCK_WWAIT) +#define __RTLD_MRLOCK_INC 8 +#define __RTLD_MRLOCK_TRIES 5 + + +typedef int __rtld_mrlock_t; + + +#define __rtld_mrlock_define(CLASS,NAME) \ + CLASS __rtld_mrlock_t NAME; + + +#define _RTLD_MRLOCK_INITIALIZER 0 +#define __rtld_mrlock_initialize(NAME) \ + (void) ((NAME) = 0) + + +#define __rtld_mrlock_lock(lock) \ + do { \ + __label__ out; \ + while (1) \ + { \ + int oldval; \ + for (int tries = 0; tries < __RTLD_MRLOCK_TRIES; ++tries) \ + { \ + oldval = lock; \ + while (__builtin_expect ((oldval \ + & (__RTLD_MRLOCK_WRITER \ + | __RTLD_MRLOCK_WWAIT)) \ + == 0, 1)) \ + { \ + int newval = ((oldval & __RTLD_MRLOCK_RBITS) \ + + __RTLD_MRLOCK_INC); \ + int ret = atomic_compare_and_exchange_val_acq (&(lock), \ + newval, \ + oldval); \ + if (__builtin_expect (ret == oldval, 1)) \ + goto out; \ + oldval = ret; \ + } \ + atomic_delay (); \ + } \ + if ((oldval & __RTLD_MRLOCK_RWAIT) == 0) \ + { \ + atomic_or (&(lock), __RTLD_MRLOCK_RWAIT); \ + oldval |= __RTLD_MRLOCK_RWAIT; \ + } \ + lll_futex_wait (lock, oldval); \ + } \ + out:; \ + } while (0) + + +#define __rtld_mrlock_unlock(lock) \ + do { \ + int oldval = atomic_exchange_and_add (&(lock), -__RTLD_MRLOCK_INC); \ + if (__builtin_expect ((oldval \ + & (__RTLD_MRLOCK_RBITS | __RTLD_MRLOCK_WWAIT)) \ + == (__RTLD_MRLOCK_INC | __RTLD_MRLOCK_WWAIT), 0)) \ + /* We have to wake all threads since there might be some queued \ + readers already. */ \ + lll_futex_wake (&(lock), 0x7fffffff); \ + } while (0) + + +/* There can only ever be one thread trying to get the exclusive lock. */ +#define __rtld_mrlock_change(lock) \ + do { \ + __label__ out; \ + while (1) \ + { \ + int oldval; \ + for (int tries = 0; tries < __RTLD_MRLOCK_TRIES; ++tries) \ + { \ + oldval = lock; \ + while (__builtin_expect ((oldval & __RTLD_MRLOCK_RBITS) == 0, 1)) \ + { \ + int newval = ((oldval & __RTLD_MRLOCK_RWAIT) \ + + __RTLD_MRLOCK_WRITER); \ + int ret = atomic_compare_and_exchange_val_acq (&(lock), \ + newval, \ + oldval); \ + if (__builtin_expect (ret == oldval, 1)) \ + goto out; \ + oldval = ret; \ + } \ + atomic_delay (); \ + } \ + atomic_or (&(lock), __RTLD_MRLOCK_WWAIT); \ + oldval |= __RTLD_MRLOCK_WWAIT; \ + lll_futex_wait (lock, oldval); \ + } \ + out:; \ + } while (0) + + +#define __rtld_mrlock_done(lock) \ + do { \ + int oldval = atomic_exchange_and_add (&(lock), -__RTLD_MRLOCK_WRITER); \ + if (__builtin_expect ((oldval & __RTLD_MRLOCK_RWAIT) != 0, 0)) \ + lll_futex_wake (&(lock), 0x7fffffff); \ + } while (0) + + /* Function to wait for variable become zero. Used in ld.so for reference counters. */ #define __rtld_waitzero(word) \ @@ -33,12 +142,12 @@ int val = word; \ if (val == 0) \ break; \ - lll_private_futex_wait (&(word), val); \ + lll_futex_wait (&(word), val); \ } \ } while (0) #define __rtld_notify(word) \ - lll_private_futex_wake (&(word), 1) + lll_futex_wake (&(word), 1) #endif diff --git a/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h index d915facba1..38d9f2ac41 100644 --- a/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -321,6 +321,8 @@ typedef int lll_lock_t; #define lll_unlock(futex) lll_mutex_unlock (futex) #define lll_islocked(futex) lll_mutex_islocked (futex) +extern int lll_unlock_wake_cb (int *__futex) attribute_hidden; + /* The states of a lock are: 1 - untaken 0 - taken by one user diff --git a/nptl/sysdeps/unix/sysv/linux/sem_post.c b/nptl/sysdeps/unix/sysv/linux/sem_post.c index 7f90325585..671b43f7f7 100644 --- a/nptl/sysdeps/unix/sysv/linux/sem_post.c +++ b/nptl/sysdeps/unix/sysv/linux/sem_post.c @@ -1,5 +1,5 @@ /* sem_post -- post to a POSIX semaphore. Generic futex-using version. - Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. @@ -29,36 +29,10 @@ int __new_sem_post (sem_t *sem) { - struct new_sem *isem = (struct new_sem *) sem; - - int nr = atomic_increment_val (&isem->value); - atomic_full_barrier (); - if (isem->nwaiters > 0) - { - int err = lll_futex_wake (&isem->value, 1, - // XYZ check mutex flag - LLL_SHARED); - if (__builtin_expect (err, 0) < 0) - { - __set_errno (-err); - return -1; - } - } - return 0; -} -versioned_symbol (libpthread, __new_sem_post, sem_post, GLIBC_2_1); - - -#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_1) -int -attribute_compat_text_section -__old_sem_post (sem_t *sem) -{ int *futex = (int *) sem; int nr = atomic_increment_val (futex); - /* We always have to assume it is a shared semaphore. */ - int err = lll_futex_wake (futex, 1, LLL_SHARED); + int err = lll_futex_wake (futex, nr); if (__builtin_expect (err, 0) < 0) { __set_errno (-err); @@ -66,5 +40,8 @@ __old_sem_post (sem_t *sem) } return 0; } +versioned_symbol (libpthread, __new_sem_post, sem_post, GLIBC_2_1); +#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_1) +strong_alias (__new_sem_post, __old_sem_post) compat_symbol (libpthread, __old_sem_post, sem_post, GLIBC_2_0); #endif diff --git a/nptl/sysdeps/unix/sysv/linux/sem_timedwait.c b/nptl/sysdeps/unix/sysv/linux/sem_timedwait.c index 8f92d78abe..ef897c1e93 100644 --- a/nptl/sysdeps/unix/sysv/linux/sem_timedwait.c +++ b/nptl/sysdeps/unix/sysv/linux/sem_timedwait.c @@ -1,5 +1,5 @@ /* sem_timedwait -- wait on a semaphore. Generic futex-using version. - Copyright (C) 2003, 2007 Free Software Foundation, Inc. + Copyright (C) 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Paul Mackerras <paulus@au.ibm.com>, 2003. @@ -28,29 +28,28 @@ #include <shlib-compat.h> -extern void __sem_wait_cleanup (void *arg) attribute_hidden; - - int sem_timedwait (sem_t *sem, const struct timespec *abstime) { - struct new_sem *isem = (struct new_sem *) sem; - int err; + /* First check for cancellation. */ + CANCELLATION_P (THREAD_SELF); - if (atomic_decrement_if_positive (&isem->value) > 0) - return 0; + int *futex = (int *) sem; + int val; + int err; - if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) + if (*futex > 0) { - __set_errno (EINVAL); - return -1; + val = atomic_decrement_if_positive (futex); + if (val > 0) + return 0; } - atomic_increment (&isem->nwaiters); - - pthread_cleanup_push (__sem_wait_cleanup, isem); + err = -EINVAL; + if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) + goto error_return; - while (1) + do { struct timeval tv; struct timespec rt; @@ -71,11 +70,7 @@ sem_timedwait (sem_t *sem, const struct timespec *abstime) /* Already timed out? */ err = -ETIMEDOUT; if (sec < 0) - { - __set_errno (ETIMEDOUT); - err = -1; - break; - } + goto error_return; /* Do wait. */ rt.tv_sec = sec; @@ -84,30 +79,21 @@ sem_timedwait (sem_t *sem, const struct timespec *abstime) /* Enable asynchronous cancellation. Required by the standard. */ int oldtype = __pthread_enable_asynccancel (); - err = lll_futex_timed_wait (&isem->value, 0, &rt, - // XYZ check mutex flag - LLL_SHARED); + err = lll_futex_timed_wait (futex, 0, &rt); /* Disable asynchronous cancellation. */ __pthread_disable_asynccancel (oldtype); if (err != 0 && err != -EWOULDBLOCK) - { - __set_errno (-err); - err = -1; - break; - } + goto error_return; - if (atomic_decrement_if_positive (&isem->value) > 0) - { - err = 0; - break; - } + val = atomic_decrement_if_positive (futex); } + while (val <= 0); - pthread_cleanup_pop (0); - - atomic_decrement (&isem->nwaiters); + return 0; - return err; + error_return: + __set_errno (-err); + return -1; } diff --git a/nptl/sysdeps/unix/sysv/linux/sem_wait.c b/nptl/sysdeps/unix/sysv/linux/sem_wait.c index 12f3f16c2d..e6733e88a3 100644 --- a/nptl/sysdeps/unix/sysv/linux/sem_wait.c +++ b/nptl/sysdeps/unix/sysv/linux/sem_wait.c @@ -1,5 +1,5 @@ /* sem_wait -- wait on a semaphore. Generic futex-using version. - Copyright (C) 2003, 2007 Free Software Foundation, Inc. + Copyright (C) 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Paul Mackerras <paulus@au.ibm.com>, 2003. @@ -28,69 +28,12 @@ #include <shlib-compat.h> -void -attribute_hidden -__sem_wait_cleanup (void *arg) -{ - struct new_sem *isem = (struct new_sem *) arg; - - atomic_decrement (&isem->nwaiters); -} - - int __new_sem_wait (sem_t *sem) { - struct new_sem *isem = (struct new_sem *) sem; - int err; - - if (atomic_decrement_if_positive (&isem->value) > 0) - return 0; - - atomic_increment (&isem->nwaiters); + /* First check for cancellation. */ + CANCELLATION_P (THREAD_SELF); - pthread_cleanup_push (__sem_wait_cleanup, isem); - - while (1) - { - /* Enable asynchronous cancellation. Required by the standard. */ - int oldtype = __pthread_enable_asynccancel (); - - err = lll_futex_wait (&isem->value, 0, - // XYZ check mutex flag - LLL_SHARED); - - /* Disable asynchronous cancellation. */ - __pthread_disable_asynccancel (oldtype); - - if (err != 0 && err != -EWOULDBLOCK) - { - __set_errno (-err); - err = -1; - break; - } - - if (atomic_decrement_if_positive (&isem->value) > 0) - { - err = 0; - break; - } - } - - pthread_cleanup_pop (0); - - atomic_decrement (&isem->nwaiters); - - return err; -} -versioned_symbol (libpthread, __new_sem_wait, sem_wait, GLIBC_2_1); - - -#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_1) -int -attribute_compat_text_section -__old_sem_wait (sem_t *sem) -{ int *futex = (int *) sem; int err; @@ -102,8 +45,7 @@ __old_sem_wait (sem_t *sem) /* Enable asynchronous cancellation. Required by the standard. */ int oldtype = __pthread_enable_asynccancel (); - /* Always assume the semaphore is shared. */ - err = lll_futex_wait (futex, 0, LLL_SHARED); + err = lll_futex_wait (futex, 0); /* Disable asynchronous cancellation. */ __pthread_disable_asynccancel (oldtype); @@ -114,5 +56,8 @@ __old_sem_wait (sem_t *sem) return -1; } +versioned_symbol (libpthread, __new_sem_wait, sem_wait, GLIBC_2_1); +#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_1) +strong_alias (__new_sem_wait, __old_sem_wait) compat_symbol (libpthread, __old_sem_wait, sem_wait, GLIBC_2_0); #endif diff --git a/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h index badcda5701..969686dd5a 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h @@ -1,5 +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 <drepper@redhat.com>, 2002. @@ -21,8 +20,6 @@ #ifndef _BITS_PTHREADTYPES_H #define _BITS_PTHREADTYPES_H 1 -#include <endian.h> - #define __SIZEOF_PTHREAD_ATTR_T 36 #define __SIZEOF_PTHREAD_MUTEX_T 24 #define __SIZEOF_PTHREAD_MUTEXATTR_T 4 @@ -130,21 +127,9 @@ typedef union unsigned int __writer_wakeup; unsigned int __nr_readers_queued; unsigned int __nr_writers_queued; -#if __BYTE_ORDER == __BIG_ENDIAN - unsigned char __pad1; - unsigned char __pad2; - unsigned char __shared; - /* FLAGS must stay at this position in the structure to maintain - binary compatibility. */ - unsigned char __flags; -#else /* FLAGS must stay at this position in the structure to maintain binary compatibility. */ - unsigned char __flags; - unsigned char __shared; - unsigned char __pad1; - unsigned char __pad2; -#endif + unsigned int __flags; pthread_t __writer; } __data; char __size[__SIZEOF_PTHREAD_RWLOCK_T]; diff --git a/nptl/sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S index be85ab7414..94a24b46ee 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2007 Free Software Foundation, Inc. +/* Copyright (C) 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 @@ -16,32 +16,4 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <kernel-features.h> - -/* All locks in libc are private. Use the kernel feature if possible. */ -#define FUTEX_PRIVATE_FLAG 128 -#ifdef __ASSUME_PRIVATE_FUTEX -# define FUTEX_WAIT (0 | FUTEX_PRIVATE_FLAG) -# define FUTEX_WAKE (1 | FUTEX_PRIVATE_FLAG) -#else -# define LOAD_FUTEX_WAIT(reg,tmp) \ - stc gbr, tmp ; \ - mov.w 99f, reg ; \ - add reg, tmp ; \ - bra 98f ; \ - mov.l @tmp, reg ; \ -99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \ -98: - -# define LOAD_FUTEX_WAKE(reg,tmp) \ - stc gbr, tmp ; \ - mov.w 99f, reg ; \ - add reg, tmp ; \ - mov.l @tmp, reg ; \ - bra 98f ; \ - mov #FUTEX_WAKE, tmp ; \ -99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \ -98: or tmp, reg -#endif - #include "lowlevellock.S" diff --git a/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S index b10903bcd7..ac3169889f 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2005 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 @@ -24,24 +24,8 @@ #define SYS_gettimeofday __NR_gettimeofday #define SYS_futex 240 -#ifndef FUTEX_WAIT -# define FUTEX_WAIT 0 -# define FUTEX_WAKE 1 -#endif - -#ifndef LOAD_FUTEX_WAIT -# if FUTEX_WAIT == 0 -# define LOAD_FUTEX_WAIT(reg,tmp) \ - xor reg, reg -# else -# define LOAD_FUTEX_WAIT(reg,tmp) \ - mov #FUTEX_WAIT, reg; \ - extu.b reg, reg -# endif -# define LOAD_FUTEX_WAKE(reg,tmp) \ - mov #FUTEX_WAKE, reg; \ - extu.b reg, reg -#endif +#define FUTEX_WAIT 0 +#define FUTEX_WAKE 1 .globl __lll_mutex_lock_wait @@ -56,7 +40,7 @@ __lll_mutex_lock_wait: mov r4, r6 mov r5, r8 mov #0, r7 /* No timeout. */ - LOAD_FUTEX_WAIT (r5, r0) + mov #FUTEX_WAIT, r5 mov #2, r4 cmp/eq r4, r6 @@ -149,7 +133,7 @@ __lll_mutex_timedlock_wait: bt 8f mov r8, r4 - LOAD_FUTEX_WAIT (r5, r0) + mov #FUTEX_WAIT, r5 mov r10, r6 mov r15, r7 mov #SYS_futex, r3 @@ -202,13 +186,41 @@ __lll_mutex_timedlock_wait: #endif +#ifdef NOT_IN_libc + .globl lll_unlock_wake_cb + .type lll_unlock_wake_cb,@function + .hidden lll_unlock_wake_cb + .align 5 + cfi_startproc +lll_unlock_wake_cb: + DEC (@r4, r2) + tst r2, r2 + bt 1f + + mov #FUTEX_WAKE, r5 + mov #1, r6 /* Wake one thread. */ + mov #0, r7 + mov.l r7, @r4 /* Stores 0. */ + mov #SYS_futex, r3 + extu.b r3, r3 + trapa #0x14 + SYSCALL_INST_PAD + +1: + rts + nop + cfi_endproc + .size lll_unlock_wake_cb,.-lll_unlock_wake_cb +#endif + + .globl __lll_mutex_unlock_wake .type __lll_mutex_unlock_wake,@function .hidden __lll_mutex_unlock_wake .align 5 cfi_startproc __lll_mutex_unlock_wake: - LOAD_FUTEX_WAKE (r5, r0) + mov #FUTEX_WAKE, r5 mov #1, r6 /* Wake one thread. */ mov #0, r7 mov.l r7, @r4 /* Stores 0. */ @@ -277,10 +289,7 @@ __lll_timedwait_tid: bt 4f mov r8, r4 - /* XXX The kernel so far uses global futex for the wakeup at - all times. */ - mov #0, r5 - extu.b r5, r5 + mov #FUTEX_WAIT, r5 mov r2, r6 mov r15, r7 mov #SYS_futex, r3 diff --git a/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h index 3092b27642..0eb1f0114c 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 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 @@ -22,7 +22,6 @@ #include <time.h> #include <sys/param.h> #include <bits/pthreadtypes.h> -#include <kernel-features.h> #define SYS_futex 240 #define FUTEX_WAIT 0 @@ -30,14 +29,6 @@ #define FUTEX_LOCK_PI 6 #define FUTEX_UNLOCK_PI 7 #define FUTEX_TRYLOCK_PI 8 -#define FUTEX_PRIVATE_FLAG 128 - - -/* Values for 'private' parameter of locking macros. Yes, the - definition seems to be backwards. But it is not. The bit will be - reversed before passing to the system call. */ -#define LLL_PRIVATE 0 -#define LLL_SHARED FUTEX_PRIVATE_FLAG /* Initializer for compatibility lock. */ @@ -260,7 +251,7 @@ extern int __lll_mutex_unlock_wake (int *__futex) attribute_hidden; and %2,%0\n\ mov.l %0,@%1\n\ 1: mov r1,r15"\ - : "=&r" (__result) : "r" (__futex), "r" (FUTEX_WAITERS) \ + : "=&r" (__result) : "r" (__futex), "r" (FUTEX_TID_MASK) \ : "r0", "r1", "memory"); \ if (__result) \ __lll_mutex_unlock_wake (__futex); }) @@ -278,7 +269,7 @@ extern int __lll_mutex_unlock_wake (int *__futex) attribute_hidden; 1: mov r1,r15"\ : "=&r" (__ignore) : "r" (__futex), "r" (FUTEX_OWNER_DIED) \ : "r0", "r1", "memory"); \ - lll_futex_wake (__futex, 1, 0); }) + lll_futex_wake (__futex, 1); }) #define lll_mutex_islocked(futex) \ (futex != 0) @@ -303,57 +294,15 @@ typedef int lll_lock_t; trapa #0x14" # endif -#define lll_futex_wait(futex, val, private) \ - lll_futex_timed_wait (futex, val, NULL, private) - - -#define lll_futex_timed_wait(futex, val, timeout, private) \ +#define lll_futex_wait(futex, val) \ ({ \ int __status; \ register unsigned long __r3 asm ("r3") = SYS_futex; \ register unsigned long __r4 asm ("r4") = (unsigned long) (futex); \ register unsigned long __r5 asm ("r5") = FUTEX_WAIT; \ register unsigned long __r6 asm ("r6") = (unsigned long) (val); \ - register unsigned long __r7 asm ("r7") = (timeout); \ - __asm __volatile (SYSCALL_WITH_INST_PAD \ - : "=z" (__status) \ - : "r" (__r3), "r" (__r4), "r" (__r5), \ - "r" (__r6), "r" (__r7) \ - : "memory", "t"); \ - __status; \ - }) - - -#define lll_futex_wake(futex, nr, private) \ - do { \ - int __ignore; \ - register unsigned long __r3 asm ("r3") = SYS_futex; \ - register unsigned long __r4 asm ("r4") = (unsigned long) (futex); \ - register unsigned long __r5 asm ("r5") = FUTEX_WAKE; \ - register unsigned long __r6 asm ("r6") = (unsigned long) (nr); \ register unsigned long __r7 asm ("r7") = 0; \ __asm __volatile (SYSCALL_WITH_INST_PAD \ - : "=z" (__ignore) \ - : "r" (__r3), "r" (__r4), "r" (__r5), \ - "r" (__r6), "r" (__r7) \ - : "memory", "t"); \ - } while (0) - - -#define lll_private_futex_wait(futex, val) \ - lll_private_futex_timed_wait (futex, val, NULL) - - -#ifdef __ASSUME_PRIVATE_FUTEX -# define lll_private_futex_timed_wait(futex, val, timeout) \ - ({ \ - int __status; \ - register unsigned long __r3 asm ("r3") = SYS_futex; \ - register unsigned long __r4 asm ("r4") = (unsigned long) (futex); \ - register unsigned long __r5 asm ("r5") = FUTEX_WAIT | FUTEX_PRIVATE_FLAG; \ - register unsigned long __r6 asm ("r6") = (unsigned long) (val); \ - register unsigned long __r7 asm ("r7") = (timeout); \ - __asm __volatile (SYSCALL_WITH_INST_PAD \ : "=z" (__status) \ : "r" (__r3), "r" (__r4), "r" (__r5), \ "r" (__r6), "r" (__r7) \ @@ -362,32 +311,14 @@ typedef int lll_lock_t; }) -# define lll_private_futex_wake(futex, nr) \ - do { \ - int __ignore; \ - register unsigned long __r3 asm ("r3") = SYS_futex; \ - register unsigned long __r4 asm ("r4") = (unsigned long) (futex); \ - register unsigned long __r5 asm ("r5") = FUTEX_WAKE | FUTEX_PRIVATE_FLAG; \ - register unsigned long __r6 asm ("r6") = (unsigned long) (nr); \ - register unsigned long __r7 asm ("r7") = 0; \ - __asm __volatile (SYSCALL_WITH_INST_PAD \ - : "=z" (__ignore) \ - : "r" (__r3), "r" (__r4), "r" (__r5), \ - "r" (__r6), "r" (__r7) \ - : "memory", "t"); \ - } while (0) - - -#else -# define lll_private_futex_timed_wait(futex, val, timeout) \ +#define lll_futex_timed_wait(futex, val, timeout) \ ({ \ int __status; \ register unsigned long __r3 asm ("r3") = SYS_futex; \ register unsigned long __r4 asm ("r4") = (unsigned long) (futex); \ - register unsigned long __r5 asm ("r5"); \ + register unsigned long __r5 asm ("r5") = FUTEX_WAIT; \ register unsigned long __r6 asm ("r6") = (unsigned long) (val); \ register unsigned long __r7 asm ("r7") = (timeout); \ - __r5 = THREAD_GETMEM (THREAD_SELF, header.private_futex); \ __asm __volatile (SYSCALL_WITH_INST_PAD \ : "=z" (__status) \ : "r" (__r3), "r" (__r4), "r" (__r5), \ @@ -397,7 +328,7 @@ typedef int lll_lock_t; }) -# define lll_private_futex_wake(futex, nr) \ +#define lll_futex_wake(futex, nr) \ do { \ int __ignore; \ register unsigned long __r3 asm ("r3") = SYS_futex; \ @@ -405,14 +336,15 @@ typedef int lll_lock_t; register unsigned long __r5 asm ("r5") = FUTEX_WAKE; \ register unsigned long __r6 asm ("r6") = (unsigned long) (nr); \ register unsigned long __r7 asm ("r7") = 0; \ - __r5 |= THREAD_GETMEM (THREAD_SELF, header.private_futex); \ __asm __volatile (SYSCALL_WITH_INST_PAD \ : "=z" (__ignore) \ : "r" (__r3), "r" (__r4), "r" (__r5), \ "r" (__r6), "r" (__r7) \ : "memory", "t"); \ } while (0) -#endif + + +extern int lll_unlock_wake_cb (int *__futex) attribute_hidden; /* The states of a lock are: @@ -438,7 +370,7 @@ extern int __lll_wait_tid (int *tid) attribute_hidden; do { \ __typeof (tid) *__tid = &(tid); \ while (*__tid != 0) \ - lll_futex_wait (__tid, *__tid, 0); \ + lll_futex_wait (__tid, *__tid); \ } while (0) extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime) diff --git a/nptl/sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S b/nptl/sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S index 35dd607fc1..1fbb23a5a6 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004 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 @@ -65,13 +65,7 @@ pthread_barrier_wait: #if CURR_EVENT != 0 add #CURR_EVENT, r4 #endif -#if FUTEX_WAIT == 0 - mov.l @(PRIVATE,r8), r5 -#else mov #FUTEX_WAIT, r5 - mov.l @(PRIVATE,r8), r0 - or r0, r5 -#endif mov #0, r7 8: mov #SYS_futex, r3 @@ -124,8 +118,6 @@ pthread_barrier_wait: #endif mov #0, r7 mov #FUTEX_WAKE, r5 - mov.l @(PRIVATE,r8), r0 - or r0, r5 mov #SYS_futex, r3 extu.b r3, r3 trapa #0x14 diff --git a/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S index 0173cfb7d8..6c782c8a76 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 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 @@ -120,7 +120,7 @@ __pthread_cond_timedwait: mov.l @(cond_futex,r8), r0 add r2, r0 mov.l r0, @(cond_futex,r8) - mov #(1 << nwaiters_shift), r2 + mov #(1 << clock_bits), r2 mov.l @(cond_nwaiters,r8), r0 add r2, r0 mov.l r0, @(cond_nwaiters,r8) @@ -136,7 +136,7 @@ __pthread_cond_timedwait: #ifdef __NR_clock_gettime /* Get the clock number. */ mov.l @(cond_nwaiters,r8), r4 - mov #((1 << nwaiters_shift) - 1), r0 + mov #((1 << clock_bits) - 1), r0 and r0, r4 /* Only clocks 0 and 1 are allowed. Both are handled in the kernel. */ @@ -323,7 +323,7 @@ __pthread_cond_timedwait: mov.l r1,@(woken_seq+4,r8) 24: - mov #(1 << nwaiters_shift), r2 + mov #(1 << clock_bits), r2 mov.l @(cond_nwaiters,r8),r0 sub r2, r0 mov.l r0,@(cond_nwaiters,r8) @@ -335,7 +335,7 @@ __pthread_cond_timedwait: not r0, r0 cmp/eq #0, r0 bf/s 25f - mov #((1 << nwaiters_shift) - 1), r1 + mov #((1 << clock_bits) - 1), r1 not r1, r1 mov.l @(cond_nwaiters,r8),r0 tst r1, r0 @@ -557,7 +557,7 @@ __condvar_tw_cleanup: mov.l r1,@(woken_seq+4,r8) 3: - mov #(1 << nwaiters_shift), r2 + mov #(1 << clock_bits), r2 mov.l @(cond_nwaiters,r8),r0 sub r2, r0 mov.l r0,@(cond_nwaiters,r8) @@ -570,7 +570,7 @@ __condvar_tw_cleanup: not r0, r0 cmp/eq #0, r0 bf/s 4f - mov #((1 << nwaiters_shift) - 1), r1 + mov #((1 << clock_bits) - 1), r1 not r1, r1 mov.l @(cond_nwaiters,r8),r0 tst r1, r0 diff --git a/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S index 5eb332e484..6c59f3e6c0 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 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 @@ -107,7 +107,7 @@ __pthread_cond_wait: mov.l @(cond_futex,r8),r0 add r2, r0 mov.l r0,@(cond_futex,r8) - mov #(1 << nwaiters_shift), r2 + mov #(1 << clock_bits), r2 mov.l @(cond_nwaiters,r8), r0 add r2, r0 mov.l r0, @(cond_nwaiters,r8) @@ -197,7 +197,7 @@ __pthread_cond_wait: mov.l r1,@(woken_seq+4,r8) 16: - mov #(1 << nwaiters_shift), r2 + mov #(1 << clock_bits), r2 mov.l @(cond_nwaiters,r8),r0 sub r2, r0 mov.l r0,@(cond_nwaiters,r8) @@ -209,7 +209,7 @@ __pthread_cond_wait: not r0, r0 cmp/eq #0, r0 bf/s 17f - mov #((1 << nwaiters_shift) - 1), r1 + mov #((1 << clock_bits) - 1), r1 not r1, r1 mov.l @(cond_nwaiters,r8),r0 tst r1, r0 @@ -421,7 +421,7 @@ __condvar_w_cleanup: mov.l r1,@(woken_seq+4,r8) 3: - mov #(1 << nwaiters_shift), r2 + mov #(1 << clock_bits), r2 mov.l @(cond_nwaiters,r8),r0 sub r2, r0 mov.l r0,@(cond_nwaiters,r8) @@ -434,7 +434,7 @@ __condvar_w_cleanup: not r0, r0 cmp/eq #0, r0 bf/s 4f - mov #((1 << nwaiters_shift) - 1), r1 + mov #((1 << clock_bits) - 1), r1 not r1, r1 mov.l @(cond_nwaiters,r8),r0 tst r1, r0 diff --git a/nptl/sysdeps/unix/sysv/linux/sh/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/sh/pthread_once.S index 3d694d8376..02af56b4c7 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/pthread_once.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/pthread_once.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -18,13 +18,11 @@ #include <unwindbuf.h> #include <sysdep.h> -#include <kernel-features.h> #include "lowlevel-atomic.h" -#define SYS_futex 240 -#define FUTEX_WAIT 0 -#define FUTEX_WAKE 1 -#define FUTEX_PRIVATE_FLAG 128 +#define SYS_futex 240 +#define FUTEX_WAIT 0 +#define FUTEX_WAKE 1 .comm __fork_generation, 4, 4 @@ -97,19 +95,7 @@ __pthread_once: bf 3f /* Different for generation -> run initializer. */ /* Somebody else got here first. Wait. */ -#if __ASSUME_PRIVATE_FUTEX - mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAIT), r5 - extu.b r5, r5 -#else - stc gbr, r1 - mov.w .Lpfoff, r2 - add r2, r1 - mov.l @r1, r5 -# if FUTEX_WAIT != 0 - mov #FUTEX_WAIT, r0 - or r0, r5 -# endif -#endif + mov #FUTEX_WAIT, r5 mov r3, r6 mov #0, r7 mov #SYS_futex, r3 @@ -171,17 +157,7 @@ __pthread_once: INC (@r9, r2) /* Wake up all other threads. */ mov r9, r4 -#if __ASSUME_PRIVATE_FUTEX - mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAKE), r5 - extu.b r5, r5 -#else - stc gbr, r1 - mov.w .Lpfoff, r2 - add r2, r1 - mov.l @r1, r5 - mov #FUTEX_WAKE, r0 - or r0, r5 -#endif + mov #FUTEX_WAKE, r5 mov #-1, r6 shlr r6 /* r6 = 0x7fffffff */ mov #0, r7 @@ -216,17 +192,7 @@ __pthread_once: mov #0, r7 mov.l r7, @r9 mov r9, r4 -#if __ASSUME_PRIVATE_FUTEX - mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAKE), r5 -#else - stc gbr, r1 - mov.w .Lpfoff, r2 - add r2, r1 - mov.l @r1, r5 - mov #FUTEX_WAKE, r0 - or r0, r5 -#endif - extu.b r5, r5 + mov #FUTEX_WAKE, r5 mov #-1, r6 shlr r6 /* r6 = 0x7fffffff */ mov #SYS_futex, r3 @@ -242,10 +208,6 @@ __pthread_once: sleep cfi_endproc -#if !__ASSUME_PRIVATE_FUTEX -.Lpfoff: - .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE -#endif .align 2 .Lsigsetjmp: .long __sigsetjmp@PLT-(.Lsigsetjmp0-.) @@ -262,3 +224,23 @@ __pthread_once_internal = __pthread_once .globl pthread_once pthread_once = __pthread_once + + + .type clear_once_control,@function + .align 5 +clear_once_control: + mov #0, r0 + mov.l r0, @r4 + + mov #FUTEX_WAKE, r5 + mov #-1, r6 + shlr r6 /* r6 = 0x7fffffff */ + mov #0, r7 + mov #SYS_futex, r3 + extu.b r3, r3 + trapa #0x14 + SYSCALL_INST_PAD + + rts + nop + .size clear_once_control,.-clear_once_control diff --git a/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S b/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S index f1795131f8..f64c7217c9 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2007 Free Software Foundation, Inc. +/* Copyright (C) 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 @@ -20,13 +20,11 @@ #include <lowlevelrwlock.h> #include <pthread-errnos.h> #include <tcb-offsets.h> -#include <kernel-features.h> #include "lowlevel-atomic.h" #define SYS_futex 240 #define FUTEX_WAIT 0 #define FUTEX_WAKE 1 -#define FUTEX_PRIVATE_FLAG 128 .text @@ -57,8 +55,7 @@ __pthread_rwlock_rdlock: mov.l @(WRITERS_QUEUED,r8), r0 tst r0, r0 bt 5f - mov #FLAGS, r0 - mov.b @(r0,r8), r0 + mov.l @(FLAGS,r8), r0 tst r0, r0 bt 5f 3: @@ -78,28 +75,9 @@ __pthread_rwlock_rdlock: tst r2, r2 bf 10f 11: -#if __ASSUME_PRIVATE_FUTEX - mov #PSHARED, r0 - mov.b @(r0,r8), r5 - mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAIT), r0 - xor r0, r5 - extu.b r5, r5 -#else - mov #PSHARED, r0 - mov.b @(r0,r8), r5 - extu.b r5, r5 -# if FUTEX_WAIT != 0 - mov #FUTEX_WAIT, r0 - or r0, r5 -# endif - stc gbr, r1 - mov.w .Lpfoff, r2 - add r2, r1 - mov.l @r1, r0 - xor r0, r5 -#endif mov r8, r4 add #READERS_WAKEUP, r4 + mov #FUTEX_WAIT, r5 mov r9, r6 mov #0, r7 mov #SYS_futex, r3 @@ -146,11 +124,6 @@ __pthread_rwlock_rdlock: rts mov r3, r0 -#if !__ASSUME_PRIVATE_FUTEX -.Lpfoff: - .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE -#endif - 1: mov r8, r5 #if MUTEX != 0 diff --git a/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S b/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S index e87326e9bd..633a14b1aa 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2007 Free Software Foundation, Inc. +/* Copyright (C) 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 @@ -20,14 +20,12 @@ #include <lowlevelrwlock.h> #include <pthread-errnos.h> #include <tcb-offsets.h> -#include <kernel-features.h> #include "lowlevel-atomic.h" #define SYS_gettimeofday __NR_gettimeofday #define SYS_futex 240 #define FUTEX_WAIT 0 #define FUTEX_WAKE 1 -#define FUTEX_PRIVATE_FLAG 128 .text @@ -61,8 +59,7 @@ pthread_rwlock_timedrdlock: mov.l @(WRITERS_QUEUED,r8), r0 tst r0, r0 bt 5f - mov #FLAGS, r0 - mov.b @(r0,r8), r0 + mov.l @(FLAGS,r8), r0 tst r0, r0 bt 5f 3: @@ -120,26 +117,7 @@ pthread_rwlock_timedrdlock: /* Futex call. */ mov r15, r7 -#if __ASSUME_PRIVATE_FUTEX - mov #PSHARED, r0 - mov.b @(r0,r8), r5 - mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAIT), r0 - xor r0, r5 - extu.b r5, r5 -#else - mov #PSHARED, r0 - mov.b @(r0,r8), r5 - extu.b r5, r5 -# if FUTEX_WAIT != 0 - mov #FUTEX_WAIT, r0 - or r0, r5 -# endif - stc gbr, r1 - mov.w .Lpfoff, r2 - add r2, r1 - mov.l @r1, r0 - xor r0, r5 -#endif + mov #FUTEX_WAIT, r5 mov r10, r6 mov r8, r4 add #READERS_WAKEUP, r4 @@ -198,10 +176,6 @@ pthread_rwlock_timedrdlock: rts mov r3, r0 -#if !__ASSUME_PRIVATE_FUTEX -.Lpfoff: - .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE -#endif .align 2 .L1k0: .long 1000 diff --git a/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S b/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S index 18641fe9df..29e29b6f65 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2007 Free Software Foundation, Inc. +/* Copyright (C) 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 @@ -20,14 +20,12 @@ #include <lowlevelrwlock.h> #include <pthread-errnos.h> #include <tcb-offsets.h> -#include <kernel-features.h> #include "lowlevel-atomic.h" #define SYS_gettimeofday __NR_gettimeofday #define SYS_futex 240 #define FUTEX_WAIT 0 #define FUTEX_WAKE 1 -#define FUTEX_PRIVATE_FLAG 128 .text @@ -116,26 +114,7 @@ pthread_rwlock_timedwrlock: /* Futex call. */ mov r15, r7 -#if __ASSUME_PRIVATE_FUTEX - mov #PSHARED, r0 - mov.b @(r0,r8), r5 - mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAIT), r0 - xor r0, r5 - extu.b r5, r5 -#else - mov #PSHARED, r0 - mov.b @(r0,r8), r5 - extu.b r5, r5 -# if FUTEX_WAIT != 0 - mov #FUTEX_WAIT, r0 - or r0, r5 -# endif - stc gbr, r1 - mov.w .Lpfoff, r2 - add r2, r1 - mov.l @r1, r0 - xor r0, r5 -#endif + mov #FUTEX_WAIT, r5 mov r10, r6 mov r8, r4 add #WRITERS_WAKEUP, r4 @@ -196,10 +175,6 @@ pthread_rwlock_timedwrlock: rts mov r3, r0 -#if !__ASSUME_PRIVATE_FUTEX -.Lpfoff: - .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE -#endif .L1k1: .word 1000 .align 2 diff --git a/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S b/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S index df4df60d7f..172689bec3 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2007 Free Software Foundation, Inc. +/* Copyright (C) 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 @@ -18,13 +18,11 @@ #include <sysdep.h> #include <lowlevelrwlock.h> -#include <kernel-features.h> #include "lowlevel-atomic.h" #define SYS_futex 240 #define FUTEX_WAIT 0 #define FUTEX_WAKE 1 -#define FUTEX_PRIVATE_FLAG 128 .text @@ -89,24 +87,7 @@ __pthread_rwlock_unlock: bf 7f 8: -#if __ASSUME_PRIVATE_FUTEX - mov #PSHARED, r0 - mov.b @(r0,r8), r5 - mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAKE), r0 - xor r0, r5 - extu.b r5, r5 -#else - mov #PSHARED, r0 - mov.b @(r0,r8), r5 - extu.b r5, r5 - mov #FUTEX_WAKE, r0 - or r0, r5 - stc gbr, r1 - mov.w .Lpfoff, r2 - add r2, r1 - mov.l @r1, r0 - xor r0, r5 -#endif + mov #FUTEX_WAKE, r5 mov #SYS_futex, r3 mov #0, r7 extu.b r3, r3 @@ -173,10 +154,6 @@ __pthread_rwlock_unlock: bra 8b mov.l @r15+, r4 -#if !__ASSUME_PRIVATE_FUTEX -.Lpfoff: - .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE -#endif .align 2 .Lwait8: .long __lll_mutex_lock_wait-.Lwait8b diff --git a/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S b/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S index 13a2fda9fd..995d823e80 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2007 Free Software Foundation, Inc. +/* Copyright (C) 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 @@ -20,13 +20,11 @@ #include <lowlevelrwlock.h> #include <pthread-errnos.h> #include <tcb-offsets.h> -#include <kernel-features.h> #include "lowlevel-atomic.h" #define SYS_futex 240 #define FUTEX_WAIT 0 #define FUTEX_WAKE 1 -#define FUTEX_PRIVATE_FLAG 128 .text @@ -76,26 +74,7 @@ __pthread_rwlock_wrlock: 11: mov r8, r4 add #WRITERS_WAKEUP, r4 -#if __ASSUME_PRIVATE_FUTEX - mov #PSHARED, r0 - mov.b @(r0,r8), r5 - mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAIT), r0 - xor r0, r5 - extu.b r5, r5 -#else - mov #PSHARED, r0 - mov.b @(r0,r8), r5 - extu.b r5, r5 -# if FUTEX_WAIT != 0 - mov #FUTEX_WAIT, r0 - or r0, r5 -# endif - stc gbr, r1 - mov.w .Lpfoff, r2 - add r2, r1 - mov.l @r1, r0 - xor r0, r5 -#endif + mov #FUTEX_WAIT, r5 mov r9, r6 mov #0, r7 mov #SYS_futex, r3 @@ -173,10 +152,6 @@ __pthread_rwlock_wrlock: bra 7b mov #0, r3 -#if !__ASSUME_PRIVATE_FUTEX -.Lpfoff: - .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE -#endif .Ltidoff: .word TID - TLS_PRE_TCB_SIZE diff --git a/nptl/sysdeps/unix/sysv/linux/sh/sem_post.S b/nptl/sysdeps/unix/sysv/linux/sh/sem_post.S index a63233feab..9bc12da7e0 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/sem_post.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/sem_post.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004 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 @@ -19,7 +19,6 @@ #include <sysdep.h> #include <shlib-compat.h> #include <pthread-errnos.h> -#include <structsem.h> #include "lowlevel-atomic.h" @@ -35,14 +34,11 @@ .align 5 __new_sem_post: mov #1, r3 - XADD (r3, @(VALUE,r4), r2) - mov.l @(NWAITERS,r4), r2 - tst r2, r2 - bt 2f + XADD (r3, @r4, r2) + mov #FUTEX_WAKE, r5 - mov.l @(PRIVATE,r4), r1 - or r1, r5 - mov #1, r6 + mov r2, r6 + add #1, r6 mov #0, r7 mov #SYS_futex, r3 extu.b r3, r3 @@ -51,7 +47,6 @@ __new_sem_post: cmp/pz r0 bf 1f -2: rts mov #0, r0 diff --git a/nptl/sysdeps/unix/sysv/linux/sh/sem_timedwait.S b/nptl/sysdeps/unix/sysv/linux/sh/sem_timedwait.S index e5e064b3a5..acb7d0f78b 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/sem_timedwait.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/sem_timedwait.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004 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 @@ -20,25 +20,32 @@ #include <shlib-compat.h> #include <pthread-errnos.h> #include <tcb-offsets.h> -#include <structsem.h> #include "lowlevel-atomic.h" #define SYS_gettimeofday __NR_gettimeofday #define SYS_futex 240 #define FUTEX_WAIT 0 - -#if VALUE != 0 -# error "code needs to be rewritten for VALUE != 0" -#endif +#define FUTEX_WAKE 1 .text .globl sem_timedwait .type sem_timedwait,@function .align 5 + cfi_startproc sem_timedwait: -.LSTARTCODE: + /* First check for cancellation. */ + stc gbr, r0 + mov.w .Lchand, r1 + mov.l @(r0,r1), r0 + mov #0xf9, r1 + and r1, r0 + cmp/eq #8, r0 + bf 0f + bra 10f + stc gbr, r0 +0: mov.l @r4, r0 2: tst r0, r0 @@ -55,17 +62,22 @@ sem_timedwait: 1: /* Check whether the timeout value is valid. */ mov.l r8, @-r15 -.Lpush_r8: + cfi_adjust_cfa_offset(4) + cfi_rel_offset (r8, 0) mov.l r9, @-r15 -.Lpush_r9: + cfi_adjust_cfa_offset(4) + cfi_rel_offset (r9, 0) mov.l r10, @-r15 -.Lpush_r10: + cfi_adjust_cfa_offset(4) + cfi_rel_offset (r10, 0) mov.l r12, @-r15 -.Lpush_r12: + cfi_adjust_cfa_offset(4) + cfi_rel_offset (r12, 0) sts.l pr, @-r15 -.Lpush_pr: + cfi_adjust_cfa_offset(4) + cfi_rel_offset (pr, 0) add #-8, r15 -.Lalloc: + cfi_adjust_cfa_offset(8) mov r4, r8 mov r5, r9 @@ -75,9 +87,13 @@ sem_timedwait: cmp/hs r1, r0 bt/s 6f mov #EINVAL, r0 - INC (@(NWAITERS,r8),r2) - 7: + mov.l .Lenable0, r1 + bsrf r1 + nop +.Lenable0b: + mov r0, r10 + /* Compute relative timeout. */ mov r15, r4 mov #0, r5 @@ -108,21 +124,9 @@ sem_timedwait: mov.l r2, @r15 mov.l r3, @(4,r15) -.LcleanupSTART: - mov.l .Lenable0, r1 - bsrf r1 - nop -.Lenable0b: - mov r0, r10 - + /* Futex call. */ mov r8, r4 -#if FUTEX_WAIT == 0 - mov.l @(PRIVATE,r8), r5 -#else - mov.l @(PRIVATE,r8), r5 - mov #FUTEX_WAIT, r0 - or r0, r5 -#endif + mov #FUTEX_WAIT, r5 mov #0, r6 mov r15, r7 mov #SYS_futex, r3 @@ -136,7 +140,6 @@ sem_timedwait: mov r0, r10 .Ldisable0b: mov r10, r0 -.LcleanupEND: tst r0, r0 bt 9f @@ -155,10 +158,6 @@ sem_timedwait: bf/s 8b mov r2, r0 - DEC (@(NWAITERS,r8), r2) - mov #0, r0 - -10: add #8, r15 lds.l @r15+, pr mov.l @r15+, r12 @@ -166,12 +165,12 @@ sem_timedwait: mov.l @r15+, r9 mov.l @r15+, r8 rts - nop + mov #0, r0 3: neg r0, r0 6: - mov r0, r10 + mov r0, r8 mova .Lgot2, r0 mov.l .Lgot2, r12 add r0, r12 @@ -181,20 +180,46 @@ sem_timedwait: stc gbr, r1 mov.l @(r0, r12), r0 add r1, r0 - mov.l r10, @r0 + mov.l r8, @r0 #else mov.l .Lerrloc2, r1 bsrf r1 nop .Lerrloc2b: - mov.l r10, @r0 + mov.l r8, @r0 #endif - DEC (@(NWAITERS,r8), r2) - bra 10b + add #8, r15 + lds.l @r15+, pr + mov.l @r15+, r12 + mov.l @r15+, r10 + mov.l @r15+, r9 + mov.l @r15+, r8 + rts mov #-1, r0 +10: + /* Canceled. */ + mov.w .Lresult, r1 + mov #-1, r2 + mov.l r2, @(r0,r1) + mov.w .Lchand, r0 + or.b #0x10, @(r0,gbr) + stc gbr, r0 + mov.w .Lclbuf, r1 + mov.l .Lunwind, r2 + braf r2 + mov.l @(r0,r1), r4 +.Lunwindb: + cfi_endproc + .L1k: .word 1000 +.Lchand: + .word CANCELHANDLING - TLS_PRE_TCB_SIZE +.Lresult: + .word RESULT - TLS_PRE_TCB_SIZE +.Lclbuf: + .word CLEANUP_JMP_BUF - TLS_PRE_TCB_SIZE .align 2 .L1g: .long 1000000000 @@ -211,151 +236,6 @@ sem_timedwait: .long __pthread_enable_asynccancel-.Lenable0b .Ldisable0: .long __pthread_disable_asynccancel-.Ldisable0b +.Lunwind: + .long HIDDEN_JUMPTARGET (__pthread_unwind)-.Lunwindb .size sem_timedwait,.-sem_timedwait - - .type sem_wait_cleanup,@function -sem_wait_cleanup: - DEC (@(NWAITERS,r8), r2) -.LcallUR: - mov.l .Lresume, r1 -#ifdef PIC - add r12, r1 -#endif - jsr @r1 - nop - sleep - - .align 2 -.Lresume: -#ifdef PIC - .long _Unwind_Resume@GOTOFF -#else - .long _Unwind_Resume -#endif -.LENDCODE: - .size sem_wait_cleanup,.-sem_wait_cleanup - - - .section .gcc_except_table,"a",@progbits -.LexceptSTART: - .byte 0xff ! @LPStart format (omit) - .byte 0xff ! @TType format (omit) - .byte 0x01 ! call-site format - ! DW_EH_PE_uleb128 - .uleb128 .Lcstend-.Lcstbegin -.Lcstbegin: - .uleb128 .LcleanupSTART-.LSTARTCODE - .uleb128 .LcleanupEND-.LcleanupSTART - .uleb128 sem_wait_cleanup-.LSTARTCODE - .uleb128 0 - .uleb128 .LcallUR-.LSTARTCODE - .uleb128 .LENDCODE-.LcallUR - .uleb128 0 - .uleb128 0 -.Lcstend: - - - .section .eh_frame,"a",@progbits -.LSTARTFRAME: - .ualong .LENDCIE-.LSTARTCIE ! Length of the CIE. -.LSTARTCIE: - .ualong 0 ! CIE ID. - .byte 1 ! Version number. -#ifdef SHARED - .string "zPLR" ! NUL-terminated augmentation - ! string. -#else - .string "zPL" ! NUL-terminated augmentation - ! string. -#endif - .uleb128 1 ! Code alignment factor. - .sleb128 -4 ! Data alignment factor. - .byte 0x11 ! Return address register - ! column. -#ifdef SHARED - .uleb128 7 ! Augmentation value length. - .byte 0x9b ! Personality: DW_EH_PE_pcrel - ! + DW_EH_PE_sdata4 - ! + DW_EH_PE_indirect - .ualong DW.ref.__gcc_personality_v0-. - .byte 0x1b ! LSDA Encoding: DW_EH_PE_pcrel - ! + DW_EH_PE_sdata4. - .byte 0x1b ! FDE Encoding: DW_EH_PE_pcrel - ! + DW_EH_PE_sdata4. -#else - .uleb128 6 ! Augmentation value length. - .byte 0x0 ! Personality: absolute - .ualong __gcc_personality_v0 - .byte 0x0 ! LSDA Encoding: absolute -#endif - .byte 0x0c ! DW_CFA_def_cfa - .uleb128 0xf - .uleb128 0 - .align 4 -.LENDCIE: - - .ualong .LENDFDE-.LSTARTFDE ! Length of the FDE. -.LSTARTFDE: - .ualong .LSTARTFDE-.LSTARTFRAME ! CIE pointer. -#ifdef SHARED - .ualong .LSTARTCODE-. ! PC-relative start address - ! of the code. -#else - .ualong .LSTARTCODE ! Start address of the code. -#endif - .ualong .LENDCODE-.LSTARTCODE ! Length of the code. - .uleb128 4 ! Augmentation size -#ifdef SHARED - .ualong .LexceptSTART-. -#else - .ualong .LexceptSTART -#endif - - .byte 4 ! DW_CFA_advance_loc4 - .ualong .Lpush_r8-.LSTARTCODE - .byte 14 ! DW_CFA_def_cfa_offset - .uleb128 4 - .byte 0x88 ! DW_CFA_offset r8 - .uleb128 1 - .byte 4 ! DW_CFA_advance_loc4 - .ualong .Lpush_r9-.Lpush_r8 - .byte 14 ! DW_CFA_def_cfa_offset - .uleb128 8 - .byte 0x89 ! DW_CFA_offset r9 - .uleb128 2 - .byte 4 ! DW_CFA_advance_loc4 - .ualong .Lpush_r10-.Lpush_r9 - .byte 14 ! DW_CFA_def_cfa_offset - .uleb128 12 - .byte 0x8a ! DW_CFA_offset r10 - .uleb128 3 - .byte 4 ! DW_CFA_advance_loc4 - .ualong .Lpush_r12-.Lpush_r10 - .byte 14 ! DW_CFA_def_cfa_offset - .uleb128 16 - .byte 0x8c ! DW_CFA_offset r12 - .uleb128 4 - .byte 4 ! DW_CFA_advance_loc4 - .ualong .Lpush_pr-.Lpush_r12 - .byte 14 ! DW_CFA_def_cfa_offset - .uleb128 20 - .byte 0x91 ! DW_CFA_offset pr - .uleb128 5 - .byte 4 ! DW_CFA_advance_loc4 - .ualong .Lalloc-.Lpush_pr - .byte 14 ! DW_CFA_def_cfa_offset - .uleb128 28 - .align 4 -.LENDFDE: - - -#ifdef SHARED - .hidden DW.ref.__gcc_personality_v0 - .weak DW.ref.__gcc_personality_v0 - .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits - .align 4 - .type DW.ref.__gcc_personality_v0, @object - .size DW.ref.__gcc_personality_v0, 4 -DW.ref.__gcc_personality_v0: - .long __gcc_personality_v0 -#endif diff --git a/nptl/sysdeps/unix/sysv/linux/sh/sem_wait.S b/nptl/sysdeps/unix/sysv/linux/sh/sem_wait.S index 85ce909259..9ceb8f1c24 100644 --- a/nptl/sysdeps/unix/sysv/linux/sh/sem_wait.S +++ b/nptl/sysdeps/unix/sysv/linux/sh/sem_wait.S @@ -20,35 +20,44 @@ #include <shlib-compat.h> #include <pthread-errnos.h> #include <tcb-offsets.h> -#include <structsem.h> #include "lowlevel-atomic.h" #define SYS_gettimeofday __NR_gettimeofday #define SYS_futex 240 #define FUTEX_WAIT 0 - -#if VALUE != 0 -# error "code needs to be rewritten for VALUE != 0" -#endif +#define FUTEX_WAKE 1 .text .globl __new_sem_wait .type __new_sem_wait,@function .align 5 + cfi_startproc __new_sem_wait: -.LSTARTCODE: + /* First check for cancellation. */ + stc gbr, r0 + mov.w .Lchand, r1 + mov.l @(r0,r1), r0 + mov #0xf9, r1 + and r1, r0 + cmp/eq #8, r0 + bt 5f + mov.l r8, @-r15 -.Lpush_r8: + cfi_adjust_cfa_offset(4) + cfi_rel_offset (r8, 0) mov.l r10, @-r15 -.Lpush_r10: + cfi_adjust_cfa_offset(4) + cfi_rel_offset (r10, 0) mov.l r12, @-r15 -.Lpush_r12: + cfi_adjust_cfa_offset(4) + cfi_rel_offset (r12, 0) sts.l pr, @-r15 -.Lpush_pr: + cfi_adjust_cfa_offset(4) + cfi_rel_offset (pr, 0) mov r4, r8 - +3: mov.l @r8, r0 2: tst r0, r0 @@ -59,21 +68,10 @@ __new_sem_wait: CMPXCHG (r4, @r8, r3, r2) bf/s 2b mov r2, r0 -7: - mov #0, r0 -9: - lds.l @r15+, pr - mov.l @r15+, r12 - mov.l @r15+, r10 - rts - mov.l @r15+, r8 + bra 9f + mov #0, r0 -.Lafter_ret: 1: - INC (@(NWAITERS,r8),r2) - -.LcleanupSTART: -6: mov.l .Lenable0, r1 bsrf r1 nop @@ -81,13 +79,7 @@ __new_sem_wait: mov r0, r10 mov r8, r4 -#if FUTEX_WAIT == 0 - mov.l @(PRIVATE,r8), r5 -#else - mov.l @(PRIVATE,r8), r5 - mov #FUTEX_WAIT, r0 - or r0, r5 -#endif + mov #FUTEX_WAIT, r5 mov #0, r6 mov #0, r7 mov #SYS_futex, r3 @@ -101,35 +93,14 @@ __new_sem_wait: mov r0, r10 .Ldisable0b: mov r10, r0 -.LcleanupEND: tst r0, r0 - bt 3f + bt 3b cmp/eq #-EWOULDBLOCK, r0 - bf 4f - -3: - mov.l @r8, r0 -5: - tst r0, r0 - bt 6b - - mov r0, r3 - mov r0, r4 - add #-1, r3 - CMPXCHG (r4, @r8, r3, r2) - bf/s 5b - mov r2, r0 - - DEC (@(NWAITERS,r8), r2) - bra 7b - nop - -4: + bt 3b neg r0, r0 - mov r0, r4 - DEC (@(NWAITERS,r8), r2) - mov r4, r8 + + mov r0, r8 mova .Lgot0, r0 mov.l .Lgot0, r12 add r0, r12 @@ -147,9 +118,36 @@ __new_sem_wait: .Lerrloc0b: mov.l r8, @r0 #endif - bra 9b - mov #-1, r0 - + mov #-1, r0 +9: + lds.l @r15+, pr + mov.l @r15+, r12 + mov.l @r15+, r10 + rts + mov.l @r15+, r8 +5: + /* Canceled. */ + stc gbr, r0 + mov.w .Lresult, r1 + mov #-1, r2 + mov.l r2, @(r0,r1) + mov.w .Lchand, r0 + or.b #0x10, @(r0,gbr) + stc gbr, r0 + mov.w .Lclbuf, r1 + mov.l .Lunwind, r2 + braf r2 + mov.l @(r0,r1), r4 +.Lunwindb: + cfi_endproc + +.Lchand: + .word CANCELHANDLING - TLS_PRE_TCB_SIZE +.Lresult: + .word RESULT - TLS_PRE_TCB_SIZE +.Lclbuf: + .word CLEANUP_JMP_BUF - TLS_PRE_TCB_SIZE + .align 2 .Lgot0: .long _GLOBAL_OFFSET_TABLE_ #if USE___THREAD @@ -163,143 +161,7 @@ __new_sem_wait: .long __pthread_enable_asynccancel-.Lenable0b .Ldisable0: .long __pthread_disable_asynccancel-.Ldisable0b +.Lunwind: + .long HIDDEN_JUMPTARGET (__pthread_unwind)-.Lunwindb .size __new_sem_wait,.-__new_sem_wait versioned_symbol(libpthread, __new_sem_wait, sem_wait, GLIBC_2_1) - - - .type sem_wait_cleanup,@function -sem_wait_cleanup: - DEC (@(NWAITERS,r8), r2) -.LcallUR: - mov.l .Lresume, r1 -#ifdef PIC - add r12, r1 -#endif - jsr @r1 - nop - sleep - - .align 2 -.Lresume: -#ifdef PIC - .long _Unwind_Resume@GOTOFF -#else - .long _Unwind_Resume -#endif -.LENDCODE: - .size sem_wait_cleanup,.-sem_wait_cleanup - - - .section .gcc_except_table,"a",@progbits -.LexceptSTART: - .byte 0xff ! @LPStart format (omit) - .byte 0xff ! @TType format (omit) - .byte 0x01 ! call-site format - ! DW_EH_PE_uleb128 - .uleb128 .Lcstend-.Lcstbegin -.Lcstbegin: - .uleb128 .LcleanupSTART-.LSTARTCODE - .uleb128 .LcleanupEND-.LcleanupSTART - .uleb128 sem_wait_cleanup-.LSTARTCODE - .uleb128 0 - .uleb128 .LcallUR-.LSTARTCODE - .uleb128 .LENDCODE-.LcallUR - .uleb128 0 - .uleb128 0 -.Lcstend: - - - .section .eh_frame,"a",@progbits -.LSTARTFRAME: - .ualong .LENDCIE-.LSTARTCIE ! Length of the CIE. -.LSTARTCIE: - .ualong 0 ! CIE ID. - .byte 1 ! Version number. -#ifdef SHARED - .string "zPLR" ! NUL-terminated augmentation - ! string. -#else - .string "zPL" ! NUL-terminated augmentation - ! string. -#endif - .uleb128 1 ! Code alignment factor. - .sleb128 -4 ! Data alignment factor. - .byte 0x11 ! Return address register - ! column. -#ifdef SHARED - .uleb128 7 ! Augmentation value length. - .byte 0x9b ! Personality: DW_EH_PE_pcrel - ! + DW_EH_PE_sdata4 - ! + DW_EH_PE_indirect - .ualong DW.ref.__gcc_personality_v0-. - .byte 0x1b ! LSDA Encoding: DW_EH_PE_pcrel - ! + DW_EH_PE_sdata4. - .byte 0x1b ! FDE Encoding: DW_EH_PE_pcrel - ! + DW_EH_PE_sdata4. -#else - .uleb128 6 ! Augmentation value length. - .byte 0x0 ! Personality: absolute - .ualong __gcc_personality_v0 - .byte 0x0 ! LSDA Encoding: absolute -#endif - .byte 0x0c ! DW_CFA_def_cfa - .uleb128 0xf - .uleb128 0 - .align 4 -.LENDCIE: - - .ualong .LENDFDE-.LSTARTFDE ! Length of the FDE. -.LSTARTFDE: - .ualong .LSTARTFDE-.LSTARTFRAME ! CIE pointer. -#ifdef SHARED - .ualong .LSTARTCODE-. ! PC-relative start address - ! of the code. -#else - .ualong .LSTARTCODE ! Start address of the code. -#endif - .ualong .LENDCODE-.LSTARTCODE ! Length of the code. - .uleb128 4 ! Augmentation size -#ifdef SHARED - .ualong .LexceptSTART-. -#else - .ualong .LexceptSTART -#endif - - .byte 4 ! DW_CFA_advance_loc4 - .ualong .Lpush_r8-.LSTARTCODE - .byte 14 ! DW_CFA_def_cfa_offset - .uleb128 4 - .byte 0x88 ! DW_CFA_offset r8 - .uleb128 1 - .byte 4 ! DW_CFA_advance_loc4 - .ualong .Lpush_r10-.Lpush_r8 - .byte 14 ! DW_CFA_def_cfa_offset - .uleb128 8 - .byte 0x8a ! DW_CFA_offset r10 - .uleb128 2 - .byte 4 ! DW_CFA_advance_loc4 - .ualong .Lpush_r12-.Lpush_r10 - .byte 14 ! DW_CFA_def_cfa_offset - .uleb128 12 - .byte 0x8c ! DW_CFA_offset r12 - .uleb128 3 - .byte 4 ! DW_CFA_advance_loc4 - .ualong .Lpush_pr-.Lpush_r12 - .byte 14 ! DW_CFA_def_cfa_offset - .uleb128 16 - .byte 0x91 ! DW_CFA_offset pr - .uleb128 4 - .align 4 -.LENDFDE: - - -#ifdef SHARED - .hidden DW.ref.__gcc_personality_v0 - .weak DW.ref.__gcc_personality_v0 - .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits - .align 4 - .type DW.ref.__gcc_personality_v0, @object - .size DW.ref.__gcc_personality_v0, 4 -DW.ref.__gcc_personality_v0: - .long __gcc_personality_v0 -#endif diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h index 6548970663..5013922a2f 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. @@ -240,6 +240,8 @@ __lll_robust_mutex_timedlock (int *futex, const struct timespec *abstime, /* Type for lock object. */ typedef int lll_lock_t; +extern int lll_unlock_wake_cb (int *__futex) attribute_hidden; + /* Initializers for lock. */ #define LLL_LOCK_INITIALIZER (0) #define LLL_LOCK_INITIALIZER_LOCKED (1) diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/pthread_once.c b/nptl/sysdeps/unix/sysv/linux/sparc/pthread_once.c index 83fedef8e8..3b07cc127d 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/pthread_once.c +++ b/nptl/sysdeps/unix/sysv/linux/sparc/pthread_once.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. @@ -30,7 +30,7 @@ clear_once_control (void *arg) pthread_once_t *once_control = (pthread_once_t *) arg; *once_control = 0; - lll_private_futex_wake (once_control, INT_MAX); + lll_futex_wake (once_control, INT_MAX); } @@ -84,7 +84,7 @@ __pthread_once (once_control, init_routine) atomic_increment (once_control); /* Wake up all other threads. */ - lll_private_futex_wake (once_control, INT_MAX); + lll_futex_wake (once_control, INT_MAX); break; } diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/lowlevellock.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/lowlevellock.c index cb9578b47b..a7611d6a88 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/lowlevellock.c +++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/lowlevellock.c @@ -1,5 +1,5 @@ /* low level locking for pthread library. SPARC version. - Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Paul Mackerras <paulus@au.ibm.com>, 2003. @@ -76,9 +76,21 @@ __lll_timedlock_wait (int *futex, const struct timespec *abstime) } -/* This function doesn't get included in libc.so */ +/* These don't get included in libc.so */ #ifdef IS_IN_libpthread int +lll_unlock_wake_cb (int *futex) +{ + int val = atomic_exchange_24_rel (futex, 0); + + if (__builtin_expect (val > 1, 0)) + lll_futex_wake (futex, 1); + + return 0; +} + + +int __lll_timedwait_tid (int *tidp, const struct timespec *abstime) { int tid; @@ -115,4 +127,5 @@ __lll_timedwait_tid (int *tidp, const struct timespec *abstime) return 0; } + #endif diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_wait.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_wait.c index 868e0d2819..4dfd11dcbe 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_wait.c +++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_wait.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003. @@ -52,9 +52,7 @@ pthread_barrier_wait (barrier) ++ibarrier->b.curr_event; /* Wake up everybody. */ - lll_futex_wake (&ibarrier->b.curr_event, INT_MAX, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wake (&ibarrier->b.curr_event, INT_MAX); /* This is the thread which finished the serialization. */ result = PTHREAD_BARRIER_SERIAL_THREAD; @@ -70,9 +68,7 @@ pthread_barrier_wait (barrier) /* Wait for the event counter of the barrier to change. */ do - lll_futex_wait (&ibarrier->b.curr_event, event, - // XYZ check mutex flag - LLL_SHARED); + lll_futex_wait (&ibarrier->b.curr_event, event); while (event == ibarrier->b.curr_event); } diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_post.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_post.c index 527aedfdc7..be1cc60b11 100644 --- a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_post.c +++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_post.c @@ -1,5 +1,5 @@ /* sem_post -- post to a POSIX semaphore. SPARC version. - Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. @@ -39,9 +39,7 @@ __new_sem_post (sem_t *sem) nr = ++*futex; __sparc32_atomic_do_unlock24 (futex + 1); } - int err = lll_futex_wake (futex, nr, - // XYZ check mutex flag - LLL_SHARED); + int err = lll_futex_wake (futex, nr); if (__builtin_expect (err, 0) < 0) { __set_errno (-err); diff --git a/nptl/sysdeps/unix/sysv/linux/structsem.sym b/nptl/sysdeps/unix/sysv/linux/structsem.sym deleted file mode 100644 index 4f32c68da5..0000000000 --- a/nptl/sysdeps/unix/sysv/linux/structsem.sym +++ /dev/null @@ -1,10 +0,0 @@ -#include <stddef.h> -#include <sched.h> -#include <bits/pthreadtypes.h> -#include "internaltypes.h" - --- - -VALUE offsetof (struct new_sem, value) -PRIVATE offsetof (struct new_sem, private) -NWAITERS offsetof (struct new_sem, nwaiters) diff --git a/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c b/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c index 240ce597f9..964f5b7094 100644 --- a/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c +++ b/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c @@ -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 <drepper@redhat.com>, 2002. @@ -104,7 +104,7 @@ __unregister_atfork (dso_handle) atomic_decrement (&deleted->handler->refcntr); unsigned int val; while ((val = deleted->handler->refcntr) != 0) - lll_private_futex_wait (&deleted->handler->refcntr, val); + lll_futex_wait (&deleted->handler->refcntr, val); deleted = deleted->next; } diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h index 7a09c81194..693387a266 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.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 <drepper@redhat.com>, 2002. @@ -159,9 +159,9 @@ typedef union unsigned int __nr_readers_queued; unsigned int __nr_writers_queued; int __writer; - int __shared; - unsigned long int __pad1; + int __pad1; unsigned long int __pad2; + unsigned long int __pad3; /* FLAGS must stay at this position in the structure to maintain binary compatibility. */ unsigned int __flags; @@ -177,10 +177,7 @@ typedef union unsigned int __nr_writers_queued; /* FLAGS must stay at this position in the structure to maintain binary compatibility. */ - unsigned char __flags; - unsigned char __shared; - unsigned char __pad1; - unsigned char __pad2; + unsigned int __flags; int __writer; } __data; # endif diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S index 3265eee0ed..3621efa4fc 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S @@ -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 <drepper@redhat.com>, 2002. @@ -17,19 +17,14 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <kernel-features.h> - -/* All locks in libc are private. Use the kernel feature if possible. */ -#define FUTEX_PRIVATE_FLAG 128 -#ifdef __ASSUME_PRIVATE_FUTEX -# define FUTEX_WAIT (0 | FUTEX_PRIVATE_FLAG) -# define FUTEX_WAKE (1 | FUTEX_PRIVATE_FLAG) -#else -# define LOAD_FUTEX_WAIT(reg) \ - movl %fs:PRIVATE_FUTEX, reg -# define LOAD_FUTEX_WAKE(reg) \ - movl %fs:PRIVATE_FUTEX, reg ; \ - orl $FUTEX_WAKE, reg +/* In libc.so we do not unconditionally use the lock prefix. Only if + the application is using threads. */ +#ifndef UP +# define LOCK \ + cmpl $0, __libc_multiple_threads(%rip); \ + je 0f; \ + lock; \ +0: #endif #include "lowlevellock.S" diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S index 502f1d442f..6724ded762 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S @@ -31,23 +31,8 @@ #endif #define SYS_futex 202 -#ifndef FUTEX_WAIT -# define FUTEX_WAIT 0 -# define FUTEX_WAKE 1 -#endif - -#ifndef LOAD_FUTEX_WAIT -# if FUTEX_WAIT == 0 -# define LOAD_FUTEX_WAIT(reg) \ - xorl reg, reg -# else -# define LOAD_FUTEX_WAIT(reg) \ - movl $FUTEX_WAIT, reg -# endif -# define LOAD_FUTEX_WAKE(reg) \ - movl $FUTEX_WAKE, reg -#endif - +#define FUTEX_WAIT 0 +#define FUTEX_WAKE 1 /* For the calculation see asm/vsyscall.h. */ #define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000 @@ -67,7 +52,11 @@ __lll_mutex_lock_wait: cfi_offset(%rdx, -24) xorq %r10, %r10 /* No timeout. */ movl $2, %edx - LOAD_FUTEX_WAIT (%esi) +#if FUTEX_WAIT == 0 + xorl %esi, %esi +#else + movl $FUTEX_WAIT, %esi +#endif cmpl %edx, %eax /* NB: %edx == 2 */ jne 2f @@ -162,7 +151,11 @@ __lll_mutex_timedlock_wait: je 8f movq %rsp, %r10 - LOAD_FUTEX_WAIT (%esi) +#if FUTEX_WAIT == 0 + xorl %esi, %esi +#else + movl $FUTEX_WAIT, %esi +#endif movq %r12, %rdi movl $SYS_futex, %eax syscall @@ -220,6 +213,26 @@ __lll_mutex_timedlock_wait: #endif +#ifdef NOT_IN_libc + .globl lll_unlock_wake_cb + .type lll_unlock_wake_cb,@function + .hidden lll_unlock_wake_cb + .align 16 +lll_unlock_wake_cb: + pushq %rsi + pushq %rdx + + LOCK + addl $1, (%rdi) + jng 1f + + popq %rdx + popq %rsi + retq + .size lll_unlock_wake_cb,.-lll_unlock_wake_cb +#endif + + .globl __lll_mutex_unlock_wake .type __lll_mutex_unlock_wake,@function .hidden __lll_mutex_unlock_wake @@ -234,7 +247,7 @@ __lll_mutex_unlock_wake: cfi_offset(%rdx, -24) movl $0, (%rdi) - LOAD_FUTEX_WAKE (%esi) + movl $FUTEX_WAKE, %esi movl $1, %edx /* Wake one thread. */ movl $SYS_futex, %eax syscall @@ -298,8 +311,6 @@ __lll_timedwait_tid: jz 4f movq %rsp, %r10 - /* XXX The kernel so far uses global futex for the wakeup at - all times. */ #if FUTEX_WAIT == 0 xorl %esi, %esi #else diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h index b86d95e93d..bb988f3b2b 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h @@ -23,8 +23,6 @@ #include <time.h> #include <sys/param.h> #include <bits/pthreadtypes.h> -#include <kernel-features.h> -#include <tcb-offsets.h> #ifndef LOCK_INSTR # ifdef UP @@ -41,14 +39,6 @@ #define FUTEX_LOCK_PI 6 #define FUTEX_UNLOCK_PI 7 #define FUTEX_TRYLOCK_PI 8 -#define FUTEX_PRIVATE_FLAG 128 - - -/* Values for 'private' parameter of locking macros. Yes, the - definition seems to be backwards. But it is not. The bit will be - reversed before passing to the system call. */ -#define LLL_PRIVATE 0 -#define LLL_SHARED FUTEX_PRIVATE_FLAG /* Initializer for compatibility lock. */ @@ -158,97 +148,44 @@ LLL_STUB_UNWIND_INFO_START \ LLL_STUB_UNWIND_INFO_END -#define lll_futex_wait(futex, val, private) \ - lll_futex_timed_wait(futex, val, NULL, private) - - -#define lll_futex_timed_wait(futex, val, timeout, private) \ +#define lll_futex_wait(futex, val) \ ({ \ - register const struct timespec *__to __asm ("r10") = timeout; \ int __status; \ register __typeof (val) _val __asm ("edx") = (val); \ - __asm __volatile ("syscall" \ + __asm __volatile ("xorq %%r10, %%r10\n\t" \ + "syscall" \ : "=a" (__status) \ : "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAIT), \ - "d" (_val), "r" (__to) \ - : "memory", "cc", "r11", "cx"); \ + "d" (_val) \ + : "memory", "cc", "r10", "r11", "cx"); \ __status; \ }) -#define lll_futex_wake(futex, nr, private) \ - do { \ - int __ignore; \ - register __typeof (nr) _nr __asm ("edx") = (nr); \ - __asm __volatile ("syscall" \ - : "=a" (__ignore) \ - : "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAKE), \ - "d" (_nr) \ - : "memory", "cc", "r10", "r11", "cx"); \ - } while (0) - - -#define lll_private_futex_wait(futex, val) \ - lll_private_futex_timed_wait (futex, val, NULL) - - -#ifdef __ASSUME_PRIVATE_FUTEX -# define lll_private_futex_timed_wait(futex, val, timeout) \ +#define lll_futex_timed_wait(futex, val, timeout) \ ({ \ register const struct timespec *__to __asm ("r10") = timeout; \ int __status; \ register __typeof (val) _val __asm ("edx") = (val); \ __asm __volatile ("syscall" \ : "=a" (__status) \ - : "0" (SYS_futex), "D" (futex), \ - "S" (FUTEX_WAIT | FUTEX_PRIVATE_FLAG), \ + : "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAIT), \ "d" (_val), "r" (__to) \ : "memory", "cc", "r11", "cx"); \ __status; \ }) -# define lll_private_futex_wake(futex, nr) \ +#define lll_futex_wake(futex, nr) \ do { \ int __ignore; \ register __typeof (nr) _nr __asm ("edx") = (nr); \ __asm __volatile ("syscall" \ : "=a" (__ignore) \ - : "0" (SYS_futex), "D" (futex), \ - "S" (FUTEX_WAKE | FUTEX_PRIVATE_FLAG), \ + : "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAKE), \ "d" (_nr) \ : "memory", "cc", "r10", "r11", "cx"); \ } while (0) -#else -# define lll_private_futex_timed_wait(futex, val, timeout) \ - ({ \ - register const struct timespec *__to __asm ("r10") = timeout; \ - int __status; \ - int __ignore; \ - register __typeof (val) _val __asm ("edx") = (val); \ - __asm __volatile ("movl %%fs:%P3, %%esi\n\t" \ - "syscall" \ - : "=a" (__status), "=S" (__ignore) \ - : "0" (SYS_futex), "i" (PRIVATE_FUTEX), "D" (futex), \ - "d" (_val), "r" (__to) \ - : "memory", "cc", "r11", "cx"); \ - __status; \ - }) - - -# define lll_private_futex_wake(futex, nr) \ - do { \ - int __ignore; \ - int __ignore2; \ - register __typeof (nr) _nr __asm ("edx") = (nr); \ - __asm __volatile ("orl %%fs:%P3, %%esi\n\t" \ - "syscall" \ - : "=a" (__ignore), "=S" (__ignore2) \ - : "0" (SYS_futex), "i" (PRIVATE_FUTEX), "D" (futex), \ - "1" (FUTEX_WAKE), "d" (_nr) \ - : "memory", "cc", "r10", "r11", "cx"); \ - } while (0) -#endif /* Does not preserve %eax and %ecx. */ @@ -517,6 +454,9 @@ typedef int lll_lock_t; #define LLL_LOCK_INITIALIZER_LOCKED (1) +extern int lll_unlock_wake_cb (int *__futex) attribute_hidden; + + /* The states of a lock are: 0 - untaken 1 - taken by one user diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S index 63771b3840..fa8125dd87 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.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 <drepper@redhat.com>, 2002. @@ -65,10 +65,9 @@ pthread_barrier_wait: if the CURR_EVENT memory has meanwhile been changed. */ 7: #if FUTEX_WAIT == 0 - movl PRIVATE(%rdi), %esi + xorl %esi, %esi #else movl $FUTEX_WAIT, %esi - orl PRIVATE(%rdi), %esi #endif xorq %r10, %r10 8: movl $SYS_futex, %eax @@ -117,7 +116,6 @@ pthread_barrier_wait: so 0x7fffffff is the highest value. */ movl $0x7fffffff, %edx movl $FUTEX_WAKE, %esi - orl PRIVATE(%rdi), %esi movl $SYS_futex, %eax syscall diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S index 2afd601b8c..ad3ae1e76e 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_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 <drepper@redhat.com>, 2002. @@ -111,7 +111,7 @@ __pthread_cond_timedwait: movq 8(%rsp), %rdi incq total_seq(%rdi) incl cond_futex(%rdi) - addl $(1 << nwaiters_shift), cond_nwaiters(%rdi) + addl $(1 << clock_bits), cond_nwaiters(%rdi) /* Install cancellation handler. */ #ifdef PIC @@ -137,7 +137,7 @@ __pthread_cond_timedwait: structure stores the number minus 1. */ movq 8(%rsp), %rdi movl cond_nwaiters(%rdi), %edi - andl $((1 << nwaiters_shift) - 1), %edi + andl $((1 << clock_bits) - 1), %edi /* Only clocks 0 and 1 are allowed so far. Both are handled in the kernel. */ leaq 24(%rsp), %rsi @@ -250,13 +250,13 @@ __pthread_cond_timedwait: 9: xorq %r14, %r14 14: incq woken_seq(%rdi) -24: subl $(1 << nwaiters_shift), cond_nwaiters(%rdi) +24: subl $(1 << clock_bits), cond_nwaiters(%rdi) /* Wake up a thread which wants to destroy the condvar object. */ cmpq $0xffffffffffffffff, total_seq(%rdi) jne 25f movl cond_nwaiters(%rdi), %eax - andl $~((1 << nwaiters_shift) - 1), %eax + andl $~((1 << clock_bits) - 1), %eax jne 25f addq $cond_nwaiters, %rdi diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S index aaad22e020..969e80da2a 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S @@ -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 <drepper@redhat.com>, 2002. @@ -77,14 +77,14 @@ __condvar_cleanup: incl cond_futex(%rdi) 6: incq woken_seq(%rdi) -3: subl $(1 << nwaiters_shift), cond_nwaiters(%rdi) +3: subl $(1 << clock_bits), cond_nwaiters(%rdi) /* Wake up a thread which wants to destroy the condvar object. */ xorq %r12, %r12 cmpq $0xffffffffffffffff, total_seq(%rdi) jne 4f movl cond_nwaiters(%rdi), %eax - andl $~((1 << nwaiters_shift) - 1), %eax + andl $~((1 << clock_bits) - 1), %eax jne 4f addq $cond_nwaiters, %rdi @@ -185,7 +185,7 @@ __pthread_cond_wait: movq 8(%rsp), %rdi incq total_seq(%rdi) incl cond_futex(%rdi) - addl $(1 << nwaiters_shift), cond_nwaiters(%rdi) + addl $(1 << clock_bits), cond_nwaiters(%rdi) /* Install cancellation handler. */ #ifdef PIC @@ -262,13 +262,13 @@ __pthread_cond_wait: incq woken_seq(%rdi) /* Unlock */ -16: subl $(1 << nwaiters_shift), cond_nwaiters(%rdi) +16: subl $(1 << clock_bits), cond_nwaiters(%rdi) /* Wake up a thread which wants to destroy the condvar object. */ cmpq $0xffffffffffffffff, total_seq(%rdi) jne 17f movl cond_nwaiters(%rdi), %eax - andl $~((1 << nwaiters_shift) - 1), %eax + andl $~((1 << clock_bits) - 1), %eax jne 17f addq $cond_nwaiters, %rdi diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S index 7740c599d1..9db5516913 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.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 <drepper@redhat.com>, 2002. @@ -17,19 +17,14 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <kernel-features.h> -#include <tcb-offsets.h> - #ifndef UP # define LOCK lock #else # define LOCK #endif -#define SYS_futex 202 -#define FUTEX_WAIT 0 -#define FUTEX_WAKE 1 -#define FUTEX_PRIVATE_FLAG 128 +#define SYS_futex 202 +#define FUTEX_WAKE 1 .comm __fork_generation, 4, 4 @@ -79,15 +74,10 @@ __pthread_once: jnz 3f /* Different for generation -> run initializer. */ /* Somebody else got here first. Wait. */ -#ifdef __ASSUME_PRIVATE_FUTEX - movl $FUTEX_WAIT|FUTEX_PRIVATE_FLAG, %esi +#if FUTEX_WAIT == 0 + xorl %esi, %esi #else -# if FUTEX_WAIT == 0 - movl %fs:PRIVATE_FUTEX, %esi -# else movl $FUTEX_WAIT, %esi - orl %fs:PRIVATE_FUTEX, %esi -# endif #endif movl $SYS_futex, %eax syscall @@ -116,12 +106,7 @@ __pthread_once: /* Wake up all other threads. */ movl $0x7fffffff, %edx -#ifdef __ASSUME_PRIVATE_FUTEX - movl $FUTEX_WAKE|FUTEX_PRIVATE_FLAG, %esi -#else movl $FUTEX_WAKE, %esi - orl %fs:PRIVATE_FUTEX, %esi -#endif movl $SYS_futex, %eax syscall @@ -148,12 +133,7 @@ clear_once_control: movl $0, (%rdi) movl $0x7fffffff, %edx -#ifdef __ASSUME_PRIVATE_FUTEX - movl $FUTEX_WAKE|FUTEX_PRIVATE_FLAG, %esi -#else movl $FUTEX_WAKE, %esi - orl %fs:PRIVATE_FUTEX, %esi -#endif movl $SYS_futex, %eax syscall diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S index da98ab3d49..5e9d8fb1d6 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.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 <drepper@redhat.com>, 2002. @@ -20,13 +20,11 @@ #include <sysdep.h> #include <lowlevelrwlock.h> #include <pthread-errnos.h> -#include <kernel-features.h> #define SYS_futex 202 #define FUTEX_WAIT 0 #define FUTEX_WAKE 1 -#define FUTEX_PRIVATE_FLAG 128 #ifndef UP # define LOCK lock @@ -75,20 +73,12 @@ __pthread_rwlock_rdlock: #endif jne 10f -11: -#if __ASSUME_PRIVATE_FUTEX - movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %esi - xorl PSHARED(%rdi), %esi +11: addq $READERS_WAKEUP, %rdi +#if FUTEX_WAIT == 0 + xorl %esi, %esi #else -# if FUTEX_WAIT == 0 - movl PSHARED(%rdi), %esi -# else movl $FUTEX_WAIT, %esi - orl PSHARED(%rdi), %esi -# endif - xorl %fs:PRIVATE_FUTEX, %esi #endif - addq $READERS_WAKEUP, %rdi movl $SYS_futex, %eax syscall diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S index 19ad27aab8..b44660418a 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.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 <drepper@redhat.com>, 2002. @@ -112,17 +112,10 @@ pthread_rwlock_timedrdlock: movq %rcx, (%rsp) /* Store relative timeout. */ movq %rdi, 8(%rsp) -#if __ASSUME_PRIVATE_FUTEX - movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %esi - xorl PSHARED(%rdi), %esi +#if FUTEX_WAIT == 0 + xorl %esi, %esi #else -# if FUTEX_WAIT == 0 - movl PSHARED(%r12), %esi -# else movl $FUTEX_WAIT, %esi - orl PSHARED(%r12), %esi -# endif - xorl %fs:PRIVATE_FUTEX, %esi #endif movq %rsp, %r10 movl %r14d, %edx diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S index 4c3e7413a8..525e5b6b93 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.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 <drepper@redhat.com>, 2002. @@ -108,17 +108,10 @@ pthread_rwlock_timedwrlock: movq %rcx, (%rsp) /* Store relative timeout. */ movq %rdi, 8(%rsp) -#if __ASSUME_PRIVATE_FUTEX - movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %esi - xorl PSHARED(%rdi), %esi +#if FUTEX_WAIT == 0 + xorl %esi, %esi #else -# if FUTEX_WAIT == 0 - movl PSHARED(%r12), %esi -# else movl $FUTEX_WAIT, %esi - orl PSHARED(%r12), %esi -# endif - xorl %fs:PRIVATE_FUTEX, %esi #endif movq %rsp, %r10 movl %r14d, %edx diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S index bf688252c8..3a6b9f0bad 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.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 <drepper@redhat.com>, 2002. @@ -56,8 +56,9 @@ __pthread_rwlock_unlock: 5: movl $0, WRITER(%rdi) - movl $1, %edx + movl $1, %esi leaq WRITERS_WAKEUP(%rdi), %r10 + movq %rsi, %rdx cmpl $0, WRITERS_QUEUED(%rdi) jne 0f @@ -77,16 +78,7 @@ __pthread_rwlock_unlock: #endif jne 7f -8: -#if __ASSUME_PRIVATE_FUTEX - movl $FUTEX_PRIVATE_FLAG|FUTEX_WAKE, %esi - xorl PSHARED(%rdi), %esi -#else - movl $FUTEX_WAKE, %esi - orl PSHARED(%rdi), %esi - xorl %fs:PRIVATE_FUTEX, %esi -#endif - movl $SYS_futex, %eax +8: movl $SYS_futex, %eax movq %r10, %rdi syscall diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S index 46d97e033e..0e82f890aa 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.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 <drepper@redhat.com>, 2002. @@ -71,20 +71,12 @@ __pthread_rwlock_wrlock: #endif jne 10f -11: -#if __ASSUME_PRIVATE_FUTEX - movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %esi - xorl PSHARED(%rdi), %esi +11: addq $WRITERS_WAKEUP, %rdi +#if FUTEX_WAIT == 0 + xorl %esi, %esi #else -# if FUTEX_WAIT == 0 - movl PSHARED(%rdi), %esi -# else movl $FUTEX_WAIT, %esi - orl PSHARED(%rdi), %esi -# endif - xorl %fs:PRIVATE_FUTEX, %esi #endif - addq $WRITERS_WAKEUP, %rdi movl $SYS_futex, %eax syscall diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S index 4919c11fd2..7f608a5974 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.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 <drepper@redhat.com>, 2002. @@ -20,7 +20,6 @@ #include <sysdep.h> #include <shlib-compat.h> #include <pthread-errnos.h> -#include <structsem.h> #ifndef UP # define LOCK lock @@ -38,26 +37,19 @@ .type sem_post,@function .align 16 sem_post: + movl $1, %edx LOCK -#if VALUE == 0 - addl $1, (%rdi) -#else - addl $1, VALUE(%rdi) -#endif - - cmpq $0, NWAITERS(%rdi) - je 2f + xaddl %edx, (%rdi) movl $SYS_futex, %eax movl $FUTEX_WAKE, %esi - orl PRIVATE(%rdi), %esi - movl $1, %edx + incl %edx syscall testq %rax, %rax js 1f -2: xorl %eax, %eax + xorl %eax, %eax retq 1: 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 4068a1b6b8..8c5c2a6974 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S @@ -20,7 +20,6 @@ #include <sysdep.h> #include <shlib-compat.h> #include <pthread-errnos.h> -#include <structsem.h> #ifndef UP # define LOCK lock @@ -29,7 +28,6 @@ #endif #define SYS_futex 202 -#define FUTEX_WAIT 0 /* For the calculation see asm/vsyscall.h. */ #define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000 @@ -40,23 +38,15 @@ .globl sem_timedwait .type sem_timedwait,@function .align 16 + cfi_startproc sem_timedwait: -.LSTARTCODE: -#if VALUE == 0 movl (%rdi), %eax -#else - movl VALUE(%rdi), %eax -#endif 2: testl %eax, %eax je 1f leaq -1(%rax), %rdx LOCK -#if VALUE == 0 cmpxchgl %edx, (%rdi) -#else - cmpxchgl %edx, VALUE(%rdi) -#endif jne 2b xorl %eax, %eax @@ -64,25 +54,25 @@ sem_timedwait: /* Check whether the timeout value is valid. */ 1: pushq %r12 -.Lpush_r12: + cfi_adjust_cfa_offset(8) pushq %r13 -.Lpush_r13: + cfi_adjust_cfa_offset(8) pushq %r14 -.Lpush_r14: + cfi_adjust_cfa_offset(8) subq $24, %rsp -.Lsubq: + cfi_adjust_cfa_offset(24) movq %rdi, %r12 + cfi_offset(12, -16) /* %r12 */ movq %rsi, %r13 + cfi_offset(13, -24) /* %r13 */ /* Check for invalid nanosecond field. */ cmpq $1000000000, 8(%r13) movl $EINVAL, %r14d + cfi_offset(14, -24) /* %r14 */ jae 6f - LOCK - addq $1, NWAITERS(%r12) - 7: xorl %esi, %esi movq %rsp, %rdi movq $VSYSCALL_ADDR_vgettimeofday, %rax @@ -106,22 +96,12 @@ sem_timedwait: movq %rdi, (%rsp) /* Store relative timeout. */ movq %rsi, 8(%rsp) -.LcleanupSTART: call __pthread_enable_asynccancel movl %eax, 16(%rsp) movq %rsp, %r10 -#if VALUE == 0 movq %r12, %rdi -#else - leaq VALUE(%r12), %rdi -#endif -#if FUTEX_WAIT == 0 - movl PRIVATE(%rdi), %esi -#else - movl $FUTEX_WAIT, %esi - orl PRIVATE(%rdi), %esi -#endif + xorl %esi, %esi movl $SYS_futex, %eax xorl %edx, %edx syscall @@ -129,47 +109,39 @@ sem_timedwait: movl 16(%rsp), %edi call __pthread_disable_asynccancel -.LcleanupEND: testq %r14, %r14 je 9f cmpq $-EWOULDBLOCK, %r14 jne 3f -9: -#if VALUE == 0 - movl (%r12), %eax -#else - movl VALUE(%r12), %eax -#endif +9: movl (%r12), %eax 8: testl %eax, %eax je 7b leaq -1(%rax), %rcx LOCK -#if VALUE == 0 cmpxchgl %ecx, (%r12) -#else - cmpxchgl %ecx, VALUE(%r12) -#endif jne 8b xorl %eax, %eax - -10: LOCK - subq $1, NWAITERS(%r12) - - addq $24, %rsp -.Laddq: +10: addq $24, %rsp + cfi_adjust_cfa_offset(-24) popq %r14 -.Lpop_r14: + cfi_adjust_cfa_offset(-8) + cfi_restore(14) popq %r13 -.Lpop_r13: + cfi_adjust_cfa_offset(-8) + cfi_restore(13) popq %r12 -.Lpop_r12: + cfi_adjust_cfa_offset(-8) + cfi_restore(12) retq -.Lafter_retq: + cfi_adjust_cfa_offset(48) + cfi_offset(12, -16) /* %r12 */ + cfi_offset(13, -24) /* %r13 */ + cfi_offset(14, -32) /* %r14 */ 3: negq %r14 6: #if USE___THREAD @@ -182,159 +154,5 @@ sem_timedwait: orl $-1, %eax jmp 10b + cfi_endproc .size sem_timedwait,.-sem_timedwait - - - .type sem_timedwait_cleanup,@function -sem_timedwait_cleanup: - LOCK - subq $1, NWAITERS(%r12) - movq %rax, %rdi -.LcallUR: - call _Unwind_Resume@PLT - hlt -.LENDCODE: - .size sem_timedwait_cleanup,.-sem_timedwait_cleanup - - - .section .gcc_except_table,"a",@progbits -.LexceptSTART: - .byte 0xff # @LPStart format (omit) - .byte 0xff # @TType format (omit) - .byte 0x01 # call-site format - # DW_EH_PE_uleb128 - .uleb128 .Lcstend-.Lcstbegin -.Lcstbegin: - .uleb128 .LcleanupSTART-.LSTARTCODE - .uleb128 .LcleanupEND-.LcleanupSTART - .uleb128 sem_timedwait_cleanup-.LSTARTCODE - .uleb128 0 - .uleb128 .LcallUR-.LSTARTCODE - .uleb128 .LENDCODE-.LcallUR - .uleb128 0 - .uleb128 0 -.Lcstend: - - - .section .eh_frame,"a",@progbits -.LSTARTFRAME: - .long .LENDCIE-.LSTARTCIE # Length of the CIE. -.LSTARTCIE: - .long 0 # CIE ID. - .byte 1 # Version number. -#ifdef SHARED - .string "zPLR" # NUL-terminated augmentation - # string. -#else - .string "zPL" # NUL-terminated augmentation - # string. -#endif - .uleb128 1 # Code alignment factor. - .sleb128 -8 # Data alignment factor. - .byte 16 # Return address register - # column. -#ifdef SHARED - .uleb128 7 # Augmentation value length. - .byte 0x9b # Personality: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4 - # + DW_EH_PE_indirect - .long DW.ref.__gcc_personality_v0-. - .byte 0x1b # LSDA Encoding: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4. - .byte 0x1b # FDE Encoding: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4. -#else - .uleb128 10 # Augmentation value length. - .byte 0x0 # Personality: absolute - .quad __gcc_personality_v0 - .byte 0x0 # LSDA Encoding: absolute -#endif - .byte 0x0c # DW_CFA_def_cfa - .uleb128 7 - .uleb128 8 - .byte 0x90 # DW_CFA_offset, column 0x10 - .uleb128 1 - .align 8 -.LENDCIE: - - .long .LENDFDE-.LSTARTFDE # Length of the FDE. -.LSTARTFDE: - .long .LSTARTFDE-.LSTARTFRAME # CIE pointer. -#ifdef SHARED - .long .LSTARTCODE-. # PC-relative start address - # of the code. - .long .LENDCODE-.LSTARTCODE # Length of the code. - .uleb128 4 # Augmentation size - .long .LexceptSTART-. -#else - .quad .LSTARTCODE # Start address of the code. - .quad .LENDCODE-.LSTARTCODE # Length of the code. - .uleb128 8 # Augmentation size - .quad .LexceptSTART -#endif - - .byte 4 # DW_CFA_advance_loc4 - .long .Lpush_r12-.LSTARTCODE - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 16 - .byte 0x8c # DW_CFA_offset %r12 - .uleb128 2 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpush_r13-.Lpush_r12 - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 24 - .byte 0x8d # DW_CFA_offset %r13 - .uleb128 3 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpush_r14-.Lpush_r13 - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 32 - .byte 0x8e # DW_CFA_offset %r14 - .uleb128 4 - .byte 4 # DW_CFA_advance_loc4 - .long .Lsubq-.Lpush_r14 - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 56 - .byte 4 # DW_CFA_advance_loc4 - .long .Laddq-.Lsubq - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 32 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpop_r14-.Laddq - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 24 - .byte 0xce # DW_CFA_restore %r14 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpop_r13-.Lpop_r14 - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 16 - .byte 0xcd # DW_CFA_restore %r13 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpop_r12-.Lpop_r13 - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 8 - .byte 0xcc # DW_CFA_restore %r12 - .byte 4 # DW_CFA_advance_loc4 - .long .Lafter_retq-.Lpop_r12 - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 56 - .byte 0x8c # DW_CFA_offset %r12 - .uleb128 2 - .byte 0x8d # DW_CFA_offset %r13 - .uleb128 3 - .byte 0x8e # DW_CFA_offset %r14 - .uleb128 4 - .align 8 -.LENDFDE: - - -#ifdef SHARED - .hidden DW.ref.__gcc_personality_v0 - .weak DW.ref.__gcc_personality_v0 - .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits - .align 8 - .type DW.ref.__gcc_personality_v0, @object - .size DW.ref.__gcc_personality_v0, 8 -DW.ref.__gcc_personality_v0: - .quad __gcc_personality_v0 -#endif diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_trywait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_trywait.S index 643090f065..6b77dfc0d8 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_trywait.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_trywait.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 <drepper@redhat.com>, 2002. @@ -37,7 +37,7 @@ sem_trywait: 2: testl %eax, %eax jz 1f - leal -1(%rax), %edx + leaq -1(%rax), %rdx LOCK cmpxchgl %edx, (%rdi) jne 2b diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S index e099ede029..5bd78eb944 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S @@ -20,7 +20,6 @@ #include <sysdep.h> #include <shlib-compat.h> #include <pthread-errnos.h> -#include <structsem.h> #ifndef UP # define LOCK lock @@ -29,7 +28,6 @@ #endif #define SYS_futex 202 -#define FUTEX_WAIT 0 .text @@ -37,93 +35,57 @@ .globl sem_wait .type sem_wait,@function .align 16 + cfi_startproc sem_wait: -.LSTARTCODE: pushq %r12 -.Lpush_r12: + cfi_adjust_cfa_offset(8) + cfi_offset(12, -16) pushq %r13 -.Lpush_r13: + cfi_adjust_cfa_offset(8) movq %rdi, %r13 + cfi_offset(13, -24) -#if VALUE == 0 - movl (%r13), %eax -#else - movl VALUE(%r13), %eax -#endif +3: movl (%r13), %eax 2: testl %eax, %eax je 1f - leal -1(%rax), %edx + leaq -1(%rax), %rdx LOCK -#if VALUE == 0 cmpxchgl %edx, (%r13) -#else - cmpxchgl %edx, VALUE(%r13) -#endif jne 2b + xorl %eax, %eax -7: xorl %eax, %eax - -9: popq %r13 -.Lpop_r13: + popq %r13 + cfi_adjust_cfa_offset(-8) + cfi_restore(13) popq %r12 -.Lpop_r12: + cfi_adjust_cfa_offset(-8) + cfi_restore(12) retq -.Lafter_retq: -1: LOCK - addq $1, NWAITERS(%r13) - -.LcleanupSTART: -6: call __pthread_enable_asynccancel + cfi_adjust_cfa_offset(16) + cfi_offset(12, -16) + cfi_offset(13, -24) +1: call __pthread_enable_asynccancel movl %eax, %r8d xorq %r10, %r10 movl $SYS_futex, %eax movq %r13, %rdi -#if FUTEX_WAIT == 0 - movl PRIVATE(%rdi), %esi -#else - movl $FUTEX_WAIT, %esi - orl PRIVATE(%rdi), %esi -#endif - xorl %edx, %edx + movq %r10, %rsi + movq %r10, %rdx syscall movq %rax, %r12 movl %r8d, %edi call __pthread_disable_asynccancel -.LcleanupEND: testq %r12, %r12 - je 3f + je 3b cmpq $-EWOULDBLOCK, %r12 - jne 4f - -3: -#if VALUE == 0 - movl (%r13), %eax -#else - movl VALUE(%r13), %eax -#endif -5: testl %eax, %eax - je 6b - - leal -1(%rax), %edx - LOCK -#if VALUE == 0 - cmpxchgl %edx, (%r13) -#else - cmpxchgl %edx, VALUE(%r13) -#endif - jne 5b - - LOCK - subq $1, NWAITERS(%r13) - jmp 7b - -4: negq %r12 + je 3b + negq %r12 #if USE___THREAD movq errno@gottpoff(%rip), %rdx movl %r12d, %fs:(%rdx) @@ -133,142 +95,13 @@ sem_wait: #endif orl $-1, %eax - LOCK - subq $1, NWAITERS(%r13) + popq %r13 + cfi_adjust_cfa_offset(-8) + cfi_restore(13) + popq %r12 + cfi_adjust_cfa_offset(-8) + cfi_restore(12) - jmp 9b + retq + cfi_endproc .size sem_wait,.-sem_wait - - - .type sem_wait_cleanup,@function -sem_wait_cleanup: - LOCK - subq $1, NWAITERS(%r13) - movq %rax, %rdi -.LcallUR: - call _Unwind_Resume@PLT - hlt -.LENDCODE: - .size sem_wait_cleanup,.-sem_wait_cleanup - - - .section .gcc_except_table,"a",@progbits -.LexceptSTART: - .byte 0xff # @LPStart format (omit) - .byte 0xff # @TType format (omit) - .byte 0x01 # call-site format - # DW_EH_PE_uleb128 - .uleb128 .Lcstend-.Lcstbegin -.Lcstbegin: - .uleb128 .LcleanupSTART-.LSTARTCODE - .uleb128 .LcleanupEND-.LcleanupSTART - .uleb128 sem_wait_cleanup-.LSTARTCODE - .uleb128 0 - .uleb128 .LcallUR-.LSTARTCODE - .uleb128 .LENDCODE-.LcallUR - .uleb128 0 - .uleb128 0 -.Lcstend: - - - .section .eh_frame,"a",@progbits -.LSTARTFRAME: - .long .LENDCIE-.LSTARTCIE # Length of the CIE. -.LSTARTCIE: - .long 0 # CIE ID. - .byte 1 # Version number. -#ifdef SHARED - .string "zPLR" # NUL-terminated augmentation - # string. -#else - .string "zPL" # NUL-terminated augmentation - # string. -#endif - .uleb128 1 # Code alignment factor. - .sleb128 -8 # Data alignment factor. - .byte 16 # Return address register - # column. -#ifdef SHARED - .uleb128 7 # Augmentation value length. - .byte 0x9b # Personality: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4 - # + DW_EH_PE_indirect - .long DW.ref.__gcc_personality_v0-. - .byte 0x1b # LSDA Encoding: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4. - .byte 0x1b # FDE Encoding: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4. -#else - .uleb128 10 # Augmentation value length. - .byte 0x0 # Personality: absolute - .quad __gcc_personality_v0 - .byte 0x0 # LSDA Encoding: absolute -#endif - .byte 0x0c # DW_CFA_def_cfa - .uleb128 7 - .uleb128 8 - .byte 0x90 # DW_CFA_offset, column 0x10 - .uleb128 1 - .align 8 -.LENDCIE: - - .long .LENDFDE-.LSTARTFDE # Length of the FDE. -.LSTARTFDE: - .long .LSTARTFDE-.LSTARTFRAME # CIE pointer. -#ifdef SHARED - .long .LSTARTCODE-. # PC-relative start address - # of the code. - .long .LENDCODE-.LSTARTCODE # Length of the code. - .uleb128 4 # Augmentation size - .long .LexceptSTART-. -#else - .quad .LSTARTCODE # Start address of the code. - .quad .LENDCODE-.LSTARTCODE # Length of the code. - .uleb128 8 # Augmentation size - .quad .LexceptSTART -#endif - - .byte 4 # DW_CFA_advance_loc4 - .long .Lpush_r12-.LSTARTCODE - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 16 - .byte 0x8c # DW_CFA_offset %r12 - .uleb128 2 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpush_r13-.Lpush_r12 - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 24 - .byte 0x8d # DW_CFA_offset %r13 - .uleb128 3 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpop_r13-.Lpush_r13 - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 16 - .byte 0xcd # DW_CFA_restore %r13 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpop_r12-.Lpop_r13 - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 8 - .byte 0xcc # DW_CFA_restore %r12 - .byte 4 # DW_CFA_advance_loc4 - .long .Lafter_retq-.Lpop_r12 - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 24 - .byte 0x8c # DW_CFA_offset %r12 - .uleb128 2 - .byte 0x8d # DW_CFA_offset %r13 - .uleb128 3 - .align 8 -.LENDFDE: - - -#ifdef SHARED - .hidden DW.ref.__gcc_personality_v0 - .weak DW.ref.__gcc_personality_v0 - .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits - .align 8 - .type DW.ref.__gcc_personality_v0, @object - .size DW.ref.__gcc_personality_v0, 8 -DW.ref.__gcc_personality_v0: - .quad __gcc_personality_v0 -#endif diff --git a/nptl/sysdeps/x86_64/tcb-offsets.sym b/nptl/sysdeps/x86_64/tcb-offsets.sym index 1c70c6bde7..21274ecab9 100644 --- a/nptl/sysdeps/x86_64/tcb-offsets.sym +++ b/nptl/sysdeps/x86_64/tcb-offsets.sym @@ -12,6 +12,3 @@ MUTEX_FUTEX offsetof (pthread_mutex_t, __data.__lock) MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads) POINTER_GUARD offsetof (tcbhead_t, pointer_guard) VGETCPU_CACHE_OFFSET offsetof (tcbhead_t, vgetcpu_cache) -#ifndef __ASSUME_PRIVATE_FUTEX -PRIVATE_FUTEX offsetof (tcbhead_t, private_futex) -#endif diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h index 029848a8fa..4a614c02af 100644 --- a/nptl/sysdeps/x86_64/tls.h +++ b/nptl/sysdeps/x86_64/tls.h @@ -26,8 +26,6 @@ # include <stddef.h> # include <stdint.h> # include <stdlib.h> -# include <sysdep.h> -# include <kernel-features.h> /* Type for the dtv. */ @@ -54,9 +52,6 @@ typedef struct uintptr_t stack_guard; uintptr_t pointer_guard; unsigned long int vgetcpu_cache[2]; -#ifndef __ASSUME_PRIVATE_FUTEX - int private_futex; -#endif } tcbhead_t; #else /* __ASSEMBLER__ */ @@ -355,7 +350,7 @@ typedef struct : "i" (offsetof (struct pthread, header.gscope_flag)), \ "0" (THREAD_GSCOPE_FLAG_UNUSED)); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ - lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ + lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \ } \ while (0) #define THREAD_GSCOPE_SET_FLAG() \ diff --git a/nptl/tst-initializers1.c b/nptl/tst-initializers1.c index 9036e6eac3..eacee35c61 100644 --- a/nptl/tst-initializers1.c +++ b/nptl/tst-initializers1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2005. @@ -37,15 +37,15 @@ main (void) if (mtx_normal.__data.__kind != PTHREAD_MUTEX_TIMED_NP) return 1; if (mtx_recursive.__data.__kind != PTHREAD_MUTEX_RECURSIVE_NP) - return 2; + return 1; if (mtx_errorchk.__data.__kind != PTHREAD_MUTEX_ERRORCHECK_NP) - return 3; + return 1; if (mtx_adaptive.__data.__kind != PTHREAD_MUTEX_ADAPTIVE_NP) - return 4; + return 1; if (rwl_normal.__data.__flags != PTHREAD_RWLOCK_PREFER_READER_NP) - return 5; + return 1; if (rwl_writer.__data.__flags != PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP) - return 6; + return 1; return 0; } diff --git a/nptl/tst-sem11.c b/nptl/tst-sem11.c deleted file mode 100644 index 6633ddd1f3..0000000000 --- a/nptl/tst-sem11.c +++ /dev/null @@ -1,76 +0,0 @@ -#include <semaphore.h> -#include <stdio.h> -#include <unistd.h> -#include <pthread.h> -#include <internaltypes.h> - -#ifndef SEM_WAIT -# define SEM_WAIT(s) sem_wait (s) -#endif - -static void * -tf (void *arg) -{ -#ifdef PREPARE - PREPARE -#endif - SEM_WAIT (arg); - return NULL; -} - -int -main (void) -{ - int tries = 5; - pthread_t th; - sem_t s; - again: - if (sem_init (&s, 0, 0) != 0) - { - puts ("sem_init failed"); - return 1; - } - - struct new_sem *is = (struct new_sem *) &s; - - if (is->nwaiters != 0) - { - puts ("nwaiters not initialized"); - return 1; - } - - if (pthread_create (&th, NULL, tf, &s) != 0) - { - puts ("pthread_create failed"); - return 1; - } - - sleep (1); - - if (pthread_cancel (th) != 0) - { - puts ("pthread_cancel failed"); - return 1; - } - - void *r; - if (pthread_join (th, &r) != 0) - { - puts ("pthread_join failed"); - return 1; - } - if (r != PTHREAD_CANCELED && --tries > 0) - { - /* Maybe we get the scheduling right the next time. */ - sem_destroy (&s); - goto again; - } - - if (is->nwaiters != 0) - { - puts ("nwaiters not reset"); - return 1; - } - - return 0; -} diff --git a/nptl/tst-sem12.c b/nptl/tst-sem12.c deleted file mode 100644 index 71d02b70e9..0000000000 --- a/nptl/tst-sem12.c +++ /dev/null @@ -1,14 +0,0 @@ -#include <time.h> -#include <sys/time.h> - - -#define PREPARE \ - struct timespec ts; \ - struct timeval tv; \ - gettimeofday (&tv, NULL); \ - TIMEVAL_TO_TIMESPEC (&tv, &ts); \ - ts.tv_sec += 60; - -#define SEM_WAIT(s) sem_timedwait (s, &ts) - -#include "tst-sem11.c" diff --git a/nptl/tst-typesizes.c b/nptl/tst-typesizes.c index 17a1e297d3..db8936f5f4 100644 --- a/nptl/tst-typesizes.c +++ b/nptl/tst-typesizes.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2005. @@ -59,8 +59,7 @@ do_test (void) TEST_TYPE2 (pthread_rwlockattr_t, struct pthread_rwlockattr); TEST_TYPE2 (pthread_barrier_t, struct pthread_barrier); TEST_TYPE2 (pthread_barrierattr_t, struct pthread_barrierattr); - TEST_TYPE2 (sem_t, struct new_sem); - TEST_TYPE2 (sem_t, struct old_sem); + TEST_TYPE2 (sem_t, struct sem); return result; } |