aboutsummaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
commit0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch)
tree2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /nptl
parentTest for stack alignment. (diff)
downloadglibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.gz
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.bz2
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip
2.5-18.1
Diffstat (limited to 'nptl')
-rw-r--r--nptl/ChangeLog1675
-rw-r--r--nptl/Makeconfig8
-rw-r--r--nptl/Makefile80
-rw-r--r--nptl/TODO4
-rw-r--r--nptl/Versions8
-rw-r--r--nptl/alloca_cutoff.c8
-rw-r--r--nptl/allocatestack.c261
-rw-r--r--nptl/configure17
-rw-r--r--nptl/descr.h125
-rw-r--r--nptl/errno-loc.c1
-rw-r--r--nptl/init.c103
-rw-r--r--nptl/libc-cancellation.c4
-rw-r--r--nptl/lowlevellock.h (renamed from nptl/sysdeps/generic/lowlevellock.h)5
-rw-r--r--nptl/old_pthread_cond_init.c12
-rw-r--r--nptl/perf.c7
-rw-r--r--nptl/pt-cleanup.c5
-rw-r--r--nptl/pt-raise.c (renamed from nptl/sysdeps/generic/pt-raise.c)3
-rw-r--r--nptl/pthreadP.h103
-rw-r--r--nptl/pthread_atfork.c5
-rw-r--r--nptl/pthread_cond_destroy.c30
-rw-r--r--nptl/pthread_cond_init.c4
-rw-r--r--nptl/pthread_create.c109
-rw-r--r--nptl/pthread_getattr_np.c84
-rw-r--r--nptl/pthread_join.c80
-rw-r--r--nptl/pthread_key_create.c55
-rw-r--r--nptl/pthread_mutex_consistent.c (renamed from nptl/sysdeps/sh/jmpbuf-unwind.h)27
-rw-r--r--nptl/pthread_mutex_destroy.c8
-rw-r--r--nptl/pthread_mutex_getprioceiling.c (renamed from nptl/sysdeps/powerpc/jmpbuf-unwind.h)29
-rw-r--r--nptl/pthread_mutex_init.c81
-rw-r--r--nptl/pthread_mutex_lock.c333
-rw-r--r--nptl/pthread_mutex_setprioceiling.c116
-rw-r--r--nptl/pthread_mutex_timedlock.c382
-rw-r--r--nptl/pthread_mutex_trylock.c327
-rw-r--r--nptl/pthread_mutex_unlock.c214
-rw-r--r--nptl/pthread_mutexattr_getprioceiling.c48
-rw-r--r--nptl/pthread_mutexattr_getprotocol.c (renamed from nptl/sysdeps/alpha/jmpbuf-unwind.h)28
-rw-r--r--nptl/pthread_mutexattr_getpshared.c6
-rw-r--r--nptl/pthread_mutexattr_getrobust.c (renamed from nptl/sysdeps/i386/jmpbuf-unwind.h)27
-rw-r--r--nptl/pthread_mutexattr_gettype.c6
-rw-r--r--nptl/pthread_mutexattr_setprioceiling.c47
-rw-r--r--nptl/pthread_mutexattr_setprotocol.c41
-rw-r--r--nptl/pthread_mutexattr_setpshared.c8
-rw-r--r--nptl/pthread_mutexattr_setrobust.c (renamed from nptl/sysdeps/s390/jmpbuf-unwind.h)40
-rw-r--r--nptl/pthread_mutexattr_settype.c6
-rw-r--r--nptl/pthread_setschedparam.c17
-rw-r--r--nptl/pthread_setschedprio.c6
-rw-r--r--nptl/pthread_setspecific.c6
-rw-r--r--nptl/pthread_timedjoin.c4
-rw-r--r--nptl/pthread_tryjoin.c4
-rw-r--r--nptl/sem_open.c4
-rw-r--r--nptl/semaphoreP.h4
-rw-r--r--nptl/shlib-versions2
-rw-r--r--nptl/sigaction.c (renamed from nptl/sysdeps/pthread/sigaction.c)19
-rw-r--r--nptl/sysdeps/alpha/tls.h34
-rw-r--r--nptl/sysdeps/i386/tcb-offsets.sym1
-rw-r--r--nptl/sysdeps/i386/tls.h58
-rw-r--r--nptl/sysdeps/ia64/pthread_spin_lock.c2
-rw-r--r--nptl/sysdeps/ia64/pthread_spin_trylock.c2
-rw-r--r--nptl/sysdeps/ia64/tcb-offsets.sym8
-rw-r--r--nptl/sysdeps/ia64/tls.h72
-rw-r--r--nptl/sysdeps/powerpc/tcb-offsets.sym4
-rw-r--r--nptl/sysdeps/powerpc/tls.h67
-rw-r--r--nptl/sysdeps/pthread/Makefile4
-rw-r--r--nptl/sysdeps/pthread/Subdirs1
-rw-r--r--nptl/sysdeps/pthread/aio_misc.h74
-rw-r--r--nptl/sysdeps/pthread/allocalim.h13
-rw-r--r--nptl/sysdeps/pthread/bits/libc-lock.h12
-rw-r--r--nptl/sysdeps/pthread/bits/sigthread.h8
-rw-r--r--nptl/sysdeps/pthread/createthread.c3
-rw-r--r--nptl/sysdeps/pthread/gai_misc.h119
-rw-r--r--nptl/sysdeps/pthread/pt-initfini.c8
-rw-r--r--nptl/sysdeps/pthread/pthread-functions.h5
-rw-r--r--nptl/sysdeps/pthread/pthread.h361
-rw-r--r--nptl/sysdeps/pthread/pthread_cond_broadcast.c8
-rw-r--r--nptl/sysdeps/pthread/pthread_cond_signal.c5
-rw-r--r--nptl/sysdeps/pthread/pthread_cond_wait.c14
-rw-r--r--nptl/sysdeps/pthread/sigfillset.c4
-rw-r--r--nptl/sysdeps/pthread/unwind-forcedunwind.c17
-rw-r--r--nptl/sysdeps/s390/tcb-offsets.sym1
-rw-r--r--nptl/sysdeps/s390/tls.h58
-rw-r--r--nptl/sysdeps/sh/tcb-offsets.sym1
-rw-r--r--nptl/sysdeps/sh/tls.h47
-rw-r--r--nptl/sysdeps/sparc/tcb-offsets.sym1
-rw-r--r--nptl/sysdeps/sparc/tls.h58
-rw-r--r--nptl/sysdeps/unix/sysv/linux/Makefile8
-rw-r--r--nptl/sysdeps/unix/sysv/linux/aio_misc.h10
-rw-r--r--nptl/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h18
-rw-r--r--nptl/sysdeps/unix/sysv/linux/alpha/clone.S11
-rw-r--r--nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h81
-rw-r--r--nptl/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h8
-rw-r--r--nptl/sysdeps/unix/sysv/linux/bits/local_lim.h8
-rw-r--r--nptl/sysdeps/unix/sysv/linux/bits/posix_opt.h24
-rw-r--r--nptl/sysdeps/unix/sysv/linux/configure3
-rw-r--r--nptl/sysdeps/unix/sysv/linux/fork.c9
-rw-r--r--nptl/sysdeps/unix/sysv/linux/fork.h4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h18
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/clone.S11
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S2
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S63
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S227
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S7
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S47
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S18
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S18
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/sem_post.S11
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S28
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S13
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i486/sem_wait.S17
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i586/lowlevelrobustlock.S (renamed from nptl/sysdeps/sparc/sparc32/jmpbuf-unwind.h)17
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/i686/lowlevelrobustlock.S20
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h332
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/not-cancel.h42
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/smp.h56
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h288
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/vfork.S19
-rw-r--r--nptl/sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S5
-rw-r--r--nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h13
-rw-r--r--nptl/sysdeps/unix/sysv/linux/ia64/clone2.S11
-rw-r--r--nptl/sysdeps/unix/sysv/linux/ia64/createthread.c4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/ia64/jmpbuf-unwind.h39
-rw-r--r--nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h85
-rw-r--r--nptl/sysdeps/unix/sysv/linux/ia64/pt-initfini.c95
-rw-r--r--nptl/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h8
-rw-r--r--nptl/sysdeps/unix/sysv/linux/ia64/unwind-forcedunwind.c3
-rw-r--r--nptl/sysdeps/unix/sysv/linux/kernel-features.h6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c12
-rw-r--r--nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c113
-rw-r--r--nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.sym6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/mq_notify.c4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h90
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h30
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h118
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S12
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h41
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S12
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h16
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstack.c51
-rw-r--r--nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c48
-rw-r--r--nptl/sysdeps/unix/sysv/linux/pthread-pi-defines.sym6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c111
-rw-r--r--nptl/sysdeps/unix/sysv/linux/pthread_kill.c18
-rw-r--r--nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c5
-rw-r--r--nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/register-atfork.c4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/rtld-lowlevel.h153
-rw-r--r--nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h30
-rw-r--r--nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h99
-rw-r--r--nptl/sysdeps/unix/sysv/linux/s390/s390-32/clone.S11
-rw-r--r--nptl/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h8
-rw-r--r--nptl/sysdeps/unix/sysv/linux/s390/s390-64/clone.S11
-rw-r--r--nptl/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h8
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h16
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sh/clone.S11
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S30
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h142
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S224
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S8
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S18
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S18
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h2
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h128
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sleep.c12
-rw-r--r--nptl/sysdeps/unix/sysv/linux/smp.h30
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/Makefile2
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h30
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h95
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S11
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/lowlevellock.c131
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/pt-vfork.S13
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_init.c62
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_wait.c100
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_init.c63
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_post.c54
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_timedwait.c117
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_trywait.c59
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_wait.c74
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_init.c1
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c1
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_init.c1
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_post.c1
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_timedwait.c1
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_trywait.c1
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_wait.c1
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h97
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S13
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S9
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc64/pt-vfork.S13
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h91
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S13
-rw-r--r--nptl/sysdeps/unix/sysv/linux/timer_create.c13
-rw-r--r--nptl/sysdeps/unix/sysv/linux/timer_routines.c50
-rw-r--r--nptl/sysdeps/unix/sysv/linux/unregister-atfork.c4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h35
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/clone.S11
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S97
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h352
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S229
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S15
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S19
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S33
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S30
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S34
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S45
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S18
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S26
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S24
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S10
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S14
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S6
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S16
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/sem_trywait.S3
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S4
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h10
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S16
-rw-r--r--nptl/sysdeps/x86_64/jmpbuf-unwind.h31
-rw-r--r--nptl/sysdeps/x86_64/tcb-offsets.sym1
-rw-r--r--nptl/sysdeps/x86_64/tls.h59
-rw-r--r--nptl/tpp.c172
-rw-r--r--nptl/tst-align3.c57
-rw-r--r--nptl/tst-cancel-wrappers.sh3
-rw-r--r--nptl/tst-cancel17.c4
-rw-r--r--nptl/tst-cancel2.c8
-rw-r--r--nptl/tst-cancel24.cc113
-rw-r--r--nptl/tst-cancel25.c171
-rw-r--r--nptl/tst-cancel4.c120
-rw-r--r--nptl/tst-cond22.c160
-rw-r--r--nptl/tst-getpid1.c4
-rw-r--r--nptl/tst-getpid3.c114
-rw-r--r--nptl/tst-initializers1-c89.c1
-rw-r--r--nptl/tst-initializers1-c99.c1
-rw-r--r--nptl/tst-initializers1-gnu89.c1
-rw-r--r--nptl/tst-initializers1-gnu99.c1
-rw-r--r--nptl/tst-initializers1.c48
-rw-r--r--nptl/tst-join5.c115
-rw-r--r--nptl/tst-join6.c2
-rw-r--r--nptl/tst-kill4.c21
-rw-r--r--nptl/tst-mutex1.c26
-rw-r--r--nptl/tst-mutex2.c67
-rw-r--r--nptl/tst-mutex3.c23
-rw-r--r--nptl/tst-mutex4.c99
-rw-r--r--nptl/tst-mutex5.c20
-rw-r--r--nptl/tst-mutex6.c26
-rw-r--r--nptl/tst-mutex7.c52
-rw-r--r--nptl/tst-mutex7a.c2
-rw-r--r--nptl/tst-mutex9.c22
-rw-r--r--nptl/tst-mutexpi1.c27
-rw-r--r--nptl/tst-mutexpi2.c2
-rw-r--r--nptl/tst-mutexpi3.c2
-rw-r--r--nptl/tst-mutexpi4.c2
-rw-r--r--nptl/tst-mutexpi5.c2
-rw-r--r--nptl/tst-mutexpi5a.c2
-rw-r--r--nptl/tst-mutexpi6.c27
-rw-r--r--nptl/tst-mutexpi7.c2
-rw-r--r--nptl/tst-mutexpi7a.c2
-rw-r--r--nptl/tst-mutexpi8.c2
-rw-r--r--nptl/tst-mutexpi9.c2
-rw-r--r--nptl/tst-mutexpp1.c45
-rw-r--r--nptl/tst-mutexpp10.c334
-rw-r--r--nptl/tst-mutexpp6.c45
-rw-r--r--nptl/tst-once3.c7
-rw-r--r--nptl/tst-robust1.c339
-rw-r--r--nptl/tst-robust2.c3
-rw-r--r--nptl/tst-robust3.c20
-rw-r--r--nptl/tst-robust4.c2
-rw-r--r--nptl/tst-robust5.c2
-rw-r--r--nptl/tst-robust6.c2
-rw-r--r--nptl/tst-robust7.c212
-rw-r--r--nptl/tst-robust8.c275
-rw-r--r--nptl/tst-robust9.c94
-rw-r--r--nptl/tst-robustpi1.c2
-rw-r--r--nptl/tst-robustpi2.c2
-rw-r--r--nptl/tst-robustpi3.c2
-rw-r--r--nptl/tst-robustpi4.c2
-rw-r--r--nptl/tst-robustpi5.c2
-rw-r--r--nptl/tst-robustpi6.c2
-rw-r--r--nptl/tst-robustpi7.c2
-rw-r--r--nptl/tst-robustpi8.c2
-rw-r--r--nptl/tst-robustpi9.c2
-rw-r--r--nptl/tst-sem10.c88
-rw-r--r--nptl/tst-signal7.c59
-rw-r--r--nptl/tst-stackguard1-static.c1
-rw-r--r--nptl/tst-stackguard1.c230
-rw-r--r--nptl/tst-tpp.h94
-rw-r--r--nptl/tst-typesizes.c68
-rw-r--r--nptl/tst-unload.c8
-rw-r--r--nptl/unwind.c4
-rw-r--r--nptl/version.c4
290 files changed, 12911 insertions, 1914 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index f9ebeda707..1bc6c2d5bc 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,1666 @@
+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-05-28 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/i386/tls.h (THREAD_GSCOPE_RESET_FLAG): Use explicit
+ insn suffix.
+ (THREAD_GSCOPE_GET_FLAG): Remove.
+ * sysdeps/x86_64/tls.h (THREAD_GSCOPE_GET_FLAG): Remove.
+ * allocatestack.c (__wait_lookup_done): Revert 2007-05-24
+ changes.
+ * sysdeps/powerpc/tls.h (tcbhead_t): Remove gscope_flag.
+ (THREAD_GSCOPE_GET_FLAG): Remove.
+ (THREAD_GSCOPE_RESET_FLAG): Use THREAD_SELF->header.gscope_flag
+ instead of THREAD_GSCOPE_GET_FLAG.
+ (THREAD_GSCOPE_SET_FLAG): Likewise. Add atomic_write_barrier after
+ it.
+ * sysdeps/s390/tls.h (THREAD_GSCOPE_FLAG_UNUSED,
+ THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT,
+ THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG,
+ THREAD_GSCOPE_WAIT): Define.
+ * sysdeps/sparc/tls.h (THREAD_GSCOPE_FLAG_UNUSED,
+ THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT,
+ THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG,
+ THREAD_GSCOPE_WAIT): Define.
+ * sysdeps/sh/tls.h (THREAD_GSCOPE_FLAG_UNUSED,
+ THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT,
+ THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG,
+ THREAD_GSCOPE_WAIT): Define.
+ * sysdeps/ia64/tls.h (THREAD_GSCOPE_FLAG_UNUSED,
+ THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT,
+ THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG,
+ THREAD_GSCOPE_WAIT): Define.
+
+2007-05-24 Richard Henderson <rth@redhat.com>
+
+ * descr.h (struct pthread): Add header.gscope_flag.
+ * sysdeps/alpha/tls.h (THREAD_GSCOPE_FLAG_UNUSED,
+ THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT,
+ THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG,
+ THREAD_GSCOPE_WAIT): Define.
+
+2007-05-26 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c: Revert last change.
+ * init.c: Likewise.
+ * sysdeps/i386/tls.h: Likewise.
+ * sysdeps/x86_64/tls.h: Likewise.
+
+2007-05-24 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/powerpc/tls.h (tcbhead_t): Add gscope_flag.
+ (THREAD_GSCOPE_FLAG_UNUSED, THREAD_GSCOPE_FLAG_USED,
+ THREAD_GSCOPE_FLAG_WAIT): Define.
+ (THREAD_GSCOPE_GET_FLAG, THREAD_GSCOPE_SET_FLAG,
+ THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_WAIT): Define.
+ * sysdeps/i386/tls.h (THREAD_GSCOPE_WAIT): Don't use
+ PTR_DEMANGLE.
+ (THREAD_GSCOPE_GET_FLAG): Define.
+ * sysdeps/x86_64/tls.h (THREAD_GSCOPE_GET_FLAG): Define.
+ * allocatestack.c (__wait_lookup_done): Use THREAD_GSCOPE_GET_FLAG
+ instead of ->header.gscope_flag directly.
+
+2007-05-21 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread-functions.h (struct pthread_functions):
+ Remove ptr_wait_lookup_done again.
+ * init.c (pthread_functions): Don't add .ptr_wait_lookup_done here.
+ (__pthread_initialize_minimal_internal): Initialize
+ _dl_wait_lookup_done pointer in _rtld_global directly.
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c (__libc_pthread_init):
+ Remove code to code _dl_wait_lookup_done.
+ * sysdeps/x86_64/tls.h (THREAD_GSCOPE_WAIT): The pointer is not
+ encrypted for now.
+
+2007-05-19 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (__wait_lookup_done): New function.
+ * sysdeps/pthread/pthread-functions.h (struct pthread_functions):
+ Add ptr_wait_lookup_done.
+ * init.c (pthread_functions): Initialize .ptr_wait_lookup_done.
+ * pthreadP.h: Declare __wait_lookup_done.
+ * sysdeps/i386/tls.h (tcbhead_t): Add gscope_flag.
+ Define macros to implement reference handling of global scope.
+ * sysdeps/x86_64/tls.h: Likewise.
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c (__libc_pthread_init):
+ Initialize GL(dl_wait_lookup_done).
+
+2006-12-09 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/rtld-lowlevel.h
+ (__rtld_mrlock_initialize): Add missing closing parenthesis.
+
+2006-10-29 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (RTLD_SINGLE_THREAD_P):
+ Define.
+ (SINGLE_THREAD_P): Define to 1 if IS_IN_rtld.
+ * sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h: Likewise.
+
+2006-10-27 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/rtld-lowlevel.h (__rtld_mrlock_lock,
+ __rtld_mrlock_change): Update oldval if atomic compare and exchange
+ failed.
+
+ * sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h (SINGLE_THREAD_P):
+ Define to THREAD_SELF->header.multiple_threads.
+ * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (SINGLE_THREAD_P):
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (SINGLE_THREAD_P):
+ Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h (SINGLE_THREAD_P):
+ Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h (SINGLE_THREAD_P):
+ Likewise.
+
+2006-10-09 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/rtld-lowlevel.h: New file..
+
+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]
+ * pthread_mutex_lock.c: Preserve FUTEX_WAITERS bit when dead owner
+ is detected.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_trylock.c: Likewise.
+ Patch in part by Atsushi Nemoto <anemo@mba.ocn.ne.jp>.
+
+ * Makefile (tests): Add tst-robust9 and tst-robustpi9.
+ * tst-robust9.c: New file.
+ * tst-robustpi9.c: New file.
+
+2007-05-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/lowlevelrobustlock.c
+ (__lll_robust_lock_wait): Fix race caused by reloading of futex value.
+ (__lll_robust_timedlock_wait): Likewise.
+ Reported by Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>.
+
+2007-05-06 Mike Frysinger <vapier@gentoo.org>
+
+ [BZ #4465]
+ * tst-cancel-wrappers.sh: Set C["fdatasync"] to 1.
+ * tst-cancel4.c (tf_fdatasync): New test.
+
+2007-02-25 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/fork.c (__libc_fork): Reset refcntr in
+ new thread, don't just decrement it.
+ Patch by Suzuki K P <suzuki@in.ibm.com>.
+
+2007-02-09 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+ (__lll_mutex_timedlock_wait): Use correct pointer when we don't
+ call into the kernel to delay.
+
+2006-12-28 David S. Miller <davem@davemloft.net>
+
+ * shlib-versions: Fix sparc64 linux target specification.
+
+2006-12-21 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/pthread_kill.c (pthread_kill): Make sure
+ tid isn't reread from pd->tid in between ESRCH test and the syscall.
+
+2006-10-08 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstack.c: New file.
+ * sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c:
+ New file.
+
+2006-10-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h: New file.
+
+2006-09-24 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #3251]
+ * descr.h (ENQUEUE_MUTEX_BOTH): Add cast to avoid warning.
+ Patch by Petr Baudis.
+
+2006-09-18 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-kill4.c (do_test): Explicitly set tf thread's stack size.
+
+ * tst-cancel2.c (tf): Loop as long as something was written.
+
+2006-09-12 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S: For PI
+ mutexes wake all mutexes.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S: Don't increment
+ WAKEUP_SEQ if this would increase the value beyond TOTAL_SEQ.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Likewise.
+
+2006-09-12 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cond22.c (tf): Slight changes to the pthread_cond_wait use
+ to guarantee the thread is always canceled.
+
+2006-09-08 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-cond22.c: Include pthread.h instead of pthreadP.h.
+ Include stdlib.h.
+ * sysdeps/pthread/pthread_cond_wait.c (__condvar_cleanup): Only
+ increase FUTEX if increasing WAKEUP_SEQ. Fix comment typo.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+
+2006-09-08 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #3123]
+ * sysdeps/pthread/pthread_cond_wait.c (__condvar_cleanup): Don't
+ increment WAKEUP_SEQ if this would increase the value beyond TOTAL_SEQ.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+ * Makefile (tests): Add tst-cond22.
+ * tst-cond22.c: New file.
+
+2006-09-05 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #3124]
+ * descr.h (struct pthread): Add parent_cancelhandling.
+ * sysdeps/pthread/createthread.c (create_thread): Pass parent
+ cancelhandling value to child.
+ * pthread_create.c (start_thread): If parent thread was canceled
+ reset the SIGCANCEL mask.
+ * Makefile (tests): Add tst-cancel25.
+ * tst-cancel25.c: New file.
+
+2006-09-05 Jakub Jelinek <jakub@redhat.com>
+ Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/gai_misc.h (GAI_MISC_NOTIFY): Don't decrement
+ counterp if it is already zero.
+ * sysdeps/pthread/aio_misc.h (AIO_MISC_NOTIFY): Likewise..
+
+2006-03-04 Jakub Jelinek <jakub@redhat.com>
+ Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h
+ (LLL_STUB_UNWIND_INFO_START, LLL_STUB_UNWIND_INFO_END,
+ LLL_STUB_UNWIND_INFO_3, LLL_STUB_UNWIND_INFO_4): Define.
+ (lll_mutex_lock, lll_robust_mutex_lock, lll_mutex_cond_lock,
+ lll_robust_mutex_cond_lock, lll_mutex_timedlock,
+ lll_robust_mutex_timedlock, lll_mutex_unlock,
+ lll_robust_mutex_unlock, lll_lock, lll_unlock): Use them.
+ Add _L_*_ symbols around the subsection.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Add unwind info.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S: Likewise.
+
+2006-03-03 Jakub Jelinek <jakub@redhat.com>
+ Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+ (LLL_STUB_UNWIND_INFO_START, LLL_STUB_UNWIND_INFO_END,
+ LLL_STUB_UNWIND_INFO_5, LLL_STUB_UNWIND_INFO_6): Define.
+ (lll_mutex_lock, lll_robust_mutex_lock, lll_mutex_cond_lock,
+ lll_robust_mutex_cond_lock, lll_mutex_timedlock,
+ lll_robust_mutex_timedlock, lll_mutex_unlock,
+ lll_robust_mutex_unlock, lll_lock, lll_unlock): Use them.
+ Add _L_*_ symbols around the subsection.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Add unwind info.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S: Likewise.
+
+2006-08-31 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_rwlock_trywrlock.c (__pthread_rwlock_trywrlock): Undo last
+ change because it can disturb too much existing code. If real hard
+ reader preference is needed we'll introduce another type.
+ * sysdeps/pthread/pthread_rwlock_timedwrlock.c
+ (pthread_rwlock_timedwrlock): Likewise.
+ * sysdeps/pthread/pthread_rwlock_wrlock.c (__pthread_rwlock_wrlock):
+ Likewise.
+
+2006-08-30 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_rwlock_trywrlock.c (__pthread_rwlock_trywrlock): Respect
+ reader preference.
+ * sysdeps/pthread/pthread_rwlock_timedwrlock.c
+ (pthread_rwlock_timedwrlock): Likewise.
+ * sysdeps/pthread/pthread_rwlock_wrlock.c (__pthread_rwlock_wrlock):
+ Likewise.
+
+2006-08-25 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c (freeres_libpthread):
+ Only define ifdef SHARED.
+
+2006-08-23 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (queue_stack): Move freeing of surplus stacks to...
+ (free_stacks): ...here.
+ (__free_stack_cache): New function.
+ * pthreadP.h: Declare __free_stack_cache.
+ * sysdeps/pthread/pthread-functions.h (pthread_functions): Add
+ ptr_freeres.
+ * init.c (pthread_functions): Initialize ptr_freeres.
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c (freeres_libptread):
+ New freeres function.
+
+2006-07-30 Joseph S. Myers <joseph@codesourcery.com>
+
+ [BZ #3018]
+ * Makefile (extra-objs): Add modules to extra-test-objs instead.
+
+2006-08-20 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h: Define
+ _XOPEN_REALTIME_THREADS.
+
+2006-08-15 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/clock_settime.c (INTERNAL_VSYSCALL): Use
+ HAVE_CLOCK_GETRES_VSYSCALL as guard macro rather than
+ HAVE_CLOCK_GETTIME_VSYSCALL.
+ (maybe_syscall_settime_cpu): Use plain INTERNAL_VSYSCALL here.
+
+2006-08-14 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h
+ (_POSIX_THREAD_PRIO_PROTECT): Define to 200112L.
+ * descr.h (struct priority_protection_data): New type.
+ (struct pthread): Add tpp field.
+ * pthreadP.h (PTHREAD_MUTEX_PP_NORMAL_NP,
+ PTHREAD_MUTEX_PP_RECURSIVE_NP, PTHREAD_MUTEX_PP_ERRORCHECK_NP,
+ PTHREAD_MUTEX_PP_ADAPTIVE_NP): New enum values.
+ * pthread_mutex_init.c (__pthread_mutex_init): Handle non-robust
+ TPP mutexes.
+ * pthread_mutex_lock.c (__pthread_mutex_lock): Handle TPP mutexes.
+ * pthread_mutex_trylock.c (__pthread_mutex_trylock): Likewise.
+ * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise.
+ * pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt): Likewise.
+ * tpp.c: New file.
+ * pthread_setschedparam.c (__pthread_setschedparam): Handle priority
+ boosted by TPP.
+ * pthread_setschedprio.c (pthread_setschedprio): Likewise.
+ * pthread_mutexattr_getprioceiling.c
+ (pthread_mutexattr_getprioceiling): If ceiling is 0, ensure it is
+ in the SCHED_FIFO priority range.
+ * pthread_mutexattr_setprioceiling.c
+ (pthread_mutexattr_setprioceiling): Fix prioceiling validation.
+ * pthread_mutex_getprioceiling.c (pthread_mutex_getprioceiling): Fail
+ if mutex is not TPP. Ceiling is now in __data.__lock.
+ * pthread_mutex_setprioceiling.c: Include stdbool.h.
+ (pthread_mutex_setprioceiling): Fix prioceiling validation. Ceiling
+ is now in __data.__lock. Add locking.
+ * pthread_create.c (__free_tcb): Free pd->tpp structure.
+ * Makefile (libpthread-routines): Add tpp.
+ (xtests): Add tst-mutexpp1, tst-mutexpp6 and tst-mutexpp10.
+ * tst-tpp.h: New file.
+ * tst-mutexpp1.c: New file.
+ * tst-mutexpp6.c: New file.
+ * tst-mutexpp10.c: New file.
+ * tst-mutex1.c (TEST_FUNCTION): Don't redefine if already defined.
+ * tst-mutex6.c (TEST_FUNCTION): Likewise.
+
+2006-08-12 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #2843]
+ * pthread_join.c (pthread_join): Account for self being canceled
+ when checking for deadlocks.
+ * tst-join5.c: Cleanups. Allow to be used in tst-join6.
+ (tf1): Don't print anything after pthread_join returns, this would be
+ another cancellation point.
+ (tf2): Likewise.
+ * tst-join6.c: New file.
+ * Makefile (tests): Add tst-join6.
+
+2006-08-03 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #2892]
+ * pthread_setspecific.c (__pthread_setspecific): Check
+ out-of-range index before checking for unused key.
+
+ * sysdeps/pthread/gai_misc.h: New file.
+
+2006-08-01 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/smp.h: New file. Old Linux-specific
+ file. Don't use sysctl.
+ * sysdeps/unix/sysv/linux/smp.h: Always assume SMP. Archs can
+ overwrite the file if this is likely not true.
+
+2006-07-31 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * allocatestack.c (__reclaim_stacks): Reset the PID on cached stacks.
+ * Makefile (tests): Add tst-getpid3.
+ * tst-getpid3.c: New file.
+
+2006-07-30 Roland McGrath <roland@redhat.com>
+
+ * Makefile (libpthread-routines): Add ptw-sigsuspend.
+
+ * sysdeps/unix/sysv/linux/i386/not-cancel.h
+ (pause_not_cancel): New macro.
+ (nanosleep_not_cancel): New macro.
+ (sigsuspend_not_cancel): New macro.
+ * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Use
+ nanosleep_not_cancel macro from <not-cancel.h>.
+ * pthread_mutex_lock.c (__pthread_mutex_lock): Use pause_not_cancel
+ macro from <not-cancel.h>.
+
+2006-07-28 Ulrich Drepper <drepper@redhat.com>
+ Jakub Jelinek <jakub@redhat.com>
+
+ * descr.h: Change ENQUEUE_MUTEX and DEQUEUE_MUTEX for bit 0
+ notification of PI mutex. Add ENQUEUE_MUTEX_PI.
+ * pthreadP.h: Define PTHREAD_MUTEX_PI_* macros for PI mutex types.
+ * pthread_mutex_setprioceilining.c: Adjust for mutex type name change.
+ * pthread_mutex_init.c: Add support for priority inheritance mutex.
+ * pthread_mutex_lock.c: Likewise.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_trylock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise.
+ * sysdeps/pthread/pthread_cond_broadcast.c: For PI mutexes wake
+ all mutexes.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.c: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.c: Likewise.
+ * sysdeps/unix/sysv/linux/pthread-pi-defines.sym: New file.
+ * sysdeps/unix/sysv/linux/Makefile (gen-as-const-header): Add
+ pthread-pi-defines.sym.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Define FUTEX_LOCK_PI,
+ FUTEX_UNLOCK_PI, and FUTEX_TRYLOCK_PI.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h: 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.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h: Define
+ _POSIX_THREAD_PRIO_INHERIT to 200112L.
+ * tst-mutex1.c: Adjust to allow use in PI mutex test.
+ * tst-mutex2.c: Likewise.
+ * tst-mutex3.c: Likewise.
+ * tst-mutex4.c: Likewise.
+ * tst-mutex5.c: Likewise.
+ * tst-mutex6.c: Likewise.
+ * tst-mutex7.c: Likewise.
+ * tst-mutex7a.c: Likewise.
+ * tst-mutex8.c: Likewise.
+ * tst-mutex9.c: Likewise.
+ * tst-robust1.c: Likewise.
+ * tst-robust7.c: Likewise.
+ * tst-robust8.c: Likewise.
+ * tst-mutexpi1.c: New file.
+ * tst-mutexpi2.c: New file.
+ * tst-mutexpi3.c: New file.
+ * tst-mutexpi4.c: New file.
+ * tst-mutexpi5.c: New file.
+ * tst-mutexpi6.c: New file.
+ * tst-mutexpi7.c: New file.
+ * tst-mutexpi7a.c: New file.
+ * tst-mutexpi8.c: New file.
+ * tst-mutexpi9.c: New file.
+ * tst-robust1.c: New file.
+ * tst-robust2.c: New file.
+ * tst-robust3.c: New file.
+ * tst-robust4.c: New file.
+ * tst-robust5.c: New file.
+ * tst-robust6.c: New file.
+ * tst-robust7.c: New file.
+ * tst-robust8.c: New file.
+ * Makefile (tests): Add the new tests.
+
+ * pthread_create.c (start_thread): Add some casts to avoid warnings.
+ * pthread_mutex_destroy.c: Remove unneeded label.
+
+2006-07-01 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_mutex_init.c (__pthread_mutex_init): Move some
+ computations to compile time.
+
+2006-06-04 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h: Add pthread_equal inline version.
+
+2006-05-15 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/fork.h: Mark __fork_handlers as hidden.
+
+2006-05-11 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_key_create.c (__pthread_key_create): Do away with
+ __pthread_keys_lock.
+
+ * sysdeps/unix/sysv/linux/pthread_setaffinity.c
+ (__kernel_cpumask_size): Mark as hidden.
+ * sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c: Likewise.
+
+ * sem_open.c (__sem_mappings_lock): Mark as hidden.
+ * semaphoreP.h (__sem_mappings_lock): Likewise.
+
+2006-05-10 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_atfork.c: Mark __dso_handle as hidden.
+
+2006-05-09 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #2644]
+ * sysdeps/pthread/unwind-forcedunwind.c: Different solution for
+ the reload problem. Change the one path in pthread_cancel_init
+ which causes the problem. Force gcc to reload. Simplify callers.
+ * sysdeps/unix/sysv/linux/ia64/unwind-forcedunwind.c
+ (_Unwind_GetBSP): Undo last patch.
+
+2006-05-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/unwind-forcedunwind.c: Make sure the
+ function pointer is reloaded after pthread_cancel_init calls.
+
+ [BZ #2644]
+ * sysdeps/pthread/unwind-forcedunwind.c: Make sure functions
+ pointers are reloaded after pthread_cancel_init calls.
+
+2006-05-01 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/allocalim.h (__libc_use_alloca): Mark with
+ __always_inline.
+
+2006-04-27 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/timer_routines.c (timer_helper_thread):
+ Allocate new object which is passed to timer_sigev_thread so that
+ the timer can be deleted before the new thread is scheduled.
+
+2006-04-26 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/x86_64/tls.h: Include <asm/prctl.h> inside [! __ASSEMBLER__].
+
+2006-04-08 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Remove branch predicion
+ suffix for conditional jumps.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S: Likewise.
+
+ * init.c (sigcancel_handler): Compare with correct PID even if the
+ thread is in the middle of a fork call.
+ (sighandler_setxid): Likewise.
+ Reported by Suzuki K P <suzuki@in.ibm.com> .
+
+2006-04-07 Jakub Jelinek <jakub@redhat.com>
+
+ * pthreadP.h (FUTEX_TID_MASK): Sync with kernel.
+
+2006-04-06 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_getattr_np.c (pthread_getattr_np): Close fp if getrlimit
+ fails [Coverity CID 105].
+
+2006-04-05 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h: Add nonnull attributes.
+
+2006-04-03 Steven Munroe <sjmunroe@us.ibm.com>
+
+ [BZ #2505]
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h [_ARCH_PWR4]:
+ Define __lll_rel_instr using lwsync.
+
+2006-03-27 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (allocate_stack): Always initialize robust_head.
+ * descr.h: Define struct robust_list_head.
+ (struct pthread): Use robust_list_head in robust mutex list definition.
+ Adjust ENQUEUE_MUTEX and DEQUEUE_MUTEX.
+ * init.c [!__ASSUME_SET_ROBUST_LIST] (__set_robust_list_avail): Define.
+ (__pthread_initialize_minimal_internal): Register robust_list with
+ the kernel.
+ * pthreadP.h: Remove PRIVATE_ from PTHREAD_MUTEX_ROBUST_* names.
+ Declare __set_robust_list_avail.
+ * pthread_create.c (start_thread): Register robust_list of new thread.
+ [!__ASSUME_SET_ROBUST_LIST]: If robust_list is not empty wake up
+ waiters.
+ * pthread_mutex_destroy.c: For robust mutexes don't look at the
+ number of users, it's unreliable.
+ * pthread_mutex_init.c: Allow use of pshared robust mutexes if
+ set_robust_list syscall is available.
+ * pthread_mutex_consistent.c: Adjust for PTHREAD_MUTEX_ROBUST_* rename.
+ * pthread_mutex_lock.c: Simplify robust mutex code a bit.
+ Set robust_head.list_op_pending before trying to lock a robust mutex.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_trylock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise for unlocking.
+ * Makefile (tests): Add tst-robust8.
+ * tst-robust8.c: New file.
+
+2006-03-08 Andreas Schwab <schwab@suse.de>
+
+ * sysdeps/unix/sysv/linux/ia64/dl-sysdep.h
+ (DL_SYSINFO_IMPLEMENTATION): Add missing newline.
+
+2006-03-05 Roland McGrath <roland@redhat.com>
+
+ * configure (libc_add_on): Disable add-on when $add_ons_automatic = yes
+ and $config_os doesn't match *linux*.
+
+2006-03-05 David S. Miller <davem@sunset.davemloft.net>
+
+ * sysdeps/unix/sysv/linux/sparc/sparc32/pt-vfork.S:
+ Use __syscall_error.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/pt-vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/Makefile: New file.
+
+2006-03-02 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/aio_misc.h: Various cleanups.
+
+2006-03-01 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
+ (__lll_robust_lock_wait): Also set FUTEX_WAITERS bit if we got the
+ mutex.
+ (__lll_robust_timedlock_wait): Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S
+ (__lll_robust_lock_wait): Likewise.
+ (__lll_robust_timedlock_wait): Likewise.
+ * sysdeps/unix/sysv/linux/lowlevelrobustlock.c
+ (__lll_robust_lock_wait): Likewise.
+ (__lll_robust_timedlock_wait): Likewise.
+
+2006-03-01 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h (lll_robust_mutex_dead,
+ lll_robust_mutex_trylock, lll_robust_mutex_lock,
+ lll_robust_mutex_cond_lock, lll_robust_mutex_timedlock,
+ lll_robust_mutex_unlock): Define.
+ (__lll_robust_lock_wait, __lll_robust_timedlock_wait): New prototypes.
+
+2006-02-28 H.J. Lu <hongjiu.lu@intel.com>
+
+ * sysdeps/unix/sysv/linux/ia64/clone2.S: Include <clone2.S>
+ instead of <clone.S>.
+
+2006-02-27 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (libpthread-routines): Add
+ pthread_mutexattr_[sg]etprotocol, pthread_mutexattr_[sg]etprioceiling
+ and pthread_mutex_[sg]etprioceiling.
+ * Versions (GLIBC_2.4): Export pthread_mutexattr_getprotocol,
+ pthread_mutexattr_setprotocol, pthread_mutexattr_getprioceiling,
+ pthread_mutexattr_setprioceiling, pthread_mutex_getprioceiling and
+ pthread_mutex_setprioceiling.
+ * sysdeps/pthread/pthread.h (PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT,
+ PTHREAD_PRIO_PROTECT): New enum values.
+ (pthread_mutexattr_getprotocol, pthread_mutexattr_setprotocol,
+ pthread_mutexattr_getprioceiling, pthread_mutexattr_setprioceiling,
+ pthread_mutex_getprioceiling, pthread_mutex_setprioceiling): New
+ prototypes.
+ * pthreadP.h (PTHREAD_MUTEX_PRIO_INHERIT_PRIVATE_NP,
+ PTHREAD_MUTEX_PRIO_PROTECT_PRIVATE_NP): New enum values.
+ (PTHREAD_MUTEX_PRIO_CEILING_SHIFT, PTHREAD_MUTEX_PRIO_CEILING_MASK):
+ Define.
+ (PTHREAD_MUTEXATTR_PROTOCOL_SHIFT, PTHREAD_MUTEXATTR_PROTOCOL_MASK,
+ PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT,
+ PTHREAD_MUTEXATTR_PRIO_CEILING_MASK): Define.
+ (PTHREAD_MUTEXATTR_FLAG_BITS): Or in PTHREAD_MUTEXATTR_PROTOCOL_MASK
+ and PTHREAD_MUTEXATTR_PRIO_CEILING_MASK.
+ * pthread_mutex_init.c (__pthread_mutex_init): For the time being
+ return ENOTSUP for PTHREAD_PRIO_INHERIT or PTHREAD_PRIO_PROTECT
+ protocol mutexes.
+ * pthread_mutex_getprioceiling.c: New file.
+ * pthread_mutex_setprioceiling.c: New file.
+ * pthread_mutexattr_getprioceiling.c: New file.
+ * pthread_mutexattr_setprioceiling.c: New file.
+ * pthread_mutexattr_getprotocol.c: New file.
+ * pthread_mutexattr_setprotocol.c: New file.
+
+2006-02-27 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/aio_misc.h: Include <limits.h>.
+
+2006-02-27 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/pthread/Subdirs: List nptl here too.
+ * configure (libc_add_on_canonical): New variable.
+
+ * sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h: Use #include_next.
+
+ * sysdeps/unix/sysv/linux/sleep.c: Use #include_next after #include of
+ self to get main source tree's file.
+ * sysdeps/unix/sysv/linux/alpha/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/clone2.S: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-32/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-64/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/vfork.S: Likewise.
+
+ * Makefile: Use $(sysdirs) in vpath directive.
+
+ * sysdeps/pthread/Makefile (CFLAGS-libc-start.c): Variable removed.
+ (CPPFLAGS-timer_routines.c): Likewise.
+
+ * Makeconfig (includes): Variable removed.
+
+2006-02-26 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/generic/pt-raise.c: Moved to ...
+ * pt-raise.c: ... here.
+ * sysdeps/generic/lowlevellock.h: Moved to ...
+ * lowlevellock.h: ... here.
+
+2006-02-23 Roland McGrath <roland@redhat.com>
+
+ * descr.h (struct pthread): Add final member `end_padding'.
+ (PTHREAD_STRUCT_END_PADDING): Use it.
+
+2006-02-20 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/mips: Directory removed, saved in ports repository.
+ * sysdeps/unix/sysv/linux/mips: Likewise.
+
+2006-02-18 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-robust1.c: Add second mutex to check that the mutex list is
+ handled correctly.
+
+2006-02-17 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h (lll_robust_mutex_dead,
+ lll_robust_mutex_trylock, lll_robust_mutex_lock,
+ lll_robust_mutex_cond_lock, lll_robust_mutex_timedlock,
+ lll_robust_mutex_unlock): New macros.
+ (__lll_robust_lock_wait, __lll_robust_timedlock_wait): New prototypes.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/lowlevelrobustlock.c: New file.
+
+2006-02-17 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h: Add lll_robust_mutex_*
+ definitions.
+ * sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S: New file.
+
+2006-02-17 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+ (lll_robust_mutex_unlock): Avoid unnecessary wakeups.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h
+ (lll_robust_mutex_unlock): Likewise.
+
+2006-02-13 Jakub Jelinek <jakub@redhat.com>
+
+ * descr.h [!__PTHREAD_MUTEX_HAVE_PREV] (DEQUEUE_MUTEX):
+ Set robust_list.__next rather than robust_list.
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
+ (__pthread_list_t): New typedef.
+ (pthread_mutex_t): Replace __next and __prev fields with __list.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h
+ (__pthread_list_t): New typedef.
+ (pthread_mutex_t): Replace __next and __prev fields with __list.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
+ (__pthread_list_t, __pthread_slist_t): New typedefs.
+ (pthread_mutex_t): Replace __next and __prev fields with __list.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h
+ (__pthread_list_t, __pthread_slist_t): New typedefs.
+ (pthread_mutex_t): Replace __next and __prev fields with __list.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h
+ (__pthread_list_t, __pthread_slist_t): New typedefs.
+ (pthread_mutex_t): Replace __next and __prev fields with __list.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h
+ (__pthread_slist_t): New typedef.
+ (pthread_mutex_t): Replace __next field with __list.
+
+2006-02-15 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h: Define PTHREAD_MUTEX_INCONSISTENT instead of
+ PTHREAD_MUTEX_OWNERDEAD.
+ (PTHREAD_MUTEX_ROBUST_PRIVATE_NP): Define as 16, not 256.
+ Define FUTEX_WAITERS, FUTEX_OWNER_DIED, FUTEX_TID_MASK.
+ * Makefile (libpthread-routines): Add lowlevelrobustlock.
+ * pthread_create.c (start_thread): Very much simplify robust_list loop.
+ * pthread_mutex_consistent.c: Inconsistent mutex have __owner now set
+ to PTHREAD_MUTEX_INCONSISTENT.
+ * pthread_mutex_destroy.c: Allow destroying of inconsistent mutexes.
+ * pthread_mutex_lock.c: Reimplement robust mutex handling.
+ * pthread_mutex_trylock.c: Likewise.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise.
+ * sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c: Likewise.
+ * sysdeps/unix/sysv/linux/Makefile (gen-as-const-headers): Add
+ lowlevelrobustlock.sym.
+ * sysdeps/unix/sysv/linux/lowlevelrobustlock.sym: New file.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Add lll_robust_mutex_*
+ definitions.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i586/lowlevelrobustlock.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/lowlevelrobustlock.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S: New file.
+
+2006-02-12 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (allocate_stack): Initialize robust_list.
+ * init.c (__pthread_initialize_minimal_internal): Likewise.
+ * descr.h (struct xid_command): Pretty printing.
+ (struct pthread): Use __pthread_list_t or __pthread_slist_t for
+ robust_list. Adjust macros.
+ * pthread_create.c (start_thread): Adjust robust_list handling.
+ * phtread_mutex_unlock.c: Don't allow unlocking from any thread
+ but the owner for all robust mutex types.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Define
+ __pthread_list_t and __pthread_slist_t. Use them in pthread_mutex_t.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/pthread/pthread.h: Adjust mutex initializers.
+
+ * sysdeps/unix/sysv/linux/i386/not-cancel.h: Define openat_not_cancel,
+ openat_not_cancel_3, openat64_not_cancel, and openat64_not_cancel_3.
+
+2006-02-08 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_futex_wait,
+ lll_futex_timedwait, lll_wait_tid): Add "memory" clobber.
+
+2006-01-20 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h (lll_futex_wait):
+ Return status.
+ (lll_futex_timed_wait): Define.
+
+2006-01-19 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cancel4.c: Test ppoll.
+
+2006-01-18 Andreas Jaeger <aj@suse.de>
+
+ [BZ #2167]
+ * sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h
+ (pthread_mutex_t): Follow changes for other archs. Based on patch
+ by Jim Gifford <patches@jg555.com>.
+
+2006-01-13 Richard Henderson <rth@redhat.com>
+
+ * sysdeps/alpha/tls.h (tcbhead_t): Rename member to __private.
+
+2006-01-10 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/alpha/jmpbuf-unwind.h: File moved to main source tree.
+ * sysdeps/i386/jmpbuf-unwind.h: Likewise.
+ * sysdeps/mips/jmpbuf-unwind.h: Likewise.
+ * sysdeps/powerpc/jmpbuf-unwind.h: Likewise.
+ * sysdeps/s390/jmpbuf-unwind.h: Likewise.
+ * sysdeps/sh/jmpbuf-unwind.h: Likewise.
+ * sysdeps/sparc/sparc32/jmpbuf-unwind.h: Likewise.
+ * sysdeps/sparc/sparc64/jmpbuf-unwind.h: Likewise.
+ * sysdeps/x86_64/jmpbuf-unwind.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/jmpbuf-unwind.h: Likewise.
+
+2006-01-09 Roland McGrath <roland@redhat.com>
+
+ * tst-initializers1-c89.c: New file.
+ * tst-initializers1-c99.c: New file.
+ * tst-initializers1-gnu89.c: New file.
+ * tst-initializers1-gnu99.c: New file.
+ * Makefile (tests): Add them.
+ (CFLAGS-tst-initializers1-c89.c): New variable.
+ (CFLAGS-tst-initializers1-c99.c): New variable.
+ (CFLAGS-tst-initializers1-gnu89.c): New variable.
+ (CFLAGS-tst-initializers1-gnu99.c): New variable.
+
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_mutex_t):
+ Use __extension__ on anonymous union definition.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h: Likewise.
+
+2006-01-08 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_mutex_t):
+ Don't give the union a name because it changes the mangled name.
+ Instead name the struct for __data.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h (pthread_mutex_t):
+ Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h (pthread_mutex_t):
+ Likewise.
+
+2006-01-09 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/sparc/sparc64/jmpbuf-unwind.h (_JMPBUF_UNWINDS_ADJ): Add
+ stack bias to mc_ftp field.
+
+2006-01-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/aio_misc.h (AIO_MISC_WAIT): Work around gcc
+ being too clever and reloading the futex value where it shouldn't.
+
+2006-01-06 Ulrich Drepper <drepper@redhat.com>
+
+ * descr.h [!__PTHREAD_MUTEX_HAVE_PREV] (DEQUEUE_MUTEX): Use
+ correct type.
+
+2006-01-06 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h (PSEUDO):
+ Add cfi directives.
+
+2006-01-06 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/ia64/tls.h (tcbhead_t): Rename private member to __private.
+ * sysdeps/ia64/tcb-offsets.sym: Adjust for private->__private
+ rename in tcbhead_t.
+
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_mutex_t):
+ Don't give the union a name because it changes the mangled name.
+ Instead name the struct for __data.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+ * pthread_create.c (start_thread): Adjust robust mutex free loop.
+ * descr.h (ENQUEUE_MUTEX, DEQUEUE_MUTEX): Adjust.
+
+2006-01-05 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_futex_wait):
+ Return status.
+ (lll_futex_timed_wait): Define.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
+ * sysdeps/pthread/aio_misc.h: New file.
+
+2006-01-03 Joseph S. Myers <joseph@codesourcery.com>
+
+ * Makefile ($(objpfx)$(multidir)): Use mkdir -p.
+
+2006-01-03 Steven Munroe <sjmunroe@us.ibm.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
+ (PSEUDO): Remove redundant cfi_startproc and cfi_endproc directives.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h: Likewise.
+
+2006-01-04 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cancel24.cc: Use C headers instead of C++ headers.
+
+2006-01-03 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Remove #error for
+ sparc-linux configured glibc.
+ (lll_futex_wake_unlock): Define to 1 for sparc-linux configured glibc.
+ (__lll_mutex_trylock, __lll_mutex_cond_trylock, __lll_mutex_lock,
+ __lll_mutex_cond_lock, __lll_mutex_timedlock): Use
+ atomic_compare_and_exchange_val_24_acq instead of
+ atomic_compare_and_exchange_val_acq.
+ (lll_mutex_unlock, lll_mutex_unlock_force): Use atomic_exchange_24_rel
+ instead of atomic_exchange_rel.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/lowlevellock.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_init.c: New
+ file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_wait.c: New
+ file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_init.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_post.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_timedwait.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_trywait.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_wait.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_init.c:
+ New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c:
+ New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_init.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_post.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_timedwait.c: New
+ file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_trywait.c: New
+ file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_wait.c: New file.
+
+2006-01-03 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h [__WORDSIZE==64]: Don't use cast in
+ mutex initializers.
+
+2006-01-02 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/sparc/tls.h (tcbhead_t): Add pointer_guard field.
+ (THREAD_GET_POINTER_GUARD, THREAD_SET_POINTER_GUARD,
+ THREAD_COPY_POINTER_GUARD): Define.
+ * sysdeps/sparc/tcb-offsets.sym (POINTER_GUARD): Define.
+ * sysdeps/sparc/sparc64/jmpbuf-unwind.h: Revert 2005-12-27 changes.
+
+2006-01-01 Ulrich Drepper <drepper@redhat.com>
+
+ * version.c: Update copyright year.
+
+2005-12-29 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h: Remove explicit
+ .eh_frame section, use cfi_* directives.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S: Add cfi instrumentation.
+
+2005-12-30 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/jmpbuf-unwind.h: Undo last change for
+ now.
+
+2005-12-29 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/sigaction.c: Removed.
+ * sigaction.c: New file.
+ * sysdeps/unix/sysv/linux/Makefile: Define CFLAGS-sigaction.c.
+
+2005-12-28 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-signal7.
+ * tst-signal7.c: New file.
+
+2005-12-27 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/x86_64/jmpbuf-unwind.h (_jmpbuf_sp): New inline function.
+ (_JMPBUF_UNWINDS_ADJ): Use it, to PTR_DEMANGLE before comparison.
+ * sysdeps/alpha/jmpbuf-unwind.h: Likewise.
+ * sysdeps/i386/jmpbuf-unwind.h: Likewise.
+ * sysdeps/mips/jmpbuf-unwind.h: Likewise.
+ * sysdeps/powerpc/jmpbuf-unwind.h: Likewise.
+ * sysdeps/s390/jmpbuf-unwind.h: Likewise.
+ * sysdeps/sh/jmpbuf-unwind.h: Likewise.
+ * sysdeps/sparc/sparc32/jmpbuf-unwind.h: Likewise.
+ * sysdeps/sparc/sparc64/jmpbuf-unwind.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/jmpbuf-unwind.h: Likewise.
+
+2005-12-27 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h: Add __next
+ and __prev field to pthread_mutex_t.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Add __next field
+ to pthread_mutex_t.
+
+2005-12-26 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h: Define PTHREAD_MUTEX_ROBUST_PRIVATE_NP,
+ PTHREAD_MUTEX_ROBUST_PRIVATE_RECURSIVE_NP,
+ PTHREAD_MUTEX_ROBUST_PRIVATE_ERRORCHECK_NP,
+ PTHREAD_MUTEX_ROBUST_PRIVATE_ADAPTIVE_NP,
+ PTHREAD_MUTEXATTR_FLAG_ROBUST, PTHREAD_MUTEXATTR_FLAG_PSHARED,
+ and PTHREAD_MUTEXATTR_FLAG_BITS.
+ * descr.h (struct pthread): Add robust_list field and define
+ ENQUEUE_MUTEX and DEQUEUE_MUTEX macros.
+ * pthread_mutexattr_getrobust.c: New file.
+ * pthread_mutexattr_setrobust.c: New file.
+ * pthread_mutex_consistent.c: New file.
+ * sysdeps/pthread/pthread.h: Declare pthread_mutexattr_getrobust,
+ pthread_mutexattr_setrobust, and pthread_mutex_consistent.
+ Define PTHREAD_MUTEX_STALLED_NP and PTHREAD_MUTEX_ROBUST_NP.
+ Adjust pthread_mutex_t initializers.
+ * nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Add __next
+ field to pthread_mutex_t.
+ * nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Add __next
+ and __prev field to pthread_mutex_t.
+ * Versions [GLIBC_2.4]: Export pthread_mutexattr_getrobust_np,
+ pthread_mutexattr_setrobust_np, and pthread_mutex_consistent_np.
+ * pthread_mutexattr_getpshared.c: Use PTHREAD_MUTEXATTR_FLAG_PSHARED
+ and PTHREAD_MUTEXATTR_FLAG_BITS macros instead of magic numbers.
+ * pthread_mutexattr_gettype.c: Likewise.
+ * pthread_mutexattr_setpshared.c: Likewise.
+ * pthread_mutexattr_settype.c: Likewise.
+ * pthread_mutex_init.c: Reject robust+pshared attribute for now.
+ Initialize mutex kind according to robust flag.
+ * pthread_mutex_lock.c: Implement local robust mutex.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_trylock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise.
+ * pthread_create.c (start_thread): Mark robust mutexes which remained
+ locked as dead.
+ * tst-robust1.c: New file.
+ * tst-robust2.c: New file.
+ * tst-robust3.c: New file.
+ * tst-robust4.c: New file.
+ * tst-robust5.c: New file.
+ * tst-robust6.c: New file.
+ * tst-robust7.c: New file.
+ * Makefile (libpthread-routines): Add pthread_mutexattr_getrobust,
+ pthread_mutexattr_setrobust, and pthread_mutex_consistent.
+ (tests): Add tst-robust1, tst-robust2, tst-robust3, tst-robust4,
+ tst-robust5, tst-robust6, and tst-robust7.
+
+ * tst-typesizes.c: New file.
+ * Makefile (tests): Add tst-typesizes.
+
+ * tst-once3.c: More debug output.
+
+2005-12-24 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_mutex_trylock.c (__pthread_mutex_trylock): Add break
+ missing after last change.
+
+ * version.c: Update copyright year.
+
+2005-12-23 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_mutex_destroy.c: Set mutex type to an invalid value.
+ * pthread_mutex_lock.c: Return EINVAL for invalid mutex type.
+ * pthread_mutex_trylock.c: Likewise.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise.
+
+2005-12-22 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/pthread/sigaction.c: Use "" instead of <> to include self,
+ so that #include_next's search location is not reset to the -I..
+ directory where <nptl/...> can be found.
+
+2005-12-22 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #1913]
+ * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S (__new_sem_wait):
+ Fix unwind info. Remove useless branch prediction prefix.
+ * tst-cancel24.cc: New file.
+ * Makefile: Add rules to build and run tst-cancel24.
+
+2005-12-21 Roland McGrath <roland@redhat.com>
+
+ * libc-cancellation.c: Use <> rather than "" #includes.
+ * pt-cleanup.c: Likewise.
+ * pthread_create.c: Likewise.
+ * pthread_join.c: Likewise.
+ * pthread_timedjoin.c: Likewise.
+ * pthread_tryjoin.c: Likewise.
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c: Likewise.
+ * sysdeps/unix/sysv/linux/register-atfork.c: Likewise.
+ * sysdeps/unix/sysv/linux/unregister-atfork.c: Likewise.
+ * unwind.c: Likewise.
+
+2005-12-19 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/sh/tcb-offsets.sym: Add POINTER_GUARD.
+ * sysdeps/sh/tls.h (tcbhead_t): Remove private and add pointer_guard.
+ (THREAD_GET_POINTER_GUARD, THREAD_SET_POINTER_GUARD,
+ THREAD_COPY_POINTER_GUARD): Define.
+
+2005-12-19 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/ia64/tls.h (TLS_PRE_TCB_SIZE): Make room for 2 uintptr_t's
+ rather than one.
+ (THREAD_GET_POINTER_GUARD, THREAD_SET_POINTER_GUARD,
+ THREAD_COPY_POINTER_GUARD): Define.
+ * sysdeps/powerpc/tcb-offsets.sym (POINTER_GUARD): Add.
+ * sysdeps/powerpc/tls.h (tcbhead_t): Add pointer_guard field.
+ (THREAD_GET_POINTER_GUARD, THREAD_SET_POINTER_GUARD,
+ THREAD_COPY_POINTER_GUARD): Define.
+ * sysdeps/s390/tcb-offsets.sym (STACK_GUARD): Add.
+ * sysdeps/s390/tls.h (THREAD_GET_POINTER_GUARD,
+ THREAD_SET_POINTER_GUARD, THREAD_COPY_POINTER_GUARD): Define.
+ * sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S (__ia64_longjmp):
+ Use PTR_DEMANGLE for B0 if defined.
+
+2005-12-17 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_create.c (__pthread_create_2_1): Use
+ THREAD_COPY_POINTER_GUARD if available.
+ * sysdeps/i386/tcb-offsets.sym: Add POINTER_GUARD.
+ * sysdeps/x86_64/tcb-offsets.sym: Likewise.
+ * sysdeps/i386/tls.h (tcbhead_t): Add pointer_guard.
+ Define THREAD_SET_POINTER_GUARD and THREAD_COPY_POINTER_GUARD.
+ * sysdeps/x86_64/tls.h: Likewise.
+
+2005-12-15 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/mq_notify.c: Don't use sysdeps/generic.
+
+2005-12-13 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/sigfillset.c: Adjust for files moved out of
+ sysdeps/generic.
+ * errno-loc.c: New file.
+
+2005-12-12 Roland McGrath <roland@redhat.com>
+
+ * init.c (__pthread_initialize_minimal_internal): Do __static_tls_size
+ adjustments before choosing stack size. Update minimum stack size
+ calculation to match allocate_stack change.
+
+2005-12-12 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (allocate_stack): Don't demand that there is an
+ additional full page available on the stack beside guard, TLS, the
+ minimum stack.
+
+2005-11-24 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h
+ (__cleanup_fct_attribute): Use __regparm__ not regparm.
+
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: When
+ compiling 32-bit code we must define __cleanup_fct_attribute.
+
+005-11-24 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #1920]
+ * sysdeps/pthread/pthread.h (__pthread_unwind_next): Use
+ __attribute__ instead of __attribute.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h
+ (__cleanup_fct_attribute): Likewise.
+
+2005-11-17 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/unwind-forcedunwind.c (pthread_cancel_init): Put
+ a write barrier before writing libgcc_s_getcfa.
+
+2005-11-06 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/configure: Removed.
+
+2005-11-05 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/pt-initfini.c: Remove trace of
+ optional init_array/fini_array support.
+
+2005-10-24 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/sem_trywait.S: Remove unnecessary
+ versioned_symbol use.
+
+2005-10-16 Roland McGrath <roland@redhat.com>
+
+ * init.c (__pthread_initialize_minimal_internal): Even when using a
+ compile-time default stack size, apply the minimum that allocate_stack
+ will require, and round up to page size.
+
+2005-10-10 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * Makefile ($(test-modules)): Remove static pattern rule.
+
+2005-10-14 Jakub Jelinek <jakub@redhat.com>
+ Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Fix stack
+ alignment in callback function.
+ * Makefile: Add rules to build and run tst-align3.
+ * tst-align3.c: New file.
+
+2005-10-03 Jakub Jelinek <jakub@redhat.com>
+
+ * allocatestack.c (setxid_signal_thread): Add
+ INTERNAL_SYSCALL_DECL (err).
+
+2005-10-02 Jakub Jelinek <jakub@redhat.com>
+
+ * allocatestack.c (setxid_signal_thread): Need to use
+ atomic_compare_and_exchange_bool_acq.
+
+2005-10-01 Ulrich Drepper <drepper@redhat.com>
+ Jakub Jelinek <jakub@redhat.com>
+
+ * descr.h: Define SETXID_BIT and SETXID_BITMASK. Adjust
+ CANCEL_RESTMASK.
+ (struct pthread): Move specific_used field to avoid padding.
+ Add setxid_futex field.
+ * init.c (sighandler_setxid): Reset setxid flag and release the
+ setxid futex.
+ * allocatestack.c (setxid_signal_thread): New function. Broken
+ out of the bodies of the two loops in __nptl_setxid. For undetached
+ threads check whether they are exiting and if yes, don't send a signal.
+ (__nptl_setxid): Simplify loops by using setxid_signal_thread.
+ * pthread_create.c (start_thread): For undetached threads, check
+ whether setxid bit is set. If yes, wait until signal has been
+ processed.
+
+ * allocatestack.c (STACK_VARIABLES): Initialize them.
+ * pthread_create.c (__pthread_create_2_1): Initialize pd.
+
+2004-09-02 Jakub Jelinek <jakub@redhat.com>
+
+ * pthread_cond_destroy.c (__pthread_cond_destroy): If there are
+ waiters, awake all waiters on the associated mutex.
+
+2005-09-22 Roland McGrath <roland@redhat.com>
+
+ * perf.c [__x86_64__] (HP_TIMING_NOW): New macro (copied from
+ ../sysdeps/x86_64/hp-timing.h).
+
+2005-08-29 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h (FUTEX_WAKE_OP,
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (lll_futex_wake_unlock): Define.
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h (FUTEX_WAKE_OP,
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (lll_futex_wake_unlock): Define.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h (FUTEX_WAKE_OP,
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (lll_futex_wake_unlock): Define.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h (FUTEX_WAKE_OP,
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (lll_futex_wake_unlock): Define.
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h (FUTEX_WAKE_OP,
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (lll_futex_wake_unlock): Define.
+ * sysdeps/pthread/pthread_cond_signal.c (__pthread_cond_signal): Use
+ lll_futex_wake_unlock.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
+ (FUTEX_WAKE_OP, FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (__pthread_cond_signal): Use FUTEX_WAKE_OP.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
+ (FUTEX_WAKE_OP, FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (__pthread_cond_signal): Use FUTEX_WAKE_OP.
+
+2005-09-05 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S (__lll_mutex_lock_wait):
+ Fix typo in register name.
+
+2005-08-23 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/timer_routines.c (timer_helper_thread):
+ Use __sigfillset. Document that sigfillset does the right thing wrt
+ to SIGSETXID.
+
+2005-08-08 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-stackguard1.c (do_test): Likewise.
+
+2005-07-29 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-stackguard1.c (do_test): Don't fail if the poor man's
+ randomization doesn't work well enough.
+
+2005-07-11 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #1102]
+ * sysdeps/pthread/pthread.h (PTHREAD_MUTEX_INITIALIZER,
+ PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
+ PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP,
+ PTHREAD_MUTEX_ADAPTIVE_NP, PTHREAD_RWLOCK_INITIALIZER,
+ PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP,
+ PTHREAD_COND_INITIALIZER): Supply zeros for all fields
+ in the structure.
+ * Makefile (tests): Add tst-initializers1.
+ (CFLAGS-tst-initializers1.c): Set.
+ * tst-initializers1.c: New test.
+
+2005-07-11 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_rwlock_t):
+ Make sure __flags are located at offset 48 from the start of the
+ structure.
+
+2005-07-02 Roland McGrath <roland@redhat.com>
+
+ * Makeconfig: Comment fix.
+
+2005-07-05 Jakub Jelinek <jakub@redhat.com>
+
+ * descr.h (PTHREAD_STRUCT_END_PADDING): Define.
+ * sysdeps/ia64/tls.h (TLS_PRE_TCB_SIZE): If PTHREAD_STRUCT_END_PADDING
+ is smaller than 8 bytes, increase TLS_PRE_TCB_SIZE by 16 bytes.
+ (THREAD_SYSINFO, THREAD_SELF, DB_THREAD_SELF): Don't assume
+ TLS_PRE_TCB_SIZE is sizeof (struct pthread).
+ (THREAD_SET_STACK_GUARD, THREAD_COPY_STACK_GUARD): Define.
+ * sysdeps/ia64/tcb-offsets.sym (PID, TID, MULTIPLE_THREADS_OFFSET):
+ Use TLS_PRE_TCB_SIZE instead of sizeof (struct pthread).
+ * sysdeps/unix/sysv/linux/ia64/createthread.c (TLS_VALUE): Don't
+ assume TLS_PRE_TCB_SIZE is sizeof (struct pthread).
+
+2005-06-25 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/i386/tls.h (tcbhead_t): Add stack_guard field.
+ (THREAD_SET_STACK_GUARD, THREAD_COPY_STACK_GUARD): Define.
+ * sysdeps/x86_64/tls.h (tcbhead_t): Add sysinfo and stack_guard
+ fields.
+ (THREAD_SET_STACK_GUARD, THREAD_COPY_STACK_GUARD): Define.
+ * sysdeps/s390/tls.h (tcbhead_t): Add stack_guard
+ field. Put in sysinfo field unconditionally.
+ (THREAD_SET_STACK_GUARD, THREAD_COPY_STACK_GUARD): Define.
+ * sysdeps/powerpc/tls.h (tcbhead_t): Add stack_guard field.
+ (THREAD_SET_STACK_GUARD, THREAD_COPY_STACK_GUARD): Define.
+ * sysdeps/sparc/tls.h (tcbhead_t): Add sysinfo and stack_guard
+ fields.
+ (THREAD_SET_STACK_GUARD, THREAD_COPY_STACK_GUARD): Define.
+ * pthread_create.c (__pthread_create_2_1): Use
+ THREAD_COPY_STACK_GUARD macro.
+ * Makefile: Add rules to build and run tst-stackguard1{,-static}
+ tests.
+ * tst-stackguard1.c: New file.
+ * tst-stackguard1-static.c: New file.
+
+2005-06-14 Alan Modra <amodra@bigpond.net.au>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h (PSEUDO):
+ Invoke CGOTSETUP and CGOTRESTORE.
+ (CGOTSETUP, CGOTRESTORE): Define.
+
+2005-05-29 Richard Henderson <rth@redhat.com>
+
+ * tst-cancel4.c (WRITE_BUFFER_SIZE): New.
+ (tf_write, tf_writev): Use it.
+ (do_test): Use socketpair instead of pipe. Set SO_SNDBUF to
+ the system minimum.
+
+2005-05-23 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
+ [IS_IN_librt] (CENABLE, CDISABLE): Use JUMPTARGET instead of
+ __librt_*_asynccancel@local.
+
+2005-05-17 Alan Modra <amodra@bigpond.net.au>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h: Delete
+ all occurrences of JUMPTARGET. Instead append @local to labels.
+
+2005-05-20 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/i386/tls.h (TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN): Define to
+ size/alignment of struct pthread rather than tcbhead_t.
+ * sysdeps/x86_64/tls.h (TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN):
+ Likewise.
+ * sysdeps/s390/tls.h (TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN):
+ Likewise.
+ * sysdeps/sparc/tls.h (TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN):
+ Likewise.
+
+2005-05-19 Richard Henderson <rth@redhat.com>
+
+ * sysdeps/ia64/pthread_spin_lock.c (pthread_spin_lock): Use
+ __sync_val_compare_and_swap, not explicit _si variant.
+ * sysdeps/ia64/pthread_spin_trylock.c (pthread_spin_trylock): Likewise.
+
+2005-05-03 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #915]
+ * sysdeps/pthread/pthread.h: Avoid empty initializers.
+
+2005-05-03 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: Remove explicit
+ .eh_frame section, use cfi_* directives.
+
+2005-04-27 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/pthread_getcpuclockid.c: Use <> instead
+ of "" includes.
+
+2005-04-27 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #1075]
+ * tst-cancel17.c (do_test): Add arbitrary factor to make sure
+ aio_write blocks.
+
+2005-04-27 Roland McGrath <roland@redhat.com>
+
+ * Makefile (tests): Remove tst-clock2.
+
+ * sysdeps/unix/sysv/linux/timer_create.c (timer_create): Handle
+ CLOCK_PROCESS_CPUTIME_ID and CLOCK_PROCESS_THREAD_ID specially,
+ translating to the kernel clockid_t for our own process/thread clock.
+
+ * sysdeps/unix/sysv/linux/pthread_getcpuclockid.c: New file.
+
+2005-04-15 Jakub Jelinek <jakub@redhat.com>
+
+ * old_pthread_cond_init.c: Include <errno.h>.
+ (__pthread_cond_init_2_0): Fail with EINVAL if COND_ATTR is
+ process shared or uses clock other than CLOCK_REALTIME.
+ * pthread_cond_init.c (__pthread_cond_init): Remove bogus comment.
+
+2005-04-13 David S. Miller <davem@davemloft.net>
+
+ * sysdeps/sparc/sparc64/jmpbuf-unwind.h: New file.
+ * sysdeps/sparc/sparc64/clone.S: New file.
+
+2005-04-05 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #1102]
+ * sysdeps/pthread/pthread.h (__pthread_cleanup_routine): Use
+ __inline instead of inline.
+ * sysdeps/pthread/bits/libc-lock.h (__libc_cleanup_routine): Likewise.
+
+2005-03-31 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S: Use
+ functionally equivalent, but shorter instructions.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_post.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Likewise.
+
+2005-03-28 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/mips/Makefile: New file.
+ * sysdeps/mips/nptl-sysdep.S: New file.
+ * sysdeps/mips/tcb-offsets.sym: New file.
+ * sysdeps/mips/pthread_spin_lock.S: New file.
+ * sysdeps/mips/pthread_spin_trylock.S: New file.
+ * sysdeps/mips/pthreaddef.h: New file.
+ * sysdeps/mips/tls.h: New file.
+ * sysdeps/mips/jmpbuf-unwind.h: New file.
+ * sysdeps/unix/sysv/linux/mips/lowlevellock.h: New file.
+ * sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h: New file.
+ * sysdeps/unix/sysv/linux/mips/bits/semaphore.h: New file.
+ * sysdeps/unix/sysv/linux/mips/pthread_once.c: New file.
+ * sysdeps/unix/sysv/linux/mips/fork.c: New file.
+ * sysdeps/unix/sysv/linux/mips/pt-vfork.S: New file.
+ * sysdeps/unix/sysv/linux/mips/vfork.S: New file.
+ * sysdeps/unix/sysv/linux/mips/clone.S: New file.
+ * sysdeps/unix/sysv/linux/mips/createthread.c: New file.
+ * sysdeps/unix/sysv/linux/mips/sysdep-cancel.h: New file.
+
+2005-03-23 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #1112]
+ * pthread_create.c (__pthread_create_2_1): Rename syscall error
+ variable to scerr.
+
+2005-03-10 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-getpid1.c (do_test): Align stack passed to clone{2,}.
+
+2005-02-25 Roland McGrath <roland@redhat.com>
+
+ * alloca_cutoff.c: Correct license text.
+ * tst-unload.c: Likewise.
+ * sysdeps/pthread/allocalim.h: Likewise.
+ * sysdeps/pthread/pt-initfini.c: Likewise.
+ * sysdeps/pthread/bits/libc-lock.h: Likewise.
+ * sysdeps/pthread/bits/sigthread.h: Likewise.
+ * sysdeps/unix/sysv/linux/bits/local_lim.h: Likewise.
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h: Likewise.
+
+2005-02-16 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/pthread/pthread-functions.h (struct pthread_functions):
+ Use unsigned int * for ptr_nthreads.
+
+2005-02-14 Alan Modra <amodra@bigpond.net.au>
+
+ [BZ #721]
+ * sysdeps/powerpc/tcb-offsets.sym (thread_offsetof): Redefine to suit
+ gcc4.
+
+2005-02-07 Richard Henderson <rth@redhat.com>
+
+ [BZ #787]
+ * sysdeps/pthread/pthread.h (__sigsetjmp): Use pointer as first
+ argument.
+
+2004-11-03 Marcus Brinkmann <marcus@gnu.org>
+
+ * sysdeps/generic/lowlevellock.h (__generic_mutex_unlock): Fix
+ order of arguments in invocation of atomic_add_zero.
+
+2005-01-26 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #737]
+ * sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S (__new_sem_trywait):
+ Use direct %gs segment access or, if NO_TLS_DIRECT_SEG_REFS,
+ at least gotntpoff relocation and addition.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S (sem_timedwait):
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_post.S (__new_sem_post):
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S (__new_sem_wait):
+ Likewise.
+
+2005-01-06 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (init_one_static_tls): Adjust initialization of DTV
+ entry for static tls deallocation fix.
+ * sysdeps/alpha/tls.h (dtv_t): Change pointer type to be struct which
+ also contains information whether the memory pointed to is static
+ TLS or not.
+ * sysdeps/i386/tls.h: Likewise.
+ * sysdeps/ia64/tls.h: Likewise.
+ * sysdeps/powerpc/tls.h: Likewise.
+ * sysdeps/s390/tls.h: Likewise.
+ * sysdeps/sh/tls.h: Likewise.
+ * sysdeps/sparc/tls.h: Likewise.
+ * sysdeps/x86_64/tls.h: Likewise.
+
+2004-12-27 Ulrich Drepper <drepper@redhat.com>
+
+ * init.c (__pthread_initialize_minimal_internal): Use __sigemptyset.
+
+2004-12-21 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/i386/tls.h (CALL_THREAD_FCT): Maintain 16 byte alignment of
+ %esp.
+ * Makefile (tests): Add tst-align2.
+ * tst-align2.c: New test.
+ * sysdeps/i386/Makefile (CFLAGS-tst-align{,2}.c): Add
+ -mpreferred-stack-boundary=4.
+
2004-12-18 Roland McGrath <roland@redhat.com>
* sysdeps/unix/sysv/linux/powerpc/powerpc64/bits/local_lim.h:
@@ -56,7 +1719,7 @@
* sysdeps/pthread/posix-timer.h (__timer_signal_thread_pclk,
__timer_signal_thread_tclk): Remove.
* sysdeps/unix/sysv/linux/i386/bits/posix_opt.h: Removed.
- * sysdeps/unix/sysv/linux/ia64/bits/posix_>opt.h: Removed.
+ * sysdeps/unix/sysv/linux/ia64/bits/posix_opt.h: Removed.
* sysdeps/unix/sysv/linux/x86_64/bits/posix_opt.h: Removed.
2004-12-07 Jakub Jelinek <jakub@redhat.com>
@@ -457,6 +2120,11 @@
Move definition inside libpthread, libc, librt check. Provide
definition for rtld.
+2004-09-02 Jakub Jelinek <jakub@redhat.com>
+
+ * pthread_cond_destroy.c (__pthread_cond_destroy): If there are
+ waiters, awake all waiters on the associated mutex.
+
2004-09-02 Ulrich Drepper <drepper@redhat.com>
* sysdeps/alpha/jmpbuf-unwind.h: Define __libc_unwind_longjmp.
@@ -2531,6 +4199,11 @@
* Makefile [$(build-shared) = yes] (tests): Depend on $(test-modules).
+2003-07-22 Jakub Jelinek <jakub@redhat.com>
+
+ * descr.h: Don't include lowlevellock.h, pthreaddef.h and dl-sysdep.h
+ if __need_struct_pthread_size, instead define lll_lock_t.
+
2003-07-25 Jakub Jelinek <jakub@redhat.com>
* tst-cancel17.c (do_test): Check if aio_cancel failed.
diff --git a/nptl/Makeconfig b/nptl/Makeconfig
index e7beea0ede..54e2f65b01 100644
--- a/nptl/Makeconfig
+++ b/nptl/Makeconfig
@@ -1,4 +1,4 @@
-# Copyright (C) 2002, 2003 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.
@@ -17,7 +17,7 @@
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307 USA.
-# Makeconfig fragment for linuxthreads add-on.
+# Makeconfig fragment for NPTL add-on.
# This gets included at the end of the main glibc Makeconfig.
have-thread-library = yes
@@ -28,7 +28,3 @@ static-thread-library = $(common-objpfx)nptl/libpthread.a
bounded-thread-library = $(common-objpfx)nptl/libpthread_b.a
rpath-dirs += nptl
-
-ifneq ($(subdir),nptl)
-includes += -I$(..)nptl
-endif
diff --git a/nptl/Makefile b/nptl/Makefile
index 3cef684226..7ccdd18409 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -100,7 +100,7 @@ libpthread-routines = init vars events version \
cleanup_defer_compat unwind \
pt-longjmp pt-cleanup\
cancellation \
- lowlevellock \
+ lowlevellock lowlevelrobustlock \
pt-vfork \
ptw-write ptw-read ptw-close ptw-fcntl ptw-accept \
ptw-connect ptw-recv ptw-recvfrom ptw-recvmsg ptw-send \
@@ -108,7 +108,7 @@ libpthread-routines = init vars events version \
ptw-msync ptw-nanosleep ptw-open ptw-open64 ptw-pause \
ptw-pread ptw-pread64 ptw-pwrite ptw-pwrite64 \
ptw-tcdrain ptw-wait ptw-waitpid ptw-msgrcv ptw-msgsnd \
- ptw-sigwait \
+ ptw-sigwait ptw-sigsuspend \
pt-raise pt-system \
flockfile ftrylockfile funlockfile \
sigaction \
@@ -116,7 +116,14 @@ libpthread-routines = init vars events version \
pthread_kill_other_threads \
pthread_getaffinity pthread_setaffinity \
pthread_attr_getaffinity pthread_attr_setaffinity \
- cleanup_routine unwind-forcedunwind
+ pthread_mutexattr_getrobust pthread_mutexattr_setrobust \
+ pthread_mutex_consistent \
+ cleanup_routine unwind-forcedunwind \
+ pthread_mutexattr_getprotocol \
+ pthread_mutexattr_setprotocol \
+ pthread_mutexattr_getprioceiling \
+ pthread_mutexattr_setprioceiling tpp \
+ pthread_mutex_getprioceiling pthread_mutex_setprioceiling
# pthread_setuid pthread_seteuid pthread_setreuid \
# pthread_setresuid \
# pthread_setgid pthread_setegid pthread_setregid \
@@ -189,27 +196,35 @@ CFLAGS-pt-system.c = -fexceptions
omit-deps = $(unix-syscalls:%=ptw-%)
-tests = tst-attr1 tst-attr2 tst-attr3 \
+tests = tst-typesizes \
+ tst-attr1 tst-attr2 tst-attr3 \
tst-mutex1 tst-mutex2 tst-mutex3 tst-mutex4 tst-mutex5 tst-mutex6 \
tst-mutex7 tst-mutex8 tst-mutex9 tst-mutex5a tst-mutex7a \
+ tst-mutexpi1 tst-mutexpi2 tst-mutexpi3 tst-mutexpi4 tst-mutexpi5 \
+ tst-mutexpi5a tst-mutexpi6 tst-mutexpi7 tst-mutexpi7a tst-mutexpi8 \
+ tst-mutexpi9 \
tst-spin1 tst-spin2 tst-spin3 \
tst-cond1 tst-cond2 tst-cond3 tst-cond4 tst-cond5 tst-cond6 tst-cond7 \
tst-cond8 tst-cond9 tst-cond10 tst-cond11 tst-cond12 tst-cond13 \
tst-cond14 tst-cond15 tst-cond16 tst-cond17 tst-cond18 tst-cond19 \
- tst-cond20 tst-cond21 \
+ tst-cond20 tst-cond21 tst-cond22 \
+ tst-robust1 tst-robust2 tst-robust3 tst-robust4 tst-robust5 \
+ tst-robust6 tst-robust7 tst-robust8 tst-robust9 \
+ tst-robustpi1 tst-robustpi2 tst-robustpi3 tst-robustpi4 tst-robustpi5 \
+ tst-robustpi6 tst-robustpi7 tst-robustpi8 tst-robustpi9 \
tst-rwlock1 tst-rwlock2 tst-rwlock3 tst-rwlock4 tst-rwlock5 \
tst-rwlock6 tst-rwlock7 tst-rwlock8 tst-rwlock9 tst-rwlock10 \
tst-rwlock11 tst-rwlock12 tst-rwlock13 tst-rwlock14 \
tst-once1 tst-once2 tst-once3 tst-once4 \
tst-key1 tst-key2 tst-key3 tst-key4 \
tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 \
- tst-sem8 tst-sem9 \
+ tst-sem8 tst-sem9 tst-sem10 \
tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 \
- tst-align tst-align2 \
+ tst-align tst-align2 tst-align3 \
tst-basic1 tst-basic2 tst-basic3 tst-basic4 tst-basic5 tst-basic6 \
tst-kill1 tst-kill2 tst-kill3 tst-kill4 tst-kill5 tst-kill6 \
tst-raise1 \
- tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 \
+ tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 tst-join6 \
tst-detach1 \
tst-eintr1 tst-eintr2 tst-eintr3 tst-eintr4 tst-eintr5 \
tst-tsd1 tst-tsd2 tst-tsd3 tst-tsd4 tst-tsd5 \
@@ -220,11 +235,11 @@ tests = tst-attr1 tst-attr2 tst-attr3 \
tst-cancel6 tst-cancel7 tst-cancel8 tst-cancel9 tst-cancel10 \
tst-cancel11 tst-cancel12 tst-cancel13 tst-cancel14 tst-cancel15 \
tst-cancel16 tst-cancel17 tst-cancel18 tst-cancel19 tst-cancel20 \
- tst-cancel21 tst-cancel22 tst-cancel23 \
+ tst-cancel21 tst-cancel22 tst-cancel23 tst-cancel24 tst-cancel25 \
tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 tst-cleanup4 \
tst-flock1 tst-flock2 \
tst-signal1 tst-signal2 tst-signal3 tst-signal4 tst-signal5 \
- tst-signal6 \
+ tst-signal6 tst-signal7 \
tst-exec1 tst-exec2 tst-exec3 tst-exec4 \
tst-exit1 tst-exit2 tst-exit3 \
tst-stdio1 tst-stdio2 \
@@ -235,14 +250,15 @@ tests = tst-attr1 tst-attr2 tst-attr3 \
tst-locale1 tst-locale2 \
tst-umask1 \
tst-popen1 \
- tst-clock1 tst-clock2 \
+ tst-clock1 \
tst-context1 \
tst-sched1 \
tst-backtrace1 \
tst-oddstacklimit \
tst-vfork1 tst-vfork2 tst-vfork1x tst-vfork2x \
- tst-getpid1 tst-getpid2
-xtests = tst-setuid1 tst-setuid1-static
+ tst-getpid1 tst-getpid2 tst-getpid3 \
+ tst-initializers1 $(patsubst %,tst-initializers1-%,c89 gnu89 c99 gnu99)
+xtests = tst-setuid1 tst-setuid1-static tst-mutexpp1 tst-mutexpp6 tst-mutexpp10
# Files which must not be linked with libpthread.
tests-nolibpthread = tst-unload
@@ -269,7 +285,8 @@ tests += tst-cancelx2 tst-cancelx3 tst-cancelx4 tst-cancelx5 \
tst-oncex3 tst-oncex4
endif
ifeq ($(build-shared),yes)
-tests += tst-atfork2 tst-tls3 tst-tls4 tst-tls5 tst-_res1 tst-fini1
+tests += tst-atfork2 tst-tls3 tst-tls4 tst-tls5 tst-_res1 tst-fini1 \
+ tst-stackguard1
tests-nolibpthread += tst-fini1
ifeq ($(have-z-execstack),yes)
tests += tst-execstack
@@ -280,7 +297,7 @@ modules-names = tst-atfork2mod tst-tls3mod tst-tls4moda tst-tls4modb \
tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
tst-tls5modd tst-tls5mode tst-tls5modf \
tst-_res1mod1 tst-_res1mod2 tst-execstack-mod tst-fini1mod
-extra-objs += $(addsuffix .os,$(strip $(modules-names))) tst-cleanup4aux.o
+extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) tst-cleanup4aux.o
test-extras += $(modules-names)
test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
@@ -294,9 +311,6 @@ tst-tls5modd.so-no-z-defs = yes
tst-tls5mode.so-no-z-defs = yes
tst-tls5modf.so-no-z-defs = yes
-$(test-modules): $(objpfx)%.so: $(objpfx)%.os $(common-objpfx)shlib.lds
- $(build-module)
-
ifeq ($(build-shared),yes)
# Build all the modules even when not actually running test programs.
tests: $(test-modules)
@@ -321,7 +335,7 @@ crti-objs += $(multidir)/crti.o
crtn-objs += $(multidir)/crtn.o
omit-deps += $(multidir)/crti $(multidir)/crtn
$(objpfx)$(multidir):
- mkdir $@
+ mkdir -p $@
endif
extra-objs += $(crti-objs) $(crtn-objs)
omit-deps += crti crtn
@@ -337,7 +351,8 @@ link-libc-static := $(common-objpfx)libc.a $(static-gnulib) \
$(common-objpfx)libc.a
ifeq ($(build-static),yes)
-tests-static += tst-locale1 tst-locale2
+tests-static += tst-locale1 tst-locale2 tst-stackguard1-static
+tests += tst-stackguard1-static
xtests-static += tst-setuid1-static
endif
# These tests are linked with libc before libpthread
@@ -410,6 +425,14 @@ CFLAGS-tst-cleanupx4.c += -fexceptions
CFLAGS-tst-oncex3.c += -fexceptions
CFLAGS-tst-oncex4.c += -fexceptions
CFLAGS-tst-align.c += $(stack-align-test-flags)
+CFLAGS-tst-align3.c += $(stack-align-test-flags)
+CFLAGS-tst-initializers1.c = -W -Wall -Werror
+CFLAGS-tst-initializers1-< = $(CFLAGS-tst-initializers1.c) \
+ $(patsubst tst-initializers1-%.c,-std=%,$<)
+CFLAGS-tst-initializers1-c89.c = $(CFLAGS-tst-initializers1-<)
+CFLAGS-tst-initializers1-c99.c = $(CFLAGS-tst-initializers1-<)
+CFLAGS-tst-initializers1-gnu89.c = $(CFLAGS-tst-initializers1-<)
+CFLAGS-tst-initializers1-gnu99.c = $(CFLAGS-tst-initializers1-<)
tst-cancel7-ARGS = --command "$(built-program-cmd)"
tst-cancelx7-ARGS = $(tst-cancel7-ARGS)
@@ -478,6 +501,8 @@ $(objpfx)tst-clock2: $(common-objpfx)rt/librt.a
$(objpfx)tst-rwlock14: $(common-objpfx)rt/librt.a
endif
+LDFLAGS-tst-cancel24 = -lstdc++
+
extra-B-pthread.so = -B$(common-objpfx)nptl/
$(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs))
$(objpfx)libpthread.so: +preinit += $(addprefix $(objpfx),$(crti-objs))
@@ -499,21 +524,25 @@ $(addprefix $(objpfx), \
$(tests) $(xtests) $(test-srcs))): $(objpfx)libpthread.so \
$(objpfx)libpthread_nonshared.a
$(objpfx)tst-unload: $(common-objpfx)dlfcn/libdl.so
-# $(objpfx)../libc.so is used instead of $(common-objpfx)libc.so,
+# $(objpfx)linklibc.so is used instead of $(common-objpfx)libc.so,
# since otherwise libpthread.so comes before libc.so when linking.
$(addprefix $(objpfx), $(tests-reverse)): \
- $(objpfx)../libc.so $(objpfx)libpthread.so \
+ $(objpfx)linklibc.so $(objpfx)libpthread.so \
$(objpfx)libpthread_nonshared.a
$(objpfx)../libc.so: $(common-objpfx)libc.so ;
$(addprefix $(objpfx),$(tests-static) $(xtests-static)): $(objpfx)libpthread.a
$(objpfx)tst-atfork2.out: $(objpfx)tst-atfork2mod.so
+
+$(objpfx)linklibc.so: $(common-objpfx)libc.so
+ ln -s ../libc.so $@
+generated += libclink.so
else
$(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a
endif
ifeq ($(build-shared),yes)
-vpath pt-initfini.c $(full_config_sysdirs)
+vpath pt-initfini.c $(sysdirs)
$(objpfx)pt-initfini.s: pt-initfini.c
$(compile.c) -S $(CFLAGS-pt-initfini.s) -finhibit-size-directive \
@@ -586,6 +615,9 @@ LDFLAGS-tst-execstack = -Wl,-z,noexecstack
$(objpfx)tst-fini1mod.so: $(shared-thread-library)
+tst-stackguard1-ARGS = --command "$(built-program-cmd) --child"
+tst-stackguard1-static-ARGS = --command "$(objpfx)tst-stackguard1-static --child"
+
# The tests here better do not run in parallel
ifneq ($(filter %tests,$(MAKECMDGOALS)),)
.NOTPARALLEL:
diff --git a/nptl/TODO b/nptl/TODO
index a4a1055f46..d597176512 100644
--- a/nptl/TODO
+++ b/nptl/TODO
@@ -6,6 +6,10 @@
- a new attribute for mutexes: number of times we spin before calling
sys_futex
+- for adaptive mutexes: when releasing, determine whether somebody spins.
+If yes, for a short time release lock. If someone else locks no wakeup
+syscall needed.
+
- test with threaded process terminating and semadj (?) being applied
diff --git a/nptl/Versions b/nptl/Versions
index 79bf190c3a..54b9b9c6a5 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -232,6 +232,14 @@ libpthread {
pthread_setschedprio;
}
+ GLIBC_2.4 {
+ pthread_mutexattr_getrobust_np; pthread_mutexattr_setrobust_np;
+ pthread_mutex_consistent_np;
+ pthread_mutexattr_getprotocol; pthread_mutexattr_setprotocol;
+ pthread_mutexattr_getprioceiling; pthread_mutexattr_setprioceiling;
+ pthread_mutex_getprioceiling; pthread_mutex_setprioceiling;
+ };
+
GLIBC_PRIVATE {
__pthread_initialize_minimal;
__pthread_clock_gettime; __pthread_clock_settime;
diff --git a/nptl/alloca_cutoff.c b/nptl/alloca_cutoff.c
index 6dc5cfa2ce..ba26ceba3d 100644
--- a/nptl/alloca_cutoff.c
+++ b/nptl/alloca_cutoff.c
@@ -3,16 +3,16 @@
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
+ You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index 8875209a11..736c63d69f 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -33,7 +33,7 @@
#ifndef NEED_SEPARATE_REGISTER_STACK
/* Most architectures have exactly one stack pointer. Some have more. */
-# define STACK_VARIABLES void *stackaddr
+# define STACK_VARIABLES void *stackaddr = NULL
/* How to pass the values to the 'create_thread' function. */
# define STACK_VARIABLES_ARGS stackaddr
@@ -52,7 +52,7 @@
/* We need two stacks. The kernel will place them but we have to tell
the kernel about the size of the reserved address space. */
-# define STACK_VARIABLES void *stackaddr; size_t stacksize
+# define STACK_VARIABLES void *stackaddr = NULL; size_t stacksize = 0
/* How to pass the values to the 'create_thread' function. */
# define STACK_VARIABLES_ARGS stackaddr, stacksize
@@ -211,6 +211,45 @@ get_cached_stack (size_t *sizep, void **memp)
}
+/* Free stacks until cache size is lower than LIMIT. */
+static void
+free_stacks (size_t limit)
+{
+ /* We reduce the size of the cache. Remove the last entries until
+ the size is below the limit. */
+ list_t *entry;
+ list_t *prev;
+
+ /* Search from the end of the list. */
+ list_for_each_prev_safe (entry, prev, &stack_cache)
+ {
+ struct pthread *curr;
+
+ curr = list_entry (entry, struct pthread, list);
+ if (FREE_P (curr))
+ {
+ /* Unlink the block. */
+ list_del (entry);
+
+ /* Account for the freed memory. */
+ stack_cache_actsize -= curr->stackblock_size;
+
+ /* Free the memory associated with the ELF TLS. */
+ _dl_deallocate_tls (TLS_TPADJ (curr), false);
+
+ /* Remove this block. This should never fail. If it does
+ something is really wrong. */
+ if (munmap (curr->stackblock, curr->stackblock_size) != 0)
+ abort ();
+
+ /* Maybe we have freed enough. */
+ if (stack_cache_actsize <= limit)
+ break;
+ }
+ }
+}
+
+
/* Add a stack frame which is not used anymore to the stack. Must be
called with the cache lock held. */
static inline void
@@ -224,40 +263,15 @@ queue_stack (struct pthread *stack)
stack_cache_actsize += stack->stackblock_size;
if (__builtin_expect (stack_cache_actsize > stack_cache_maxsize, 0))
- {
- /* We reduce the size of the cache. Remove the last entries
- until the size is below the limit. */
- list_t *entry;
- list_t *prev;
-
- /* Search from the end of the list. */
- list_for_each_prev_safe (entry, prev, &stack_cache)
- {
- struct pthread *curr;
-
- curr = list_entry (entry, struct pthread, list);
- if (FREE_P (curr))
- {
- /* Unlink the block. */
- list_del (entry);
-
- /* Account for the freed memory. */
- stack_cache_actsize -= curr->stackblock_size;
-
- /* Free the memory associated with the ELF TLS. */
- _dl_deallocate_tls (TLS_TPADJ (curr), false);
+ free_stacks (stack_cache_maxsize);
+}
- /* Remove this block. This should never fail. If it
- does something is really wrong. */
- if (munmap (curr->stackblock, curr->stackblock_size) != 0)
- abort ();
- /* Maybe we have freed enough. */
- if (stack_cache_actsize <= stack_cache_maxsize)
- break;
- }
- }
- }
+/* This function is called indirectly from the freeres code in libc. */
+void
+__free_stack_cache (void)
+{
+ free_stacks (0);
}
@@ -406,8 +420,9 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
/* Make sure the size of the stack is enough for the guard and
eventually the thread descriptor. */
guardsize = (attr->guardsize + pagesize_m1) & ~pagesize_m1;
- if (__builtin_expect (size < (guardsize + __static_tls_size
- + MINIMAL_REST_STACK + pagesize_m1 + 1),
+ if (__builtin_expect (size < ((guardsize + __static_tls_size
+ + MINIMAL_REST_STACK + pagesize_m1)
+ & ~pagesize_m1),
0))
/* The stack is too small (or the guard too large). */
return EINVAL;
@@ -621,6 +636,18 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
stillborn thread could be canceled while the lock is taken. */
pd->lock = LLL_LOCK_INITIALIZER;
+ /* The robust mutex lists also need to be initialized
+ unconditionally because the cleanup for the previous stack owner
+ might have happened in the kernel. */
+ pd->robust_head.futex_offset = (offsetof (pthread_mutex_t, __data.__lock)
+ - offsetof (pthread_mutex_t,
+ __data.__list.__next));
+ pd->robust_head.list_op_pending = NULL;
+#ifdef __PTHREAD_MUTEX_HAVE_PREV
+ pd->robust_prev = &pd->robust_head;
+#endif
+ pd->robust_head.list = &pd->robust_head;
+
/* We place the thread descriptor at the end of the stack. */
*pdp = pd;
@@ -729,9 +756,7 @@ __reclaim_stacks (void)
list_t *runp;
list_for_each (runp, &stack_used)
{
- struct pthread *curp;
-
- curp = list_entry (runp, struct pthread, list);
+ struct pthread *curp = list_entry (runp, struct pthread, list);
if (curp != self)
{
/* This marks the stack as free. */
@@ -745,6 +770,13 @@ __reclaim_stacks (void)
}
}
+ /* Reset the PIDs in any cached stacks. */
+ list_for_each (runp, &stack_cache)
+ {
+ struct pthread *curp = list_entry (runp, struct pthread, list);
+ curp->pid = self->pid;
+ }
+
/* Add the stack of all running threads to the cache. */
list_splice (&stack_used, &stack_cache);
@@ -817,6 +849,46 @@ __find_thread_by_id (pid_t tid)
}
#endif
+
+static void
+internal_function
+setxid_signal_thread (struct xid_command *cmdp, struct pthread *t)
+{
+ if (! IS_DETACHED (t))
+ {
+ int ch;
+ do
+ {
+ ch = t->cancelhandling;
+
+ /* If the thread is exiting right now, ignore it. */
+ if ((ch & EXITING_BITMASK) != 0)
+ return;
+ }
+ while (atomic_compare_and_exchange_bool_acq (&t->cancelhandling,
+ ch | SETXID_BITMASK, ch));
+ }
+
+ int val;
+ INTERNAL_SYSCALL_DECL (err);
+#if __ASSUME_TGKILL
+ val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
+ t->tid, SIGSETXID);
+#else
+# ifdef __NR_tgkill
+ val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
+ t->tid, SIGSETXID);
+ if (INTERNAL_SYSCALL_ERROR_P (val, err)
+ && INTERNAL_SYSCALL_ERRNO (val, err) == ENOSYS)
+# endif
+ val = INTERNAL_SYSCALL (tkill, err, 2, t->tid, SIGSETXID);
+#endif
+
+ if (!INTERNAL_SYSCALL_ERROR_P (val, err))
+ atomic_increment (&cmdp->cntr);
+}
+
+
int
attribute_hidden
__nptl_setxid (struct xid_command *cmdp)
@@ -827,8 +899,6 @@ __nptl_setxid (struct xid_command *cmdp)
__xidcmd = cmdp;
cmdp->cntr = 0;
- INTERNAL_SYSCALL_DECL (err);
-
struct pthread *self = THREAD_SELF;
/* Iterate over the list with system-allocated threads first. */
@@ -836,54 +906,20 @@ __nptl_setxid (struct xid_command *cmdp)
list_for_each (runp, &stack_used)
{
struct pthread *t = list_entry (runp, struct pthread, list);
- if (t != self)
- {
- int val;
-#if __ASSUME_TGKILL
- val = INTERNAL_SYSCALL (tgkill, err, 3,
- THREAD_GETMEM (THREAD_SELF, pid),
- t->tid, SIGSETXID);
-#else
-# ifdef __NR_tgkill
- val = INTERNAL_SYSCALL (tgkill, err, 3,
- THREAD_GETMEM (THREAD_SELF, pid),
- t->tid, SIGSETXID);
- if (INTERNAL_SYSCALL_ERROR_P (val, err)
- && INTERNAL_SYSCALL_ERRNO (val, err) == ENOSYS)
-# endif
- val = INTERNAL_SYSCALL (tkill, err, 2, t->tid, SIGSETXID);
-#endif
+ if (t == self)
+ continue;
- if (!INTERNAL_SYSCALL_ERROR_P (val, err))
- atomic_increment (&cmdp->cntr);
- }
+ setxid_signal_thread (cmdp, t);
}
/* Now the list with threads using user-allocated stacks. */
list_for_each (runp, &__stack_user)
{
struct pthread *t = list_entry (runp, struct pthread, list);
- if (t != self)
- {
- int val;
-#if __ASSUME_TGKILL
- val = INTERNAL_SYSCALL (tgkill, err, 3,
- THREAD_GETMEM (THREAD_SELF, pid),
- t->tid, SIGSETXID);
-#else
-# ifdef __NR_tgkill
- val = INTERNAL_SYSCALL (tgkill, err, 3,
- THREAD_GETMEM (THREAD_SELF, pid),
- t->tid, SIGSETXID);
- if (INTERNAL_SYSCALL_ERROR_P (val, err)
- && INTERNAL_SYSCALL_ERRNO (val, err) == ENOSYS)
-# endif
- val = INTERNAL_SYSCALL (tkill, err, 2, t->tid, SIGSETXID);
-#endif
+ if (t == self)
+ continue;
- if (!INTERNAL_SYSCALL_ERROR_P (val, err))
- atomic_increment (&cmdp->cntr);
- }
+ setxid_signal_thread (cmdp, t);
}
int cur = cmdp->cntr;
@@ -895,6 +931,7 @@ __nptl_setxid (struct xid_command *cmdp)
/* This must be last, otherwise the current thread might not have
permissions to send SIGSETXID syscall to the other threads. */
+ INTERNAL_SYSCALL_DECL (err);
result = INTERNAL_SYSCALL_NCS (cmdp->syscall_no, err, 3,
cmdp->id[0], cmdp->id[1], cmdp->id[2]);
if (INTERNAL_SYSCALL_ERROR_P (result, err))
@@ -920,7 +957,8 @@ init_one_static_tls (struct pthread *curp, struct link_map *map)
# endif
/* Fill in the DTV slot so that a later LD/GD access will find it. */
- dtv[map->l_tls_modid].pointer = dest;
+ dtv[map->l_tls_modid].pointer.val = dest;
+ dtv[map->l_tls_modid].pointer.is_static = true;
/* Initialize the memory. */
memset (__mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size),
@@ -944,3 +982,60 @@ __pthread_init_static_tls (struct link_map *map)
lll_unlock (stack_cache_lock);
}
+
+
+void
+attribute_hidden
+__wait_lookup_done (void)
+{
+ lll_lock (stack_cache_lock);
+
+ struct pthread *self = THREAD_SELF;
+
+ /* Iterate over the list with system-allocated threads first. */
+ list_t *runp;
+ list_for_each (runp, &stack_used)
+ {
+ struct pthread *t = list_entry (runp, struct pthread, list);
+ if (t == self || t->header.gscope_flag == THREAD_GSCOPE_FLAG_UNUSED)
+ continue;
+
+ int *const gscope_flagp = &t->header.gscope_flag;
+
+ /* We have to wait until this thread is done with the global
+ scope. First tell the thread that we are waiting and
+ possibly have to be woken. */
+ if (atomic_compare_and_exchange_bool_acq (gscope_flagp,
+ THREAD_GSCOPE_FLAG_WAIT,
+ THREAD_GSCOPE_FLAG_USED))
+ continue;
+
+ do
+ lll_futex_wait (gscope_flagp, THREAD_GSCOPE_FLAG_WAIT);
+ while (*gscope_flagp == THREAD_GSCOPE_FLAG_WAIT);
+ }
+
+ /* Now the list with threads using user-allocated stacks. */
+ list_for_each (runp, &__stack_user)
+ {
+ struct pthread *t = list_entry (runp, struct pthread, list);
+ if (t == self || t->header.gscope_flag == THREAD_GSCOPE_FLAG_UNUSED)
+ continue;
+
+ int *const gscope_flagp = &t->header.gscope_flag;
+
+ /* We have to wait until this thread is done with the global
+ scope. First tell the thread that we are waiting and
+ possibly have to be woken. */
+ if (atomic_compare_and_exchange_bool_acq (gscope_flagp,
+ THREAD_GSCOPE_FLAG_WAIT,
+ THREAD_GSCOPE_FLAG_USED))
+ continue;
+
+ do
+ lll_futex_wait (gscope_flagp, THREAD_GSCOPE_FLAG_WAIT);
+ while (*gscope_flagp == THREAD_GSCOPE_FLAG_WAIT);
+ }
+
+ lll_unlock (stack_cache_lock);
+}
diff --git a/nptl/configure b/nptl/configure
index 3ad635f48d..dd246c755a 100644
--- a/nptl/configure
+++ b/nptl/configure
@@ -1,6 +1,13 @@
-# This is only to keep the GNU C library configure mechanism happy.
# This is a shell script fragment sourced by the main configure script.
-# We have nothing we need to add here.
-#
-# Perhaps some day we will need a real configuration script for different
-# kernel versions or so.
+# We're obliged to give here the canonical name that will be used to
+# as a subdirectory to search for in other add-ons' sysdeps trees.
+
+libc_add_on_canonical=nptl
+
+# Only linux configurations support NPTL.
+if test $add_ons_automatic = yes; then
+ case "$config_os" in
+ *linux*) ;;
+ *) libc_add_on= ;;
+ esac
+fi
diff --git a/nptl/descr.h b/nptl/descr.h
index 454bb2a547..241ba527ed 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -97,11 +97,28 @@ struct pthread_unwind_buf
struct xid_command
{
int syscall_no;
- long id[3];
+ long int id[3];
volatile int cntr;
};
+/* Data structure used by the kernel to find robust futexes. */
+struct robust_list_head
+{
+ void *list;
+ long int futex_offset;
+ void *list_op_pending;
+};
+
+
+/* Data strcture used to handle thread priority protection. */
+struct priority_protection_data
+{
+ int priomax;
+ unsigned int priomap[];
+};
+
+
/* Thread descriptor data structure. */
struct pthread
{
@@ -114,6 +131,7 @@ struct pthread
struct
{
int multiple_threads;
+ int gscope_flag;
} header;
#endif
@@ -134,6 +152,82 @@ struct pthread
/* Process ID - thread group ID in kernel speak. */
pid_t pid;
+ /* List of robust mutexes the thread is holding. */
+#ifdef __PTHREAD_MUTEX_HAVE_PREV
+ void *robust_prev;
+ struct robust_list_head robust_head;
+
+ /* The list above is strange. It is basically a double linked list
+ but the pointer to the next/previous element of the list points
+ in the middle of the object, the __next element. Whenever
+ casting to __pthread_list_t we need to adjust the pointer
+ first. */
+# define QUEUE_PTR_ADJUST (offsetof (__pthread_list_t, __next))
+
+# define ENQUEUE_MUTEX_BOTH(mutex, val) \
+ do { \
+ __pthread_list_t *next = (__pthread_list_t *) \
+ ((((uintptr_t) THREAD_GETMEM (THREAD_SELF, robust_head.list)) & ~1ul) \
+ - QUEUE_PTR_ADJUST); \
+ next->__prev = (void *) &mutex->__data.__list.__next; \
+ mutex->__data.__list.__next = THREAD_GETMEM (THREAD_SELF, \
+ robust_head.list); \
+ mutex->__data.__list.__prev = (void *) &THREAD_SELF->robust_head; \
+ THREAD_SETMEM (THREAD_SELF, robust_head.list, \
+ (void *) (((uintptr_t) &mutex->__data.__list.__next) \
+ | val)); \
+ } while (0)
+# define DEQUEUE_MUTEX(mutex) \
+ do { \
+ __pthread_list_t *next = (__pthread_list_t *) \
+ ((char *) (((uintptr_t) mutex->__data.__list.__next) & ~1ul) \
+ - QUEUE_PTR_ADJUST); \
+ next->__prev = mutex->__data.__list.__prev; \
+ __pthread_list_t *prev = (__pthread_list_t *) \
+ ((char *) (((uintptr_t) mutex->__data.__list.__prev) & ~1ul) \
+ - QUEUE_PTR_ADJUST); \
+ prev->__next = mutex->__data.__list.__next; \
+ mutex->__data.__list.__prev = NULL; \
+ mutex->__data.__list.__next = NULL; \
+ } while (0)
+#else
+ union
+ {
+ __pthread_slist_t robust_list;
+ struct robust_list_head robust_head;
+ };
+
+# define ENQUEUE_MUTEX_BOTH(mutex, val) \
+ do { \
+ mutex->__data.__list.__next \
+ = THREAD_GETMEM (THREAD_SELF, robust_list.__next); \
+ THREAD_SETMEM (THREAD_SELF, robust_list.__next, \
+ (void *) (((uintptr_t) &mutex->__data.__list) | val)); \
+ } while (0)
+# define DEQUEUE_MUTEX(mutex) \
+ do { \
+ __pthread_slist_t *runp = (__pthread_slist_t *) \
+ (((uintptr_t) THREAD_GETMEM (THREAD_SELF, robust_list.__next)) & ~1ul); \
+ if (runp == &mutex->__data.__list) \
+ THREAD_SETMEM (THREAD_SELF, robust_list.__next, runp->__next); \
+ else \
+ { \
+ __pthread_slist_t *next = (__pthread_slist_t *) \
+ (((uintptr_t) runp->__next) & ~1ul); \
+ while (next != &mutex->__data.__list) \
+ { \
+ runp = next; \
+ next = (__pthread_slist_t *) (((uintptr_t) runp->__next) & ~1ul); \
+ } \
+ \
+ runp->__next = next->__next; \
+ mutex->__data.__list.__next = NULL; \
+ } \
+ } while (0)
+#endif
+#define ENQUEUE_MUTEX(mutex) ENQUEUE_MUTEX_BOTH (mutex, 0)
+#define ENQUEUE_MUTEX_PI(mutex) ENQUEUE_MUTEX_BOTH (mutex, 1)
+
/* List of cleanup buffers. */
struct _pthread_cleanup_buffer *cleanup;
@@ -161,8 +255,11 @@ struct pthread
/* Bit set if thread terminated and TCB is freed. */
#define TERMINATED_BIT 5
#define TERMINATED_BITMASK 0x20
+ /* Bit set if thread is supposed to change XID. */
+#define SETXID_BIT 6
+#define SETXID_BITMASK 0x40
/* Mask for the rest. Helps the compiler to optimize. */
-#define CANCEL_RESTMASK 0xffffffc0
+#define CANCEL_RESTMASK 0xffffff80
#define CANCEL_ENABLED_AND_CANCELED(value) \
(((value) & (CANCELSTATE_BITMASK | CANCELED_BITMASK | EXITING_BITMASK \
@@ -185,12 +282,12 @@ struct pthread
void *data;
} specific_1stblock[PTHREAD_KEY_2NDLEVEL_SIZE];
- /* Flag which is set when specific data is set. */
- bool specific_used;
-
/* Two-level array for the thread-specific data. */
struct pthread_key_data *specific[PTHREAD_KEY_1STLEVEL_SIZE];
+ /* Flag which is set when specific data is set. */
+ bool specific_used;
+
/* True if events must be reported. */
bool report_events;
@@ -200,9 +297,16 @@ struct pthread
/* True if thread must stop at startup time. */
bool stopped_start;
+ /* The parent's cancel handling at the time of the pthread_create
+ call. This might be needed to undo the effects of a cancellation. */
+ int parent_cancelhandling;
+
/* Lock to synchronize access to the descriptor. */
lll_lock_t lock;
+ /* Lock for synchronizing setxid calls. */
+ lll_lock_t setxid_futex;
+
#if HP_TIMING_AVAIL
/* Offset of the CPU clock at start thread start time. */
hp_timing_t cpuclock_offset;
@@ -252,8 +356,17 @@ struct pthread
/* This is what the user specified and what we will report. */
size_t reported_guardsize;
+ /* Thread Priority Protection data. */
+ struct priority_protection_data *tpp;
+
/* Resolver state. */
struct __res_state res;
+
+ /* This member must be last. */
+ char end_padding[];
+
+#define PTHREAD_STRUCT_END_PADDING \
+ (sizeof (struct pthread) - offsetof (struct pthread, end_padding))
} __attribute ((aligned (TCB_ALIGNMENT)));
diff --git a/nptl/errno-loc.c b/nptl/errno-loc.c
new file mode 100644
index 0000000000..712b2b119c
--- /dev/null
+++ b/nptl/errno-loc.c
@@ -0,0 +1 @@
+#include "../csu/errno-loc.c"
diff --git a/nptl/init.c b/nptl/init.c
index 3751e6be77..7144abd3fb 100644
--- a/nptl/init.c
+++ b/nptl/init.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -60,6 +60,15 @@
size_t __static_tls_size;
size_t __static_tls_align_m1;
+#ifndef __ASSUME_SET_ROBUST_LIST
+/* Negative if we do not have the system call and we can use it. */
+int __set_robust_list_avail;
+# define set_robust_list_not_avail() \
+ __set_robust_list_avail = -1
+#else
+# define set_robust_list_not_avail() do { } while (0)
+#endif
+
/* Version of the library, used in libthread_db to detect mismatches. */
static const char nptl_version[] __attribute_used__ = VERSION;
@@ -127,7 +136,9 @@ static const struct pthread_functions pthread_functions =
.ptr_nthreads = &__nptl_nthreads,
.ptr___pthread_unwind = &__pthread_unwind,
.ptr__nptl_deallocate_tsd = __nptl_deallocate_tsd,
- .ptr__nptl_setxid = __nptl_setxid
+ .ptr__nptl_setxid = __nptl_setxid,
+ /* For now only the stack cache needs to be freed. */
+ .ptr_freeres = __free_stack_cache
};
# define ptr_pthread_functions &pthread_functions
#else
@@ -139,6 +150,14 @@ static const struct pthread_functions pthread_functions =
static void
sigcancel_handler (int sig, siginfo_t *si, void *ctx)
{
+#ifdef __ASSUME_CORRECT_SI_PID
+ /* Determine the process ID. It might be negative if the thread is
+ in the middle of a fork() call. */
+ pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
+ if (__builtin_expect (pid < 0, 0))
+ pid = -pid;
+#endif
+
/* Safety check. It would be possible to call this function for
other signals and send a signal from another process. This is not
correct and might even be a security problem. Try to catch as
@@ -147,7 +166,7 @@ sigcancel_handler (int sig, siginfo_t *si, void *ctx)
#ifdef __ASSUME_CORRECT_SI_PID
/* Kernels before 2.5.75 stored the thread ID and not the process
ID in si_pid so we skip this test. */
- || si->si_pid != THREAD_GETMEM (THREAD_SELF, pid)
+ || si->si_pid != pid
#endif
|| si->si_code != SI_TKILL)
return;
@@ -192,6 +211,14 @@ struct xid_command *__xidcmd attribute_hidden;
static void
sighandler_setxid (int sig, siginfo_t *si, void *ctx)
{
+#ifdef __ASSUME_CORRECT_SI_PID
+ /* Determine the process ID. It might be negative if the thread is
+ in the middle of a fork() call. */
+ pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
+ if (__builtin_expect (pid < 0, 0))
+ pid = -pid;
+#endif
+
/* Safety check. It would be possible to call this function for
other signals and send a signal from another process. This is not
correct and might even be a security problem. Try to catch as
@@ -200,7 +227,7 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx)
#ifdef __ASSUME_CORRECT_SI_PID
/* Kernels before 2.5.75 stored the thread ID and not the process
ID in si_pid so we skip this test. */
- || si->si_pid != THREAD_GETMEM (THREAD_SELF, pid)
+ || si->si_pid != pid
#endif
|| si->si_code != SI_TKILL)
return;
@@ -211,6 +238,15 @@ sighandler_setxid (int sig, siginfo_t *si, void *ctx)
if (atomic_decrement_val (&__xidcmd->cntr) == 0)
lll_futex_wake (&__xidcmd->cntr, 1);
+
+ /* Reset the SETXID flag. */
+ struct pthread *self = THREAD_SELF;
+ int flags = THREAD_GETMEM (self, cancelhandling);
+ THREAD_SETMEM (self, cancelhandling, flags & ~SETXID_BITMASK);
+
+ /* And release the futex. */
+ self->setxid_futex = 1;
+ lll_futex_wake (&self->setxid_futex, 1);
}
@@ -246,6 +282,21 @@ __pthread_initialize_minimal_internal (void)
THREAD_SETMEM (pd, cpuclock_offset, GL(dl_cpuclock_offset));
#endif
+ /* Initialize the robust mutex data. */
+#ifdef __PTHREAD_MUTEX_HAVE_PREV
+ pd->robust_prev = &pd->robust_head;
+#endif
+ pd->robust_head.list = &pd->robust_head;
+#ifdef __NR_set_robust_list
+ pd->robust_head.futex_offset = (offsetof (pthread_mutex_t, __data.__lock)
+ - offsetof (pthread_mutex_t,
+ __data.__list.__next));
+ int res = INTERNAL_SYSCALL (set_robust_list, err, 2, &pd->robust_head,
+ sizeof (struct robust_list_head));
+ if (INTERNAL_SYSCALL_ERROR_P (res, err))
+#endif
+ set_robust_list_not_avail ();
+
/* 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. */
@@ -262,7 +313,7 @@ __pthread_initialize_minimal_internal (void)
struct sigaction sa;
sa.sa_sigaction = sigcancel_handler;
sa.sa_flags = SA_SIGINFO;
- sigemptyset (&sa.sa_mask);
+ __sigemptyset (&sa.sa_mask);
(void) __libc_sigaction (SIGCANCEL, &sa, NULL);
@@ -280,6 +331,17 @@ __pthread_initialize_minimal_internal (void)
(void) INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_UNBLOCK, &sa.sa_mask,
NULL, _NSIG / 8);
+ /* Get the size of the static and alignment requirements for the TLS
+ block. */
+ size_t static_tls_align;
+ _dl_get_tls_static_info (&__static_tls_size, &static_tls_align);
+
+ /* Make sure the size takes all the alignments into account. */
+ if (STACK_ALIGN > static_tls_align)
+ static_tls_align = STACK_ALIGN;
+ __static_tls_align_m1 = static_tls_align - 1;
+
+ __static_tls_size = roundup (__static_tls_size, static_tls_align);
/* Determine the default allowed stack size. This is the size used
in case the user does not specify one. */
@@ -288,29 +350,22 @@ __pthread_initialize_minimal_internal (void)
|| limit.rlim_cur == RLIM_INFINITY)
/* The system limit is not usable. Use an architecture-specific
default. */
- __default_stacksize = ARCH_STACK_DEFAULT_SIZE;
+ limit.rlim_cur = ARCH_STACK_DEFAULT_SIZE;
else if (limit.rlim_cur < PTHREAD_STACK_MIN)
/* The system limit is unusably small.
Use the minimal size acceptable. */
- __default_stacksize = PTHREAD_STACK_MIN;
- else
- {
- /* Round the resource limit up to page size. */
- const uintptr_t pagesz = __sysconf (_SC_PAGESIZE);
- __default_stacksize = (limit.rlim_cur + pagesz - 1) & -pagesz;
- }
+ limit.rlim_cur = PTHREAD_STACK_MIN;
- /* Get the size of the static and alignment requirements for the TLS
- block. */
- size_t static_tls_align;
- _dl_get_tls_static_info (&__static_tls_size, &static_tls_align);
+ /* Make sure it meets the minimum size that allocate_stack
+ (allocatestack.c) will demand, which depends on the page size. */
+ const uintptr_t pagesz = __sysconf (_SC_PAGESIZE);
+ const size_t minstack = pagesz + __static_tls_size + MINIMAL_REST_STACK;
+ if (limit.rlim_cur < minstack)
+ limit.rlim_cur = minstack;
- /* Make sure the size takes all the alignments into account. */
- if (STACK_ALIGN > static_tls_align)
- static_tls_align = STACK_ALIGN;
- __static_tls_align_m1 = static_tls_align - 1;
-
- __static_tls_size = roundup (__static_tls_size, static_tls_align);
+ /* Round the resource limit up to page size. */
+ limit.rlim_cur = (limit.rlim_cur + pagesz - 1) & -pagesz;
+ __default_stacksize = limit.rlim_cur;
#ifdef SHARED
/* Transfer the old value from the dynamic linker's internal location. */
@@ -331,6 +386,8 @@ __pthread_initialize_minimal_internal (void)
GL(dl_init_static_tls) = &__pthread_init_static_tls;
+ GL(dl_wait_lookup_done) = &__wait_lookup_done;
+
/* Register the fork generation counter with the libc. */
#ifndef TLS_MULTIPLE_THREADS_IN_TCB
__libc_multiple_threads_ptr =
diff --git a/nptl/libc-cancellation.c b/nptl/libc-cancellation.c
index c9237e0950..b88a32fefd 100644
--- a/nptl/libc-cancellation.c
+++ b/nptl/libc-cancellation.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 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,7 @@
#include <setjmp.h>
#include <stdlib.h>
#include "pthreadP.h"
-#include "atomic.h"
+#include <atomic.h>
#include <bits/libc-lock.h>
diff --git a/nptl/sysdeps/generic/lowlevellock.h b/nptl/lowlevellock.h
index 9cffca83e6..338da39990 100644
--- a/nptl/sysdeps/generic/lowlevellock.h
+++ b/nptl/lowlevellock.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Low level locking macros used in NPTL implementation. Stub version.
+ Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -76,7 +77,7 @@ __generic_mutex_unlock (int *mutex)
/* Adding 0x80000000 to the counter results in 0 if and only if
there are not other interested threads - we can return (this is
the fastpath). */
- if (atomic_add_zero (0x80000000, mutex))
+ if (atomic_add_zero (mutex, 0x80000000))
return;
/* There are other threads waiting for this mutex, wake one of them
diff --git a/nptl/old_pthread_cond_init.c b/nptl/old_pthread_cond_init.c
index 21bc856a02..47e68b000d 100644
--- a/nptl/old_pthread_cond_init.c
+++ b/nptl/old_pthread_cond_init.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 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,6 +17,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <errno.h>
#include "pthreadP.h"
#include <shlib-compat.h>
@@ -27,15 +28,18 @@ __pthread_cond_init_2_0 (cond, cond_attr)
pthread_cond_2_0_t *cond;
const pthread_condattr_t *cond_attr;
{
- /* Note that we don't need the COND-ATTR. It contains only the
- PSHARED flag which is unimportant here since conditional
- variables are always usable in multiple processes. */
+ struct pthread_condattr *icond_attr = (struct pthread_condattr *) cond_attr;
/* The type of the first argument is actually that of the old, too
small pthread_cond_t. We use only the first word of it, as a
pointer. */
cond->cond = NULL;
+ /* We can't support PSHARED condvars in the old pthread_cond_*
+ functions and neither clocks other than CLOCK_REALTIME. */
+ if (icond_attr != NULL && icond_attr->value)
+ return EINVAL;
+
return 0;
}
compat_symbol (libpthread, __pthread_cond_init_2_0, pthread_cond_init,
diff --git a/nptl/perf.c b/nptl/perf.c
index 5b920d719d..f0dbc29ca0 100644
--- a/nptl/perf.c
+++ b/nptl/perf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -705,6 +705,11 @@ clock_getcpuclockid (pid_t pid, clockid_t *clock_id)
#ifdef i386
#define HP_TIMING_NOW(Var) __asm__ __volatile__ ("rdtsc" : "=A" (Var))
+#elif defined __x86_64__
+# define HP_TIMING_NOW(Var) \
+ ({ unsigned int _hi, _lo; \
+ asm volatile ("rdtsc" : "=a" (_lo), "=d" (_hi)); \
+ (Var) = ((unsigned long long int) _hi << 32) | _lo; })
#elif defined __ia64__
#define HP_TIMING_NOW(Var) __asm__ __volatile__ ("mov %0=ar.itc" : "=r" (Var) : : "memory")
#else
diff --git a/nptl/pt-cleanup.c b/nptl/pt-cleanup.c
index 96836a14a1..f72ea26e96 100644
--- a/nptl/pt-cleanup.c
+++ b/nptl/pt-cleanup.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 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,7 @@
#include <setjmp.h>
#include <stdlib.h>
#include "pthreadP.h"
-#include "jmpbuf-unwind.h"
+#include <jmpbuf-unwind.h>
void
__pthread_cleanup_upto (__jmp_buf target, char *targetframe)
@@ -61,4 +61,3 @@ __pthread_cleanup_upto (__jmp_buf target, char *targetframe)
THREAD_SETMEM (self, cleanup, cbuf);
}
hidden_def (__pthread_cleanup_upto)
-
diff --git a/nptl/sysdeps/generic/pt-raise.c b/nptl/pt-raise.c
index 59d9590e6e..a72cf85502 100644
--- a/nptl/sysdeps/generic/pt-raise.c
+++ b/nptl/pt-raise.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* ISO C raise function for libpthread.
+ Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index 24168146fa..21ce6fe0b7 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -31,6 +31,7 @@
#include <internaltypes.h>
#include <pthread-functions.h>
#include <atomic.h>
+#include <kernel-features.h>
/* Atomic operations on TLS memory. */
@@ -51,6 +52,78 @@
#endif
+/* Magic cookie representing robust mutex with dead owner. */
+#define PTHREAD_MUTEX_INCONSISTENT INT_MAX
+/* Magic cookie representing not recoverable robust mutex. */
+#define PTHREAD_MUTEX_NOTRECOVERABLE (INT_MAX - 1)
+
+
+/* Internal mutex type value. */
+enum
+{
+ PTHREAD_MUTEX_KIND_MASK_NP = 3,
+ PTHREAD_MUTEX_ROBUST_NORMAL_NP = 16,
+ PTHREAD_MUTEX_ROBUST_RECURSIVE_NP
+ = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_RECURSIVE_NP,
+ PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP
+ = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_ERRORCHECK_NP,
+ PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP
+ = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_ADAPTIVE_NP,
+ PTHREAD_MUTEX_PRIO_INHERIT_NP = 32,
+ PTHREAD_MUTEX_PI_NORMAL_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_NORMAL,
+ PTHREAD_MUTEX_PI_RECURSIVE_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_RECURSIVE_NP,
+ PTHREAD_MUTEX_PI_ERRORCHECK_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ERRORCHECK_NP,
+ PTHREAD_MUTEX_PI_ADAPTIVE_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ADAPTIVE_NP,
+ PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_NORMAL_NP,
+ PTHREAD_MUTEX_PI_ROBUST_RECURSIVE_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_RECURSIVE_NP,
+ PTHREAD_MUTEX_PI_ROBUST_ERRORCHECK_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP,
+ PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP,
+ PTHREAD_MUTEX_PRIO_PROTECT_NP = 64,
+ PTHREAD_MUTEX_PP_NORMAL_NP
+ = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_NORMAL,
+ PTHREAD_MUTEX_PP_RECURSIVE_NP
+ = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_RECURSIVE_NP,
+ PTHREAD_MUTEX_PP_ERRORCHECK_NP
+ = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ERRORCHECK_NP,
+ PTHREAD_MUTEX_PP_ADAPTIVE_NP
+ = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ADAPTIVE_NP
+};
+
+/* 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
+ masking if the value is then shifted down by
+ PTHREAD_MUTEX_PRIO_CEILING_SHIFT. */
+#define PTHREAD_MUTEX_PRIO_CEILING_SHIFT 19
+#define PTHREAD_MUTEX_PRIO_CEILING_MASK 0xfff80000
+
+
+/* Flags in mutex attr. */
+#define PTHREAD_MUTEXATTR_PROTOCOL_SHIFT 28
+#define PTHREAD_MUTEXATTR_PROTOCOL_MASK 0x30000000
+#define PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT 12
+#define PTHREAD_MUTEXATTR_PRIO_CEILING_MASK 0x00fff000
+#define PTHREAD_MUTEXATTR_FLAG_ROBUST 0x40000000
+#define PTHREAD_MUTEXATTR_FLAG_PSHARED 0x80000000
+#define PTHREAD_MUTEXATTR_FLAG_BITS \
+ (PTHREAD_MUTEXATTR_FLAG_ROBUST | PTHREAD_MUTEXATTR_FLAG_PSHARED \
+ | PTHREAD_MUTEXATTR_PROTOCOL_MASK | PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
+
+
+/* Bits used in robust mutex implementation. */
+#define FUTEX_WAITERS 0x80000000
+#define FUTEX_OWNER_DIED 0x40000000
+#define FUTEX_TID_MASK 0x3fffffff
+
+
/* Internal variables. */
@@ -87,6 +160,19 @@ hidden_proto (__pthread_keys)
/* Number of threads running. */
extern unsigned int __nptl_nthreads attribute_hidden;
+#ifndef __ASSUME_SET_ROBUST_LIST
+/* Negative if we do not have the system call and we can use it. */
+extern int __set_robust_list_avail attribute_hidden;
+#endif
+
+/* Thread Priority Protection. */
+extern int __sched_fifo_min_prio attribute_hidden;
+extern int __sched_fifo_max_prio attribute_hidden;
+extern void __init_sched_fifo_prio (void) attribute_hidden;
+extern int __pthread_tpp_change_priority (int prev_prio, int new_prio)
+ attribute_hidden;
+extern int __pthread_current_priority (void) attribute_hidden;
+
/* The library can run in debugging mode where it performs a lot more
tests. */
extern int __pthread_debug attribute_hidden;
@@ -457,10 +543,25 @@ extern void __nptl_deallocate_tsd (void) attribute_hidden;
extern int __nptl_setxid (struct xid_command *cmdp) attribute_hidden;
+extern void __free_stack_cache (void) attribute_hidden;
+
+extern void __wait_lookup_done (void) attribute_hidden;
+
#ifdef SHARED
# define PTHREAD_STATIC_FN_REQUIRE(name)
#else
# define PTHREAD_STATIC_FN_REQUIRE(name) __asm (".globl " #name);
#endif
+
+#ifndef __NR_set_robust_list
+/* XXX For the time being... Once we can rely on the kernel headers
+ having the definition remove these lines. */
+# if defined __i386__
+# define __NR_set_robust_list 311
+# elif defined __x86_64__
+# define __NR_set_robust_list 273
+# endif
+#endif
+
#endif /* pthreadP.h */
diff --git a/nptl/pthread_atfork.c b/nptl/pthread_atfork.c
index 6437d64906..b2495c7022 100644
--- a/nptl/pthread_atfork.c
+++ b/nptl/pthread_atfork.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -38,7 +38,8 @@
#include <fork.h>
/* This is defined by newer gcc version unique for each module. */
-extern void *__dso_handle __attribute__ ((__weak__));
+extern void *__dso_handle __attribute__ ((__weak__,
+ __visibility__ ("hidden")));
/* Hide the symbol so that no definition but the one locally in the
diff --git a/nptl/pthread_cond_destroy.c b/nptl/pthread_cond_destroy.c
index 0208d18ce4..3e4ec8d0e4 100644
--- a/nptl/pthread_cond_destroy.c
+++ b/nptl/pthread_cond_destroy.c
@@ -44,15 +44,35 @@ __pthread_cond_destroy (cond)
broadcasted, but still are using the pthread_cond_t structure,
pthread_cond_destroy needs to wait for them. */
unsigned int nwaiters = cond->__data.__nwaiters;
- while (nwaiters >= (1 << COND_CLOCK_BITS))
+
+ if (nwaiters >= (1 << COND_CLOCK_BITS))
{
- lll_mutex_unlock (cond->__data.__lock);
+ /* Wake everybody on the associated mutex in case there are
+ threads that have been requeued to it.
+ Without this, pthread_cond_destroy could block potentially
+ for a long time or forever, as it would depend on other
+ thread's using the mutex.
+ When all threads waiting on the mutex are woken up, pthread_cond_wait
+ only waits for threads to acquire and release the internal
+ condvar lock. */
+ if (cond->__data.__mutex != NULL
+ && cond->__data.__mutex != (void *) ~0l)
+ {
+ pthread_mutex_t *mut = (pthread_mutex_t *) cond->__data.__mutex;
+ lll_futex_wake (&mut->__data.__lock, INT_MAX);
+ }
+
+ do
+ {
+ lll_mutex_unlock (cond->__data.__lock);
- lll_futex_wait (&cond->__data.__nwaiters, nwaiters);
+ lll_futex_wait (&cond->__data.__nwaiters, nwaiters);
- lll_mutex_lock (cond->__data.__lock);
+ lll_mutex_lock (cond->__data.__lock);
- nwaiters = cond->__data.__nwaiters;
+ nwaiters = cond->__data.__nwaiters;
+ }
+ while (nwaiters >= (1 << COND_CLOCK_BITS));
}
return 0;
diff --git a/nptl/pthread_cond_init.c b/nptl/pthread_cond_init.c
index 03ac59dbd2..5e2e6704a9 100644
--- a/nptl/pthread_cond_init.c
+++ b/nptl/pthread_cond_init.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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.
@@ -26,8 +26,6 @@ __pthread_cond_init (cond, cond_attr)
pthread_cond_t *cond;
const pthread_condattr_t *cond_attr;
{
- /* Note that we don't need the PSHARED information from COND-ATTR.
- Conditional variables are always usable in multiple processes. */
struct pthread_condattr *icond_attr = (struct pthread_condattr *) cond_attr;
cond->__data.__lock = LLL_MUTEX_LOCK_INITIALIZER;
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index bf41e9fcc9..79729ced03 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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.
@@ -52,7 +52,7 @@ unsigned int __nptl_nthreads = 1;
#include "allocatestack.c"
/* Code to create the thread. */
-#include "createthread.c"
+#include <createthread.c>
struct pthread *
@@ -206,6 +206,15 @@ __free_tcb (struct pthread *pd)
running thread is gone. */
abort ();
+ /* Free TPP data. */
+ if (__builtin_expect (pd->tpp != NULL, 0))
+ {
+ struct priority_protection_data *tpp = pd->tpp;
+
+ pd->tpp = NULL;
+ free (tpp);
+ }
+
/* Queue the stack memory block for reuse and exit the process. The
kernel will signal via writing to the address returned by
QUEUE-STACK when the stack is available. */
@@ -229,6 +238,32 @@ start_thread (void *arg)
/* Initialize resolver state pointer. */
__resp = &pd->res;
+#ifdef __NR_set_robust_list
+# ifndef __ASSUME_SET_ROBUST_LIST
+ if (__set_robust_list_avail >= 0)
+# endif
+ {
+ INTERNAL_SYSCALL_DECL (err);
+ /* This call should never fail because the initial call in init.c
+ succeeded. */
+ INTERNAL_SYSCALL (set_robust_list, err, 2, &pd->robust_head,
+ sizeof (struct robust_list_head));
+ }
+#endif
+
+ /* If the parent was running cancellation handlers while creating
+ the thread the new thread inherited the signal mask. Reset the
+ cancellation signal mask. */
+ if (__builtin_expect (pd->parent_cancelhandling & CANCELING_BITMASK, 0))
+ {
+ INTERNAL_SYSCALL_DECL (err);
+ sigset_t mask;
+ __sigemptyset (&mask);
+ __sigaddset (&mask, SIGCANCEL);
+ (void) INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_UNBLOCK, &mask,
+ NULL, _NSIG / 8);
+ }
+
/* This is where the try/finally block should be created. For
compilers without that support we do use setjmp. */
struct pthread_unwind_buf unwind_buf;
@@ -310,10 +345,52 @@ start_thread (void *arg)
the breakpoint reports TD_THR_RUN state rather than TD_THR_ZOMBIE. */
atomic_bit_set (&pd->cancelhandling, EXITING_BIT);
+#ifndef __ASSUME_SET_ROBUST_LIST
+ /* If this thread has any robust mutexes locked, handle them now. */
+# if __WORDSIZE == 64
+ void *robust = pd->robust_head.list;
+# else
+ __pthread_slist_t *robust = pd->robust_list.__next;
+# endif
+ /* We let the kernel do the notification if it is able to do so.
+ If we have to do it here there for sure are no PI mutexes involved
+ since the kernel support for them is even more recent. */
+ if (__set_robust_list_avail < 0
+ && __builtin_expect (robust != (void *) &pd->robust_head, 0))
+ {
+ do
+ {
+ struct __pthread_mutex_s *this = (struct __pthread_mutex_s *)
+ ((char *) robust - offsetof (struct __pthread_mutex_s,
+ __list.__next));
+ robust = *((void **) robust);
+
+# ifdef __PTHREAD_MUTEX_HAVE_PREV
+ this->__list.__prev = NULL;
+# endif
+ this->__list.__next = NULL;
+
+ lll_robust_mutex_dead (this->__lock);
+ }
+ while (robust != (void *) &pd->robust_head);
+ }
+#endif
+
/* If the thread is detached free the TCB. */
if (IS_DETACHED (pd))
/* Free the TCB. */
__free_tcb (pd);
+ else if (__builtin_expect (pd->cancelhandling & SETXID_BITMASK, 0))
+ {
+ /* 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_futex_wait (&pd->setxid_futex, 0);
+ while (pd->cancelhandling & SETXID_BITMASK);
+
+ /* Reset the value so that the stack can be reused. */
+ pd->setxid_futex = 0;
+ }
/* We cannot call '_exit' here. '_exit' will terminate the process.
@@ -347,17 +424,15 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg)
void *arg;
{
STACK_VARIABLES;
- const struct pthread_attr *iattr;
- struct pthread *pd;
- int err;
- iattr = (struct pthread_attr *) attr;
+ const struct pthread_attr *iattr = (struct pthread_attr *) attr;
if (iattr == NULL)
/* Is this the best idea? On NUMA machines this could mean
accessing far-away memory. */
iattr = &default_attr;
- err = ALLOCATE_STACK (iattr, &pd);
+ struct pthread *pd = NULL;
+ int err = ALLOCATE_STACK (iattr, &pd);
if (__builtin_expect (err != 0, 0))
/* Something went wrong. Maybe a parameter of the attributes is
invalid or we could not allocate memory. */
@@ -401,19 +476,29 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg)
pd->schedpolicy = self->schedpolicy;
pd->schedparam = self->schedparam;
+ /* Copy the stack guard canary. */
+#ifdef THREAD_COPY_STACK_GUARD
+ THREAD_COPY_STACK_GUARD (pd);
+#endif
+
+ /* Copy the pointer guard value. */
+#ifdef THREAD_COPY_POINTER_GUARD
+ THREAD_COPY_POINTER_GUARD (pd);
+#endif
+
/* Determine scheduling parameters for the thread. */
if (attr != NULL
&& __builtin_expect ((iattr->flags & ATTR_FLAG_NOTINHERITSCHED) != 0, 0)
&& (iattr->flags & (ATTR_FLAG_SCHED_SET | ATTR_FLAG_POLICY_SET)) != 0)
{
- INTERNAL_SYSCALL_DECL (err);
+ INTERNAL_SYSCALL_DECL (scerr);
/* Use the scheduling parameters the user provided. */
if (iattr->flags & ATTR_FLAG_POLICY_SET)
pd->schedpolicy = iattr->schedpolicy;
else if ((pd->flags & ATTR_FLAG_POLICY_SET) == 0)
{
- pd->schedpolicy = INTERNAL_SYSCALL (sched_getscheduler, err, 1, 0);
+ pd->schedpolicy = INTERNAL_SYSCALL (sched_getscheduler, scerr, 1, 0);
pd->flags |= ATTR_FLAG_POLICY_SET;
}
@@ -422,14 +507,14 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg)
sizeof (struct sched_param));
else if ((pd->flags & ATTR_FLAG_SCHED_SET) == 0)
{
- INTERNAL_SYSCALL (sched_getparam, err, 2, 0, &pd->schedparam);
+ INTERNAL_SYSCALL (sched_getparam, scerr, 2, 0, &pd->schedparam);
pd->flags |= ATTR_FLAG_SCHED_SET;
}
/* Check for valid priorities. */
- int minprio = INTERNAL_SYSCALL (sched_get_priority_min, err, 1,
+ int minprio = INTERNAL_SYSCALL (sched_get_priority_min, scerr, 1,
iattr->schedpolicy);
- int maxprio = INTERNAL_SYSCALL (sched_get_priority_max, err, 1,
+ int maxprio = INTERNAL_SYSCALL (sched_get_priority_max, scerr, 1,
iattr->schedpolicy);
if (pd->schedparam.sched_priority < minprio
|| pd->schedparam.sched_priority > maxprio)
diff --git a/nptl/pthread_getattr_np.c b/nptl/pthread_getattr_np.c
index ba720af6cd..f6cd8899d8 100644
--- a/nptl/pthread_getattr_np.c
+++ b/nptl/pthread_getattr_np.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -83,51 +83,55 @@ pthread_getattr_np (thread_id, attr)
if (fp == NULL)
ret = errno;
/* We need the limit of the stack in any case. */
- else if (getrlimit (RLIMIT_STACK, &rl) != 0)
- ret = errno;
else
{
- /* We need no locking. */
- __fsetlocking (fp, FSETLOCKING_BYCALLER);
+ if (getrlimit (RLIMIT_STACK, &rl) != 0)
+ ret = errno;
+ else
+ {
+ /* We need no locking. */
+ __fsetlocking (fp, FSETLOCKING_BYCALLER);
- /* Until we found an entry (which should always be the case)
- mark the result as a failure. */
- ret = ENOENT;
+ /* Until we found an entry (which should always be the case)
+ mark the result as a failure. */
+ ret = ENOENT;
- char *line = NULL;
- size_t linelen = 0;
- uintptr_t last_to = 0;
+ char *line = NULL;
+ size_t linelen = 0;
+ uintptr_t last_to = 0;
- while (! feof_unlocked (fp))
- {
- if (__getdelim (&line, &linelen, '\n', fp) <= 0)
- break;
-
- uintptr_t from;
- uintptr_t to;
- if (sscanf (line, "%" SCNxPTR "-%" SCNxPTR, &from, &to) != 2)
- continue;
- if (from <= (uintptr_t) __libc_stack_end
- && (uintptr_t) __libc_stack_end < to)
+ while (! feof_unlocked (fp))
{
- /* Found the entry. Now we have the info we need. */
- iattr->stacksize = rl.rlim_cur;
- iattr->stackaddr = (void *) to;
-
- /* The limit might be too high. */
- if ((size_t) iattr->stacksize
- > (size_t) iattr->stackaddr - last_to)
- iattr->stacksize = (size_t) iattr->stackaddr - last_to;
-
- /* We succeed and no need to look further. */
- ret = 0;
- break;
+ if (__getdelim (&line, &linelen, '\n', fp) <= 0)
+ break;
+
+ uintptr_t from;
+ uintptr_t to;
+ if (sscanf (line, "%" SCNxPTR "-%" SCNxPTR, &from, &to) != 2)
+ continue;
+ if (from <= (uintptr_t) __libc_stack_end
+ && (uintptr_t) __libc_stack_end < to)
+ {
+ /* Found the entry. Now we have the info we need. */
+ iattr->stacksize = rl.rlim_cur;
+ iattr->stackaddr = (void *) to;
+
+ /* The limit might be too high. */
+ if ((size_t) iattr->stacksize
+ > (size_t) iattr->stackaddr - last_to)
+ iattr->stacksize = (size_t) iattr->stackaddr - last_to;
+
+ /* We succeed and no need to look further. */
+ ret = 0;
+ break;
+ }
+ last_to = to;
}
- last_to = to;
+
+ free (line);
}
fclose (fp);
- free (line);
}
}
@@ -164,8 +168,12 @@ pthread_getattr_np (thread_id, attr)
{
free (cpuset);
if (ret == ENOSYS)
- /* There is no such functionality. */
- ret = 0;
+ {
+ /* There is no such functionality. */
+ ret = 0;
+ iattr->cpuset = NULL;
+ iattr->cpusetsize = 0;
+ }
}
}
diff --git a/nptl/pthread_join.c b/nptl/pthread_join.c
index f94128dd96..c88d85b52f 100644
--- a/nptl/pthread_join.c
+++ b/nptl/pthread_join.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 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.
@@ -20,14 +20,18 @@
#include <errno.h>
#include <stdlib.h>
-#include "atomic.h"
+#include <atomic.h>
#include "pthreadP.h"
static void
cleanup (void *arg)
{
- *(void **) arg = NULL;
+ /* If we already changed the waiter ID, reset it. The call cannot
+ fail for any reason but the thread not having done that yet so
+ there is no reason for a loop. */
+ atomic_compare_and_exchange_bool_acq ((struct pthread **) arg, NULL,
+ THREAD_SELF);
}
@@ -36,7 +40,6 @@ pthread_join (threadid, thread_return)
pthread_t threadid;
void **thread_return;
{
- struct pthread *self;
struct pthread *pd = (struct pthread *) threadid;
/* Make sure the descriptor is valid. */
@@ -49,12 +52,23 @@ pthread_join (threadid, thread_return)
/* We cannot wait for the thread. */
return EINVAL;
- self = THREAD_SELF;
- if (pd == self
- || (self->joinid == pd
- && (pd->cancelhandling
- & (CANCELING_BITMASK | CANCELED_BITMASK | EXITING_BITMASK
- | TERMINATED_BITMASK)) == 0))
+ struct pthread *self = THREAD_SELF;
+ int result = 0;
+
+ /* During the wait we change to asynchronous cancellation. If we
+ are canceled the thread we are waiting for must be marked as
+ un-wait-ed for again. */
+ pthread_cleanup_push (cleanup, &pd->joinid);
+
+ /* Switch to asynchronous cancellation. */
+ int oldtype = CANCEL_ASYNC ();
+
+ if ((pd == self
+ || (self->joinid == pd
+ && (pd->cancelhandling
+ & (CANCELING_BITMASK | CANCELED_BITMASK | EXITING_BITMASK
+ | TERMINATED_BITMASK)) == 0))
+ && !CANCEL_ENABLED_AND_CANCELED (self->cancelhandling))
/* This is a deadlock situation. The threads are waiting for each
other to finish. Note that this is a "may" error. To be 100%
sure we catch this error we would have to lock the data
@@ -62,28 +76,17 @@ pthread_join (threadid, thread_return)
two threads are really caught in this situation they will
deadlock. It is the programmer's problem to figure this
out. */
- return EDEADLK;
-
+ result = EDEADLK;
/* Wait for the thread to finish. If it is already locked something
is wrong. There can only be one waiter. */
- if (__builtin_expect (atomic_compare_and_exchange_bool_acq (&pd->joinid,
- self,
- NULL), 0))
+ else if (__builtin_expect (atomic_compare_and_exchange_bool_acq (&pd->joinid,
+ self,
+ NULL), 0))
/* There is already somebody waiting for the thread. */
- return EINVAL;
-
-
- /* During the wait we change to asynchronous cancellation. If we
- are cancelled the thread we are waiting for must be marked as
- un-wait-ed for again. */
- pthread_cleanup_push (cleanup, &pd->joinid);
-
- /* Switch to asynchronous cancellation. */
- int oldtype = CANCEL_ASYNC ();
-
-
- /* Wait for the child. */
- lll_wait_tid (pd->tid);
+ result = EINVAL;
+ else
+ /* Wait for the child. */
+ lll_wait_tid (pd->tid);
/* Restore cancellation mode. */
@@ -93,16 +96,19 @@ pthread_join (threadid, thread_return)
pthread_cleanup_pop (0);
- /* We mark the thread as terminated and as joined. */
- pd->tid = -1;
+ if (__builtin_expect (result == 0, 1))
+ {
+ /* We mark the thread as terminated and as joined. */
+ pd->tid = -1;
- /* Store the return value if the caller is interested. */
- if (thread_return != NULL)
- *thread_return = pd->result;
+ /* Store the return value if the caller is interested. */
+ if (thread_return != NULL)
+ *thread_return = pd->result;
- /* Free the TCB. */
- __free_tcb (pd);
+ /* Free the TCB. */
+ __free_tcb (pd);
+ }
- return 0;
+ return result;
}
diff --git a/nptl/pthread_key_create.c b/nptl/pthread_key_create.c
index cf35bc8776..5fc8846243 100644
--- a/nptl/pthread_key_create.c
+++ b/nptl/pthread_key_create.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -19,45 +19,36 @@
#include <errno.h>
#include "pthreadP.h"
+#include <atomic.h>
-/* Internal mutex for __pthread_keys table handling. */
-lll_lock_t __pthread_keys_lock = LLL_LOCK_INITIALIZER;
-
int
__pthread_key_create (key, destr)
pthread_key_t *key;
void (*destr) (void *);
{
- int result = EAGAIN;
- size_t cnt;
-
- lll_lock (__pthread_keys_lock);
-
/* Find a slot in __pthread_kyes which is unused. */
- for (cnt = 0; cnt < PTHREAD_KEYS_MAX; ++cnt)
- if (KEY_UNUSED (__pthread_keys[cnt].seq)
- && KEY_USABLE (__pthread_keys[cnt].seq))
- {
- /* We found an unused slot. */
- ++__pthread_keys[cnt].seq;
-
- /* Remember the destructor. */
- __pthread_keys[cnt].destr = destr;
-
- /* Return the key to the caller. */
- *key = cnt;
-
- /* The call succeeded. */
- result = 0;
-
- /* We found a key and can stop now. */
- break;
- }
-
- lll_unlock (__pthread_keys_lock);
-
- return result;
+ for (size_t cnt = 0; cnt < PTHREAD_KEYS_MAX; ++cnt)
+ {
+ uintptr_t seq = __pthread_keys[cnt].seq;
+
+ if (KEY_UNUSED (seq) && KEY_USABLE (seq)
+ /* We found an unused slot. Try to allocate it. */
+ && ! atomic_compare_and_exchange_bool_acq (&__pthread_keys[cnt].seq,
+ seq + 1, seq))
+ {
+ /* Remember the destructor. */
+ __pthread_keys[cnt].destr = destr;
+
+ /* Return the key to the caller. */
+ *key = cnt;
+
+ /* The call succeeded. */
+ return 0;
+ }
+ }
+
+ return EAGAIN;
}
strong_alias (__pthread_key_create, pthread_key_create)
strong_alias (__pthread_key_create, __pthread_key_create_internal)
diff --git a/nptl/sysdeps/sh/jmpbuf-unwind.h b/nptl/pthread_mutex_consistent.c
index cf6d25f041..d4f287b755 100644
--- a/nptl/sysdeps/sh/jmpbuf-unwind.h
+++ b/nptl/pthread_mutex_consistent.c
@@ -1,6 +1,6 @@
-/* Copyright (C) 2003, 2004 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>, 2003.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2005.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -17,15 +17,20 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
+#include <errno.h>
+#include <pthreadP.h>
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-#define _JMPBUF_UNWINDS_ADJ(jmpbuf, address, adj) \
- ((uintptr_t) (address) - (adj) < (uintptr_t) (jmpbuf)[0].__regs[7] - (adj))
+int
+pthread_mutex_consistent_np (mutex)
+ pthread_mutex_t *mutex;
+{
+ /* Test whether this is a robust mutex with a dead owner. */
+ if ((mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP) == 0
+ || mutex->__data.__owner != PTHREAD_MUTEX_INCONSISTENT)
+ return EINVAL;
-/* We use the normal lobngjmp for unwinding. */
-#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
+ mutex->__data.__owner = THREAD_GETMEM (THREAD_SELF, tid);
+
+ return 0;
+}
diff --git a/nptl/pthread_mutex_destroy.c b/nptl/pthread_mutex_destroy.c
index 91ccfb0d29..e2c9f8a39f 100644
--- a/nptl/pthread_mutex_destroy.c
+++ b/nptl/pthread_mutex_destroy.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 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.
@@ -25,9 +25,13 @@ int
__pthread_mutex_destroy (mutex)
pthread_mutex_t *mutex;
{
- if (mutex->__data.__nusers != 0)
+ if ((mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP) == 0
+ && mutex->__data.__nusers != 0)
return EBUSY;
+ /* Set to an invalid value. */
+ mutex->__data.__kind = -1;
+
return 0;
}
strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy)
diff --git a/nptl/sysdeps/powerpc/jmpbuf-unwind.h b/nptl/pthread_mutex_getprioceiling.c
index 0b817160d3..1ce5eaebef 100644
--- a/nptl/sysdeps/powerpc/jmpbuf-unwind.h
+++ b/nptl/pthread_mutex_getprioceiling.c
@@ -1,6 +1,7 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Get current priority ceiling of pthread_mutex_t.
+ Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -17,15 +18,21 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
+#include <errno.h>
+#include <pthreadP.h>
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_GPR1] - (_adj))
+int
+pthread_mutex_getprioceiling (mutex, prioceiling)
+ const pthread_mutex_t *mutex;
+ int *prioceiling;
+{
+ if (__builtin_expect ((mutex->__data.__kind
+ & PTHREAD_MUTEX_PRIO_PROTECT_NP) == 0, 0))
+ return EINVAL;
-/* We use the normal lobngjmp for unwinding. */
-#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
+ *prioceiling = (mutex->__data.__lock & PTHREAD_MUTEX_PRIO_CEILING_MASK)
+ >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+
+ return 0;
+}
diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c
index 074941daf3..96f1fb00f8 100644
--- a/nptl/pthread_mutex_init.c
+++ b/nptl/pthread_mutex_init.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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.
@@ -18,10 +18,10 @@
02111-1307 USA. */
#include <assert.h>
+#include <errno.h>
#include <string.h>
#include "pthreadP.h"
-
static const struct pthread_mutexattr default_attr =
{
/* Default is a normal mutex, not shared between processes. */
@@ -29,6 +29,11 @@ static const struct pthread_mutexattr default_attr =
};
+#ifndef __ASSUME_FUTEX_LOCK_PI
+static int tpi_supported;
+#endif
+
+
int
__pthread_mutex_init (mutex, mutexattr)
pthread_mutex_t *mutex;
@@ -40,17 +45,87 @@ __pthread_mutex_init (mutex, mutexattr)
imutexattr = (const struct pthread_mutexattr *) mutexattr ?: &default_attr;
+ /* Sanity checks. */
+ switch (__builtin_expect (imutexattr->mutexkind
+ & PTHREAD_MUTEXATTR_PROTOCOL_MASK,
+ PTHREAD_PRIO_NONE
+ << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT))
+ {
+ case PTHREAD_PRIO_NONE << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT:
+ break;
+
+ case PTHREAD_PRIO_INHERIT << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT:
+#ifndef __ASSUME_FUTEX_LOCK_PI
+ if (__builtin_expect (tpi_supported == 0, 0))
+ {
+ int lock = 0;
+ INTERNAL_SYSCALL_DECL (err);
+ int ret = INTERNAL_SYSCALL (futex, err, 4, &lock, FUTEX_UNLOCK_PI,
+ 0, 0);
+ assert (INTERNAL_SYSCALL_ERROR_P (ret, err));
+ tpi_supported = INTERNAL_SYSCALL_ERRNO (ret, err) == ENOSYS ? -1 : 1;
+ }
+ if (__builtin_expect (tpi_supported < 0, 0))
+ return ENOTSUP;
+#endif
+ break;
+
+ default:
+ /* XXX: For now we don't support robust priority protected mutexes. */
+ if (imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_ROBUST)
+ return ENOTSUP;
+ break;
+ }
+
/* Clear the whole variable. */
memset (mutex, '\0', __SIZEOF_PTHREAD_MUTEX_T);
/* Copy the values from the attribute. */
- mutex->__data.__kind = imutexattr->mutexkind & ~0x80000000;
+ mutex->__data.__kind = imutexattr->mutexkind & ~PTHREAD_MUTEXATTR_FLAG_BITS;
+
+ if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_ROBUST) != 0)
+ {
+#ifndef __ASSUME_SET_ROBUST_LIST
+ if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_PSHARED) != 0
+ && __set_robust_list_avail < 0)
+ return ENOTSUP;
+#endif
+
+ mutex->__data.__kind |= PTHREAD_MUTEX_ROBUST_NORMAL_NP;
+ }
+
+ switch (imutexattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK)
+ {
+ case PTHREAD_PRIO_INHERIT << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT:
+ mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_INHERIT_NP;
+ break;
+
+ case PTHREAD_PRIO_PROTECT << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT:
+ mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_PROTECT_NP;
+
+ int ceiling = (imutexattr->mutexkind
+ & PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
+ >> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT;
+ if (! ceiling)
+ {
+ if (__sched_fifo_min_prio == -1)
+ __init_sched_fifo_prio ();
+ if (ceiling < __sched_fifo_min_prio)
+ ceiling = __sched_fifo_min_prio;
+ }
+ mutex->__data.__lock = ceiling << PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+ break;
+
+ default:
+ break;
+ }
/* Default values: mutex not used yet. */
// mutex->__count = 0; already done by memset
// mutex->__owner = 0; already done by memset
// mutex->__nusers = 0; already done by memset
// mutex->__spins = 0; already done by memset
+ // mutex->__next = NULL; already done by memset
return 0;
}
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
index ee39f20820..1c3ee4fe25 100644
--- a/nptl/pthread_mutex_lock.c
+++ b/nptl/pthread_mutex_lock.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -19,6 +19,9 @@
#include <assert.h>
#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <not-cancel.h>
#include "pthreadP.h"
#include <lowlevellock.h>
@@ -26,6 +29,7 @@
#ifndef LLL_MUTEX_LOCK
# define LLL_MUTEX_LOCK(mutex) lll_mutex_lock (mutex)
# define LLL_MUTEX_TRYLOCK(mutex) lll_mutex_trylock (mutex)
+# define LLL_ROBUST_MUTEX_LOCK(mutex, id) lll_robust_mutex_lock (mutex, id)
#endif
@@ -35,8 +39,10 @@ __pthread_mutex_lock (mutex)
{
assert (sizeof (mutex->__size) >= sizeof (mutex->__data));
+ int oldval;
pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
+ int retval = 0;
switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP))
{
/* Recursive mutex. */
@@ -57,23 +63,23 @@ __pthread_mutex_lock (mutex)
/* We have to get the mutex. */
LLL_MUTEX_LOCK (mutex->__data.__lock);
+ assert (mutex->__data.__owner == 0);
mutex->__data.__count = 1;
break;
/* Error checking mutex. */
case PTHREAD_MUTEX_ERRORCHECK_NP:
/* Check whether we already hold the mutex. */
- if (mutex->__data.__owner == id)
+ if (__builtin_expect (mutex->__data.__owner == id, 0))
return EDEADLK;
/* FALLTHROUGH */
- default:
- /* Correct code cannot set any other type. */
case PTHREAD_MUTEX_TIMED_NP:
simple:
/* Normal mutex. */
LLL_MUTEX_LOCK (mutex->__data.__lock);
+ assert (mutex->__data.__owner == 0);
break;
case PTHREAD_MUTEX_ADAPTIVE_NP:
@@ -101,17 +107,332 @@ __pthread_mutex_lock (mutex)
mutex->__data.__spins += (cnt - mutex->__data.__spins) / 8;
}
+ assert (mutex->__data.__owner == 0);
break;
+
+ case PTHREAD_MUTEX_ROBUST_RECURSIVE_NP:
+ case PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP:
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ &mutex->__data.__list.__next);
+
+ oldval = mutex->__data.__lock;
+ do
+ {
+ again:
+ if ((oldval & FUTEX_OWNER_DIED) != 0)
+ {
+ /* The previous owner died. Try locking the mutex. */
+ int newval = id;
+#ifdef NO_INCR
+ newval |= FUTEX_WAITERS;
+#else
+ newval |= (oldval & FUTEX_WAITERS);
+#endif
+
+ newval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ newval, oldval);
+
+ if (newval != oldval)
+ {
+ oldval = newval;
+ goto again;
+ }
+
+ /* We got the mutex. */
+ mutex->__data.__count = 1;
+ /* But it is inconsistent unless marked otherwise. */
+ mutex->__data.__owner = PTHREAD_MUTEX_INCONSISTENT;
+
+ ENQUEUE_MUTEX (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Note that we deliberately exit here. If we fall
+ through to the end of the function __nusers would be
+ incremented which is not correct because the old
+ owner has to be discounted. If we are not supposed
+ to increment __nusers we actually have to decrement
+ it here. */
+#ifdef NO_INCR
+ --mutex->__data.__nusers;
+#endif
+
+ return EOWNERDEAD;
+ }
+
+ /* Check whether we already hold the mutex. */
+ if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0))
+ {
+ if (mutex->__data.__kind
+ == PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ NULL);
+ return EDEADLK;
+ }
+
+ if (mutex->__data.__kind
+ == PTHREAD_MUTEX_ROBUST_RECURSIVE_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ NULL);
+
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ oldval = LLL_ROBUST_MUTEX_LOCK (mutex->__data.__lock, id);
+
+ if (__builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
+ {
+ /* This mutex is now not recoverable. */
+ mutex->__data.__count = 0;
+ lll_mutex_unlock (mutex->__data.__lock);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return ENOTRECOVERABLE;
+ }
+ }
+ while ((oldval & FUTEX_OWNER_DIED) != 0);
+
+ mutex->__data.__count = 1;
+ ENQUEUE_MUTEX (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ break;
+
+ case PTHREAD_MUTEX_PI_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PI_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ADAPTIVE_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP:
+ {
+ int kind = mutex->__data.__kind & PTHREAD_MUTEX_KIND_MASK_NP;
+ int robust = mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP;
+
+ if (robust)
+ /* Note: robust PI futexes are signaled by setting bit 0. */
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ (void *) (((uintptr_t) &mutex->__data.__list.__next)
+ | 1));
+
+ oldval = mutex->__data.__lock;
+
+ /* Check whether we already hold the mutex. */
+ if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0))
+ {
+ if (kind == PTHREAD_MUTEX_ERRORCHECK_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return EDEADLK;
+ }
+
+ if (kind == PTHREAD_MUTEX_RECURSIVE_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ int newval = id;
+#ifdef NO_INCR
+ newval |= FUTEX_WAITERS;
+#endif
+ oldval = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ newval, 0);
+
+ if (oldval != 0)
+ {
+ /* The mutex is locked. The kernel will now take care of
+ everything. */
+ INTERNAL_SYSCALL_DECL (__err);
+ int e = INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
+ FUTEX_LOCK_PI, 1, 0);
+
+ if (INTERNAL_SYSCALL_ERROR_P (e, __err)
+ && (INTERNAL_SYSCALL_ERRNO (e, __err) == ESRCH
+ || INTERNAL_SYSCALL_ERRNO (e, __err) == EDEADLK))
+ {
+ assert (INTERNAL_SYSCALL_ERRNO (e, __err) != EDEADLK
+ || (kind != PTHREAD_MUTEX_ERRORCHECK_NP
+ && kind != PTHREAD_MUTEX_RECURSIVE_NP));
+ /* ESRCH can happen only for non-robust PI mutexes where
+ the owner of the lock died. */
+ assert (INTERNAL_SYSCALL_ERRNO (e, __err) != ESRCH || !robust);
+
+ /* Delay the thread indefinitely. */
+ while (1)
+ pause_not_cancel ();
+ }
+
+ oldval = mutex->__data.__lock;
+
+ assert (robust || (oldval & FUTEX_OWNER_DIED) == 0);
+ }
+
+ if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
+ {
+ atomic_and (&mutex->__data.__lock, ~FUTEX_OWNER_DIED);
+
+ /* We got the mutex. */
+ mutex->__data.__count = 1;
+ /* But it is inconsistent unless marked otherwise. */
+ mutex->__data.__owner = PTHREAD_MUTEX_INCONSISTENT;
+
+ ENQUEUE_MUTEX_PI (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Note that we deliberately exit here. If we fall
+ through to the end of the function __nusers would be
+ incremented which is not correct because the old owner
+ has to be discounted. If we are not supposed to
+ increment __nusers we actually have to decrement it here. */
+#ifdef NO_INCR
+ --mutex->__data.__nusers;
+#endif
+
+ return EOWNERDEAD;
+ }
+
+ if (robust
+ && __builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
+ {
+ /* This mutex is now not recoverable. */
+ mutex->__data.__count = 0;
+
+ INTERNAL_SYSCALL_DECL (__err);
+ INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
+ FUTEX_UNLOCK_PI, 0, 0);
+
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return ENOTRECOVERABLE;
+ }
+
+ mutex->__data.__count = 1;
+ if (robust)
+ {
+ ENQUEUE_MUTEX_PI (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ }
+ }
+ break;
+
+ case PTHREAD_MUTEX_PP_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PP_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PP_NORMAL_NP:
+ case PTHREAD_MUTEX_PP_ADAPTIVE_NP:
+ {
+ int kind = mutex->__data.__kind & PTHREAD_MUTEX_KIND_MASK_NP;
+
+ oldval = mutex->__data.__lock;
+
+ /* Check whether we already hold the mutex. */
+ if (mutex->__data.__owner == id)
+ {
+ if (kind == PTHREAD_MUTEX_ERRORCHECK_NP)
+ return EDEADLK;
+
+ if (kind == PTHREAD_MUTEX_RECURSIVE_NP)
+ {
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ int oldprio = -1, ceilval;
+ do
+ {
+ int ceiling = (oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK)
+ >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+
+ if (__pthread_current_priority () > ceiling)
+ {
+ if (oldprio != -1)
+ __pthread_tpp_change_priority (oldprio, -1);
+ return EINVAL;
+ }
+
+ retval = __pthread_tpp_change_priority (oldprio, ceiling);
+ if (retval)
+ return retval;
+
+ ceilval = ceiling << PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+ oldprio = ceiling;
+
+ oldval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+#ifdef NO_INCR
+ ceilval | 2,
+#else
+ ceilval | 1,
+#endif
+ ceilval);
+
+ if (oldval == ceilval)
+ break;
+
+ do
+ {
+ oldval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 2,
+ ceilval | 1);
+
+ if ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval)
+ break;
+
+ if (oldval != ceilval)
+ lll_futex_wait (&mutex->__data.__lock, ceilval | 2);
+ }
+ while (atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 2, ceilval)
+ != ceilval);
+ }
+ while ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval);
+
+ assert (mutex->__data.__owner == 0);
+ mutex->__data.__count = 1;
+ }
+ break;
+
+ default:
+ /* Correct code cannot set any other type. */
+ return EINVAL;
}
/* Record the ownership. */
- assert (mutex->__data.__owner == 0);
mutex->__data.__owner = id;
#ifndef NO_INCR
++mutex->__data.__nusers;
#endif
- return 0;
+ return retval;
}
#ifndef __pthread_mutex_lock
strong_alias (__pthread_mutex_lock, pthread_mutex_lock)
diff --git a/nptl/pthread_mutex_setprioceiling.c b/nptl/pthread_mutex_setprioceiling.c
new file mode 100644
index 0000000000..cd13d1c14c
--- /dev/null
+++ b/nptl/pthread_mutex_setprioceiling.c
@@ -0,0 +1,116 @@
+/* Set current priority ceiling of pthread_mutex_t.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdbool.h>
+#include <errno.h>
+#include <pthreadP.h>
+
+
+int
+pthread_mutex_setprioceiling (mutex, prioceiling, old_ceiling)
+ pthread_mutex_t *mutex;
+ int prioceiling;
+ int *old_ceiling;
+{
+ /* The low bits of __kind aren't ever changed after pthread_mutex_init,
+ so we don't need a lock yet. */
+ if ((mutex->__data.__kind & PTHREAD_MUTEX_PRIO_PROTECT_NP) == 0)
+ return EINVAL;
+
+ if (__sched_fifo_min_prio == -1)
+ __init_sched_fifo_prio ();
+
+ if (__builtin_expect (prioceiling < __sched_fifo_min_prio, 0)
+ || __builtin_expect (prioceiling > __sched_fifo_max_prio, 0)
+ || __builtin_expect ((prioceiling
+ & (PTHREAD_MUTEXATTR_PRIO_CEILING_MASK
+ >> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT))
+ != prioceiling, 0))
+ return EINVAL;
+
+ /* Check whether we already hold the mutex. */
+ bool locked = false;
+ if (mutex->__data.__owner == THREAD_GETMEM (THREAD_SELF, tid))
+ {
+ if (mutex->__data.__kind == PTHREAD_MUTEX_PP_ERRORCHECK_NP)
+ return EDEADLK;
+
+ if (mutex->__data.__kind == PTHREAD_MUTEX_PP_RECURSIVE_NP)
+ locked = true;
+ }
+
+ int oldval = mutex->__data.__lock;
+ if (! locked)
+ do
+ {
+ /* Need to lock the mutex, but without obeying the priority
+ protect protocol. */
+ int ceilval = (oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK);
+
+ oldval = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 1, ceilval);
+ if (oldval == ceilval)
+ break;
+
+ do
+ {
+ oldval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 2,
+ ceilval | 1);
+
+ if ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval)
+ break;
+
+ if (oldval != ceilval)
+ lll_futex_wait (&mutex->__data.__lock, ceilval | 2);
+ }
+ while (atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 2, ceilval)
+ != ceilval);
+
+ if ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval)
+ continue;
+ }
+ while (0);
+
+ int oldprio = (oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK)
+ >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+ if (locked)
+ {
+ int ret = __pthread_tpp_change_priority (oldprio, prioceiling);
+ if (ret)
+ return ret;
+ }
+
+ if (old_ceiling != NULL)
+ *old_ceiling = oldprio;
+
+ int newlock = 0;
+ if (locked)
+ newlock = (mutex->__data.__lock & ~PTHREAD_MUTEX_PRIO_CEILING_MASK);
+ mutex->__data.__lock = newlock
+ | (prioceiling << PTHREAD_MUTEX_PRIO_CEILING_SHIFT);
+ atomic_full_barrier ();
+
+ 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 1cd2c7e606..8fd681c6ef 100644
--- a/nptl/pthread_mutex_timedlock.c
+++ b/nptl/pthread_mutex_timedlock.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -17,9 +17,12 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <assert.h>
#include <errno.h>
+#include <time.h>
#include "pthreadP.h"
#include <lowlevellock.h>
+#include <not-cancel.h>
int
@@ -27,13 +30,14 @@ pthread_mutex_timedlock (mutex, abstime)
pthread_mutex_t *mutex;
const struct timespec *abstime;
{
+ int oldval;
pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
int result = 0;
/* We must not check ABSTIME here. If the thread does not block
abstime must not be checked for a valid value. */
- switch (mutex->__data.__kind)
+ switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP))
{
/* Recursive mutex. */
case PTHREAD_MUTEX_RECURSIVE_NP:
@@ -49,29 +53,25 @@ pthread_mutex_timedlock (mutex, abstime)
goto out;
}
- else
- {
- /* We have to get the mutex. */
- result = lll_mutex_timedlock (mutex->__data.__lock, abstime);
- if (result != 0)
- goto out;
+ /* We have to get the mutex. */
+ result = lll_mutex_timedlock (mutex->__data.__lock, abstime);
- /* Only locked once so far. */
- mutex->__data.__count = 1;
- }
+ if (result != 0)
+ goto out;
+
+ /* Only locked once so far. */
+ mutex->__data.__count = 1;
break;
/* Error checking mutex. */
case PTHREAD_MUTEX_ERRORCHECK_NP:
/* Check whether we already hold the mutex. */
- if (mutex->__data.__owner == id)
+ if (__builtin_expect (mutex->__data.__owner == id, 0))
return EDEADLK;
/* FALLTHROUGH */
- default:
- /* Correct code cannot set any other type. */
case PTHREAD_MUTEX_TIMED_NP:
simple:
/* Normal mutex. */
@@ -104,6 +104,360 @@ pthread_mutex_timedlock (mutex, abstime)
mutex->__data.__spins += (cnt - mutex->__data.__spins) / 8;
}
break;
+
+ case PTHREAD_MUTEX_ROBUST_RECURSIVE_NP:
+ case PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP:
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ &mutex->__data.__list.__next);
+
+ oldval = mutex->__data.__lock;
+ do
+ {
+ again:
+ if ((oldval & FUTEX_OWNER_DIED) != 0)
+ {
+ /* The previous owner died. Try locking the mutex. */
+ int newval = id | (oldval & FUTEX_WAITERS);
+
+ newval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ newval, oldval);
+ if (newval != oldval)
+ {
+ oldval = newval;
+ goto again;
+ }
+
+ /* We got the mutex. */
+ mutex->__data.__count = 1;
+ /* But it is inconsistent unless marked otherwise. */
+ mutex->__data.__owner = PTHREAD_MUTEX_INCONSISTENT;
+
+ ENQUEUE_MUTEX (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Note that we deliberately exit here. If we fall
+ through to the end of the function __nusers would be
+ incremented which is not correct because the old
+ owner has to be discounted. */
+ return EOWNERDEAD;
+ }
+
+ /* Check whether we already hold the mutex. */
+ if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0))
+ {
+ if (mutex->__data.__kind
+ == PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ NULL);
+ return EDEADLK;
+ }
+
+ if (mutex->__data.__kind
+ == PTHREAD_MUTEX_ROBUST_RECURSIVE_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ NULL);
+
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ result = lll_robust_mutex_timedlock (mutex->__data.__lock, abstime,
+ id);
+
+ if (__builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
+ {
+ /* This mutex is now not recoverable. */
+ mutex->__data.__count = 0;
+ lll_mutex_unlock (mutex->__data.__lock);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return ENOTRECOVERABLE;
+ }
+
+ if (result == ETIMEDOUT || result == EINVAL)
+ goto out;
+
+ oldval = result;
+ }
+ while ((oldval & FUTEX_OWNER_DIED) != 0);
+
+ mutex->__data.__count = 1;
+ ENQUEUE_MUTEX (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ break;
+
+ case PTHREAD_MUTEX_PI_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PI_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ADAPTIVE_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP:
+ {
+ int kind = mutex->__data.__kind & PTHREAD_MUTEX_KIND_MASK_NP;
+ int robust = mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP;
+
+ if (robust)
+ /* Note: robust PI futexes are signaled by setting bit 0. */
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ (void *) (((uintptr_t) &mutex->__data.__list.__next)
+ | 1));
+
+ oldval = mutex->__data.__lock;
+
+ /* Check whether we already hold the mutex. */
+ if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0))
+ {
+ if (kind == PTHREAD_MUTEX_ERRORCHECK_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return EDEADLK;
+ }
+
+ if (kind == PTHREAD_MUTEX_RECURSIVE_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ oldval = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ id, 0);
+
+ if (oldval != 0)
+ {
+ /* The mutex is locked. The kernel will now take care of
+ everything. The timeout value must be a relative value.
+ Convert it. */
+ INTERNAL_SYSCALL_DECL (__err);
+
+ int e = INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
+ FUTEX_LOCK_PI, 1, abstime);
+ if (INTERNAL_SYSCALL_ERROR_P (e, __err))
+ {
+ if (INTERNAL_SYSCALL_ERRNO (e, __err) == ETIMEDOUT)
+ return ETIMEDOUT;
+
+ if (INTERNAL_SYSCALL_ERRNO (e, __err) == ESRCH
+ || INTERNAL_SYSCALL_ERRNO (e, __err) == EDEADLK)
+ {
+ assert (INTERNAL_SYSCALL_ERRNO (e, __err) != EDEADLK
+ || (kind != PTHREAD_MUTEX_ERRORCHECK_NP
+ && kind != PTHREAD_MUTEX_RECURSIVE_NP));
+ /* ESRCH can happen only for non-robust PI mutexes where
+ the owner of the lock died. */
+ assert (INTERNAL_SYSCALL_ERRNO (e, __err) != ESRCH
+ || !robust);
+
+ /* Delay the thread until the timeout is reached.
+ Then return ETIMEDOUT. */
+ struct timespec reltime;
+ struct timespec now;
+
+ INTERNAL_SYSCALL (clock_gettime, __err, 2, CLOCK_REALTIME,
+ &now);
+ reltime.tv_sec = abstime->tv_sec - now.tv_sec;
+ reltime.tv_nsec = abstime->tv_nsec - now.tv_nsec;
+ if (reltime.tv_nsec < 0)
+ {
+ reltime.tv_nsec += 1000000000;
+ --reltime.tv_sec;
+ }
+ if (reltime.tv_sec >= 0)
+ while (nanosleep_not_cancel (&reltime, &reltime) != 0)
+ continue;
+
+ return ETIMEDOUT;
+ }
+
+ return INTERNAL_SYSCALL_ERRNO (e, __err);
+ }
+
+ oldval = mutex->__data.__lock;
+
+ assert (robust || (oldval & FUTEX_OWNER_DIED) == 0);
+ }
+
+ if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
+ {
+ atomic_and (&mutex->__data.__lock, ~FUTEX_OWNER_DIED);
+
+ /* We got the mutex. */
+ mutex->__data.__count = 1;
+ /* But it is inconsistent unless marked otherwise. */
+ mutex->__data.__owner = PTHREAD_MUTEX_INCONSISTENT;
+
+ ENQUEUE_MUTEX_PI (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Note that we deliberately exit here. If we fall
+ through to the end of the function __nusers would be
+ incremented which is not correct because the old owner
+ has to be discounted. */
+ return EOWNERDEAD;
+ }
+
+ if (robust
+ && __builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
+ {
+ /* This mutex is now not recoverable. */
+ mutex->__data.__count = 0;
+
+ INTERNAL_SYSCALL_DECL (__err);
+ INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
+ FUTEX_UNLOCK_PI, 0, 0);
+
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return ENOTRECOVERABLE;
+ }
+
+ mutex->__data.__count = 1;
+ if (robust)
+ {
+ ENQUEUE_MUTEX_PI (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ }
+ }
+ break;
+
+ case PTHREAD_MUTEX_PP_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PP_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PP_NORMAL_NP:
+ case PTHREAD_MUTEX_PP_ADAPTIVE_NP:
+ {
+ int kind = mutex->__data.__kind & PTHREAD_MUTEX_KIND_MASK_NP;
+
+ oldval = mutex->__data.__lock;
+
+ /* Check whether we already hold the mutex. */
+ if (mutex->__data.__owner == id)
+ {
+ if (kind == PTHREAD_MUTEX_ERRORCHECK_NP)
+ return EDEADLK;
+
+ if (kind == PTHREAD_MUTEX_RECURSIVE_NP)
+ {
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ int oldprio = -1, ceilval;
+ do
+ {
+ int ceiling = (oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK)
+ >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+
+ if (__pthread_current_priority () > ceiling)
+ {
+ result = EINVAL;
+ failpp:
+ if (oldprio != -1)
+ __pthread_tpp_change_priority (oldprio, -1);
+ return result;
+ }
+
+ result = __pthread_tpp_change_priority (oldprio, ceiling);
+ if (result)
+ return result;
+
+ ceilval = ceiling << PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+ oldprio = ceiling;
+
+ oldval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 1, ceilval);
+
+ if (oldval == ceilval)
+ break;
+
+ do
+ {
+ oldval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 2,
+ ceilval | 1);
+
+ if ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval)
+ break;
+
+ if (oldval != ceilval)
+ {
+ /* Reject invalid timeouts. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ {
+ result = EINVAL;
+ goto failpp;
+ }
+
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ {
+ result = ETIMEDOUT;
+ goto failpp;
+ }
+
+ lll_futex_timed_wait (&mutex->__data.__lock,
+ ceilval | 2, &rt);
+ }
+ }
+ while (atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 2, ceilval)
+ != ceilval);
+ }
+ while ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval);
+
+ assert (mutex->__data.__owner == 0);
+ mutex->__data.__count = 1;
+ }
+ break;
+
+ default:
+ /* Correct code cannot set any other type. */
+ return EINVAL;
}
if (result == 0)
diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c
index 7008af3d97..66aca8e4b2 100644
--- a/nptl/pthread_mutex_trylock.c
+++ b/nptl/pthread_mutex_trylock.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -17,7 +17,9 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <assert.h>
#include <errno.h>
+#include <stdlib.h>
#include "pthreadP.h"
#include <lowlevellock.h>
@@ -26,13 +28,13 @@ int
__pthread_mutex_trylock (mutex)
pthread_mutex_t *mutex;
{
- pid_t id;
+ int oldval;
+ pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP))
{
/* Recursive mutex. */
case PTHREAD_MUTEX_RECURSIVE_NP:
- id = THREAD_GETMEM (THREAD_SELF, tid);
/* Check whether we already hold the mutex. */
if (mutex->__data.__owner == id)
{
@@ -56,20 +58,323 @@ __pthread_mutex_trylock (mutex)
break;
case PTHREAD_MUTEX_ERRORCHECK_NP:
- /* Error checking mutex. We do not check for deadlocks. */
- default:
- /* Correct code cannot set any other type. */
+ /* Check whether we already hold the mutex. */
+ if (__builtin_expect (mutex->__data.__owner == id, 0))
+ return EDEADLK;
+
+ /* FALLTHROUGH */
+
case PTHREAD_MUTEX_TIMED_NP:
case PTHREAD_MUTEX_ADAPTIVE_NP:
/* Normal mutex. */
- if (lll_mutex_trylock (mutex->__data.__lock) == 0)
+ if (lll_mutex_trylock (mutex->__data.__lock) != 0)
+ break;
+
+ /* Record the ownership. */
+ mutex->__data.__owner = id;
+ ++mutex->__data.__nusers;
+
+ return 0;
+
+
+ case PTHREAD_MUTEX_ROBUST_RECURSIVE_NP:
+ case PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP:
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ &mutex->__data.__list.__next);
+
+ oldval = mutex->__data.__lock;
+ do
{
- /* Record the ownership. */
- mutex->__data.__owner = THREAD_GETMEM (THREAD_SELF, tid);
- ++mutex->__data.__nusers;
+ again:
+ if ((oldval & FUTEX_OWNER_DIED) != 0)
+ {
+ /* The previous owner died. Try locking the mutex. */
+ int newval = id | (oldval & FUTEX_WAITERS);
- return 0;
+ newval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ newval, oldval);
+
+ if (newval != oldval)
+ {
+ oldval = newval;
+ goto again;
+ }
+
+ /* We got the mutex. */
+ mutex->__data.__count = 1;
+ /* But it is inconsistent unless marked otherwise. */
+ mutex->__data.__owner = PTHREAD_MUTEX_INCONSISTENT;
+
+ ENQUEUE_MUTEX (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Note that we deliberately exist here. If we fall
+ through to the end of the function __nusers would be
+ incremented which is not correct because the old
+ owner has to be discounted. */
+ return EOWNERDEAD;
+ }
+
+ /* Check whether we already hold the mutex. */
+ if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0))
+ {
+ if (mutex->__data.__kind
+ == PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ NULL);
+ return EDEADLK;
+ }
+
+ if (mutex->__data.__kind
+ == PTHREAD_MUTEX_ROBUST_RECURSIVE_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ NULL);
+
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ oldval = lll_robust_mutex_trylock (mutex->__data.__lock, id);
+ if (oldval != 0 && (oldval & FUTEX_OWNER_DIED) == 0)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ return EBUSY;
+ }
+
+ if (__builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
+ {
+ /* This mutex is now not recoverable. */
+ mutex->__data.__count = 0;
+ if (oldval == id)
+ lll_mutex_unlock (mutex->__data.__lock);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return ENOTRECOVERABLE;
+ }
}
+ while ((oldval & FUTEX_OWNER_DIED) != 0);
+
+ ENQUEUE_MUTEX (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ mutex->__data.__owner = id;
+ ++mutex->__data.__nusers;
+ mutex->__data.__count = 1;
+
+ return 0;
+
+ case PTHREAD_MUTEX_PI_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PI_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ADAPTIVE_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP:
+ {
+ int kind = mutex->__data.__kind & PTHREAD_MUTEX_KIND_MASK_NP;
+ int robust = mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP;
+
+ if (robust)
+ /* Note: robust PI futexes are signaled by setting bit 0. */
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ (void *) (((uintptr_t) &mutex->__data.__list.__next)
+ | 1));
+
+ oldval = mutex->__data.__lock;
+
+ /* Check whether we already hold the mutex. */
+ if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0))
+ {
+ if (kind == PTHREAD_MUTEX_ERRORCHECK_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return EDEADLK;
+ }
+
+ if (kind == PTHREAD_MUTEX_RECURSIVE_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ oldval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ id, 0);
+
+ if (oldval != 0)
+ {
+ if ((oldval & FUTEX_OWNER_DIED) == 0)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ return EBUSY;
+ }
+
+ assert (robust);
+
+ /* The mutex owner died. The kernel will now take care of
+ everything. */
+ INTERNAL_SYSCALL_DECL (__err);
+ int e = INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
+ FUTEX_TRYLOCK_PI, 0, 0);
+
+ if (INTERNAL_SYSCALL_ERROR_P (e, __err)
+ && INTERNAL_SYSCALL_ERRNO (e, __err) == EWOULDBLOCK)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ return EBUSY;
+ }
+
+ oldval = mutex->__data.__lock;
+ }
+
+ if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
+ {
+ atomic_and (&mutex->__data.__lock, ~FUTEX_OWNER_DIED);
+
+ /* We got the mutex. */
+ mutex->__data.__count = 1;
+ /* But it is inconsistent unless marked otherwise. */
+ mutex->__data.__owner = PTHREAD_MUTEX_INCONSISTENT;
+
+ ENQUEUE_MUTEX (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Note that we deliberately exit here. If we fall
+ through to the end of the function __nusers would be
+ incremented which is not correct because the old owner
+ has to be discounted. */
+ return EOWNERDEAD;
+ }
+
+ if (robust
+ && __builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
+ {
+ /* This mutex is now not recoverable. */
+ mutex->__data.__count = 0;
+
+ INTERNAL_SYSCALL_DECL (__err);
+ INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
+ FUTEX_UNLOCK_PI, 0, 0);
+
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return ENOTRECOVERABLE;
+ }
+
+ if (robust)
+ {
+ ENQUEUE_MUTEX_PI (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ }
+
+ mutex->__data.__owner = id;
+ ++mutex->__data.__nusers;
+ mutex->__data.__count = 1;
+
+ return 0;
+ }
+
+ case PTHREAD_MUTEX_PP_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PP_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PP_NORMAL_NP:
+ case PTHREAD_MUTEX_PP_ADAPTIVE_NP:
+ {
+ int kind = mutex->__data.__kind & PTHREAD_MUTEX_KIND_MASK_NP;
+
+ oldval = mutex->__data.__lock;
+
+ /* Check whether we already hold the mutex. */
+ if (mutex->__data.__owner == id)
+ {
+ if (kind == PTHREAD_MUTEX_ERRORCHECK_NP)
+ return EDEADLK;
+
+ if (kind == PTHREAD_MUTEX_RECURSIVE_NP)
+ {
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ int oldprio = -1, ceilval;
+ do
+ {
+ int ceiling = (oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK)
+ >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+
+ if (__pthread_current_priority () > ceiling)
+ {
+ if (oldprio != -1)
+ __pthread_tpp_change_priority (oldprio, -1);
+ return EINVAL;
+ }
+
+ int retval = __pthread_tpp_change_priority (oldprio, ceiling);
+ if (retval)
+ return retval;
+
+ ceilval = ceiling << PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+ oldprio = ceiling;
+
+ oldval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 1, ceilval);
+
+ if (oldval == ceilval)
+ break;
+ }
+ while ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval);
+
+ if (oldval != ceilval)
+ {
+ __pthread_tpp_change_priority (oldprio, -1);
+ break;
+ }
+
+ assert (mutex->__data.__owner == 0);
+ /* Record the ownership. */
+ mutex->__data.__owner = id;
+ ++mutex->__data.__nusers;
+ mutex->__data.__count = 1;
+
+ return 0;
+ }
+ break;
+
+ default:
+ /* Correct code cannot set any other type. */
+ return EINVAL;
}
return EBUSY;
diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c
index 32bc2a4bc1..33919d60af 100644
--- a/nptl/pthread_mutex_unlock.c
+++ b/nptl/pthread_mutex_unlock.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 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.
@@ -18,6 +18,7 @@
02111-1307 USA. */
#include <errno.h>
+#include <stdlib.h>
#include "pthreadP.h"
#include <lowlevellock.h>
@@ -28,6 +29,8 @@ __pthread_mutex_unlock_usercnt (mutex, decr)
pthread_mutex_t *mutex;
int decr;
{
+ int newowner = 0;
+
switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP))
{
case PTHREAD_MUTEX_RECURSIVE_NP:
@@ -38,31 +41,214 @@ __pthread_mutex_unlock_usercnt (mutex, decr)
if (--mutex->__data.__count != 0)
/* We still hold the mutex. */
return 0;
- break;
+ goto normal;
case PTHREAD_MUTEX_ERRORCHECK_NP:
/* Error checking mutex. */
if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid)
|| ! lll_mutex_islocked (mutex->__data.__lock))
return EPERM;
- break;
+ /* FALLTHROUGH */
- default:
- /* Correct code cannot set any other type. */
case PTHREAD_MUTEX_TIMED_NP:
case PTHREAD_MUTEX_ADAPTIVE_NP:
- /* Normal mutex. Nothing special to do. */
+ /* Always reset the owner field. */
+ normal:
+ mutex->__data.__owner = 0;
+ if (decr)
+ /* One less user. */
+ --mutex->__data.__nusers;
+
+ /* Unlock. */
+ lll_mutex_unlock (mutex->__data.__lock);
break;
- }
- /* Always reset the owner field. */
- mutex->__data.__owner = 0;
- if (decr)
- /* One less user. */
- --mutex->__data.__nusers;
+ case PTHREAD_MUTEX_ROBUST_RECURSIVE_NP:
+ /* Recursive mutex. */
+ if ((mutex->__data.__lock & FUTEX_TID_MASK)
+ == THREAD_GETMEM (THREAD_SELF, tid)
+ && __builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_INCONSISTENT, 0))
+ {
+ if (--mutex->__data.__count != 0)
+ /* We still hold the mutex. */
+ return ENOTRECOVERABLE;
+
+ goto notrecoverable;
+ }
+
+ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid))
+ return EPERM;
+
+ if (--mutex->__data.__count != 0)
+ /* We still hold the mutex. */
+ return 0;
+
+ goto robust;
+
+ case PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP:
+ if ((mutex->__data.__lock & FUTEX_TID_MASK)
+ != THREAD_GETMEM (THREAD_SELF, tid)
+ || ! lll_mutex_islocked (mutex->__data.__lock))
+ return EPERM;
+
+ /* If the previous owner died and the caller did not succeed in
+ making the state consistent, mark the mutex as unrecoverable
+ and make all waiters. */
+ if (__builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_INCONSISTENT, 0))
+ notrecoverable:
+ newowner = PTHREAD_MUTEX_NOTRECOVERABLE;
+
+ robust:
+ /* Remove mutex from the list. */
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ &mutex->__data.__list.__next);
+ DEQUEUE_MUTEX (mutex);
+
+ mutex->__data.__owner = newowner;
+ if (decr)
+ /* One less user. */
+ --mutex->__data.__nusers;
+
+ /* Unlock. */
+ lll_robust_mutex_unlock (mutex->__data.__lock);
+
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ break;
+
+ case PTHREAD_MUTEX_PI_RECURSIVE_NP:
+ /* Recursive mutex. */
+ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid))
+ return EPERM;
+
+ if (--mutex->__data.__count != 0)
+ /* We still hold the mutex. */
+ return 0;
+ goto continue_pi;
+
+ case PTHREAD_MUTEX_PI_ROBUST_RECURSIVE_NP:
+ /* Recursive mutex. */
+ if ((mutex->__data.__lock & FUTEX_TID_MASK)
+ == THREAD_GETMEM (THREAD_SELF, tid)
+ && __builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_INCONSISTENT, 0))
+ {
+ if (--mutex->__data.__count != 0)
+ /* We still hold the mutex. */
+ return ENOTRECOVERABLE;
+
+ goto pi_notrecoverable;
+ }
- /* Unlock. */
- lll_mutex_unlock (mutex->__data.__lock);
+ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid))
+ return EPERM;
+
+ if (--mutex->__data.__count != 0)
+ /* We still hold the mutex. */
+ return 0;
+
+ goto continue_pi;
+
+ case PTHREAD_MUTEX_PI_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ADAPTIVE_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP:
+ if ((mutex->__data.__lock & FUTEX_TID_MASK)
+ != THREAD_GETMEM (THREAD_SELF, tid)
+ || ! lll_mutex_islocked (mutex->__data.__lock))
+ return EPERM;
+
+ /* If the previous owner died and the caller did not succeed in
+ making the state consistent, mark the mutex as unrecoverable
+ and make all waiters. */
+ if ((mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP) != 0
+ && __builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_INCONSISTENT, 0))
+ pi_notrecoverable:
+ newowner = PTHREAD_MUTEX_NOTRECOVERABLE;
+
+ continue_pi:
+ if ((mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP) != 0)
+ {
+ /* Remove mutex from the list.
+ Note: robust PI futexes are signaled by setting bit 0. */
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ (void *) (((uintptr_t) &mutex->__data.__list.__next)
+ | 1));
+ DEQUEUE_MUTEX (mutex);
+ }
+
+ mutex->__data.__owner = newowner;
+ if (decr)
+ /* One less user. */
+ --mutex->__data.__nusers;
+
+ /* Unlock. */
+ if ((mutex->__data.__lock & FUTEX_WAITERS) != 0
+ || atomic_compare_and_exchange_bool_acq (&mutex->__data.__lock, 0,
+ THREAD_GETMEM (THREAD_SELF,
+ tid)))
+ {
+ INTERNAL_SYSCALL_DECL (__err);
+ INTERNAL_SYSCALL (futex, __err, 2, &mutex->__data.__lock,
+ FUTEX_UNLOCK_PI);
+ }
+
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ break;
+
+ case PTHREAD_MUTEX_PP_RECURSIVE_NP:
+ /* Recursive mutex. */
+ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid))
+ return EPERM;
+
+ if (--mutex->__data.__count != 0)
+ /* We still hold the mutex. */
+ return 0;
+ goto pp;
+
+ case PTHREAD_MUTEX_PP_ERRORCHECK_NP:
+ /* Error checking mutex. */
+ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid)
+ || (mutex->__data.__lock & ~ PTHREAD_MUTEX_PRIO_CEILING_MASK) == 0)
+ return EPERM;
+ /* FALLTHROUGH */
+
+ case PTHREAD_MUTEX_PP_NORMAL_NP:
+ case PTHREAD_MUTEX_PP_ADAPTIVE_NP:
+ /* Always reset the owner field. */
+ pp:
+ mutex->__data.__owner = 0;
+
+ if (decr)
+ /* One less user. */
+ --mutex->__data.__nusers;
+
+ /* Unlock. */
+ int newval, oldval;
+ do
+ {
+ oldval = mutex->__data.__lock;
+ newval = oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK;
+ }
+ while (atomic_compare_and_exchange_bool_acq (&mutex->__data.__lock,
+ newval, oldval));
+
+ if ((oldval & ~PTHREAD_MUTEX_PRIO_CEILING_MASK) > 1)
+ lll_futex_wake (&mutex->__data.__lock, 1);
+
+ int oldprio = newval >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+ return __pthread_tpp_change_priority (oldprio, -1);
+
+ default:
+ /* Correct code cannot set any other type. */
+ return EINVAL;
+ }
return 0;
}
diff --git a/nptl/pthread_mutexattr_getprioceiling.c b/nptl/pthread_mutexattr_getprioceiling.c
new file mode 100644
index 0000000000..792e9a43d6
--- /dev/null
+++ b/nptl/pthread_mutexattr_getprioceiling.c
@@ -0,0 +1,48 @@
+/* Get priority ceiling setting from pthread_mutexattr_t.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <pthreadP.h>
+
+
+int
+pthread_mutexattr_getprioceiling (attr, prioceiling)
+ const pthread_mutexattr_t *attr;
+ int *prioceiling;
+{
+ const struct pthread_mutexattr *iattr;
+ int ceiling;
+
+ iattr = (const struct pthread_mutexattr *) attr;
+
+ ceiling = ((iattr->mutexkind & PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
+ >> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT);
+
+ if (! ceiling)
+ {
+ if (__sched_fifo_min_prio == -1)
+ __init_sched_fifo_prio ();
+ if (ceiling < __sched_fifo_min_prio)
+ ceiling = __sched_fifo_min_prio;
+ }
+
+ *prioceiling = ceiling;
+
+ return 0;
+}
diff --git a/nptl/sysdeps/alpha/jmpbuf-unwind.h b/nptl/pthread_mutexattr_getprotocol.c
index 5cef8b1cf5..0c28699c87 100644
--- a/nptl/sysdeps/alpha/jmpbuf-unwind.h
+++ b/nptl/pthread_mutexattr_getprotocol.c
@@ -1,6 +1,7 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Get priority protocol setting from pthread_mutexattr_t.
+ Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -17,15 +18,20 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
+#include <pthreadP.h>
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
+int
+pthread_mutexattr_getprotocol (attr, protocol)
+ const pthread_mutexattr_t *attr;
+ int *protocol;
+{
+ const struct pthread_mutexattr *iattr;
-/* We use the normal lobngjmp for unwinding. */
-#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
+ iattr = (const struct pthread_mutexattr *) attr;
+
+ *protocol = ((iattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK)
+ >> PTHREAD_MUTEXATTR_PROTOCOL_SHIFT);
+
+ return 0;
+}
diff --git a/nptl/pthread_mutexattr_getpshared.c b/nptl/pthread_mutexattr_getpshared.c
index 4bd4ea18db..6454125db2 100644
--- a/nptl/pthread_mutexattr_getpshared.c
+++ b/nptl/pthread_mutexattr_getpshared.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -29,9 +29,7 @@ pthread_mutexattr_getpshared (attr, pshared)
iattr = (const struct pthread_mutexattr *) attr;
- /* We use bit 31 to signal whether the mutex is going to be
- process-shared or not. */
- *pshared = ((iattr->mutexkind & 0x80000000) != 0
+ *pshared = ((iattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_PSHARED) != 0
? PTHREAD_PROCESS_SHARED : PTHREAD_PROCESS_PRIVATE);
return 0;
diff --git a/nptl/sysdeps/i386/jmpbuf-unwind.h b/nptl/pthread_mutexattr_getrobust.c
index 5cef8b1cf5..5ec43d1f7c 100644
--- a/nptl/sysdeps/i386/jmpbuf-unwind.h
+++ b/nptl/pthread_mutexattr_getrobust.c
@@ -1,6 +1,6 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2005.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -17,15 +17,20 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
+#include <pthreadP.h>
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
+int
+pthread_mutexattr_getrobust_np (attr, robustness)
+ const pthread_mutexattr_t *attr;
+ int *robustness;
+{
+ const struct pthread_mutexattr *iattr;
-/* We use the normal lobngjmp for unwinding. */
-#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
+ iattr = (const struct pthread_mutexattr *) attr;
+
+ *robustness = ((iattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_ROBUST) != 0
+ ? PTHREAD_MUTEX_ROBUST_NP : PTHREAD_MUTEX_STALLED_NP);
+
+ return 0;
+}
diff --git a/nptl/pthread_mutexattr_gettype.c b/nptl/pthread_mutexattr_gettype.c
index 5c32b2c6f1..7303703bf4 100644
--- a/nptl/pthread_mutexattr_gettype.c
+++ b/nptl/pthread_mutexattr_gettype.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -29,9 +29,7 @@ pthread_mutexattr_gettype (attr, kind)
iattr = (const struct pthread_mutexattr *) attr;
- /* We use bit 31 to signal whether the mutex is going to be
- process-shared or not. */
- *kind = iattr->mutexkind & ~0x80000000;
+ *kind = iattr->mutexkind & ~PTHREAD_MUTEXATTR_FLAG_BITS;
return 0;
}
diff --git a/nptl/pthread_mutexattr_setprioceiling.c b/nptl/pthread_mutexattr_setprioceiling.c
new file mode 100644
index 0000000000..9b7874f739
--- /dev/null
+++ b/nptl/pthread_mutexattr_setprioceiling.c
@@ -0,0 +1,47 @@
+/* Change priority ceiling setting in pthread_mutexattr_t.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <pthreadP.h>
+
+
+int
+pthread_mutexattr_setprioceiling (attr, prioceiling)
+ pthread_mutexattr_t *attr;
+ int prioceiling;
+{
+ if (__sched_fifo_min_prio == -1)
+ __init_sched_fifo_prio ();
+
+ if (__builtin_expect (prioceiling < __sched_fifo_min_prio, 0)
+ || __builtin_expect (prioceiling > __sched_fifo_max_prio, 0)
+ || __builtin_expect ((prioceiling
+ & (PTHREAD_MUTEXATTR_PRIO_CEILING_MASK
+ >> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT))
+ != prioceiling, 0))
+ return EINVAL;
+
+ struct pthread_mutexattr *iattr = (struct pthread_mutexattr *) attr;
+
+ iattr->mutexkind = ((iattr->mutexkind & ~PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
+ | (prioceiling << PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT));
+
+ return 0;
+}
diff --git a/nptl/pthread_mutexattr_setprotocol.c b/nptl/pthread_mutexattr_setprotocol.c
new file mode 100644
index 0000000000..191231244e
--- /dev/null
+++ b/nptl/pthread_mutexattr_setprotocol.c
@@ -0,0 +1,41 @@
+/* Change priority protocol setting in pthread_mutexattr_t.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <pthreadP.h>
+
+
+int
+pthread_mutexattr_setprotocol (attr, protocol)
+ pthread_mutexattr_t *attr;
+ int protocol;
+{
+ if (protocol != PTHREAD_PRIO_NONE
+ && protocol != PTHREAD_PRIO_INHERIT
+ && __builtin_expect (protocol != PTHREAD_PRIO_PROTECT, 0))
+ return EINVAL;
+
+ struct pthread_mutexattr *iattr = (struct pthread_mutexattr *) attr;
+
+ iattr->mutexkind = ((iattr->mutexkind & ~PTHREAD_MUTEXATTR_PROTOCOL_MASK)
+ | (protocol << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT));
+
+ return 0;
+}
diff --git a/nptl/pthread_mutexattr_setpshared.c b/nptl/pthread_mutexattr_setpshared.c
index 5f2cf417e3..8e08b9e161 100644
--- a/nptl/pthread_mutexattr_setpshared.c
+++ b/nptl/pthread_mutexattr_setpshared.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -34,12 +34,10 @@ pthread_mutexattr_setpshared (attr, pshared)
iattr = (struct pthread_mutexattr *) attr;
- /* We use bit 31 to signal whether the mutex is going to be
- process-shared or not. */
if (pshared == PTHREAD_PROCESS_PRIVATE)
- iattr->mutexkind &= ~0x80000000;
+ iattr->mutexkind &= ~PTHREAD_MUTEXATTR_FLAG_PSHARED;
else
- iattr->mutexkind |= 0x80000000;
+ iattr->mutexkind |= PTHREAD_MUTEXATTR_FLAG_PSHARED;
return 0;
}
diff --git a/nptl/sysdeps/s390/jmpbuf-unwind.h b/nptl/pthread_mutexattr_setrobust.c
index 9f7e1ad583..cf95e35b6f 100644
--- a/nptl/sysdeps/s390/jmpbuf-unwind.h
+++ b/nptl/pthread_mutexattr_setrobust.c
@@ -1,6 +1,6 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2005.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -17,21 +17,27 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-#include <bits/wordsize.h>
+#include <errno.h>
+#include <pthreadP.h>
-/* On s390{,x}, CFA is always 96 (resp. 160) bytes above actual
- %r15. */
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, \
- (void *) (_Unwind_GetCFA (_context) \
- - 32 - 2 * __WORDSIZE), _adj)
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) \
- < (uintptr_t) (_jmpbuf)->__gregs[__JB_GPR15] - (_adj))
+int
+pthread_mutexattr_setrobust_np (attr, robustness)
+ pthread_mutexattr_t *attr;
+ int robustness;
+{
+ if (robustness != PTHREAD_MUTEX_STALLED_NP
+ && __builtin_expect (robustness != PTHREAD_MUTEX_ROBUST_NP, 0))
+ return EINVAL;
-/* We use the normal longjmp for unwinding. */
-#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
+ struct pthread_mutexattr *iattr = (struct pthread_mutexattr *) attr;
+
+ /* We use bit 30 to signal whether the mutex is going to be
+ robust or not. */
+ if (robustness == PTHREAD_MUTEX_STALLED_NP)
+ iattr->mutexkind &= ~PTHREAD_MUTEXATTR_FLAG_ROBUST;
+ else
+ iattr->mutexkind |= PTHREAD_MUTEXATTR_FLAG_ROBUST;
+
+ return 0;
+}
diff --git a/nptl/pthread_mutexattr_settype.c b/nptl/pthread_mutexattr_settype.c
index c77fe79df5..fe6b5c22cd 100644
--- a/nptl/pthread_mutexattr_settype.c
+++ b/nptl/pthread_mutexattr_settype.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -33,9 +33,7 @@ __pthread_mutexattr_settype (attr, kind)
iattr = (struct pthread_mutexattr *) attr;
- /* We use bit 31 to signal whether the mutex is going to be
- process-shared or not. */
- iattr->mutexkind = (iattr->mutexkind & 0x80000000) | kind;
+ iattr->mutexkind = (iattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_BITS) | kind;
return 0;
}
diff --git a/nptl/pthread_setschedparam.c b/nptl/pthread_setschedparam.c
index 5889cc98a9..30ac6b3e89 100644
--- a/nptl/pthread_setschedparam.c
+++ b/nptl/pthread_setschedparam.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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.
@@ -45,6 +45,19 @@ __pthread_setschedparam (threadid, policy, param)
lll_lock (pd->lock);
+ struct sched_param p;
+ const struct sched_param *orig_param = param;
+
+ /* If the thread should have higher priority because of some
+ PTHREAD_PRIO_PROTECT mutexes it holds, adjust the priority. */
+ if (__builtin_expect (pd->tpp != NULL, 0)
+ && pd->tpp->priomax > param->sched_priority)
+ {
+ p = *param;
+ p.sched_priority = pd->tpp->priomax;
+ param = &p;
+ }
+
/* Try to set the scheduler information. */
if (__builtin_expect (__sched_setscheduler (pd->tid, policy,
param) == -1, 0))
@@ -54,7 +67,7 @@ __pthread_setschedparam (threadid, policy, param)
/* We succeeded changing the kernel information. Reflect this
change in the thread descriptor. */
pd->schedpolicy = policy;
- memcpy (&pd->schedparam, param, sizeof (struct sched_param));
+ memcpy (&pd->schedparam, orig_param, sizeof (struct sched_param));
pd->flags |= ATTR_FLAG_SCHED_SET | ATTR_FLAG_POLICY_SET;
}
diff --git a/nptl/pthread_setschedprio.c b/nptl/pthread_setschedprio.c
index 063f5232f5..4a71f6c7b3 100644
--- a/nptl/pthread_setschedprio.c
+++ b/nptl/pthread_setschedprio.c
@@ -47,6 +47,11 @@ pthread_setschedprio (threadid, prio)
lll_lock (pd->lock);
+ /* If the thread should have higher priority because of some
+ PTHREAD_PRIO_PROTECT mutexes it holds, adjust the priority. */
+ if (__builtin_expect (pd->tpp != NULL, 0) && pd->tpp->priomax > prio)
+ param.sched_priority = pd->tpp->priomax;
+
/* Try to set the scheduler information. */
if (__builtin_expect (sched_setparam (pd->tid, &param) == -1, 0))
result = errno;
@@ -54,6 +59,7 @@ pthread_setschedprio (threadid, prio)
{
/* We succeeded changing the kernel information. Reflect this
change in the thread descriptor. */
+ param.sched_priority = prio;
memcpy (&pd->schedparam, &param, sizeof (struct sched_param));
pd->flags |= ATTR_FLAG_SCHED_SET;
}
diff --git a/nptl/pthread_setspecific.c b/nptl/pthread_setspecific.c
index b6e66b5f22..152f5590e2 100644
--- a/nptl/pthread_setspecific.c
+++ b/nptl/pthread_setspecific.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -52,8 +52,8 @@ __pthread_setspecific (key, value)
}
else
{
- if (KEY_UNUSED ((seq = __pthread_keys[key].seq))
- || key >= PTHREAD_KEYS_MAX)
+ if (key >= PTHREAD_KEYS_MAX
+ || KEY_UNUSED ((seq = __pthread_keys[key].seq)))
/* Not valid. */
return EINVAL;
diff --git a/nptl/pthread_timedjoin.c b/nptl/pthread_timedjoin.c
index 1cc07213c8..5df6ab6a80 100644
--- a/nptl/pthread_timedjoin.c
+++ b/nptl/pthread_timedjoin.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 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.
@@ -19,7 +19,7 @@
#include <errno.h>
#include <stdlib.h>
-#include "atomic.h"
+#include <atomic.h>
#include "pthreadP.h"
diff --git a/nptl/pthread_tryjoin.c b/nptl/pthread_tryjoin.c
index 904cb5280b..fc363dd778 100644
--- a/nptl/pthread_tryjoin.c
+++ b/nptl/pthread_tryjoin.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 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,7 @@
#include <errno.h>
#include <stdlib.h>
-#include "atomic.h"
+#include <atomic.h>
#include "pthreadP.h"
diff --git a/nptl/sem_open.c b/nptl/sem_open.c
index a4b2f5b3ac..66bcb13aec 100644
--- a/nptl/sem_open.c
+++ b/nptl/sem_open.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -147,7 +147,7 @@ __sem_search (const void *a, const void *b)
void *__sem_mappings attribute_hidden;
/* Lock to protect the search tree. */
-lll_lock_t __sem_mappings_lock = LLL_LOCK_INITIALIZER;
+lll_lock_t __sem_mappings_lock attribute_hidden = LLL_LOCK_INITIALIZER;
/* Search for existing mapping and if possible add the one provided. */
diff --git a/nptl/semaphoreP.h b/nptl/semaphoreP.h
index d14ea92c74..754609a1a8 100644
--- a/nptl/semaphoreP.h
+++ b/nptl/semaphoreP.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -48,7 +48,7 @@ extern pthread_once_t __namedsem_once attribute_hidden;
extern void *__sem_mappings attribute_hidden;
/* Lock to protect the search tree. */
-extern lll_lock_t __sem_mappings_lock;
+extern lll_lock_t __sem_mappings_lock attribute_hidden;
/* Initializer for mountpoint. */
diff --git a/nptl/shlib-versions b/nptl/shlib-versions
index 5e18753be2..06ac620f06 100644
--- a/nptl/shlib-versions
+++ b/nptl/shlib-versions
@@ -1,5 +1,5 @@
mips.*-.*-linux.* libpthread=0 GLIBC_2.0 GLIBC_2.2
-sparc64-.*-linux.* libpthread=0 GLIBC_2.2
+sparc64.*-.*-linux.* libpthread=0 GLIBC_2.2
sh.*-.*-linux.* libpthread=0 GLIBC_2.2
ia64.*-.*-linux.* libpthread=0 GLIBC_2.2
hppa.*-.*-linux.* libpthread=0 GLIBC_2.2
diff --git a/nptl/sysdeps/pthread/sigaction.c b/nptl/sigaction.c
index 4d36150a90..60e1f1d355 100644
--- a/nptl/sysdeps/pthread/sigaction.c
+++ b/nptl/sigaction.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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,18 +17,17 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-/* This is tricky. GCC doesn't like #include_next in the primary
- source file and even if it did, the first #include_next is this
- exact file anyway. */
-#ifndef LIBC_SIGACTION
+
+/* This is no complete implementation. The file is meant to be
+ included in the real implementation to provide the wrapper around
+ __libc_sigaction. */
#include <nptl/pthreadP.h>
/* We use the libc implementation but we tell it to not allow
SIGCANCEL or SIGTIMER to be handled. */
-# define LIBC_SIGACTION 1
+#define LIBC_SIGACTION 1
-# include <nptl/sysdeps/pthread/sigaction.c>
int
__sigaction (sig, act, oact)
@@ -46,9 +45,3 @@ __sigaction (sig, act, oact)
}
libc_hidden_weak (__sigaction)
weak_alias (__sigaction, sigaction)
-
-#else
-
-# include_next <sigaction.c>
-
-#endif /* LIBC_SIGACTION */
diff --git a/nptl/sysdeps/alpha/tls.h b/nptl/sysdeps/alpha/tls.h
index bc6630953f..07db15939d 100644
--- a/nptl/sysdeps/alpha/tls.h
+++ b/nptl/sysdeps/alpha/tls.h
@@ -1,5 +1,5 @@
/* Definition for thread-local data handling. NPTL/Alpha version.
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -23,6 +23,7 @@
# include <dl-sysdep.h>
#ifndef __ASSEMBLER__
+# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
@@ -30,7 +31,11 @@
typedef union dtv
{
size_t counter;
- void *pointer;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
} dtv_t;
#else /* __ASSEMBLER__ */
@@ -60,7 +65,7 @@ typedef union dtv
typedef struct
{
dtv_t *dtv;
- void *private;
+ void *__private;
} tcbhead_t;
/* This is the size of the initial TCB. */
@@ -119,6 +124,29 @@ typedef struct
#define THREAD_SETMEM_NC(descr, member, idx, value) \
descr->member[idx] = (value)
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
#endif /* __ASSEMBLER__ */
#endif /* tls.h */
diff --git a/nptl/sysdeps/i386/tcb-offsets.sym b/nptl/sysdeps/i386/tcb-offsets.sym
index 4e0444ba38..7c8d9a5ca5 100644
--- a/nptl/sysdeps/i386/tcb-offsets.sym
+++ b/nptl/sysdeps/i386/tcb-offsets.sym
@@ -11,3 +11,4 @@ SYSINFO_OFFSET offsetof (tcbhead_t, sysinfo)
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)
diff --git a/nptl/sysdeps/i386/tls.h b/nptl/sysdeps/i386/tls.h
index 945a4c71d6..b3d9142fc5 100644
--- a/nptl/sysdeps/i386/tls.h
+++ b/nptl/sysdeps/i386/tls.h
@@ -1,5 +1,5 @@
/* Definition for thread-local data handling. nptl/i386 version.
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002,2003,2004,2005,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -22,6 +22,7 @@
#include <dl-sysdep.h>
#ifndef __ASSEMBLER__
+# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
# include <stdlib.h>
@@ -32,18 +33,25 @@
typedef union dtv
{
size_t counter;
- void *pointer;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
} dtv_t;
typedef struct
{
- void *tcb; /* Pointer to the TCB. Not necessary the
+ void *tcb; /* Pointer to the TCB. Not necessarily the
thread descriptor used by libpthread. */
dtv_t *dtv;
void *self; /* Pointer to the thread descriptor. */
int multiple_threads;
uintptr_t sysinfo;
+ uintptr_t stack_guard;
+ uintptr_t pointer_guard;
+ int gscope_flag;
} tcbhead_t;
# define TLS_MULTIPLE_THREADS_IN_TCB 1
@@ -97,11 +105,13 @@ union user_desc_init
/* Get the thread descriptor definition. */
# include <nptl/descr.h>
-/* This is the size of the initial TCB. */
-# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+/* This is the size of the initial TCB. Can't be just sizeof (tcbhead_t),
+ because NPTL getpid, __libc_alloca_cutoff etc. need (almost) the whole
+ struct pthread even when not linked with -lpthread. */
+# define TLS_INIT_TCB_SIZE sizeof (struct pthread)
/* Alignment requirements for the initial TCB. */
-# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
/* This is the size of the TCB. */
# define TLS_TCB_SIZE sizeof (struct pthread)
@@ -409,6 +419,42 @@ union user_desc_init
__res; })
+/* Set the stack guard field in TCB head. */
+#define THREAD_SET_STACK_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
+#define THREAD_COPY_STACK_GUARD(descr) \
+ ((descr)->header.stack_guard \
+ = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
+
+
+/* Set the pointer guard field in the TCB head. */
+#define THREAD_SET_POINTER_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.pointer_guard, value)
+#define THREAD_COPY_POINTER_GUARD(descr) \
+ ((descr)->header.pointer_guard \
+ = THREAD_GETMEM (THREAD_SELF, header.pointer_guard))
+
+
+/* Get and set the global scope generation counter in the TCB head. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res; \
+ asm volatile ("xchgl %0, %%gs:%P1" \
+ : "=r" (__res) \
+ : "i" (offsetof (struct pthread, header.gscope_flag)), \
+ "0" (THREAD_GSCOPE_FLAG_UNUSED)); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ THREAD_SETMEM (THREAD_SELF, header.gscope_flag, THREAD_GSCOPE_FLAG_USED)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
#endif /* __ASSEMBLER__ */
#endif /* tls.h */
diff --git a/nptl/sysdeps/ia64/pthread_spin_lock.c b/nptl/sysdeps/ia64/pthread_spin_lock.c
index 71aaef9451..7d25af7c4b 100644
--- a/nptl/sysdeps/ia64/pthread_spin_lock.c
+++ b/nptl/sysdeps/ia64/pthread_spin_lock.c
@@ -25,7 +25,7 @@ pthread_spin_lock (lock)
{
int *p = (int *) lock;
- while (__builtin_expect (__sync_val_compare_and_swap_si (p, 0, 1), 0))
+ while (__builtin_expect (__sync_val_compare_and_swap (p, 0, 1), 0))
{
/* Spin without using the atomic instruction. */
do
diff --git a/nptl/sysdeps/ia64/pthread_spin_trylock.c b/nptl/sysdeps/ia64/pthread_spin_trylock.c
index b7cbf14782..0fd8b99b7a 100644
--- a/nptl/sysdeps/ia64/pthread_spin_trylock.c
+++ b/nptl/sysdeps/ia64/pthread_spin_trylock.c
@@ -24,5 +24,5 @@ int
pthread_spin_trylock (lock)
pthread_spinlock_t *lock;
{
- return __sync_val_compare_and_swap_si ((int *) lock, 0, 1) == 0 ? 0 : EBUSY;
+ return __sync_val_compare_and_swap ((int *) lock, 0, 1) == 0 ? 0 : EBUSY;
}
diff --git a/nptl/sysdeps/ia64/tcb-offsets.sym b/nptl/sysdeps/ia64/tcb-offsets.sym
index f5108e0a9e..e1707ab1c8 100644
--- a/nptl/sysdeps/ia64/tcb-offsets.sym
+++ b/nptl/sysdeps/ia64/tcb-offsets.sym
@@ -1,7 +1,7 @@
#include <sysdep.h>
#include <tls.h>
-PID offsetof (struct pthread, pid) - sizeof (struct pthread)
-TID offsetof (struct pthread, tid) - sizeof (struct pthread)
-MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads) - sizeof (struct pthread)
-SYSINFO_OFFSET offsetof (tcbhead_t, private)
+PID offsetof (struct pthread, pid) - TLS_PRE_TCB_SIZE
+TID offsetof (struct pthread, tid) - TLS_PRE_TCB_SIZE
+MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads) - TLS_PRE_TCB_SIZE
+SYSINFO_OFFSET offsetof (tcbhead_t, __private)
diff --git a/nptl/sysdeps/ia64/tls.h b/nptl/sysdeps/ia64/tls.h
index 4591a415c0..a43f096798 100644
--- a/nptl/sysdeps/ia64/tls.h
+++ b/nptl/sysdeps/ia64/tls.h
@@ -1,5 +1,5 @@
/* Definition for thread-local data handling. nptl/IA-64 version.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -22,6 +22,7 @@
#include <dl-sysdep.h>
#ifndef __ASSEMBLER__
+# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
# include <stdlib.h>
@@ -32,14 +33,18 @@
typedef union dtv
{
size_t counter;
- void *pointer;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
} dtv_t;
typedef struct
{
dtv_t *dtv;
- void *private;
+ void *__private;
} tcbhead_t;
register struct pthread *__thread_self __asm__("r13");
@@ -75,8 +80,16 @@ register struct pthread *__thread_self __asm__("r13");
/* This is the size of the TCB. */
# define TLS_TCB_SIZE sizeof (tcbhead_t)
-/* This is the size we need before TCB. */
-# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
+/* This is the size we need before TCB.
+ If there is not any room for uintptr_t stack_guard and
+ uintptr_t pointer_guard in struct pthread's final padding,
+ we need to put struct pthread 16 byte slower. */
+# define TLS_PRE_TCB_SIZE \
+ (sizeof (struct pthread) \
+ + (PTHREAD_STRUCT_END_PADDING < 2 * sizeof (uintptr_t) \
+ ? ((2 * sizeof (uintptr_t) + __alignof__ (struct pthread) - 1) \
+ & ~(__alignof__ (struct pthread) - 1)) \
+ : 0))
/* Alignment requirements for the TCB. */
# define TLS_TCB_ALIGN __alignof__ (struct pthread)
@@ -100,8 +113,9 @@ register struct pthread *__thread_self __asm__("r13");
# define GET_DTV(descr) \
(((tcbhead_t *) (descr))->dtv)
-#define THREAD_SELF_SYSINFO (((tcbhead_t *) __thread_self)->private)
-#define THREAD_SYSINFO(pd) (((tcbhead_t *) ((pd) + 1))->private)
+#define THREAD_SELF_SYSINFO (((tcbhead_t *) __thread_self)->__private)
+#define THREAD_SYSINFO(pd) \
+ (((tcbhead_t *) ((char *) (pd) + TLS_PRE_TCB_SIZE))->__private)
#if defined NEED_DL_SYSINFO
# define INIT_SYSINFO THREAD_SELF_SYSINFO = (void *) GLRO(dl_sysinfo)
@@ -120,10 +134,11 @@ register struct pthread *__thread_self __asm__("r13");
(((tcbhead_t *)__thread_self)->dtv)
/* Return the thread descriptor for the current thread. */
-# define THREAD_SELF (__thread_self - 1)
+# define THREAD_SELF \
+ ((struct pthread *) ((char *) __thread_self - TLS_PRE_TCB_SIZE))
/* Magic for libthread_db to know how to do THREAD_SELF. */
-# define DB_THREAD_SELF REGISTER (64, 64, 13 * 8, -sizeof (struct pthread))
+# define DB_THREAD_SELF REGISTER (64, 64, 13 * 8, -TLS_PRE_TCB_SIZE)
/* Access to data in the thread descriptor is easy. */
#define THREAD_GETMEM(descr, member) \
@@ -135,6 +150,45 @@ register struct pthread *__thread_self __asm__("r13");
#define THREAD_SETMEM_NC(descr, member, idx, value) \
descr->member[idx] = (value)
+/* Set the stack guard field in TCB head. */
+#define THREAD_SET_STACK_GUARD(value) \
+ (((uintptr_t *) __thread_self)[-1] = (value))
+#define THREAD_COPY_STACK_GUARD(descr) \
+ (((uintptr_t *) ((char *) (descr) + TLS_PRE_TCB_SIZE))[-1] \
+ = ((uintptr_t *) __thread_self)[-1])
+
+/* Set the pointer guard field in TCB head. */
+#define THREAD_GET_POINTER_GUARD() \
+ (((uintptr_t *) __thread_self)[-2])
+#define THREAD_SET_POINTER_GUARD(value) \
+ (((uintptr_t *) __thread_self)[-2] = (value))
+#define THREAD_COPY_POINTER_GUARD(descr) \
+ (((uintptr_t *) ((char *) (descr) + TLS_PRE_TCB_SIZE))[-2] \
+ = THREAD_GET_POINTER_GUARD ())
+
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
#endif /* __ASSEMBLER__ */
#endif /* tls.h */
diff --git a/nptl/sysdeps/powerpc/tcb-offsets.sym b/nptl/sysdeps/powerpc/tcb-offsets.sym
index a9701fb5b7..4a8671e802 100644
--- a/nptl/sysdeps/powerpc/tcb-offsets.sym
+++ b/nptl/sysdeps/powerpc/tcb-offsets.sym
@@ -6,10 +6,12 @@
-- Abuse tls.h macros to derive offsets relative to the thread register.
# undef __thread_register
# define __thread_register ((void *) 0)
-# define thread_offsetof(mem) ((void *) &THREAD_SELF->mem - (void *) 0)
+# define thread_offsetof(mem) ((ptrdiff_t) THREAD_SELF + offsetof (struct pthread, mem))
+
#if TLS_MULTIPLE_THREADS_IN_TCB
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
#endif
PID thread_offsetof (pid)
TID thread_offsetof (tid)
+POINTER_GUARD (offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
diff --git a/nptl/sysdeps/powerpc/tls.h b/nptl/sysdeps/powerpc/tls.h
index ce7f5bd53d..ad5698c6f8 100644
--- a/nptl/sysdeps/powerpc/tls.h
+++ b/nptl/sysdeps/powerpc/tls.h
@@ -1,5 +1,5 @@
/* Definition for thread-local data handling. NPTL/PowerPC version.
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -23,6 +23,7 @@
# include <dl-sysdep.h>
#ifndef __ASSEMBLER__
+# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
@@ -30,7 +31,11 @@
typedef union dtv
{
size_t counter;
- void *pointer;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
} dtv_t;
#else /* __ASSEMBLER__ */
@@ -60,11 +65,13 @@ typedef union dtv
/* Get the thread descriptor definition. */
# include <nptl/descr.h>
-/* This layout is actually wholly private and not affected by the ABI.
- Nor does it overlap the pthread data structure, so we need nothing
- extra here at all. */
+/* The stack_guard is accessed directly by GCC -fstack-protector code,
+ so it is a part of public ABI. The dtv and pointer_guard fields
+ are private. */
typedef struct
{
+ uintptr_t pointer_guard;
+ uintptr_t stack_guard;
dtv_t *dtv;
} tcbhead_t;
@@ -122,7 +129,7 @@ register void *__thread_register __asm__ ("r13");
/* Return the address of the dtv for the current thread. */
# define THREAD_DTV() \
- (((tcbhead_t *) (__thread_register - TLS_TCB_OFFSET))[-1].dtv)
+ (((tcbhead_t *) (__thread_register - TLS_TCB_OFFSET))[-1].dtv)
/* Return the thread descriptor for the current thread. */
# define THREAD_SELF \
@@ -131,9 +138,9 @@ register void *__thread_register __asm__ ("r13");
/* Magic for libthread_db to know how to do THREAD_SELF. */
# define DB_THREAD_SELF \
- REGISTER (32, 32, PT_THREAD_POINTER * 4, \
+ REGISTER (32, 32, PT_THREAD_POINTER * 4, \
- TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE) \
- REGISTER (64, 64, PT_THREAD_POINTER * 8, \
+ REGISTER (64, 64, PT_THREAD_POINTER * 8, \
- TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
/* Read member of the thread descriptor directly. */
@@ -151,10 +158,54 @@ register void *__thread_register __asm__ ("r13");
# define THREAD_SETMEM_NC(descr, member, idx, value) \
((void)(descr), (THREAD_SELF)->member[idx] = (value))
+/* Set the stack guard field in TCB head. */
+# define THREAD_SET_STACK_GUARD(value) \
+ (((tcbhead_t *) ((char *) __thread_register \
+ - TLS_TCB_OFFSET))[-1].stack_guard = (value))
+# define THREAD_COPY_STACK_GUARD(descr) \
+ (((tcbhead_t *) ((char *) (descr) \
+ + TLS_PRE_TCB_SIZE))[-1].stack_guard \
+ = ((tcbhead_t *) ((char *) __thread_register \
+ - TLS_TCB_OFFSET))[-1].stack_guard)
+
+/* Set the stack guard field in TCB head. */
+# define THREAD_GET_POINTER_GUARD() \
+ (((tcbhead_t *) ((char *) __thread_register \
+ - TLS_TCB_OFFSET))[-1].pointer_guard)
+# define THREAD_SET_POINTER_GUARD(value) \
+ (THREAD_GET_POINTER_GUARD () = (value))
+# define THREAD_COPY_POINTER_GUARD(descr) \
+ (((tcbhead_t *) ((char *) (descr) \
+ + TLS_PRE_TCB_SIZE))[-1].pointer_guard \
+ = THREAD_GET_POINTER_GUARD())
+
/* l_tls_offset == 0 is perfectly valid on PPC, so we have to use some
different value to mean unset l_tls_offset. */
# define NO_TLS_OFFSET -1
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
#endif /* __ASSEMBLER__ */
#endif /* tls.h */
diff --git a/nptl/sysdeps/pthread/Makefile b/nptl/sysdeps/pthread/Makefile
index 207e10fad2..72550d74a7 100644
--- a/nptl/sysdeps/pthread/Makefile
+++ b/nptl/sysdeps/pthread/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 2002, 2003, 2004 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.
@@ -18,7 +18,6 @@
# 02111-1307 USA.
ifeq ($(subdir),csu)
-CFLAGS-libc-start.c += -I../nptl
routines += unwind-resume
shared-only-routines += unwind-resume
CFLAGS-unwind-resume.c += -fexceptions -fasynchronous-unwind-tables
@@ -31,7 +30,6 @@ endif
ifeq ($(subdir),rt)
librt-sysdep_routines += timer_routines librt-cancellation rt-unwind-resume
librt-shared-only-routines += rt-unwind-resume
-CPPFLAGS-timer_routines.c = -I../nptl
CFLAGS-librt-cancellation.c += -fexceptions -fasynchronous-unwind-tables
CFLAGS-rt-unwind-resume.c += -fexceptions -fasynchronous-unwind-tables
diff --git a/nptl/sysdeps/pthread/Subdirs b/nptl/sysdeps/pthread/Subdirs
index 4d1f4d876b..36266c1e69 100644
--- a/nptl/sysdeps/pthread/Subdirs
+++ b/nptl/sysdeps/pthread/Subdirs
@@ -1 +1,2 @@
+nptl
nptl_db
diff --git a/nptl/sysdeps/pthread/aio_misc.h b/nptl/sysdeps/pthread/aio_misc.h
new file mode 100644
index 0000000000..c5a11f4550
--- /dev/null
+++ b/nptl/sysdeps/pthread/aio_misc.h
@@ -0,0 +1,74 @@
+/* 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* We define a special synchronization primitive for AIO. POSIX
+ conditional variables would be ideal but the pthread_cond_*wait
+ operations do not return on EINTR. This is a requirement for
+ correct aio_suspend and lio_listio implementations. */
+
+#include <assert.h>
+#include <pthreadP.h>
+#include <lowlevellock.h>
+
+#define DONT_NEED_AIO_MISC_COND 1
+
+#define AIO_MISC_NOTIFY(waitlist) \
+ do { \
+ if (*waitlist->counterp > 0 && --*waitlist->counterp == 0) \
+ lll_futex_wake (waitlist->counterp, 1); \
+ } while (0)
+
+#define AIO_MISC_WAIT(result, futex, timeout, cancel) \
+ do { \
+ volatile int *futexaddr = &futex; \
+ int oldval = futex; \
+ \
+ if (oldval != 0) \
+ { \
+ pthread_mutex_unlock (&__aio_requests_mutex); \
+ \
+ int oldtype; \
+ if (cancel) \
+ oldtype = LIBC_CANCEL_ASYNC (); \
+ \
+ int status; \
+ do \
+ { \
+ status = lll_futex_timed_wait (futexaddr, oldval, timeout); \
+ if (status != -EWOULDBLOCK) \
+ break; \
+ \
+ oldval = *futexaddr; \
+ } \
+ while (oldval != 0); \
+ \
+ if (cancel) \
+ LIBC_CANCEL_RESET (oldtype); \
+ \
+ if (status == -EINTR) \
+ result = EINTR; \
+ else if (status == -ETIMEDOUT) \
+ result = EAGAIN; \
+ else \
+ assert (status == 0 || status == -EWOULDBLOCK); \
+ \
+ pthread_mutex_lock (&__aio_requests_mutex); \
+ } \
+ } while (0)
+
+#include_next <aio_misc.h>
diff --git a/nptl/sysdeps/pthread/allocalim.h b/nptl/sysdeps/pthread/allocalim.h
index 2d666c0b0a..f13c3a3305 100644
--- a/nptl/sysdeps/pthread/allocalim.h
+++ b/nptl/sysdeps/pthread/allocalim.h
@@ -1,18 +1,18 @@
/* Determine whether block of given size can be allocated on the stack or not.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
+ You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
@@ -21,7 +21,8 @@
#include <limits.h>
-extern inline int
+extern int
+__always_inline
__libc_use_alloca (size_t size)
{
return (__builtin_expect (size <= PTHREAD_STACK_MIN / 4, 1)
diff --git a/nptl/sysdeps/pthread/bits/libc-lock.h b/nptl/sysdeps/pthread/bits/libc-lock.h
index 0adf273e35..795caa7135 100644
--- a/nptl/sysdeps/pthread/bits/libc-lock.h
+++ b/nptl/sysdeps/pthread/bits/libc-lock.h
@@ -1,18 +1,18 @@
/* libc-internal interface for mutex locks. NPTL version.
- Copyright (C) 1996-2001, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1996-2001, 2002, 2003, 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
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
+ You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
@@ -408,7 +408,7 @@ extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer
/* Normal cleanup handling, based on C cleanup attribute. */
-extern inline void
+extern __inline void
__libc_cleanup_routine (struct __pthread_cleanup_frame *f)
{
if (f->__do_it)
diff --git a/nptl/sysdeps/pthread/bits/sigthread.h b/nptl/sysdeps/pthread/bits/sigthread.h
index df2bcac291..960bde18a9 100644
--- a/nptl/sysdeps/pthread/bits/sigthread.h
+++ b/nptl/sysdeps/pthread/bits/sigthread.h
@@ -3,16 +3,16 @@
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
+ You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
diff --git a/nptl/sysdeps/pthread/createthread.c b/nptl/sysdeps/pthread/createthread.c
index 03a0f1aa37..88658a16e1 100644
--- a/nptl/sysdeps/pthread/createthread.c
+++ b/nptl/sysdeps/pthread/createthread.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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.
@@ -242,6 +242,7 @@ create_thread (struct pthread *pd, const struct pthread_attr *attr,
|| (attr->flags & ATTR_FLAG_NOTINHERITSCHED) != 0))
stopped = true;
pd->stopped_start = stopped;
+ pd->parent_cancelhandling = THREAD_GETMEM (THREAD_SELF, cancelhandling);
/* Actually create the thread. */
int res = do_clone (pd, attr, clone_flags, start_thread,
diff --git a/nptl/sysdeps/pthread/gai_misc.h b/nptl/sysdeps/pthread/gai_misc.h
new file mode 100644
index 0000000000..9f6a73dad1
--- /dev/null
+++ b/nptl/sysdeps/pthread/gai_misc.h
@@ -0,0 +1,119 @@
+/* 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* We define a special synchronization primitive for AIO. POSIX
+ conditional variables would be ideal but the pthread_cond_*wait
+ operations do not return on EINTR. This is a requirement for
+ correct aio_suspend and lio_listio implementations. */
+
+#include <assert.h>
+#include <signal.h>
+#include <pthreadP.h>
+#include <lowlevellock.h>
+
+#define DONT_NEED_GAI_MISC_COND 1
+
+#define GAI_MISC_NOTIFY(waitlist) \
+ do { \
+ if (*waitlist->counterp > 0 && --*waitlist->counterp == 0) \
+ lll_futex_wake (waitlist->counterp, 1); \
+ } while (0)
+
+#define GAI_MISC_WAIT(result, futex, timeout, cancel) \
+ do { \
+ volatile int *futexaddr = &futex; \
+ int oldval = futex; \
+ \
+ if (oldval != 0) \
+ { \
+ pthread_mutex_unlock (&__gai_requests_mutex); \
+ \
+ int oldtype; \
+ if (cancel) \
+ oldtype = LIBC_CANCEL_ASYNC (); \
+ \
+ int status; \
+ do \
+ { \
+ status = lll_futex_timed_wait (futexaddr, oldval, timeout); \
+ if (status != -EWOULDBLOCK) \
+ break; \
+ \
+ oldval = *futexaddr; \
+ } \
+ while (oldval != 0); \
+ \
+ if (cancel) \
+ LIBC_CANCEL_RESET (oldtype); \
+ \
+ if (status == -EINTR) \
+ result = EINTR; \
+ else if (status == -ETIMEDOUT) \
+ result = EAGAIN; \
+ else \
+ assert (status == 0 || status == -EWOULDBLOCK); \
+ \
+ pthread_mutex_lock (&__gai_requests_mutex); \
+ } \
+ } while (0)
+
+
+#define gai_start_notify_thread __gai_start_notify_thread
+#define gai_create_helper_thread __gai_create_helper_thread
+
+extern inline void
+__gai_start_notify_thread (void)
+{
+ sigset_t ss;
+ sigemptyset (&ss);
+ INTERNAL_SYSCALL_DECL (err);
+ INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, NULL, _NSIG / 8);
+}
+
+extern inline int
+__gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
+ void *arg)
+{
+ pthread_attr_t attr;
+
+ /* Make sure the thread is created detached. */
+ pthread_attr_init (&attr);
+ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+
+ /* The helper thread needs only very little resources. */
+ (void) pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
+
+ /* Block all signals in the helper thread. To do this thoroughly we
+ temporarily have to block all signals here. */
+ sigset_t ss;
+ sigset_t oss;
+ sigfillset (&ss);
+ INTERNAL_SYSCALL_DECL (err);
+ INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, &oss, _NSIG / 8);
+
+ int ret = pthread_create (threadp, &attr, tf, arg);
+
+ /* Restore the signal mask. */
+ INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &oss, NULL,
+ _NSIG / 8);
+
+ (void) pthread_attr_destroy (&attr);
+ return ret;
+}
+
+#include_next <gai_misc.h>
diff --git a/nptl/sysdeps/pthread/pt-initfini.c b/nptl/sysdeps/pthread/pt-initfini.c
index e9169e652a..1e35edd3eb 100644
--- a/nptl/sysdeps/pthread/pt-initfini.c
+++ b/nptl/sysdeps/pthread/pt-initfini.c
@@ -3,11 +3,11 @@
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it
- and/or modify it under the terms of the GNU Library General Public
+ and/or modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
- In addition to the permissions in the GNU Library General Public
+ In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
@@ -19,9 +19,9 @@
The GNU C Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Library General Public License for more details.
+ GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
+ You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
diff --git a/nptl/sysdeps/pthread/pthread-functions.h b/nptl/sysdeps/pthread/pthread-functions.h
index 2845346128..74d24005c3 100644
--- a/nptl/sysdeps/pthread/pthread-functions.h
+++ b/nptl/sysdeps/pthread/pthread-functions.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 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 Ulrich Drepper <drepper@redhat.com>, 2003.
@@ -90,11 +90,12 @@ struct pthread_functions
void (*ptr__pthread_cleanup_pop_restore) (struct _pthread_cleanup_buffer *,
int);
#define HAVE_PTR_NTHREADS
- int *ptr_nthreads;
+ unsigned int *ptr_nthreads;
void (*ptr___pthread_unwind) (__pthread_unwind_buf_t *)
__attribute ((noreturn)) __cleanup_fct_attribute;
void (*ptr__nptl_deallocate_tsd) (void);
int (*ptr__nptl_setxid) (struct xid_command *);
+ void (*ptr_freeres) (void);
};
/* Variable in libc.so. */
diff --git a/nptl/sysdeps/pthread/pthread.h b/nptl/sysdeps/pthread/pthread.h
index 5046a6976b..f60ecdee18 100644
--- a/nptl/sysdeps/pthread/pthread.h
+++ b/nptl/sysdeps/pthread/pthread.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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
@@ -60,24 +60,50 @@ enum
#endif
};
-/* Mutex initializers. */
-#define PTHREAD_MUTEX_INITIALIZER \
- { }
+
#ifdef __USE_GNU
-# if __WORDSIZE == 64
+/* Robust mutex or not flags. */
+enum
+{
+ PTHREAD_MUTEX_STALLED_NP,
+ PTHREAD_MUTEX_ROBUST_NP
+};
+#endif
+
+
+#ifdef __USE_UNIX98
+/* Mutex protocols. */
+enum
+{
+ PTHREAD_PRIO_NONE,
+ PTHREAD_PRIO_INHERIT,
+ PTHREAD_PRIO_PROTECT
+};
+#endif
+
+
+/* Mutex initializers. */
+#if __WORDSIZE == 64
+# define PTHREAD_MUTEX_INITIALIZER \
+ { { 0, 0, 0, 0, 0, 0, { 0, 0 } } }
+# ifdef __USE_GNU
# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
- { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
+ { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { 0, 0 } } }
# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
- { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
+ { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { 0, 0 } } }
# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
- { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
-# else
+ { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { 0, 0 } } }
+# endif
+#else
+# define PTHREAD_MUTEX_INITIALIZER \
+ { { 0, 0, 0, 0, 0, { 0 } } }
+# ifdef __USE_GNU
# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
- { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
+ { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { 0 } } }
# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
- { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
+ { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { 0 } } }
# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
- { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
+ { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { 0 } } }
# endif
#endif
@@ -93,8 +119,13 @@ 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 \
@@ -102,7 +133,7 @@ enum
PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
# else
# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
- { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
+ { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, 0 } }
# endif
# endif
#endif /* Unix98 or XOpen2K */
@@ -140,7 +171,7 @@ enum
/* Conditional variable handling. */
-#define PTHREAD_COND_INITIALIZER { }
+#define PTHREAD_COND_INITIALIZER { { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }
/* Cleanup buffers */
@@ -190,7 +221,7 @@ __BEGIN_DECLS
extern int pthread_create (pthread_t *__restrict __newthread,
__const pthread_attr_t *__restrict __attr,
void *(*__start_routine) (void *),
- void *__restrict __arg) __THROW;
+ void *__restrict __arg) __THROW __nonnull ((1, 3));
/* Terminate calling thread.
@@ -240,71 +271,78 @@ extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) __THROW;
/* Initialize thread attribute *ATTR with default attributes
(detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER,
no user-provided stack). */
-extern int pthread_attr_init (pthread_attr_t *__attr) __THROW;
+extern int pthread_attr_init (pthread_attr_t *__attr) __THROW __nonnull ((1));
/* Destroy thread attribute *ATTR. */
-extern int pthread_attr_destroy (pthread_attr_t *__attr) __THROW;
+extern int pthread_attr_destroy (pthread_attr_t *__attr)
+ __THROW __nonnull ((1));
/* Get detach state attribute. */
extern int pthread_attr_getdetachstate (__const pthread_attr_t *__attr,
- int *__detachstate) __THROW;
+ int *__detachstate)
+ __THROW __nonnull ((1, 2));
/* Set detach state attribute. */
extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
- int __detachstate) __THROW;
+ int __detachstate)
+ __THROW __nonnull ((1));
/* Get the size of the guard area created for stack overflow protection. */
extern int pthread_attr_getguardsize (__const pthread_attr_t *__attr,
- size_t *__guardsize) __THROW;
+ size_t *__guardsize)
+ __THROW __nonnull ((1, 2));
/* Set the size of the guard area created for stack overflow protection. */
extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
- size_t __guardsize) __THROW;
+ size_t __guardsize)
+ __THROW __nonnull ((1));
/* Return in *PARAM the scheduling parameters of *ATTR. */
extern int pthread_attr_getschedparam (__const pthread_attr_t *__restrict
__attr,
struct sched_param *__restrict __param)
- __THROW;
+ __THROW __nonnull ((1, 2));
/* Set scheduling parameters (priority, etc) in *ATTR according to PARAM. */
extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
__const struct sched_param *__restrict
- __param) __THROW;
+ __param) __THROW __nonnull ((1, 2));
/* Return in *POLICY the scheduling policy of *ATTR. */
extern int pthread_attr_getschedpolicy (__const pthread_attr_t *__restrict
__attr, int *__restrict __policy)
- __THROW;
+ __THROW __nonnull ((1, 2));
/* Set scheduling policy in *ATTR according to POLICY. */
extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
- __THROW;
+ __THROW __nonnull ((1));
/* Return in *INHERIT the scheduling inheritance mode of *ATTR. */
extern int pthread_attr_getinheritsched (__const pthread_attr_t *__restrict
__attr, int *__restrict __inherit)
- __THROW;
+ __THROW __nonnull ((1, 2));
/* Set scheduling inheritance mode in *ATTR according to INHERIT. */
extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
- int __inherit) __THROW;
+ int __inherit)
+ __THROW __nonnull ((1));
/* Return in *SCOPE the scheduling contention scope of *ATTR. */
extern int pthread_attr_getscope (__const pthread_attr_t *__restrict __attr,
- int *__restrict __scope) __THROW;
+ int *__restrict __scope)
+ __THROW __nonnull ((1, 2));
/* Set scheduling contention scope in *ATTR according to SCOPE. */
extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
- __THROW;
+ __THROW __nonnull ((1));
/* Return the previously set address for the stack. */
extern int pthread_attr_getstackaddr (__const pthread_attr_t *__restrict
__attr, void **__restrict __stackaddr)
- __THROW __attribute_deprecated__;
+ __THROW __nonnull ((1, 2)) __attribute_deprecated__;
/* Set the starting address of the stack of the thread to be created.
Depending on whether the stack grows up or down the value must either
@@ -312,30 +350,32 @@ extern int pthread_attr_getstackaddr (__const pthread_attr_t *__restrict
minimal size of the block must be PTHREAD_STACK_MIN. */
extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
void *__stackaddr)
- __THROW __attribute_deprecated__;
+ __THROW __nonnull ((1)) __attribute_deprecated__;
/* Return the currently used minimal stack size. */
extern int pthread_attr_getstacksize (__const pthread_attr_t *__restrict
__attr, size_t *__restrict __stacksize)
- __THROW;
+ __THROW __nonnull ((1, 2));
/* Add information about the minimum stack size needed for the thread
to be started. This size must never be less than PTHREAD_STACK_MIN
and must also not exceed the system limits. */
extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
- size_t __stacksize) __THROW;
+ size_t __stacksize)
+ __THROW __nonnull ((1));
#ifdef __USE_XOPEN2K
/* Return the previously set address for the stack. */
extern int pthread_attr_getstack (__const pthread_attr_t *__restrict __attr,
void **__restrict __stackaddr,
- size_t *__restrict __stacksize) __THROW;
+ size_t *__restrict __stacksize)
+ __THROW __nonnull ((1, 2, 3));
/* The following two interfaces are intended to replace the last two. They
require setting the address as well as the size since only setting the
address will make the implementation on some architectures impossible. */
extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
- size_t __stacksize) __THROW;
+ size_t __stacksize) __THROW __nonnull ((1));
#endif
#ifdef __USE_GNU
@@ -343,19 +383,22 @@ extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
the processors represented in CPUSET. */
extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
size_t __cpusetsize,
- __const cpu_set_t *__cpuset) __THROW;
+ __const cpu_set_t *__cpuset)
+ __THROW __nonnull ((1, 3));
/* Get bit set in CPUSET representing the processors threads created with
ATTR can run on. */
extern int pthread_attr_getaffinity_np (__const pthread_attr_t *__attr,
size_t __cpusetsize,
- cpu_set_t *__cpuset) __THROW;
+ cpu_set_t *__cpuset)
+ __THROW __nonnull ((1, 3));
/* Initialize thread attribute *ATTR with attributes corresponding to the
already running thread TH. It shall be called on unitialized ATTR
and destroyed with pthread_attr_destroy when no longer needed. */
-extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW;
+extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr)
+ __THROW __nonnull ((2));
#endif
@@ -365,13 +408,13 @@ extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW;
and *PARAM. */
extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
__const struct sched_param *__param)
- __THROW;
+ __THROW __nonnull ((3));
/* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */
extern int pthread_getschedparam (pthread_t __target_thread,
int *__restrict __policy,
struct sched_param *__restrict __param)
- __THROW;
+ __THROW __nonnull ((2, 3));
/* Set the scheduling priority for TARGET_THREAD. */
extern int pthread_setschedprio (pthread_t __target_thread, int __prio)
@@ -397,11 +440,13 @@ extern int pthread_yield (void) __THROW;
/* Limit specified thread TH to run only on the processors represented
in CPUSET. */
extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize,
- __const cpu_set_t *__cpuset) __THROW;
+ __const cpu_set_t *__cpuset)
+ __THROW __nonnull ((3));
/* Get bit set in CPUSET representing the processors TH can run on. */
extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize,
- cpu_set_t *__cpuset) __THROW;
+ cpu_set_t *__cpuset)
+ __THROW __nonnull ((3));
#endif
@@ -415,7 +460,7 @@ extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize,
The initialization functions might throw exception which is why
this function is not marked with __THROW. */
extern int pthread_once (pthread_once_t *__once_control,
- void (*__init_routine) (void));
+ void (*__init_routine) (void)) __nonnull ((1, 2));
/* Functions for handling cancellation.
@@ -527,7 +572,7 @@ class __pthread_cleanup_class
function the compiler is free to decide inlining the change when
needed or fall back on the copy which must exist somewhere
else. */
-extern inline void
+extern __inline void
__pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame)
{
if (__frame->__do_it)
@@ -652,16 +697,16 @@ extern void __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *__buf)
/* Internal interface to initiate cleanup. */
extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
- __cleanup_fct_attribute __attribute ((__noreturn__))
+ __cleanup_fct_attribute __attribute__ ((__noreturn__))
# ifndef SHARED
- __attribute ((__weak__))
+ __attribute__ ((__weak__))
# endif
;
#endif
/* Function used in the macros. */
struct __jmp_buf_tag;
-extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROW;
+extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROW;
/* Mutex handling. */
@@ -669,56 +714,123 @@ extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROW;
/* Initialize a mutex. */
extern int pthread_mutex_init (pthread_mutex_t *__mutex,
__const pthread_mutexattr_t *__mutexattr)
- __THROW;
+ __THROW __nonnull ((1));
/* Destroy a mutex. */
-extern int pthread_mutex_destroy (pthread_mutex_t *__mutex) __THROW;
+extern int pthread_mutex_destroy (pthread_mutex_t *__mutex)
+ __THROW __nonnull ((1));
/* Try locking a mutex. */
-extern int pthread_mutex_trylock (pthread_mutex_t *_mutex) __THROW;
+extern int pthread_mutex_trylock (pthread_mutex_t *__mutex)
+ __THROW __nonnull ((1));
/* Lock a mutex. */
-extern int pthread_mutex_lock (pthread_mutex_t *__mutex) __THROW;
+extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
+ __THROW __nonnull ((1));
#ifdef __USE_XOPEN2K
/* Wait until lock becomes available, or specified time passes. */
extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
__const struct timespec *__restrict
- __abstime) __THROW;
+ __abstime) __THROW __nonnull ((1, 2));
#endif
/* Unlock a mutex. */
-extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROW;
+extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
+ __THROW __nonnull ((1));
+
+
+#ifdef __USE_UNIX98
+/* Get the priority ceiling of MUTEX. */
+extern int pthread_mutex_getprioceiling (__const pthread_mutex_t *
+ __restrict __mutex,
+ int *__restrict __prioceiling)
+ __THROW __nonnull ((1, 2));
+
+/* Set the priority ceiling of MUTEX to PRIOCEILING, return old
+ priority ceiling value in *OLD_CEILING. */
+extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
+ int __prioceiling,
+ int *__restrict __old_ceiling)
+ __THROW __nonnull ((1, 3));
+#endif
+
+
+#ifdef __USE_GNU
+/* Declare the state protected by MUTEX as consistent. */
+extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex)
+ __THROW __nonnull ((1));
+#endif
/* Functions for handling mutex attributes. */
/* Initialize mutex attribute object ATTR with default attributes
(kind is PTHREAD_MUTEX_TIMED_NP). */
-extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr) __THROW;
+extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr)
+ __THROW __nonnull ((1));
/* Destroy mutex attribute object ATTR. */
-extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr) __THROW;
+extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr)
+ __THROW __nonnull ((1));
/* Get the process-shared flag of the mutex attribute ATTR. */
extern int pthread_mutexattr_getpshared (__const pthread_mutexattr_t *
__restrict __attr,
- int *__restrict __pshared) __THROW;
+ int *__restrict __pshared)
+ __THROW __nonnull ((1, 2));
/* Set the process-shared flag of the mutex attribute ATTR. */
extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
- int __pshared) __THROW;
+ int __pshared)
+ __THROW __nonnull ((1));
#ifdef __USE_UNIX98
/* Return in *KIND the mutex kind attribute in *ATTR. */
extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict
- __attr, int *__restrict __kind) __THROW;
+ __attr, int *__restrict __kind)
+ __THROW __nonnull ((1, 2));
/* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,
PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or
PTHREAD_MUTEX_DEFAULT). */
extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
- __THROW;
+ __THROW __nonnull ((1));
+
+/* Return in *PROTOCOL the mutex protocol attribute in *ATTR. */
+extern int pthread_mutexattr_getprotocol (__const pthread_mutexattr_t *
+ __restrict __attr,
+ int *__restrict __protocol)
+ __THROW __nonnull ((1, 2));
+
+/* Set the mutex protocol attribute in *ATTR to PROTOCOL (either
+ PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT). */
+extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr,
+ int __protocol)
+ __THROW __nonnull ((1));
+
+/* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR. */
+extern int pthread_mutexattr_getprioceiling (__const pthread_mutexattr_t *
+ __restrict __attr,
+ int *__restrict __prioceiling)
+ __THROW __nonnull ((1, 2));
+
+/* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING. */
+extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr,
+ int __prioceiling)
+ __THROW __nonnull ((1));
+#endif
+
+#ifdef __USE_GNU
+/* Get the robustness flag of the mutex attribute ATTR. */
+extern int pthread_mutexattr_getrobust_np (__const pthread_mutexattr_t *__attr,
+ int *__robustness)
+ __THROW __nonnull ((1, 2));
+
+/* Set the robustness flag of the mutex attribute ATTR. */
+extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr,
+ int __robustness)
+ __THROW __nonnull ((1));
#endif
@@ -729,66 +841,77 @@ extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
the default values if later is NULL. */
extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
__const pthread_rwlockattr_t *__restrict
- __attr) __THROW;
+ __attr) __THROW __nonnull ((1));
/* Destroy read-write lock RWLOCK. */
-extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock)
+ __THROW __nonnull ((1));
/* Acquire read lock for RWLOCK. */
-extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock)
+ __THROW __nonnull ((1));
/* Try to acquire read lock for RWLOCK. */
-extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
+ __THROW __nonnull ((1));
# ifdef __USE_XOPEN2K
/* Try to acquire read lock for RWLOCK or return after specfied time. */
extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
__const struct timespec *__restrict
- __abstime) __THROW;
+ __abstime) __THROW __nonnull ((1, 2));
# endif
/* Acquire write lock for RWLOCK. */
-extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
+ __THROW __nonnull ((1));
/* Try to acquire write lock for RWLOCK. */
-extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
+ __THROW __nonnull ((1));
# ifdef __USE_XOPEN2K
/* Try to acquire write lock for RWLOCK or return after specfied time. */
extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
__const struct timespec *__restrict
- __abstime) __THROW;
+ __abstime) __THROW __nonnull ((1, 2));
# endif
/* Unlock RWLOCK. */
-extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
+ __THROW __nonnull ((1));
/* Functions for handling read-write lock attributes. */
/* Initialize attribute object ATTR with default values. */
-extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr) __THROW;
+extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr)
+ __THROW __nonnull ((1));
/* Destroy attribute object ATTR. */
-extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr) __THROW;
+extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr)
+ __THROW __nonnull ((1));
/* Return current setting of process-shared attribute of ATTR in PSHARED. */
extern int pthread_rwlockattr_getpshared (__const pthread_rwlockattr_t *
__restrict __attr,
- int *__restrict __pshared) __THROW;
+ int *__restrict __pshared)
+ __THROW __nonnull ((1, 2));
/* Set process-shared attribute of ATTR to PSHARED. */
extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
- int __pshared) __THROW;
+ int __pshared)
+ __THROW __nonnull ((1));
/* Return current setting of reader/writer preference. */
extern int pthread_rwlockattr_getkind_np (__const pthread_rwlockattr_t *
__restrict __attr,
- int *__restrict __pref) __THROW;
+ int *__restrict __pref)
+ __THROW __nonnull ((1, 2));
/* Set reader/write preference. */
extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
- int __pref) __THROW;
+ int __pref) __THROW __nonnull ((1));
#endif
@@ -798,16 +921,19 @@ extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
the default values if later is NULL. */
extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
__const pthread_condattr_t *__restrict
- __cond_attr) __THROW;
+ __cond_attr) __THROW __nonnull ((1));
/* Destroy condition variable COND. */
-extern int pthread_cond_destroy (pthread_cond_t *__cond) __THROW;
+extern int pthread_cond_destroy (pthread_cond_t *__cond)
+ __THROW __nonnull ((1));
/* Wake up one thread waiting for condition variable COND. */
-extern int pthread_cond_signal (pthread_cond_t *__cond) __THROW;
+extern int pthread_cond_signal (pthread_cond_t *__cond)
+ __THROW __nonnull ((1));
/* Wake up all threads waiting for condition variables COND. */
-extern int pthread_cond_broadcast (pthread_cond_t *__cond) __THROW;
+extern int pthread_cond_broadcast (pthread_cond_t *__cond)
+ __THROW __nonnull ((1));
/* Wait for condition variable COND to be signaled or broadcast.
MUTEX is assumed to be locked before.
@@ -815,7 +941,8 @@ extern int pthread_cond_broadcast (pthread_cond_t *__cond) __THROW;
This function is a cancellation point and therefore not marked with
__THROW. */
extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
- pthread_mutex_t *__restrict __mutex);
+ pthread_mutex_t *__restrict __mutex)
+ __nonnull ((1, 2));
/* Wait for condition variable COND to be signaled or broadcast until
ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an
@@ -827,36 +954,39 @@ extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex,
__const struct timespec *__restrict
- __abstime);
+ __abstime) __nonnull ((1, 2, 3));
/* Functions for handling condition variable attributes. */
/* Initialize condition variable attribute ATTR. */
-extern int pthread_condattr_init (pthread_condattr_t *__attr) __THROW;
+extern int pthread_condattr_init (pthread_condattr_t *__attr)
+ __THROW __nonnull ((1));
/* Destroy condition variable attribute ATTR. */
-extern int pthread_condattr_destroy (pthread_condattr_t *__attr) __THROW;
+extern int pthread_condattr_destroy (pthread_condattr_t *__attr)
+ __THROW __nonnull ((1));
/* Get the process-shared flag of the condition variable attribute ATTR. */
extern int pthread_condattr_getpshared (__const pthread_condattr_t *
__restrict __attr,
- int *__restrict __pshared) __THROW;
+ int *__restrict __pshared)
+ __THROW __nonnull ((1, 2));
/* Set the process-shared flag of the condition variable attribute ATTR. */
extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
- int __pshared) __THROW;
+ int __pshared) __THROW __nonnull ((1));
#ifdef __USE_XOPEN2K
/* Get the clock selected for the conditon variable attribute ATTR. */
extern int pthread_condattr_getclock (__const pthread_condattr_t *
__restrict __attr,
__clockid_t *__restrict __clock_id)
- __THROW;
+ __THROW __nonnull ((1, 2));
/* Set the clock selected for the conditon variable attribute ATTR. */
extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
- __clockid_t __clock_id) __THROW;
-
+ __clockid_t __clock_id)
+ __THROW __nonnull ((1));
#endif
@@ -866,19 +996,23 @@ extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
/* Initialize the spinlock LOCK. If PSHARED is nonzero the spinlock can
be shared between different processes. */
extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
- __THROW;
+ __THROW __nonnull ((1));
/* Destroy the spinlock LOCK. */
-extern int pthread_spin_destroy (pthread_spinlock_t *__lock) __THROW;
+extern int pthread_spin_destroy (pthread_spinlock_t *__lock)
+ __THROW __nonnull ((1));
/* Wait until spinlock LOCK is retrieved. */
-extern int pthread_spin_lock (pthread_spinlock_t *__lock) __THROW;
+extern int pthread_spin_lock (pthread_spinlock_t *__lock)
+ __THROW __nonnull ((1));
/* Try to lock spinlock LOCK. */
-extern int pthread_spin_trylock (pthread_spinlock_t *__lock) __THROW;
+extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
+ __THROW __nonnull ((1));
/* Release spinlock LOCK. */
-extern int pthread_spin_unlock (pthread_spinlock_t *__lock) __THROW;
+extern int pthread_spin_unlock (pthread_spinlock_t *__lock)
+ __THROW __nonnull ((1));
/* Functions to handle barriers. */
@@ -887,29 +1021,36 @@ extern int pthread_spin_unlock (pthread_spinlock_t *__lock) __THROW;
opened when COUNT waiters arrived. */
extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
__const pthread_barrierattr_t *__restrict
- __attr, unsigned int __count) __THROW;
+ __attr, unsigned int __count)
+ __THROW __nonnull ((1));
/* Destroy a previously dynamically initialized barrier BARRIER. */
-extern int pthread_barrier_destroy (pthread_barrier_t *__barrier) __THROW;
+extern int pthread_barrier_destroy (pthread_barrier_t *__barrier)
+ __THROW __nonnull ((1));
/* Wait on barrier BARRIER. */
-extern int pthread_barrier_wait (pthread_barrier_t *__barrier) __THROW;
+extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
+ __THROW __nonnull ((1));
/* Initialize barrier attribute ATTR. */
-extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr) __THROW;
+extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr)
+ __THROW __nonnull ((1));
/* Destroy previously dynamically initialized barrier attribute ATTR. */
-extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr) __THROW;
+extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr)
+ __THROW __nonnull ((1));
/* Get the process-shared flag of the barrier attribute ATTR. */
extern int pthread_barrierattr_getpshared (__const pthread_barrierattr_t *
__restrict __attr,
- int *__restrict __pshared) __THROW;
+ int *__restrict __pshared)
+ __THROW __nonnull ((1, 2));
/* Set the process-shared flag of the barrier attribute ATTR. */
extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
- int __pshared) __THROW;
+ int __pshared)
+ __THROW __nonnull ((1));
#endif
@@ -922,7 +1063,8 @@ extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
DESTR_FUNCTION is not called if the value associated is NULL when
the key is destroyed. */
extern int pthread_key_create (pthread_key_t *__key,
- void (*__destr_function) (void *)) __THROW;
+ void (*__destr_function) (void *))
+ __THROW __nonnull ((1));
/* Destroy KEY. */
extern int pthread_key_delete (pthread_key_t __key) __THROW;
@@ -932,13 +1074,14 @@ extern void *pthread_getspecific (pthread_key_t __key) __THROW;
/* Store POINTER in the thread-specific data slot identified by KEY. */
extern int pthread_setspecific (pthread_key_t __key,
- __const void *__pointer) __THROW;
+ __const void *__pointer) __THROW ;
#ifdef __USE_XOPEN2K
/* Get ID of CPU-time clock for thread THREAD_ID. */
extern int pthread_getcpuclockid (pthread_t __thread_id,
- __clockid_t *__clock_id) __THROW;
+ __clockid_t *__clock_id)
+ __THROW __nonnull ((2));
#endif
@@ -957,6 +1100,16 @@ extern int pthread_atfork (void (*__prepare) (void),
void (*__parent) (void),
void (*__child) (void)) __THROW;
+
+#ifdef __USE_EXTERN_INLINES
+/* Optimizations. */
+extern __inline int
+__NTH (pthread_equal (pthread_t __thread1, pthread_t __thread2))
+{
+ return __thread1 == __thread2;
+}
+#endif
+
__END_DECLS
#endif /* pthread.h */
diff --git a/nptl/sysdeps/pthread/pthread_cond_broadcast.c b/nptl/sysdeps/pthread/pthread_cond_broadcast.c
index 1eac8ecf83..2b8b5460f4 100644
--- a/nptl/sysdeps/pthread/pthread_cond_broadcast.c
+++ b/nptl/sysdeps/pthread/pthread_cond_broadcast.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 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.
@@ -55,6 +55,12 @@ __pthread_cond_broadcast (cond)
/* Wake everybody. */
pthread_mutex_t *mut = (pthread_mutex_t *) cond->__data.__mutex;
+
+ /* XXX: Kernel so far doesn't support requeue to PI futex. */
+ if (__builtin_expect (mut->__data.__kind & PTHREAD_MUTEX_PRIO_INHERIT_NP,
+ 0))
+ goto wake_all;
+
/* lll_futex_requeue returns 0 for success and non-zero
for errors. */
if (__builtin_expect (lll_futex_requeue (&cond->__data.__futex, 1,
diff --git a/nptl/sysdeps/pthread/pthread_cond_signal.c b/nptl/sysdeps/pthread/pthread_cond_signal.c
index f5623480f8..5a9bbcad91 100644
--- a/nptl/sysdeps/pthread/pthread_cond_signal.c
+++ b/nptl/sysdeps/pthread/pthread_cond_signal.c
@@ -43,6 +43,11 @@ __pthread_cond_signal (cond)
++cond->__data.__futex;
/* Wake one. */
+ if (! __builtin_expect (lll_futex_wake_unlock (&cond->__data.__futex, 1,
+ 1, &cond->__data.__lock),
+ 0))
+ return 0;
+
lll_futex_wake (&cond->__data.__futex, 1);
}
diff --git a/nptl/sysdeps/pthread/pthread_cond_wait.c b/nptl/sysdeps/pthread/pthread_cond_wait.c
index 86669458a0..f5f5cec5a8 100644
--- a/nptl/sysdeps/pthread/pthread_cond_wait.c
+++ b/nptl/sysdeps/pthread/pthread_cond_wait.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 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.
@@ -50,10 +50,16 @@ __condvar_cleanup (void *arg)
if (cbuffer->bc_seq == cbuffer->cond->__data.__broadcast_seq)
{
/* This thread is not waiting anymore. Adjust the sequence counters
- appropriately. */
- ++cbuffer->cond->__data.__wakeup_seq;
+ appropriately. We do not increment WAKEUP_SEQ if this would
+ bump it over the value of TOTAL_SEQ. This can happen if a thread
+ was woken and then canceled. */
+ if (cbuffer->cond->__data.__wakeup_seq
+ < cbuffer->cond->__data.__total_seq)
+ {
+ ++cbuffer->cond->__data.__wakeup_seq;
+ ++cbuffer->cond->__data.__futex;
+ }
++cbuffer->cond->__data.__woken_seq;
- ++cbuffer->cond->__data.__futex;
}
cbuffer->cond->__data.__nwaiters -= 1 << COND_CLOCK_BITS;
diff --git a/nptl/sysdeps/pthread/sigfillset.c b/nptl/sysdeps/pthread/sigfillset.c
index fe58ccd53e..180607c77b 100644
--- a/nptl/sysdeps/pthread/sigfillset.c
+++ b/nptl/sysdeps/pthread/sigfillset.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 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
@@ -18,4 +18,4 @@
#include <nptl/pthreadP.h>
-#include <sysdeps/generic/sigfillset.c>
+#include <signal/sigfillset.c>
diff --git a/nptl/sysdeps/pthread/unwind-forcedunwind.c b/nptl/sysdeps/pthread/unwind-forcedunwind.c
index b0f8487086..6792d719d3 100644
--- a/nptl/sysdeps/pthread/unwind-forcedunwind.c
+++ b/nptl/sysdeps/pthread/unwind-forcedunwind.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>.
@@ -31,13 +31,18 @@ static _Unwind_Reason_Code (*libgcc_s_forcedunwind)
static _Unwind_Word (*libgcc_s_getcfa) (struct _Unwind_Context *);
void
+__attribute_noinline__
pthread_cancel_init (void)
{
void *resume, *personality, *forcedunwind, *getcfa;
void *handle;
if (__builtin_expect (libgcc_s_getcfa != NULL, 1))
- return;
+ {
+ /* Force gcc to reload all values. */
+ asm volatile ("" ::: "memory");
+ return;
+ }
handle = __libc_dlopen ("libgcc_s.so.1");
@@ -56,6 +61,10 @@ pthread_cancel_init (void)
libgcc_s_resume = resume;
libgcc_s_personality = personality;
libgcc_s_forcedunwind = forcedunwind;
+ /* Make sure libgcc_s_getcfa is written last. Otherwise,
+ pthread_cancel_init might return early even when the pointer the
+ caller is interested in is not initialized yet. */
+ atomic_write_barrier ();
libgcc_s_getcfa = getcfa;
}
@@ -64,6 +73,7 @@ _Unwind_Resume (struct _Unwind_Exception *exc)
{
if (__builtin_expect (libgcc_s_resume == NULL, 0))
pthread_cancel_init ();
+
libgcc_s_resume (exc);
}
@@ -75,6 +85,7 @@ __gcc_personality_v0 (int version, _Unwind_Action actions,
{
if (__builtin_expect (libgcc_s_personality == NULL, 0))
pthread_cancel_init ();
+
return libgcc_s_personality (version, actions, exception_class,
ue_header, context);
}
@@ -85,6 +96,7 @@ _Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop,
{
if (__builtin_expect (libgcc_s_forcedunwind == NULL, 0))
pthread_cancel_init ();
+
return libgcc_s_forcedunwind (exc, stop, stop_argument);
}
@@ -93,5 +105,6 @@ _Unwind_GetCFA (struct _Unwind_Context *context)
{
if (__builtin_expect (libgcc_s_getcfa == NULL, 0))
pthread_cancel_init ();
+
return libgcc_s_getcfa (context);
}
diff --git a/nptl/sysdeps/s390/tcb-offsets.sym b/nptl/sysdeps/s390/tcb-offsets.sym
index 237f975b25..9cfae211e0 100644
--- a/nptl/sysdeps/s390/tcb-offsets.sym
+++ b/nptl/sysdeps/s390/tcb-offsets.sym
@@ -2,5 +2,6 @@
#include <tls.h>
MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
+STACK_GUARD offsetof (tcbhead_t, stack_guard)
PID offsetof (struct pthread, pid)
TID offsetof (struct pthread, tid)
diff --git a/nptl/sysdeps/s390/tls.h b/nptl/sysdeps/s390/tls.h
index c9b991df32..8e8f86d64e 100644
--- a/nptl/sysdeps/s390/tls.h
+++ b/nptl/sysdeps/s390/tls.h
@@ -1,5 +1,5 @@
/* Definition for thread-local data handling. NPTL/s390 version.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -22,6 +22,7 @@
#include <dl-sysdep.h>
#ifndef __ASSEMBLER__
+# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
# include <stdlib.h>
@@ -32,7 +33,11 @@
typedef union dtv
{
size_t counter;
- void *pointer;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
} dtv_t;
@@ -43,9 +48,9 @@ typedef struct
dtv_t *dtv;
void *self; /* Pointer to the thread descriptor. */
int multiple_threads;
-# ifdef NEED_DL_SYSINFO
uintptr_t sysinfo;
-# endif
+ uintptr_t stack_guard;
+ int gscope_flag;
} tcbhead_t;
# ifndef __s390x__
@@ -76,11 +81,13 @@ typedef struct
/* Get the thread descriptor definition. */
# include <nptl/descr.h>
-/* This is the size of the initial TCB. */
-# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+/* This is the size of the initial TCB. Can't be just sizeof (tcbhead_t),
+ because NPTL getpid, __libc_alloca_cutoff etc. need (almost) the whole
+ struct pthread even when not linked with -lpthread. */
+# define TLS_INIT_TCB_SIZE sizeof (struct pthread)
/* Alignment requirements for the initial TCB. */
-# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
/* This is the size of the TCB. */
# define TLS_TCB_SIZE sizeof (struct pthread)
@@ -151,6 +158,43 @@ typedef struct
#define THREAD_SETMEM_NC(descr, member, idx, value) \
descr->member[idx] = (value)
+/* Set the stack guard field in TCB head. */
+#define THREAD_SET_STACK_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
+#define THREAD_COPY_STACK_GUARD(descr) \
+ ((descr)->header.stack_guard \
+ = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
+
+/* s390 doesn't have HP_TIMING_*, so for the time being
+ use stack_guard as pointer_guard. */
+#define THREAD_GET_POINTER_GUARD() \
+ THREAD_GETMEM (THREAD_SELF, header.stack_guard)
+#define THREAD_SET_POINTER_GUARD(value)
+#define THREAD_COPY_POINTER_GUARD(descr)
+
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
#endif /* __ASSEMBLER__ */
#endif /* tls.h */
diff --git a/nptl/sysdeps/sh/tcb-offsets.sym b/nptl/sysdeps/sh/tcb-offsets.sym
index 539789a817..4ad866335b 100644
--- a/nptl/sysdeps/sh/tcb-offsets.sym
+++ b/nptl/sysdeps/sh/tcb-offsets.sym
@@ -9,3 +9,4 @@ CLEANUP_JMP_BUF offsetof (struct pthread, cleanup_jmp_buf)
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)
diff --git a/nptl/sysdeps/sh/tls.h b/nptl/sysdeps/sh/tls.h
index db490ab7ee..2873fe73a8 100644
--- a/nptl/sysdeps/sh/tls.h
+++ b/nptl/sysdeps/sh/tls.h
@@ -1,5 +1,5 @@
/* Definition for thread-local data handling. NPTL/SH version.
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -23,6 +23,7 @@
# include <dl-sysdep.h>
#ifndef __ASSEMBLER__
+# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
@@ -30,13 +31,17 @@
typedef union dtv
{
size_t counter;
- void *pointer;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
} dtv_t;
typedef struct
{
dtv_t *dtv;
- void *private;
+ uintptr_t pointer_guard;
} tcbhead_t;
# define TLS_MULTIPLE_THREADS_IN_TCB 1
@@ -135,6 +140,42 @@ typedef struct
# define THREAD_SETMEM_NC(descr, member, idx, value) \
descr->member[idx] = (value)
+#define THREAD_GET_POINTER_GUARD() \
+ ({ tcbhead_t *__tcbp; \
+ __asm __volatile ("stc gbr,%0" : "=r" (__tcbp)); \
+ __tcbp->pointer_guard;})
+ #define THREAD_SET_POINTER_GUARD(value) \
+ ({ tcbhead_t *__tcbp; \
+ __asm __volatile ("stc gbr,%0" : "=r" (__tcbp)); \
+ __tcbp->pointer_guard = (value);})
+#define THREAD_COPY_POINTER_GUARD(descr) \
+ ({ tcbhead_t *__tcbp; \
+ __asm __volatile ("stc gbr,%0" : "=r" (__tcbp)); \
+ ((tcbhead_t *) (descr + 1))->pointer_guard = __tcbp->pointer_guard;})
+
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
#endif /* __ASSEMBLER__ */
#endif /* tls.h */
diff --git a/nptl/sysdeps/sparc/tcb-offsets.sym b/nptl/sysdeps/sparc/tcb-offsets.sym
index 237f975b25..923af8a5b7 100644
--- a/nptl/sysdeps/sparc/tcb-offsets.sym
+++ b/nptl/sysdeps/sparc/tcb-offsets.sym
@@ -2,5 +2,6 @@
#include <tls.h>
MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
+POINTER_GUARD offsetof (tcbhead_t, pointer_guard)
PID offsetof (struct pthread, pid)
TID offsetof (struct pthread, tid)
diff --git a/nptl/sysdeps/sparc/tls.h b/nptl/sysdeps/sparc/tls.h
index 8980f9fc0c..a008f29055 100644
--- a/nptl/sysdeps/sparc/tls.h
+++ b/nptl/sysdeps/sparc/tls.h
@@ -1,5 +1,5 @@
/* Definitions for thread-local data handling. NPTL/sparc version.
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -22,6 +22,7 @@
#include <dl-sysdep.h>
#ifndef __ASSEMBLER__
+# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
# include <stdlib.h>
@@ -31,7 +32,11 @@
typedef union dtv
{
size_t counter;
- void *pointer;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
} dtv_t;
typedef struct
@@ -41,6 +46,9 @@ typedef struct
dtv_t *dtv;
void *self;
int multiple_threads;
+ uintptr_t sysinfo;
+ uintptr_t stack_guard;
+ uintptr_t pointer_guard;
} tcbhead_t;
#else /* __ASSEMBLER__ */
@@ -64,11 +72,13 @@ typedef struct
register struct pthread *__thread_self __asm__("%g7");
-/* This is the size of the initial TCB. */
-# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+/* This is the size of the initial TCB. Can't be just sizeof (tcbhead_t),
+ because NPTL getpid, __libc_alloca_cutoff etc. need (almost) the whole
+ struct pthread even when not linked with -lpthread. */
+# define TLS_INIT_TCB_SIZE sizeof (struct pthread)
/* Alignment requirements for the initial TCB. */
-# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
/* This is the size of the TCB. */
# define TLS_TCB_SIZE sizeof (struct pthread)
@@ -119,6 +129,44 @@ register struct pthread *__thread_self __asm__("%g7");
#define THREAD_SETMEM_NC(descr, member, idx, value) \
descr->member[idx] = (value)
+/* Set the stack guard field in TCB head. */
+#define THREAD_SET_STACK_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
+# define THREAD_COPY_STACK_GUARD(descr) \
+ ((descr)->header.stack_guard \
+ = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
+
+/* Get/set the stack guard field in TCB head. */
+#define THREAD_GET_POINTER_GUARD() \
+ THREAD_GETMEM (THREAD_SELF, header.pointer_guard)
+#define THREAD_SET_POINTER_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.pointer_guard, value)
+# define THREAD_COPY_POINTER_GUARD(descr) \
+ ((descr)->header.pointer_guard = THREAD_GET_POINTER_GUARD ())
+
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
#endif /* !ASSEMBLER */
#endif /* tls.h */
diff --git a/nptl/sysdeps/unix/sysv/linux/Makefile b/nptl/sysdeps/unix/sysv/linux/Makefile
index 991398242a..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 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.
@@ -24,7 +24,8 @@ sysdep_routines += register-atfork unregister-atfork libc_pthread_init \
libpthread-sysdep_routines += pt-fork pthread_mutex_cond_lock
gen-as-const-headers += lowlevelcond.sym lowlevelrwlock.sym \
- lowlevelbarrier.sym unwindbuf.sym
+ lowlevelbarrier.sym unwindbuf.sym \
+ lowlevelrobustlock.sym pthread-pi-defines.sym
endif
ifeq ($(subdir),posix)
@@ -32,3 +33,6 @@ CFLAGS-fork.c = -D_IO_MTSAFE_IO
CFLAGS-getpid.o = -fomit-frame-pointer
CFLAGS-getpid.os = -fomit-frame-pointer
endif
+
+# Needed in both the signal and nptl subdir.
+CFLAGS-sigaction.c = -DWRAPPER_INCLUDE='<nptl/sigaction.c>'
diff --git a/nptl/sysdeps/unix/sysv/linux/aio_misc.h b/nptl/sysdeps/unix/sysv/linux/aio_misc.h
index 7b0bac75f2..406d96e865 100644
--- a/nptl/sysdeps/unix/sysv/linux/aio_misc.h
+++ b/nptl/sysdeps/unix/sysv/linux/aio_misc.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
@@ -19,9 +19,10 @@
#ifndef _AIO_MISC_H
# include_next <aio_misc.h>
+# include <limits.h>
+# include <pthread.h>
# include <signal.h>
# include <sysdep.h>
-# include <pthread.h>
# define aio_start_notify_thread __aio_start_notify_thread
# define aio_create_helper_thread __aio_create_helper_thread
@@ -36,7 +37,8 @@ __aio_start_notify_thread (void)
}
extern inline int
-__aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *), void *arg)
+__aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
+ void *arg)
{
pthread_attr_t attr;
@@ -63,5 +65,5 @@ __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *), void *arg)
(void) pthread_attr_destroy (&attr);
return ret;
-}
+}
#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
index d13d6e86a4..41a54d4b0d 100644
--- a/nptl/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
+++ b/nptl/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
@@ -1,5 +1,5 @@
/* Machine-specific pthread type layouts. Alpha version.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -43,11 +43,18 @@ typedef union
} pthread_attr_t;
+typedef struct __pthread_internal_list
+{
+ struct __pthread_internal_list *__prev;
+ struct __pthread_internal_list *__next;
+} __pthread_list_t;
+
+
/* Data structures for mutex handling. The structure of the attribute
type is deliberately not exposed. */
typedef union
{
- struct
+ struct __pthread_mutex_s
{
int __lock;
unsigned int __count;
@@ -57,6 +64,8 @@ typedef union
binary compatibility. */
int __kind;
int __spins;
+ __pthread_list_t __list;
+#define __PTHREAD_MUTEX_HAVE_PREV 1
} __data;
char __size[__SIZEOF_PTHREAD_MUTEX_T];
long int __align;
@@ -117,8 +126,9 @@ typedef union
unsigned int __nr_readers_queued;
unsigned int __nr_writers_queued;
int __writer;
-
- unsigned int __reserved[6];
+ 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;
diff --git a/nptl/sysdeps/unix/sysv/linux/alpha/clone.S b/nptl/sysdeps/unix/sysv/linux/alpha/clone.S
index eea1cbeed1..675a997e97 100644
--- a/nptl/sysdeps/unix/sysv/linux/alpha/clone.S
+++ b/nptl/sysdeps/unix/sysv/linux/alpha/clone.S
@@ -1,2 +1,9 @@
-#define RESET_PID
-#include <sysdeps/unix/sysv/linux/alpha/clone.S>
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <clone.S>
+#else
+# define RESET_PID
+# include_next <clone.S>
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h
index fd4a7ca4bb..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 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
@@ -31,6 +31,11 @@
#define FUTEX_WAKE 1
#define FUTEX_REQUEUE 3
#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
/* Initializer for compatibility lock. */
#define LLL_MUTEX_LOCK_INITIALIZER (0)
@@ -62,6 +67,15 @@
INTERNAL_SYSCALL_ERROR_P (__ret, __err)? -__ret : __ret; \
})
+#define lll_robust_mutex_dead(futexv) \
+ do \
+ { \
+ int *__futexp = &(futexv); \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ lll_futex_wake (__futexp, 1); \
+ } \
+ while (0)
+
/* Returns non-zero if error happened, zero if success. */
#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val) \
({ \
@@ -73,6 +87,20 @@
INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
})
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, \
+ (futexp), FUTEX_WAKE_OP, (nr_wake), \
+ (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+
+
static inline int __attribute__((always_inline))
__lll_mutex_trylock(int *futex)
@@ -90,7 +118,16 @@ __lll_mutex_cond_trylock(int *futex)
#define lll_mutex_cond_trylock(lock) __lll_mutex_cond_trylock (&(lock))
+static inline int __attribute__((always_inline))
+__lll_robust_mutex_trylock(int *futex, int id)
+{
+ return atomic_compare_and_exchange_val_acq (futex, id, 0) != 0;
+}
+#define lll_robust_mutex_trylock(lock, id) \
+ __lll_robust_mutex_trylock (&(lock), id)
+
extern void __lll_lock_wait (int *futex) attribute_hidden;
+extern int __lll_robust_lock_wait (int *futex) attribute_hidden;
static inline void __attribute__((always_inline))
__lll_mutex_lock(int *futex)
@@ -101,6 +138,18 @@ __lll_mutex_lock(int *futex)
#define lll_mutex_lock(futex) __lll_mutex_lock (&(futex))
+static inline int __attribute__ ((always_inline))
+__lll_robust_mutex_lock (int *futex, int id)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_lock_wait (futex);
+ return result;
+}
+#define lll_robust_mutex_lock(futex, id) \
+ __lll_robust_mutex_lock (&(futex), id)
+
+
static inline void __attribute__ ((always_inline))
__lll_mutex_cond_lock (int *futex)
{
@@ -110,8 +159,14 @@ __lll_mutex_cond_lock (int *futex)
#define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex))
+#define lll_robust_mutex_cond_lock(futex, id) \
+ __lll_robust_mutex_lock (&(futex), (id) | FUTEX_WAITERS)
+
+
extern int __lll_timedlock_wait (int *futex, const struct timespec *)
attribute_hidden;
+extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *)
+ attribute_hidden;
static inline int __attribute__ ((always_inline))
__lll_mutex_timedlock (int *futex, const struct timespec *abstime)
@@ -125,6 +180,19 @@ __lll_mutex_timedlock (int *futex, const struct timespec *abstime)
__lll_mutex_timedlock (&(futex), abstime)
+static inline int __attribute__ ((always_inline))
+__lll_robust_mutex_timedlock (int *futex, const struct timespec *abstime,
+ int id)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_timedlock_wait (futex, abstime);
+ return result;
+}
+#define lll_robust_mutex_timedlock(futex, abstime, id) \
+ __lll_robust_mutex_timedlock (&(futex), abstime, id)
+
+
static inline void __attribute__ ((always_inline))
__lll_mutex_unlock (int *futex)
{
@@ -136,6 +204,17 @@ __lll_mutex_unlock (int *futex)
static inline void __attribute__ ((always_inline))
+__lll_robust_mutex_unlock (int *futex, int mask)
+{
+ int val = atomic_exchange_rel (futex, 0);
+ if (__builtin_expect (val & mask, 0))
+ lll_futex_wake (futex, 1);
+}
+#define lll_robust_mutex_unlock(futex) \
+ __lll_robust_mutex_unlock(&(futex), FUTEX_WAITERS)
+
+
+static inline void __attribute__ ((always_inline))
__lll_mutex_unlock_force (int *futex)
{
(void) atomic_exchange_rel (futex, 0);
diff --git a/nptl/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
index f3f7718e3e..aa42768f70 100644
--- a/nptl/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -167,3 +167,9 @@ extern int __local_multiple_threads attribute_hidden;
# define NO_CANCELLATION 1
#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h b/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h
index 0bc8e048af..b639ba44af 100644
--- a/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h
+++ b/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h
@@ -3,16 +3,16 @@
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
+ You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
diff --git a/nptl/sysdeps/unix/sysv/linux/bits/posix_opt.h b/nptl/sysdeps/unix/sysv/linux/bits/posix_opt.h
index 09f3df11cb..dd0798a073 100644
--- a/nptl/sysdeps/unix/sysv/linux/bits/posix_opt.h
+++ b/nptl/sysdeps/unix/sysv/linux/bits/posix_opt.h
@@ -1,18 +1,18 @@
/* Define POSIX options for Linux.
- Copyright (C) 1996-2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1996-2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
+ You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
@@ -60,6 +60,9 @@
/* X/Open realtime support is available. */
#define _XOPEN_REALTIME 1
+/* X/Open thread realtime support is available. */
+#define _XOPEN_REALTIME_THREADS 1
+
/* XPG4.2 shared memory is supported. */
#define _XOPEN_SHM 1
@@ -79,6 +82,13 @@
/* We support user-defined stacks. */
#define _POSIX_THREAD_ATTR_STACKADDR 200112L
+/* We support priority inheritence. */
+#define _POSIX_THREAD_PRIO_INHERIT 200112L
+
+/* We support priority protection, though only for non-robust
+ mutexes. */
+#define _POSIX_THREAD_PRIO_PROTECT 200112L
+
/* We support POSIX.1b semaphores. */
#define _POSIX_SEMAPHORES 200112L
@@ -171,8 +181,4 @@
/* Typed memory objects are not available. */
#define _POSIX_TYPED_MEMORY_OBJECTS -1
-/* No support for priority inheritance or protection so far. */
-#define _POSIX_THREAD_PRIO_INHERIT -1
-#define _POSIX_THREAD_PRIO_PROTECT -1
-
#endif /* posix_opt.h */
diff --git a/nptl/sysdeps/unix/sysv/linux/configure b/nptl/sysdeps/unix/sysv/linux/configure
deleted file mode 100644
index 229414dd74..0000000000
--- a/nptl/sysdeps/unix/sysv/linux/configure
+++ /dev/null
@@ -1,3 +0,0 @@
-# Local configure fragment for sysdeps/unix/sysv/linux.
-
-DEFINES="$DEFINES -D_LIBC_REENTRANT"
diff --git a/nptl/sysdeps/unix/sysv/linux/fork.c b/nptl/sysdeps/unix/sysv/linux/fork.c
index 840974401b..98bb237c06 100644
--- a/nptl/sysdeps/unix/sysv/linux/fork.c
+++ b/nptl/sysdeps/unix/sysv/linux/fork.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -167,8 +167,11 @@ __libc_fork (void)
allp->handler->child_handler ();
/* Note that we do not have to wake any possible waiter.
- This is the only thread in the new process. */
- --allp->handler->refcntr;
+ This is the only thread in the new process. The count
+ may have been bumped up by other threads doing a fork.
+ We reset it to 1, to avoid waiting for non-existing
+ thread(s) to release the count. */
+ allp->handler->refcntr = 1;
/* XXX We could at this point look through the object pool
and mark all objects not on the __fork_handlers list as
diff --git a/nptl/sysdeps/unix/sysv/linux/fork.h b/nptl/sysdeps/unix/sysv/linux/fork.h
index d093ccc907..6458977b99 100644
--- a/nptl/sysdeps/unix/sysv/linux/fork.h
+++ b/nptl/sysdeps/unix/sysv/linux/fork.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -41,7 +41,7 @@ struct fork_handler
};
/* The single linked list of all currently registered for handlers. */
-extern struct fork_handler *__fork_handlers;
+extern struct fork_handler *__fork_handlers attribute_hidden;
/* Function to call to unregister fork handlers. */
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h
index 4d1c9450b5..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 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
@@ -43,11 +43,17 @@ typedef union
} pthread_attr_t;
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+
/* Data structures for mutex handling. The structure of the attribute
type is not exposed on purpose. */
typedef union
{
- struct
+ struct __pthread_mutex_s
{
int __lock;
unsigned int __count;
@@ -56,7 +62,11 @@ typedef union
binary compatibility. */
int __kind;
unsigned int __nusers;
- int __spins;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
} __data;
char __size[__SIZEOF_PTHREAD_MUTEX_T];
long int __align;
@@ -155,6 +165,6 @@ typedef union
/* Extra attributes for the cleanup functions. */
-#define __cleanup_fct_attribute __attribute ((regparm (1)))
+#define __cleanup_fct_attribute __attribute__ ((__regparm__ (1)))
#endif /* bits/pthreadtypes.h */
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/clone.S b/nptl/sysdeps/unix/sysv/linux/i386/clone.S
index 95c17f18e4..675a997e97 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/clone.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/clone.S
@@ -1,2 +1,9 @@
-#define RESET_PID
-#include <sysdeps/unix/sysv/linux/i386/clone.S>
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <clone.S>
+#else
+# define RESET_PID
+# include_next <clone.S>
+#endif
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 223b111083..88885b735d 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S
@@ -22,7 +22,7 @@
#ifndef UP
# define LOCK \
cmpl $0, %gs:MULTIPLE_THREADS_OFFSET; \
- je,pt 0f; \
+ je 0f; \
lock; \
0:
#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
index dc65b709a1..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 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.
@@ -41,9 +41,16 @@
.hidden __lll_mutex_lock_wait
.align 16
__lll_mutex_lock_wait:
+ cfi_startproc
pushl %edx
+ cfi_adjust_cfa_offset(4)
pushl %ebx
+ cfi_adjust_cfa_offset(4)
pushl %esi
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%edx, -8)
+ cfi_offset(%ebx, -12)
+ cfi_offset(%esi, -16)
movl $2, %edx
movl %ecx, %ebx
@@ -60,12 +67,19 @@ __lll_mutex_lock_wait:
xchgl %eax, (%ebx) /* NB: lock is implied */
testl %eax, %eax
- jnz,pn 1b
+ jnz 1b
popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
popl %edx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edx)
ret
+ cfi_endproc
.size __lll_mutex_lock_wait,.-__lll_mutex_lock_wait
@@ -75,17 +89,27 @@ __lll_mutex_lock_wait:
.hidden __lll_mutex_timedlock_wait
.align 16
__lll_mutex_timedlock_wait:
+ cfi_startproc
/* Check for a valid timeout value. */
cmpl $1000000000, 4(%edx)
jae 3f
pushl %edi
+ cfi_adjust_cfa_offset(4)
pushl %esi
+ cfi_adjust_cfa_offset(4)
pushl %ebx
+ cfi_adjust_cfa_offset(4)
pushl %ebp
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%edi, -8)
+ cfi_offset(%esi, -12)
+ cfi_offset(%ebx, -16)
+ cfi_offset(%ebp, -20)
/* Stack frame for the timespec and timeval structs. */
subl $8, %esp
+ cfi_adjust_cfa_offset(8)
movl %ecx, %ebp
movl %edx, %edi
@@ -140,12 +164,29 @@ __lll_mutex_timedlock_wait:
jnz 7f
6: addl $8, %esp
+ cfi_adjust_cfa_offset(-8)
popl %ebp
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebp)
popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
popl %edi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edi)
ret
+3: movl $EINVAL, %eax
+ ret
+
+ cfi_adjust_cfa_offset(24)
+ cfi_offset(%edi, -8)
+ cfi_offset(%esi, -12)
+ cfi_offset(%ebx, -16)
+ cfi_offset(%ebp, -20)
/* Check whether the time expired. */
7: cmpl $-ETIMEDOUT, %ecx
je 5f
@@ -157,11 +198,9 @@ __lll_mutex_timedlock_wait:
jz 6b
jmp 1b
-3: movl $EINVAL, %eax
- ret
-
5: movl $ETIMEDOUT, %eax
jmp 6b
+ cfi_endproc
.size __lll_mutex_timedlock_wait,.-__lll_mutex_timedlock_wait
#endif
@@ -200,9 +239,16 @@ lll_unlock_wake_cb:
.hidden __lll_mutex_unlock_wake
.align 16
__lll_mutex_unlock_wake:
+ cfi_startproc
pushl %ebx
+ cfi_adjust_cfa_offset(4)
pushl %ecx
+ cfi_adjust_cfa_offset(4)
pushl %edx
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%ebx, -8)
+ cfi_offset(%ecx, -12)
+ cfi_offset(%edx, -16)
movl %eax, %ebx
movl $0, (%eax)
@@ -212,9 +258,16 @@ __lll_mutex_unlock_wake:
ENTER_KERNEL
popl %edx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edx)
popl %ecx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ecx)
popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
ret
+ cfi_endproc
.size __lll_mutex_unlock_wake,.-__lll_mutex_unlock_wake
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S
new file mode 100644
index 0000000000..73d8bc4ccc
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S
@@ -0,0 +1,227 @@
+/* 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.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <pthread-errnos.h>
+#include <lowlevelrobustlock.h>
+
+ .text
+
+#ifndef LOCK
+# ifdef UP
+# define LOCK
+# else
+# define LOCK lock
+# endif
+#endif
+
+#define SYS_gettimeofday __NR_gettimeofday
+#define SYS_futex 240
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_WAITERS 0x80000000
+#define FUTEX_OWNER_DIED 0x40000000
+
+
+ .globl __lll_robust_mutex_lock_wait
+ .type __lll_robust_mutex_lock_wait,@function
+ .hidden __lll_robust_mutex_lock_wait
+ .align 16
+__lll_robust_mutex_lock_wait:
+ cfi_startproc
+ pushl %edx
+ cfi_adjust_cfa_offset(4)
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%edx, -8)
+ cfi_offset(%ebx, -12)
+ cfi_offset(%esi, -16)
+
+ movl %ecx, %ebx
+ xorl %esi, %esi /* No timeout. */
+ xorl %ecx, %ecx /* movl $FUTEX_WAIT, %ecx */
+
+4: movl %eax, %edx
+ orl $FUTEX_WAITERS, %edx
+
+ testl $FUTEX_OWNER_DIED, %eax
+ jnz 3f
+
+ cmpl %edx, %eax /* NB: %edx == 2 */
+ je 1f
+
+ LOCK
+ cmpxchgl %edx, (%ebx)
+ jnz 2f
+
+1: movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+ movl (%ebx), %eax
+
+2: test %eax, %eax
+ jne 4b
+
+ movl %gs:TID, %edx
+ orl $FUTEX_WAITERS, %edx
+ LOCK
+ cmpxchgl %edx, (%ebx)
+ jnz 4b
+ /* NB: %eax == 0 */
+
+3: popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ popl %edx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edx)
+ ret
+ cfi_endproc
+ .size __lll_robust_mutex_lock_wait,.-__lll_robust_mutex_lock_wait
+
+
+ .globl __lll_robust_mutex_timedlock_wait
+ .type __lll_robust_mutex_timedlock_wait,@function
+ .hidden __lll_robust_mutex_timedlock_wait
+ .align 16
+__lll_robust_mutex_timedlock_wait:
+ cfi_startproc
+ /* Check for a valid timeout value. */
+ cmpl $1000000000, 4(%edx)
+ jae 3f
+
+ pushl %edi
+ cfi_adjust_cfa_offset(4)
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ pushl %ebp
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%edi, -8)
+ cfi_offset(%esi, -12)
+ cfi_offset(%ebx, -16)
+ cfi_offset(%ebp, -20)
+
+ /* Stack frame for the timespec and timeval structs. */
+ subl $12, %esp
+ cfi_adjust_cfa_offset(12)
+
+ movl %ecx, %ebp
+ movl %edx, %edi
+
+1: movl %eax, 8(%esp)
+
+ /* Get current time. */
+ movl %esp, %ebx
+ xorl %ecx, %ecx
+ movl $SYS_gettimeofday, %eax
+ ENTER_KERNEL
+
+ /* Compute relative timeout. */
+ movl 4(%esp), %eax
+ movl $1000, %edx
+ mul %edx /* Milli seconds to nano seconds. */
+ movl (%edi), %ecx
+ movl 4(%edi), %edx
+ subl (%esp), %ecx
+ subl %eax, %edx
+ jns 4f
+ addl $1000000000, %edx
+ subl $1, %ecx
+4: testl %ecx, %ecx
+ js 8f /* Time is already up. */
+
+ /* Store relative timeout. */
+ movl %ecx, (%esp)
+ movl %edx, 4(%esp)
+
+ movl %ebp, %ebx
+
+ movl 8(%esp), %edx
+ movl %edx, %eax
+ orl $FUTEX_WAITERS, %edx
+
+ testl $FUTEX_OWNER_DIED, %eax
+ jnz 6f
+
+ cmpl %eax, %edx
+ je 2f
+
+ LOCK
+ cmpxchgl %edx, (%ebx)
+ movl $0, %ecx /* Must use mov to avoid changing cc. */
+ jnz 5f
+
+2:
+ /* Futex call. */
+ movl %esp, %esi
+ xorl %ecx, %ecx /* movl $FUTEX_WAIT, %ecx */
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+ movl %eax, %ecx
+
+ movl (%ebx), %eax
+
+5: testl %eax, %eax
+ jne 7f
+
+ movl %gs:TID, %edx
+ orl $FUTEX_WAITERS, %edx
+ LOCK
+ cmpxchgl %edx, (%ebx)
+ jnz 7f
+
+6: addl $12, %esp
+ cfi_adjust_cfa_offset(-12)
+ popl %ebp
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebp)
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+ popl %edi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edi)
+ ret
+
+3: movl $EINVAL, %eax
+ ret
+
+ cfi_adjust_cfa_offset(28)
+ cfi_offset(%edi, -8)
+ cfi_offset(%esi, -12)
+ cfi_offset(%ebx, -16)
+ cfi_offset(%ebp, -20)
+ /* Check whether the time expired. */
+7: cmpl $-ETIMEDOUT, %ecx
+ jne 1b
+
+8: movl $ETIMEDOUT, %eax
+ jmp 6b
+ cfi_endproc
+ .size __lll_robust_mutex_timedlock_wait,.-__lll_robust_mutex_timedlock_wait
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 114284c44c..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
@@ -82,7 +82,7 @@ pthread_barrier_wait:
#else
cmpl %edx, CURR_EVENT(%ebx)
#endif
- je,pn 8b
+ je 8b
/* Increment LEFT. If this brings the count back to the
initial count unlock the object. */
@@ -92,7 +92,7 @@ pthread_barrier_wait:
xaddl %edx, LEFT(%ebx)
subl $1, %ecx
cmpl %ecx, %edx
- jne,pt 10f
+ jne 10f
/* Release the mutex. We cannot release the lock before
waking the waiting threads since otherwise a new thread might
@@ -131,7 +131,7 @@ pthread_barrier_wait:
xaddl %edx, LEFT(%ebx)
subl $1, %ecx
cmpl %ecx, %edx
- jne,pt 5f
+ jne 5f
/* Release the mutex. We cannot release the lock before
waking the waiting threads since otherwise a new thread might
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S
index 5471c1c927..56f7be8246 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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.
@@ -21,6 +21,7 @@
#include <shlib-compat.h>
#include <lowlevelcond.h>
#include <kernel-features.h>
+#include <pthread-pi-defines.h>
#ifdef UP
# define LOCK
@@ -94,6 +95,10 @@ __pthread_cond_broadcast:
8: cmpl $-1, %edi
je 9f
+ /* XXX: The kernel so far doesn't support requeue to PI futex. */
+ testl $PI_BIT, MUTEX_KIND(%edi)
+ jne 9f
+
/* Wake up all threads. */
movl $FUTEX_CMP_REQUEUE, %ecx
movl $SYS_futex, %eax
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
index 3c5a1db59c..d0f931ff15 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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,7 +31,9 @@
#define SYS_futex 240
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
-#define FUTEX_REQUEUE 3
+#define FUTEX_WAKE_OP 5
+
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
#define EINVAL 22
@@ -79,21 +81,46 @@ __pthread_cond_signal:
addl $1, (%ebx)
/* Wake up one thread. */
- movl $FUTEX_WAKE, %ecx
+ pushl %esi
+ pushl %ebp
+ movl $FUTEX_WAKE_OP, %ecx
movl $SYS_futex, %eax
movl $1, %edx
+ movl $1, %esi
+ movl $FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, %ebp
+ /* FIXME: Until Ingo fixes 4G/4G vDSO, 6 arg syscalls are broken for
+ sysenter.
+ ENTER_KERNEL */
+ int $0x80
+ popl %ebp
+ popl %esi
+
+ /* For any kind of error, we try again with WAKE.
+ The general test also covers running on old kernels. */
+ cmpl $-4095, %eax
+ jae 7f
+
+6: xorl %eax, %eax
+ popl %edi
+ popl %ebx
+ ret
+
+7: movl $FUTEX_WAKE, %ecx
+ movl $SYS_futex, %eax
+ /* %edx should be 1 already from $FUTEX_WAKE_OP syscall.
+ movl $1, %edx */
ENTER_KERNEL
/* Unlock. Note that at this point %edi always points to
cond_lock. */
4: LOCK
subl $1, (%edi)
- jne 5f
+ je 6b
-6: xorl %eax, %eax
- popl %edi
- popl %ebx
- ret
+ /* Unlock in loop requires wakeup. */
+5: movl %edi, %eax
+ call __lll_mutex_unlock_wake
+ jmp 6b
/* Initial locking failed. */
1:
@@ -105,10 +132,6 @@ __pthread_cond_signal:
call __lll_mutex_lock_wait
jmp 2b
- /* Unlock in loop requires wakeup. */
-5: movl %edi, %eax
- call __lll_mutex_unlock_wake
- jmp 6b
.size __pthread_cond_signal, .-__pthread_cond_signal
versioned_symbol (libpthread, __pthread_cond_signal, pthread_cond_signal,
GLIBC_2_3_2)
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 699c2cb227..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 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.
@@ -406,12 +406,22 @@ __condvar_tw_cleanup:
cmpl 20(%esp), %eax
jne 3f
- addl $1, wakeup_seq(%ebx)
+ /* We increment the wakeup_seq counter only if it is lower than
+ total_seq. If this is not the case the thread was woken and
+ then canceled. In this case we ignore the signal. */
+ movl total_seq(%ebx), %eax
+ movl total_seq+4(%ebx), %edi
+ cmpl wakeup_seq+4(%ebx), %edi
+ jb 6f
+ ja 7f
+ cmpl wakeup_seq(%ebx), %eax
+ jbe 7f
+
+6: addl $1, wakeup_seq(%ebx)
adcl $0, wakeup_seq+4(%ebx)
-
addl $1, cond_futex(%ebx)
- addl $1, woken_seq(%ebx)
+7: addl $1, woken_seq(%ebx)
adcl $0, woken_seq+4(%ebx)
3: subl $(1 << clock_bits), 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 d282785151..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 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.
@@ -297,12 +297,22 @@ __condvar_w_cleanup:
cmpl 12(%esp), %eax
jne 3f
- addl $1, wakeup_seq(%ebx)
+ /* We increment the wakeup_seq counter only if it is lower than
+ total_seq. If this is not the case the thread was woken and
+ then canceled. In this case we ignore the signal. */
+ movl total_seq(%ebx), %eax
+ movl total_seq+4(%ebx), %edi
+ cmpl wakeup_seq+4(%ebx), %edi
+ jb 6f
+ ja 7f
+ cmpl wakeup_seq(%ebx), %eax
+ jbe 7f
+
+6: addl $1, wakeup_seq(%ebx)
adcl $0, wakeup_seq+4(%ebx)
-
addl $1, cond_futex(%ebx)
- addl $1, woken_seq(%ebx)
+7: addl $1, woken_seq(%ebx)
adcl $0, woken_seq+4(%ebx)
3: subl $(1 << clock_bits), cond_nwaiters(%ebx)
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 3d67329bd1..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 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.
@@ -65,9 +65,14 @@ __new_sem_post:
#endif
addl $_GLOBAL_OFFSET_TABLE_, %ebx
#if USE___THREAD
- movl %gs:0, %edx
- subl errno@gottpoff(%ebx), %edx
+# ifdef NO_TLS_DIRECT_SEG_REFS
+ movl errno@gotntpoff(%ebx), %edx
+ addl %gs:0, %edx
movl $EINVAL, (%edx)
+# else
+ movl errno@gotntpoff(%ebx), %edx
+ movl $EINVAL, %gs:(%edx)
+# endif
#else
call __errno_location@plt
movl $EINVAL, (%eax)
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 5b24476936..bf70e17fca 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -49,12 +49,12 @@ sem_timedwait:
movl (%ecx), %eax
2: testl %eax, %eax
- je,pn 1f
+ je 1f
leal -1(%eax), %edx
LOCK
cmpxchgl %edx, (%ecx)
- jne,pn 2b
+ jne 2b
xorl %eax, %eax
ret
@@ -79,10 +79,7 @@ sem_timedwait:
jae 6f
cfi_offset(3, -16) /* %ebx */
-7: call __pthread_enable_asynccancel
- movl %eax, 8(%esp)
-
- xorl %ecx, %ecx
+7: xorl %ecx, %ecx
movl %esp, %ebx
movl %ecx, %edx
movl $SYS_gettimeofday, %eax
@@ -105,6 +102,10 @@ sem_timedwait:
movl %ecx, (%esp) /* Store relative timeout. */
movl %edx, 4(%esp)
+
+ call __pthread_enable_asynccancel
+ movl %eax, 8(%esp)
+
movl 28(%esp), %ebx
xorl %ecx, %ecx
movl %esp, %esi
@@ -117,7 +118,7 @@ sem_timedwait:
call __pthread_disable_asynccancel
testl %esi, %esi
- je,pt 9f
+ je 9f
cmpl $-EWOULDBLOCK, %esi
jne 3f
@@ -128,7 +129,7 @@ sem_timedwait:
leal -1(%eax), %ecx
LOCK
cmpxchgl %ecx, (%ebx)
- jne,pn 8b
+ jne 8b
addl $12, %esp
cfi_adjust_cfa_offset(-12)
@@ -158,9 +159,14 @@ sem_timedwait:
#endif
addl $_GLOBAL_OFFSET_TABLE_, %ebx
#if USE___THREAD
- movl %gs:0, %edx
- subl errno@gottpoff(%ebx), %edx
+# 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)
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S
index a7c405d95f..fbc3b3c932 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 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.
@@ -42,7 +42,7 @@ __new_sem_trywait:
leal -1(%eax), %edx
LOCK
cmpxchgl %edx, (%ecx)
- jne,pn 2b
+ jne 2b
xorl %eax, %eax
ret
@@ -55,9 +55,14 @@ __new_sem_trywait:
#endif
addl $_GLOBAL_OFFSET_TABLE_, %ecx
#if USE___THREAD
- movl %gs:0, %edx
- subl errno@gottpoff(%ecx), %edx
+# ifdef NO_TLS_DIRECT_SEG_REFS
+ movl errno@gotntpoff(%ecx), %edx
+ addl %gs:0, %edx
movl $EAGAIN, (%edx)
+# else
+ movl errno@gotntpoff(%ecx), %edx
+ movl $EAGAIN, %gs:(%edx)
+# endif
#else
call __errno_location@plt
movl $EAGAIN, (%eax)
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 b7674dc3ba..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 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.
@@ -57,12 +57,12 @@ __new_sem_wait:
cfi_offset(6, -12) /* %esi */
3: movl (%ebx), %eax
2: testl %eax, %eax
- je,pn 1f
+ je 1f
leal -1(%eax), %edx
LOCK
cmpxchgl %edx, (%ebx)
- jne,pn 2b
+ jne 2b
xorl %eax, %eax
movl 4(%esp), %esi
@@ -73,7 +73,7 @@ __new_sem_wait:
cfi_adjust_cfa_offset(-12)
ret
- cfi_adjust_cfa_offset(8)
+ cfi_adjust_cfa_offset(12)
cfi_offset(3, -8) /* %ebx */
cfi_offset(6, -12) /* %esi */
1: call __pthread_enable_asynccancel
@@ -102,9 +102,14 @@ __new_sem_wait:
#endif
addl $_GLOBAL_OFFSET_TABLE_, %ebx
#if USE___THREAD
- movl %gs:0, %edx
- subl errno@gottpoff(%ebx), %edx
+# 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)
diff --git a/nptl/sysdeps/sparc/sparc32/jmpbuf-unwind.h b/nptl/sysdeps/unix/sysv/linux/i386/i586/lowlevelrobustlock.S
index 5cef8b1cf5..f768e16a7d 100644
--- a/nptl/sysdeps/sparc/sparc32/jmpbuf-unwind.h
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i586/lowlevelrobustlock.S
@@ -1,6 +1,6 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -17,15 +17,4 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
-
-/* We use the normal lobngjmp for unwinding. */
-#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
+#include "../i486/lowlevelrobustlock.S"
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i686/lowlevelrobustlock.S b/nptl/sysdeps/unix/sysv/linux/i386/i686/lowlevelrobustlock.S
new file mode 100644
index 0000000000..f768e16a7d
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i686/lowlevelrobustlock.S
@@ -0,0 +1,20 @@
+/* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "../i486/lowlevelrobustlock.S"
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h
index b86f11c9b4..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 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.
@@ -35,6 +35,9 @@
#define SYS_futex 240
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
/* Initializer for compatibility lock. */
@@ -65,18 +68,112 @@
#define BUSY_WAIT_NOP asm ("rep; nop")
+#define LLL_STUB_UNWIND_INFO_START \
+ ".section .eh_frame,\"a\",@progbits\n" \
+"5:\t" ".long 7f-6f # Length of Common Information Entry\n" \
+"6:\t" ".long 0x0 # CIE Identifier Tag\n\t" \
+ ".byte 0x1 # CIE Version\n\t" \
+ ".ascii \"zR\\0\" # CIE Augmentation\n\t" \
+ ".uleb128 0x1 # CIE Code Alignment Factor\n\t" \
+ ".sleb128 -4 # CIE Data Alignment Factor\n\t" \
+ ".byte 0x8 # CIE RA Column\n\t" \
+ ".uleb128 0x1 # Augmentation size\n\t" \
+ ".byte 0x1b # FDE Encoding (pcrel sdata4)\n\t" \
+ ".byte 0xc # DW_CFA_def_cfa\n\t" \
+ ".uleb128 0x4\n\t" \
+ ".uleb128 0x0\n\t" \
+ ".align 4\n" \
+"7:\t" ".long 17f-8f # FDE Length\n" \
+"8:\t" ".long 8b-5b # FDE CIE offset\n\t" \
+ ".long 1b-. # FDE initial location\n\t" \
+ ".long 4b-1b # FDE address range\n\t" \
+ ".uleb128 0x0 # Augmentation size\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x8\n\t" \
+ ".uleb128 10f-9f\n" \
+"9:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
+ ".sleb128 3b-1b\n"
+#define LLL_STUB_UNWIND_INFO_END \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x8\n\t" \
+ ".uleb128 12f-11f\n" \
+"11:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
+ ".sleb128 3b-2b\n" \
+"12:\t" ".byte 0x40 + (3b-2b-1) # DW_CFA_advance_loc\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x8\n\t" \
+ ".uleb128 16f-13f\n" \
+"13:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
+ ".sleb128 15f-14f\n\t" \
+ ".byte 0x0d # DW_OP_const4s\n" \
+"14:\t" ".4byte 3b-.\n\t" \
+ ".byte 0x1c # DW_OP_minus\n\t" \
+ ".byte 0x0d # DW_OP_const4s\n" \
+"15:\t" ".4byte 18f-.\n\t" \
+ ".byte 0x22 # DW_OP_plus\n" \
+"16:\t" ".align 4\n" \
+"17:\t" ".previous\n"
+
+/* Unwind info for
+ 1: lea ..., ...
+ 2: call ...
+ 3: jmp 18f
+ 4:
+ snippet. */
+#define LLL_STUB_UNWIND_INFO_3 \
+LLL_STUB_UNWIND_INFO_START \
+"10:\t" ".byte 0x40 + (2b-1b) # DW_CFA_advance_loc\n\t" \
+LLL_STUB_UNWIND_INFO_END
+
+/* Unwind info for
+ 1: lea ..., ...
+ 0: movl ..., ...
+ 2: call ...
+ 3: jmp 18f
+ 4:
+ snippet. */
+#define LLL_STUB_UNWIND_INFO_4 \
+LLL_STUB_UNWIND_INFO_START \
+"10:\t" ".byte 0x40 + (0b-1b) # DW_CFA_advance_loc\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x8\n\t" \
+ ".uleb128 20f-19f\n" \
+"19:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
+ ".sleb128 3b-0b\n" \
+"20:\t" ".byte 0x40 + (2b-0b) # DW_CFA_advance_loc\n\t" \
+LLL_STUB_UNWIND_INFO_END
+
+
#define lll_futex_wait(futex, val) \
- do { \
- int __ignore; \
+ ({ \
+ int __status; \
register __typeof (val) _val asm ("edx") = (val); \
__asm __volatile (LLL_EBX_LOAD \
LLL_ENTER_KERNEL \
LLL_EBX_LOAD \
- : "=a" (__ignore) \
+ : "=a" (__status) \
: "0" (SYS_futex), LLL_EBX_REG (futex), "S" (0), \
"c" (FUTEX_WAIT), "d" (_val), \
- "i" (offsetof (tcbhead_t, sysinfo))); \
- } while (0)
+ "i" (offsetof (tcbhead_t, sysinfo)) \
+ : "memory"); \
+ __status; \
+ })
+
+
+#define lll_futex_timed_wait(futex, val, timeout) \
+ ({ \
+ int __status; \
+ register __typeof (val) _val asm ("edx") = (val); \
+ __asm __volatile (LLL_EBX_LOAD \
+ LLL_ENTER_KERNEL \
+ LLL_EBX_LOAD \
+ : "=a" (__status) \
+ : "0" (SYS_futex), LLL_EBX_REG (futex), "S" (timeout), \
+ "c" (FUTEX_WAIT), "d" (_val), \
+ "i" (offsetof (tcbhead_t, sysinfo)) \
+ : "memory"); \
+ __status; \
+ })
#define lll_futex_wake(futex, nr) \
@@ -121,6 +218,16 @@ extern int __lll_mutex_unlock_wake (int *__futex)
ret; })
+#define lll_robust_mutex_trylock(futex, id) \
+ ({ int ret; \
+ __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1" \
+ : "=a" (ret), "=m" (futex) \
+ : "r" (id), "m" (futex), \
+ "0" (LLL_MUTEX_LOCK_INITIALIZER) \
+ : "memory"); \
+ ret; })
+
+
#define lll_mutex_cond_trylock(futex) \
({ int ret; \
__asm __volatile (LOCK_INSTR "cmpxchgl %2, %1" \
@@ -137,18 +244,39 @@ extern int __lll_mutex_unlock_wake (int *__futex)
"jnz _L_mutex_lock_%=\n\t" \
".subsection 1\n\t" \
".type _L_mutex_lock_%=,@function\n" \
- "_L_mutex_lock_%=:\n\t" \
- "leal %2, %%ecx\n\t" \
- "call __lll_mutex_lock_wait\n\t" \
- "jmp 1f\n\t" \
- ".size _L_mutex_lock_%=,.-_L_mutex_lock_%=\n" \
+ "_L_mutex_lock_%=:\n" \
+ "1:\tleal %2, %%ecx\n" \
+ "2:\tcall __lll_mutex_lock_wait\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_mutex_lock_%=, 4b-1b\n\t" \
".previous\n" \
- "1:" \
+ LLL_STUB_UNWIND_INFO_3 \
+ "18:" \
: "=a" (ignore1), "=c" (ignore2), "=m" (futex) \
: "0" (0), "1" (1), "m" (futex) \
: "memory"); })
+#define lll_robust_mutex_lock(futex, id) \
+ ({ int result, ignore; \
+ __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
+ "jnz _L_robust_mutex_lock_%=\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_mutex_lock_%=,@function\n" \
+ "_L_robust_mutex_lock_%=:\n" \
+ "1:\tleal %2, %%ecx\n" \
+ "2:\tcall __lll_robust_mutex_lock_wait\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_robust_mutex_lock_%=, 4b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_3 \
+ "18:" \
+ : "=a" (result), "=c" (ignore), "=m" (futex) \
+ : "0" (0), "1" (id), "m" (futex) \
+ : "memory"); \
+ result; })
+
+
/* Special version of lll_mutex_lock which causes the unlock function to
always wakeup waiters. */
#define lll_mutex_cond_lock(futex) \
@@ -157,32 +285,54 @@ extern int __lll_mutex_unlock_wake (int *__futex)
"jnz _L_mutex_cond_lock_%=\n\t" \
".subsection 1\n\t" \
".type _L_mutex_cond_lock_%=,@function\n" \
- "_L_mutex_cond_lock_%=:\n\t" \
- "leal %2, %%ecx\n\t" \
- "call __lll_mutex_lock_wait\n\t" \
- "jmp 1f\n\t" \
- ".size _L_mutex_cond_lock_%=,.-_L_mutex_cond_lock_%=\n" \
+ "_L_mutex_cond_lock_%=:\n" \
+ "1:\tleal %2, %%ecx\n" \
+ "2:\tcall __lll_mutex_lock_wait\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_mutex_cond_lock_%=, 4b-1b\n\t" \
".previous\n" \
- "1:" \
+ LLL_STUB_UNWIND_INFO_3 \
+ "18:" \
: "=a" (ignore1), "=c" (ignore2), "=m" (futex) \
: "0" (0), "1" (2), "m" (futex) \
: "memory"); })
+#define lll_robust_mutex_cond_lock(futex, id) \
+ ({ int result, ignore; \
+ __asm __volatile (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
+ "jnz _L_robust_mutex_cond_lock_%=\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_mutex_cond_lock_%=,@function\n" \
+ "_L_robust_mutex_cond_lock_%=:\n" \
+ "1:\tleal %2, %%ecx\n" \
+ "2:\tcall __lll_robust_mutex_lock_wait\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_robust_mutex_cond_lock_%=, 4b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_3 \
+ "18:" \
+ : "=a" (result), "=c" (ignore), "=m" (futex) \
+ : "0" (0), "1" (id | FUTEX_WAITERS), "m" (futex) \
+ : "memory"); \
+ result; })
+
+
#define lll_mutex_timedlock(futex, timeout) \
({ int result, ignore1, ignore2; \
__asm __volatile (LOCK_INSTR "cmpxchgl %1, %3\n\t" \
"jnz _L_mutex_timedlock_%=\n\t" \
".subsection 1\n\t" \
".type _L_mutex_timedlock_%=,@function\n" \
- "_L_mutex_timedlock_%=:\n\t" \
- "leal %3, %%ecx\n\t" \
- "movl %7, %%edx\n\t" \
- "call __lll_mutex_timedlock_wait\n\t" \
- "jmp 1f\n\t" \
- ".size _L_mutex_timedlock_%=,.-_L_mutex_timedlock_%=\n"\
+ "_L_mutex_timedlock_%=:\n" \
+ "1:\tleal %3, %%ecx\n" \
+ "0:\tmovl %7, %%edx\n" \
+ "2:\tcall __lll_mutex_timedlock_wait\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_mutex_timedlock_%=, 4b-1b\n\t" \
".previous\n" \
- "1:" \
+ LLL_STUB_UNWIND_INFO_4 \
+ "18:" \
: "=a" (result), "=c" (ignore1), "=&d" (ignore2), \
"=m" (futex) \
: "0" (0), "1" (1), "m" (futex), "m" (timeout) \
@@ -190,24 +340,95 @@ extern int __lll_mutex_unlock_wake (int *__futex)
result; })
+#define lll_robust_mutex_timedlock(futex, timeout, id) \
+ ({ int result, ignore1, ignore2; \
+ __asm __volatile (LOCK_INSTR "cmpxchgl %1, %3\n\t" \
+ "jnz _L_robust_mutex_timedlock_%=\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_mutex_timedlock_%=,@function\n" \
+ "_L_robust_mutex_timedlock_%=:\n" \
+ "1:\tleal %3, %%ecx\n" \
+ "0:\tmovl %7, %%edx\n" \
+ "2:\tcall __lll_robust_mutex_timedlock_wait\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_robust_mutex_timedlock_%=, 4b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_4 \
+ "18:" \
+ : "=a" (result), "=c" (ignore1), "=&d" (ignore2), \
+ "=m" (futex) \
+ : "0" (0), "1" (id), "m" (futex), "m" (timeout) \
+ : "memory"); \
+ result; })
+
+
#define lll_mutex_unlock(futex) \
(void) ({ int ignore; \
- __asm __volatile (LOCK_INSTR "subl $1,%0\n\t" \
+ __asm __volatile (LOCK_INSTR "subl $1, %0\n\t" \
"jne _L_mutex_unlock_%=\n\t" \
".subsection 1\n\t" \
".type _L_mutex_unlock_%=,@function\n" \
- "_L_mutex_unlock_%=:\n\t" \
- "leal %0, %%eax\n\t" \
- "call __lll_mutex_unlock_wake\n\t" \
- "jmp 1f\n\t" \
- ".size _L_mutex_unlock_%=,.-_L_mutex_unlock_%=\n" \
+ "_L_mutex_unlock_%=:\n" \
+ "1:\tleal %0, %%eax\n" \
+ "2:\tcall __lll_mutex_unlock_wake\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_mutex_unlock_%=, 4b-1b\n\t" \
".previous\n" \
- "1:" \
+ LLL_STUB_UNWIND_INFO_3 \
+ "18:" \
: "=m" (futex), "=&a" (ignore) \
: "m" (futex) \
: "memory"); })
+#define lll_robust_mutex_unlock(futex) \
+ (void) ({ int ignore; \
+ __asm __volatile (LOCK_INSTR "andl %2, %0\n\t" \
+ "jne _L_robust_mutex_unlock_%=\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_mutex_unlock_%=,@function\n" \
+ "_L_robust_mutex_unlock_%=:\n\t" \
+ "1:\tleal %0, %%eax\n" \
+ "2:\tcall __lll_mutex_unlock_wake\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_robust_mutex_unlock_%=, 4b-1b\n\t"\
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_3 \
+ "18:" \
+ : "=m" (futex), "=&a" (ignore) \
+ : "i" (FUTEX_WAITERS), "m" (futex) \
+ : "memory"); })
+
+
+#define lll_robust_mutex_dead(futex) \
+ (void) ({ int __ignore; \
+ register int _nr asm ("edx") = 1; \
+ __asm __volatile (LOCK_INSTR "orl %5, (%2)\n\t" \
+ LLL_EBX_LOAD \
+ LLL_ENTER_KERNEL \
+ LLL_EBX_LOAD \
+ : "=a" (__ignore) \
+ : "0" (SYS_futex), LLL_EBX_REG (&(futex)), \
+ "c" (FUTEX_WAKE), "d" (_nr), \
+ "i" (FUTEX_OWNER_DIED), \
+ "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)
@@ -250,7 +471,7 @@ extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
# define lll_trylock(futex) \
({ unsigned char ret; \
__asm __volatile ("cmpl $0, %%gs:%P5\n\t" \
- "je,pt 0f\n\t" \
+ "je 0f\n\t" \
"lock\n" \
"0:\tcmpxchgl %2, %1; setne %0" \
: "=a" (ret), "=m" (futex) \
@@ -264,19 +485,20 @@ extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
# define lll_lock(futex) \
(void) ({ int ignore1, ignore2; \
__asm __volatile ("cmpl $0, %%gs:%P6\n\t" \
- "je,pt 0f\n\t" \
+ "je 0f\n\t" \
"lock\n" \
"0:\tcmpxchgl %1, %2\n\t" \
- "jnz _L_mutex_lock_%=\n\t" \
+ "jnz _L_lock_%=\n\t" \
".subsection 1\n\t" \
- ".type _L_mutex_lock_%=,@function\n" \
- "_L_mutex_lock_%=:\n\t" \
- "leal %2, %%ecx\n\t" \
- "call __lll_mutex_lock_wait\n\t" \
- "jmp 1f\n\t" \
- ".size _L_mutex_lock_%=,.-_L_mutex_lock_%=\n" \
+ ".type _L_lock_%=,@function\n" \
+ "_L_lock_%=:\n" \
+ "1:\tleal %2, %%ecx\n" \
+ "2:\tcall __lll_mutex_lock_wait\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_lock_%=, 4b-1b\n\t" \
".previous\n" \
- "1:" \
+ LLL_STUB_UNWIND_INFO_3 \
+ "18:" \
: "=a" (ignore1), "=c" (ignore2), "=m" (futex) \
: "0" (0), "1" (1), "m" (futex), \
"i" (offsetof (tcbhead_t, multiple_threads)) \
@@ -286,19 +508,20 @@ extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
# define lll_unlock(futex) \
(void) ({ int ignore; \
__asm __volatile ("cmpl $0, %%gs:%P3\n\t" \
- "je,pt 0f\n\t" \
+ "je 0f\n\t" \
"lock\n" \
- "0:\tsubl $1,%0\n\t" \
- "jne _L_mutex_unlock_%=\n\t" \
+ "0:\tsubl $1,%0\n\t" \
+ "jne _L_unlock_%=\n\t" \
".subsection 1\n\t" \
- ".type _L_mutex_unlock_%=,@function\n" \
- "_L_mutex_unlock_%=:\n\t" \
- "leal %0, %%eax\n\t" \
- "call __lll_mutex_unlock_wake\n\t" \
- "jmp 1f\n\t" \
- ".size _L_mutex_unlock_%=,.-_L_mutex_unlock_%=\n" \
+ ".type _L_unlock_%=,@function\n" \
+ "_L_unlock_%=:\n" \
+ "1:\tleal %0, %%eax\n" \
+ "2:\tcall __lll_mutex_unlock_wake\n" \
+ "3:\tjmp 18f\n\t" \
+ "4:\t.size _L_unlock_%=, 4b-1b\n\t" \
".previous\n" \
- "1:" \
+ LLL_STUB_UNWIND_INFO_3 \
+ "18:" \
: "=m" (futex), "=&a" (ignore) \
: "m" (futex), \
"i" (offsetof (tcbhead_t, multiple_threads)) \
@@ -325,12 +548,13 @@ extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
"1:\tmovl %1, %%eax\n\t" \
LLL_ENTER_KERNEL \
"cmpl $0, (%%ebx)\n\t" \
- "jne,pn 1b\n\t" \
+ "jne 1b\n\t" \
LLL_EBX_LOAD \
: "=&a" (__ignore) \
: "i" (SYS_futex), LLL_EBX_REG (&tid), "S" (0), \
"c" (FUTEX_WAIT), "d" (_tid), \
- "i" (offsetof (tcbhead_t, sysinfo))); \
+ "i" (offsetof (tcbhead_t, sysinfo)) \
+ : "memory"); \
} while (0)
extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/not-cancel.h b/nptl/sysdeps/unix/sysv/linux/i386/not-cancel.h
index cc3282fbdd..6557359b43 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/not-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/i386/not-cancel.h
@@ -1,5 +1,5 @@
/* Uncancelable versions of cancelable interfaces. Linux/NPTL version.
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
@@ -26,13 +26,21 @@ extern int __close_nocancel (int) attribute_hidden;
extern int __read_nocancel (int, void *, size_t) attribute_hidden;
extern int __write_nocancel (int, const void *, size_t) attribute_hidden;
extern pid_t __waitpid_nocancel (pid_t, int *, int) attribute_hidden;
+extern int __openat_nocancel (int fd, const char *fname, int oflag,
+ mode_t mode) attribute_hidden;
+extern int __openat64_nocancel (int fd, const char *fname, int oflag,
+ mode_t mode) attribute_hidden;
#else
-#define __open_nocancel(name, ...) __open (name, __VA_ARGS__)
-#define __close_nocancel(fd) __close (fd)
-#define __read_nocancel(fd, buf, len) __read (fd, buf, len)
-#define __write_nocancel(fd, buf, len) __write (fd, buf, len)
-#define __waitpid_nocancel(pid, stat_loc, options) \
+# define __open_nocancel(name, ...) __open (name, __VA_ARGS__)
+# define __close_nocancel(fd) __close (fd)
+# define __read_nocancel(fd, buf, len) __read (fd, buf, len)
+# define __write_nocancel(fd, buf, len) __write (fd, buf, len)
+# define __waitpid_nocancel(pid, stat_loc, options) \
__waitpid (pid, stat_loc, options)
+# define __openat_nocancel(fd, fname, oflag, mode) \
+ openat (fd, fname, oflag, mode)
+# define __openat64_nocancel(fd, fname, oflag, mode) \
+ openat64 (fd, fname, oflag, mode)
#endif
/* Uncancelable open. */
@@ -41,6 +49,16 @@ extern pid_t __waitpid_nocancel (pid_t, int *, int) attribute_hidden;
#define open_not_cancel_2(name, flags) \
__open_nocancel (name, flags)
+/* Uncancelable openat. */
+#define openat_not_cancel(fd, fname, oflag, mode) \
+ __openat_nocancel (fd, fname, oflag, mode)
+#define openat_not_cancel_3(fd, fname, oflag) \
+ __openat_nocancel (fd, fname, oflag, 0)
+#define openat64_not_cancel(fd, fname, oflag, mode) \
+ __openat64_nocancel (fd, fname, oflag, mode)
+#define openat64_not_cancel_3(fd, fname, oflag) \
+ __openat64_nocancel (fd, fname, oflag, 0)
+
/* Uncancelable close. */
#define close_not_cancel(fd) \
__close_nocancel (fd)
@@ -73,3 +91,15 @@ extern pid_t __waitpid_nocancel (pid_t, int *, int) attribute_hidden;
# define waitpid_not_cancel(pid, stat_loc, options) \
INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
#endif
+
+/* Uncancelable pause. */
+#define pause_not_cancel() \
+ __pause_nocancel ()
+
+/* Uncancelable nanosleep. */
+#define nanosleep_not_cancel(requested_time, remaining) \
+ __nanosleep_nocancel (requested_time, remaining)
+
+/* Uncancelable sigsuspend. */
+#define sigsuspend_not_cancel(set) \
+ __sigsuspend_nocancel (set)
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/smp.h b/nptl/sysdeps/unix/sysv/linux/i386/smp.h
new file mode 100644
index 0000000000..f68a0c0758
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/i386/smp.h
@@ -0,0 +1,56 @@
+/* Determine whether the host has multiple processors. Linux version.
+ Copyright (C) 1996, 2002, 2004, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/utsname.h>
+#include <not-cancel.h>
+
+/* Test whether the machine has more than one processor. This is not the
+ best test but good enough. More complicated tests would require `malloc'
+ which is not available at that time. */
+static inline int
+is_smp_system (void)
+{
+ union
+ {
+ struct utsname uts;
+ char buf[512];
+ } u;
+ char *cp;
+
+ /* Try reading the number using `sysctl' first. */
+ if (uname (&u.uts) == 0)
+ cp = u.uts.version;
+ else
+ {
+ /* This was not successful. Now try reading the /proc filesystem. */
+ int fd = open_not_cancel_2 ("/proc/sys/kernel/version", O_RDONLY);
+ if (__builtin_expect (fd, 0) == -1
+ || read_not_cancel (fd, u.buf, sizeof (u.buf)) <= 0)
+ /* This also didn't work. We give up and say it's a UP machine. */
+ u.buf[0] = '\0';
+
+ close_not_cancel_no_status (fd);
+ cp = u.buf;
+ }
+
+ return strstr (cp, "SMP") != NULL;
+}
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
index 8142455781..d60dcd33d5 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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 Jakub Jelinek <jakub@redhat.com>, 2002.
@@ -29,7 +29,6 @@
# define PSEUDO(name, syscall_name, args) \
.text; \
ENTRY (name) \
- L(name##START): \
cmpl $0, %gs:MULTIPLE_THREADS_OFFSET; \
jne L(pseudo_cancel); \
.type __##syscall_name##_nocancel,@function; \
@@ -51,258 +50,11 @@
POPSTATE_##args \
cmpl $-4095, %eax; \
jae SYSCALL_ERROR_LABEL; \
- L(pseudo_end): \
- \
- /* Create unwinding information for the syscall wrapper. */ \
- .section .eh_frame,"a",@progbits; \
- L(STARTFRAME): \
- /* Length of the CIE. */ \
- .long L(ENDCIE)-L(STARTCIE); \
- L(STARTCIE): \
- /* CIE ID. */ \
- .long 0; \
- /* Version number. */ \
- .byte 1; \
- /* NUL-terminated augmentation string. */ \
- AUGMENTATION_STRING; \
- /* Code alignment factor. */ \
- .uleb128 1; \
- /* Data alignment factor. */ \
- .sleb128 -4; \
- /* Return address register column. */ \
- .byte 8; \
- /* Optional augmentation parameter. */ \
- AUGMENTATION_PARAM \
- /* Start of the table initialization. */ \
- .byte 0xc; /* DW_CFA_def_cfa */ \
- .uleb128 4; \
- .uleb128 4; \
- .byte 0x88; /* DW_CFA_offset, column 0x8 */ \
- .uleb128 1; \
- .align 4; \
- L(ENDCIE): \
- /* Length of the FDE. */ \
- .long L(ENDFDE)-L(STARTFDE); \
- L(STARTFDE): \
- /* CIE pointer. */ \
- .long L(STARTFDE)-L(STARTFRAME); \
- /* Start address of the code. */ \
- START_SYMBOL_REF (name); \
- /* Length of the code. */ \
- .long L(name##END)-L(name##START); \
- /* Augmentation data. */ \
- AUGMENTATION_PARAM_FDE \
- /* The rest of the code depends on the number of parameters the syscall \
- takes. */ \
- EH_FRAME_##args(name); \
- .align 4; \
- L(ENDFDE): \
- .previous
-
-# ifdef SHARED
-/* NUL-terminated augmentation string. Note "z" means there is an
- augmentation value later on. */
-# define AUGMENTATION_STRING .string "zR"
-# define AUGMENTATION_PARAM \
- /* Augmentation value length. */ \
- .uleb128 1; \
- /* Encoding: DW_EH_PE_pcrel + DW_EH_PE_sdata4. */ \
- .byte 0x1b;
-# define AUGMENTATION_PARAM_FDE \
- /* No augmentation data. */ \
- .uleb128 0;
-# define START_SYMBOL_REF(name) \
- /* PC-relative start address of the code. */ \
- .long L(name##START)-.
-# else
-/* No augmentation. */
-# define AUGMENTATION_STRING .ascii "\0"
-# define AUGMENTATION_PARAM /* nothing */
-# define AUGMENTATION_PARAM_FDE /* nothing */
-# define START_SYMBOL_REF(name) \
- /* Absolute start address of the code. */ \
- .long L(name##START)
-# endif
-
-/* Callframe description for syscalls without parameters. This is very
- simple. The only place the stack pointer is changed is when the old
- cancellation state value is saved. */
-# define EH_FRAME_0(name) \
- .byte 0x40+L(PUSHSTATE)-L(name##START); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 8; \
- .byte 0x40+L(POPSTATE)-L(PUSHSTATE); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 4
-
-/* For syscalls with one and two parameters the code is the same as for
- those which take no parameter. */
-# define EH_FRAME_1(name) \
- .byte 0x40+L(SAVEBX1)-L(name##START); /* DW_CFA_advance_loc+N */ \
- .byte 9; /* DW_CFA_register */ \
- .uleb128 3; /* %ebx */ \
- .uleb128 2; /* %edx */ \
- .byte 0x40+L(RESTBX1)-L(SAVEBX1); /* DW_CFA_advance_loc+N */ \
- .byte 0xc3; /* DW_CFA_restore %ebx */ \
- .byte 0x40+L(PUSHSTATE)-L(RESTBX1); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 8; \
- .byte 0x40+L(SAVEBX2)-L(PUSHSTATE); /* DW_CFA_advance_loc+N */ \
- .byte 9; /* DW_CFA_register */ \
- .uleb128 3; /* %ebx */ \
- .uleb128 2; /* %edx */ \
- .byte 0x40+L(RESTBX2)-L(SAVEBX2); /* DW_CFA_advance_loc+N */ \
- .byte 0xc3; /* DW_CFA_restore %ebx */ \
- .byte 0x40+L(POPSTATE)-L(RESTBX2); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 4
-
-# define EH_FRAME_2(name) EH_FRAME_1 (name)
-
-/* For syscalls with three parameters the stack pointer is changed
- also to save the content of the %ebx register. */
-# define EH_FRAME_3(name) \
- .byte 0x40+L(PUSHBX1)-L(name##START); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 8; \
- .byte 0x83; /* DW_CFA_offset %ebx */ \
- .uleb128 2; \
- .byte 0x40+L(POPBX1)-L(PUSHBX1); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 4; \
- .byte 0xc3; /* DW_CFA_restore %ebx */ \
- .byte 0x40+L(PUSHSTATE)-L(POPBX1); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 8; \
- .byte 0x40+L(PUSHBX2)-L(PUSHSTATE); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 12; \
- .byte 0x83; /* DW_CFA_offset %ebx */ \
- .uleb128 3; \
- .byte 0x40+L(POPBX2)-L(PUSHBX2); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 8; \
- .byte 0xc3; /* DW_CFA_restore %ebx */ \
- .byte 0x40+L(POPSTATE)-L(POPBX2); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 4
-
-/* With four parameters the syscall wrappers have to save %ebx and %esi. */
-# define EH_FRAME_4(name) \
- .byte 0x40+L(PUSHSI1)-L(name##START); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 8; \
- .byte 0x86; /* DW_CFA_offset %esi */ \
- .uleb128 2; \
- .byte 0x40+L(PUSHBX1)-L(PUSHSI1); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 12; \
- .byte 0x83; /* DW_CFA_offset %ebx */ \
- .uleb128 3; \
- .byte 0x40+L(POPBX1)-L(PUSHBX1); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 8; \
- .byte 0xc3; /* DW_CFA_restore %ebx */ \
- .byte 0x40+L(POPSI1)-L(POPBX1); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 4; \
- .byte 0xc6; /* DW_CFA_restore %esi */ \
- .byte 0x40+L(PUSHSTATE)-L(POPSI1); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 8; \
- .byte 0x40+L(PUSHSI2)-L(PUSHSTATE); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 12; \
- .byte 0x86; /* DW_CFA_offset %esi */ \
- .uleb128 3; \
- .byte 0x40+L(PUSHBX2)-L(PUSHSI2); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 16; \
- .byte 0x83; /* DW_CFA_offset %ebx */ \
- .uleb128 4; \
- .byte 0x40+L(POPBX2)-L(PUSHBX2); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 12; \
- .byte 0xc3; /* DW_CFA_restore %ebx */ \
- .byte 0x40+L(POPSI2)-L(POPBX2); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 8; \
- .byte 0xc6; /* DW_CFA_restore %esi */ \
- .byte 0x40+L(POPSTATE)-L(POPSI2); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 4
-
-/* With five parameters the syscall wrappers have to save %ebx, %esi,
- and %edi. */
-# define EH_FRAME_5(name) \
- .byte 0x40+L(PUSHDI1)-L(name##START); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 8; \
- .byte 0x87; /* DW_CFA_offset %edi */ \
- .uleb128 2; \
- .byte 0x40+L(PUSHSI1)-L(PUSHDI1); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 12; \
- .byte 0x86; /* DW_CFA_offset %esi */ \
- .uleb128 3; \
- .byte 0x40+L(PUSHBX1)-L(PUSHSI1); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 16; \
- .byte 0x83; /* DW_CFA_offset %ebx */ \
- .uleb128 4; \
- .byte 0x40+L(POPBX1)-L(PUSHBX1); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 12; \
- .byte 0xc3; /* DW_CFA_restore %ebx */ \
- .byte 0x40+L(POPSI1)-L(POPBX1); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 8; \
- .byte 0xc6; /* DW_CFA_restore %esi */ \
- .byte 0x40+L(POPDI1)-L(POPSI1); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 4; \
- .byte 0xc7; /* DW_CFA_restore %edi */ \
- .byte 0x40+L(PUSHSTATE)-L(POPDI1); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 8; \
- .byte 0x40+L(PUSHDI2)-L(PUSHSTATE); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 12; \
- .byte 0x87; /* DW_CFA_offset %edi */ \
- .uleb128 3; \
- .byte 0x40+L(PUSHSI2)-L(PUSHDI2); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 16; \
- .byte 0x86; /* DW_CFA_offset %esi */ \
- .uleb128 4; \
- .byte 0x40+L(PUSHBX2)-L(PUSHSI2); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 20; \
- .byte 0x83; /* DW_CFA_offset %ebx */ \
- .uleb128 5; \
- .byte 0x40+L(POPBX2)-L(PUSHBX2); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 16; \
- .byte 0xc3; /* DW_CFA_restore %ebx */ \
- .byte 0x40+L(POPSI2)-L(POPBX2); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 12; \
- .byte 0xc6; /* DW_CFA_restore %esi */ \
- .byte 0x40+L(POPDI2)-L(POPSI2); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 8; \
- .byte 0xc7; /* DW_CFA_restore %edi */ \
- .byte 0x40+L(POPSTATE)-L(POPDI2); /* DW_CFA_advance_loc+N */ \
- .byte 14; /* DW_CFA_def_cfa_offset */ \
- .uleb128 4
-
-
-# undef ASM_SIZE_DIRECTIVE
-# define ASM_SIZE_DIRECTIVE(name) L(name##END): .size name,.-name;
+ L(pseudo_end):
# define SAVE_OLDTYPE_0 movl %eax, %ecx;
# define SAVE_OLDTYPE_1 SAVE_OLDTYPE_0
-# define SAVE_OLDTYPE_2 pushl %eax; L(PUSHSTATE):
+# define SAVE_OLDTYPE_2 pushl %eax; cfi_adjust_cfa_offset (4);
# define SAVE_OLDTYPE_3 SAVE_OLDTYPE_2
# define SAVE_OLDTYPE_4 SAVE_OLDTYPE_2
# define SAVE_OLDTYPE_5 SAVE_OLDTYPE_2
@@ -313,11 +65,13 @@
# define _PUSHCARGS_0 /* No arguments to push. */
# define _POPCARGS_0 /* No arguments to pop. */
-# define PUSHCARGS_1 movl %ebx, %edx; L(SAVEBX2): PUSHCARGS_0
+# define PUSHCARGS_1 movl %ebx, %edx; cfi_register (ebx, edx); PUSHCARGS_0
# define DOCARGS_1 _DOARGS_1 (4)
-# define POPCARGS_1 POPCARGS_0; movl %edx, %ebx; L(RESTBX2):
-# define _PUSHCARGS_1 pushl %ebx; L(PUSHBX2): _PUSHCARGS_0
-# define _POPCARGS_1 _POPCARGS_0; popl %ebx; L(POPBX2):
+# define POPCARGS_1 POPCARGS_0; movl %edx, %ebx; cfi_restore (ebx);
+# define _PUSHCARGS_1 pushl %ebx; cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (ebx, 0); _PUSHCARGS_0
+# define _POPCARGS_1 _POPCARGS_0; popl %ebx; \
+ cfi_adjust_cfa_offset (-4); cfi_restore (ebx);
# define PUSHCARGS_2 PUSHCARGS_1
# define DOCARGS_2 _DOARGS_2 (12)
@@ -334,14 +88,18 @@
# define PUSHCARGS_4 _PUSHCARGS_4
# define DOCARGS_4 _DOARGS_4 (28)
# define POPCARGS_4 _POPCARGS_4
-# define _PUSHCARGS_4 pushl %esi; L(PUSHSI2): _PUSHCARGS_3
-# define _POPCARGS_4 _POPCARGS_3; popl %esi; L(POPSI2):
+# define _PUSHCARGS_4 pushl %esi; cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (esi, 0); _PUSHCARGS_3
+# define _POPCARGS_4 _POPCARGS_3; popl %esi; \
+ cfi_adjust_cfa_offset (-4); cfi_restore (esi);
# define PUSHCARGS_5 _PUSHCARGS_5
# define DOCARGS_5 _DOARGS_5 (36)
# define POPCARGS_5 _POPCARGS_5
-# define _PUSHCARGS_5 pushl %edi; L(PUSHDI2): _PUSHCARGS_4
-# define _POPCARGS_5 _POPCARGS_4; popl %edi; L(POPDI2):
+# define _PUSHCARGS_5 pushl %edi; cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (edi, 0); _PUSHCARGS_4
+# define _POPCARGS_5 _POPCARGS_4; popl %edi; \
+ cfi_adjust_cfa_offset (-4); cfi_restore (edi);
# ifdef IS_IN_libpthread
# define CENABLE call __pthread_enable_asynccancel;
@@ -356,9 +114,11 @@
# error Unsupported library
# endif
# define POPSTATE_0 \
- pushl %eax; L(PUSHSTATE): movl %ecx, %eax; CDISABLE; popl %eax; L(POPSTATE):
+ pushl %eax; cfi_adjust_cfa_offset (4); movl %ecx, %eax; \
+ CDISABLE; popl %eax; cfi_adjust_cfa_offset (-4);
# define POPSTATE_1 POPSTATE_0
-# define POPSTATE_2 xchgl (%esp), %eax; CDISABLE; popl %eax; L(POPSTATE):
+# define POPSTATE_2 xchgl (%esp), %eax; CDISABLE; popl %eax; \
+ cfi_adjust_cfa_offset (-4);
# define POPSTATE_3 POPSTATE_2
# define POPSTATE_4 POPSTATE_3
# define POPSTATE_5 POPSTATE_4
@@ -377,3 +137,9 @@
# define NO_CANCELLATION 1
#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/vfork.S b/nptl/sysdeps/unix/sysv/linux/i386/vfork.S
index 52336102c7..37f0842051 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/vfork.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/vfork.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1999,2002,2004,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,10 +16,17 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <tcb-offsets.h>
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <vfork.S>
+#else
+
+# include <tcb-offsets.h>
/* Save the PID value. */
-#define SAVE_PID \
+# define SAVE_PID \
movl %gs:PID, %edx; \
movl %edx, %eax; \
negl %eax; \
@@ -28,11 +35,11 @@
1: movl %eax, %gs:PID
/* Restore the old PID value in the parent. */
-#define RESTORE_PID \
+# define RESTORE_PID \
testl %eax, %eax; \
je 1f; \
movl %edx, %gs:PID; \
1:
-
-#include <sysdeps/unix/sysv/linux/i386/vfork.S>
+# include_next <vfork.S>
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S b/nptl/sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S
index 1ceb210c2f..a1120d4d72 100644
--- a/nptl/sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S
+++ b/nptl/sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
The GNU C Library is free software; you can redistribute it and/or
@@ -102,6 +102,9 @@ LEAF(__ia64_longjmp)
;;
ld8.nta r20=[r2],16 // b4
ld8.nta r21=[r3],16 // b5
+#ifdef PTR_DEMANGLE
+ PTR_DEMANGLE (r16, r24)
+#endif
;;
ld8.nta r11=[r2],16 // ar.pfs
ld8.nta r22=[r3],56 // ar.lc
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h
index afb8800ac9..892769dca4 100644
--- a/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h
+++ b/nptl/sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 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 Jakub Jelinek <jakub@redhat.com>, 2003.
@@ -43,11 +43,18 @@ typedef union
} pthread_attr_t;
+typedef struct __pthread_internal_list
+{
+ struct __pthread_internal_list *__prev;
+ struct __pthread_internal_list *__next;
+} __pthread_list_t;
+
+
/* Data structures for mutex handling. The structure of the attribute
type is not exposed on purpose. */
typedef union
{
- struct
+ struct __pthread_mutex_s
{
int __lock;
unsigned int __count;
@@ -57,6 +64,8 @@ typedef union
binary compatibility. */
int __kind;
int __spins;
+ __pthread_list_t __list;
+#define __PTHREAD_MUTEX_HAVE_PREV 1
} __data;
char __size[__SIZEOF_PTHREAD_MUTEX_T];
long int __align;
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/clone2.S b/nptl/sysdeps/unix/sysv/linux/ia64/clone2.S
index 8664056f27..91f28bab37 100644
--- a/nptl/sysdeps/unix/sysv/linux/ia64/clone2.S
+++ b/nptl/sysdeps/unix/sysv/linux/ia64/clone2.S
@@ -1,2 +1,9 @@
-#define RESET_PID
-#include <sysdeps/unix/sysv/linux/ia64/clone2.S>
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <clone2.S>
+#else
+# define RESET_PID
+# include_next <clone2.S>
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/createthread.c b/nptl/sysdeps/unix/sysv/linux/ia64/createthread.c
index 8ac06e8101..cd5f8137d5 100644
--- a/nptl/sysdeps/unix/sysv/linux/ia64/createthread.c
+++ b/nptl/sysdeps/unix/sysv/linux/ia64/createthread.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>.
@@ -18,7 +18,7 @@
02111-1307 USA. */
/* Value passed to 'clone' for initialization of the thread register. */
-#define TLS_VALUE (pd + 1)
+#define TLS_VALUE ((char *) pd + TLS_PRE_TCB_SIZE)
#define ARCH_CLONE __clone2
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h b/nptl/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h
index af835c44b1..525b622a68 100644
--- a/nptl/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h
+++ b/nptl/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h
@@ -1,5 +1,5 @@
/* System-specific settings for dynamic linker code. IA-64 version.
- Copyright (C) 2003, 2004 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
@@ -57,7 +57,7 @@ extern int _dl_sysinfo_break attribute_hidden;
".body\n\t" \
"break 0x100000;\n\t" \
"br.ret.sptk.many b6;\n\t" \
- ".endp _dl_sysinfo_break" \
+ ".endp _dl_sysinfo_break\n\t" \
".previous");
#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/jmpbuf-unwind.h b/nptl/sysdeps/unix/sysv/linux/ia64/jmpbuf-unwind.h
deleted file mode 100644
index c6ef5f7fbd..0000000000
--- a/nptl/sysdeps/unix/sysv/linux/ia64/jmpbuf-unwind.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* 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.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- ({ uintptr_t _cfa = (uintptr_t) _Unwind_GetCFA (_context) - (_adj); \
- (_cfa < (uintptr_t)(((long *)(_jmpbuf))[0]) - (_adj) \
- || (_cfa == (uintptr_t)(((long *)(_jmpbuf))[0]) - (_adj) \
- && (uintptr_t) _Unwind_GetBSP (_context) - (_adj) \
- >= (uintptr_t)(((long *)(_jmpbuf))[17]) - (_adj))); \
- })
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t)(_address) - (_adj) < (uintptr_t)(((long *)_jmpbuf)[0]) - (_adj))
-
-/* We use a longjmp() which can cross from the alternate signal-stack
- to the normal stack. */
-extern void __libc_unwind_longjmp (sigjmp_buf env, int val)
- __attribute__ ((noreturn));
-hidden_proto (__libc_unwind_longjmp)
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h
index e13358ffef..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 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.
@@ -31,6 +31,11 @@
#define FUTEX_WAKE 1
#define FUTEX_REQUEUE 3
#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
/* Delay in spinlock loop. */
#define BUSY_WAIT_NOP asm ("hint @pause")
@@ -53,6 +58,15 @@
_r10 == -1 ? -_retval : _retval; \
})
+#define lll_robust_mutex_dead(futexv) \
+do \
+ { \
+ int *__futexp = &(futexv); \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ DO_INLINE_SYSCALL(futex, 3, (long) __futexp, FUTEX_WAKE, 1); \
+ } \
+while (0)
+
/* Returns non-zero if error happened, zero if success. */
#define lll_futex_requeue(ftx, nr_wake, nr_move, mutex, val) \
({ \
@@ -62,18 +76,34 @@
_r10 == -1; \
})
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(ftx, nr_wake, nr_wake2, ftx2) \
+({ \
+ DO_INLINE_SYSCALL(futex, 6, (long) (ftx), FUTEX_WAKE_OP, \
+ (int) (nr_wake), (int) (nr_wake2), (long) (ftx2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ _r10 == -1; \
+})
+
#define __lll_mutex_trylock(futex) \
(atomic_compare_and_exchange_val_acq (futex, 1, 0) != 0)
#define lll_mutex_trylock(futex) __lll_mutex_trylock (&(futex))
+#define __lll_robust_mutex_trylock(futex, id) \
+ (atomic_compare_and_exchange_val_acq (futex, id, 0) != 0)
+#define lll_robust_mutex_trylock(futex, id) \
+ __lll_robust_mutex_trylock (&(futex), id)
+
+
#define __lll_mutex_cond_trylock(futex) \
(atomic_compare_and_exchange_val_acq (futex, 2, 0) != 0)
#define lll_mutex_cond_trylock(futex) __lll_mutex_cond_trylock (&(futex))
extern void __lll_lock_wait (int *futex) attribute_hidden;
+extern int __lll_robust_lock_wait (int *futex) attribute_hidden;
#define __lll_mutex_lock(futex) \
@@ -85,6 +115,18 @@ extern void __lll_lock_wait (int *futex) attribute_hidden;
#define lll_mutex_lock(futex) __lll_mutex_lock (&(futex))
+#define __lll_robust_mutex_lock(futex, id) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (atomic_compare_and_exchange_bool_acq (__futex, id, 0) != 0) \
+ __val = __lll_robust_lock_wait (__futex); \
+ __val; \
+ })
+#define lll_robust_mutex_lock(futex, id) __lll_robust_mutex_lock (&(futex), id)
+
+
#define __lll_mutex_cond_lock(futex) \
((void) ({ \
int *__futex = (futex); \
@@ -94,8 +136,24 @@ extern void __lll_lock_wait (int *futex) attribute_hidden;
#define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex))
+#define __lll_robust_mutex_cond_lock(futex, id) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ int __id = (id) | FUTEX_WAITERS; \
+ \
+ if (atomic_compare_and_exchange_bool_acq (__futex, __id, 0) != 0) \
+ __val = __lll_robust_lock_wait (__futex); \
+ __val; \
+ })
+#define lll_robust_mutex_cond_lock(futex, id) \
+ __lll_robust_mutex_cond_lock (&(futex), id)
+
+
extern int __lll_timedlock_wait (int *futex, const struct timespec *)
attribute_hidden;
+extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *)
+ attribute_hidden;
#define __lll_mutex_timedlock(futex, abstime) \
@@ -111,6 +169,19 @@ extern int __lll_timedlock_wait (int *futex, const struct timespec *)
__lll_mutex_timedlock (&(futex), abstime)
+#define __lll_robust_mutex_timedlock(futex, abstime, id) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (atomic_compare_and_exchange_bool_acq (__futex, id, 0) != 0) \
+ __val = __lll_robust_timedlock_wait (__futex, abstime); \
+ __val; \
+ })
+#define lll_robust_mutex_timedlock(futex, abstime, id) \
+ __lll_robust_mutex_timedlock (&(futex), abstime, id)
+
+
#define __lll_mutex_unlock(futex) \
((void) ({ \
int *__futex = (futex); \
@@ -123,6 +194,18 @@ extern int __lll_timedlock_wait (int *futex, const struct timespec *)
__lll_mutex_unlock(&(futex))
+#define __lll_robust_mutex_unlock(futex) \
+ ((void) ({ \
+ int *__futex = (futex); \
+ int __val = atomic_exchange_rel (__futex, 0); \
+ \
+ if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \
+ lll_futex_wake (__futex, 1); \
+ }))
+#define lll_robust_mutex_unlock(futex) \
+ __lll_robust_mutex_unlock(&(futex))
+
+
#define __lll_mutex_unlock_force(futex) \
((void) ({ \
int *__futex = (futex); \
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/pt-initfini.c b/nptl/sysdeps/unix/sysv/linux/ia64/pt-initfini.c
index b7d4e57945..b6d2cec0d0 100644
--- a/nptl/sysdeps/unix/sysv/linux/ia64/pt-initfini.c
+++ b/nptl/sysdeps/unix/sysv/linux/ia64/pt-initfini.c
@@ -1,5 +1,5 @@
/* Special .init and .fini section support for ia64. NPTL version.
- Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2002, 2003, 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
@@ -38,7 +38,6 @@
#include <stddef.h>
-#ifdef HAVE_INITFINI_ARRAY
__asm__ ("\n\
#include \"defs.h\"\n\
@@ -49,95 +48,3 @@ __asm__ ("\n\
.xdata8 \".init_array\",@fptr(__pthread_initialize_minimal_internal)\n\
/*@_init_PROLOG_ENDS*/\n\
");
-
-#else
-
-__asm__ ("\n\
-\n\
-#include \"defs.h\"\n\
-\n\
-/*@HEADER_ENDS*/\n\
-\n\
-/*@_init_PROLOG_BEGINS*/\n\
- .section .init\n\
- .align 16\n\
- .global _init#\n\
- .proc _init#\n\
-_init:\n\
- .prologue\n\
- .save ar.pfs, r34\n\
- alloc r34 = ar.pfs, 0, 3, 0, 0\n\
- .vframe r32\n\
- mov r32 = r12\n\
- .save rp, r33\n\
- mov r33 = b0\n\
- .body\n\
- adds r12 = -16, r12\n\
- ;;\n\
- st8 [r12] = gp, -16\n\
- br.call.sptk.many b0 = __pthread_initialize_minimal_internal# ;;\n\
- ;;\n\
- adds r12 = 16, r12\n\
- ;;\n\
- ld8 gp = [r12]\n\
- ;;\n\
- .endp _init#\n\
-\n\
-/*@_init_PROLOG_ENDS*/\n\
-\n\
-/*@_init_EPILOG_BEGINS*/\n\
- .section .init\n\
- .proc _init#\n\
- .prologue\n\
- .save ar.pfs, r34\n\
- .vframe r32\n\
- .save rp, r33\n\
- .body\n\
- mov r12 = r32\n\
- mov ar.pfs = r34\n\
- mov b0 = r33\n\
- br.ret.sptk.many b0\n\
- .endp _init#\n\
-/*@_init_EPILOG_ENDS*/\n\
-\n\
-/*@_fini_PROLOG_BEGINS*/\n\
- .section .fini\n\
- .align 16\n\
- .global _fini#\n\
- .proc _fini#\n\
-_fini:\n\
- .prologue\n\
- .save ar.pfs, r34\n\
- alloc r34 = ar.pfs, 0, 3, 0, 0\n\
- .vframe r32\n\
- mov r32 = r12\n\
- .save rp, r33\n\
- mov r33 = b0\n\
- .body\n\
- adds r12 = -16, r12\n\
- ;;\n\
- .endp _fini#\n\
-\n\
-/*@_fini_PROLOG_ENDS*/\n\
-\n\
-/*@_fini_EPILOG_BEGINS*/\n\
- .section .fini\n\
- .proc _fini#\n\
- .prologue\n\
- .save ar.pfs, r34\n\
- .vframe r32\n\
- .save rp, r33\n\
- .body\n\
- mov r12 = r32\n\
- mov ar.pfs = r34\n\
- mov b0 = r33\n\
- br.ret.sptk.many b0\n\
- .endp _fini#\n\
-\n\
-/*@_fini_EPILOG_ENDS*/\n\
-\n\
-/*@TRAILER_BEGINS*/\n\
- .weak __gmon_start__#\n\
-");
-
-#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
index 63aaa96eb0..c4d52860dd 100644
--- a/nptl/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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 Jakub Jelinek <jakub@redhat.com>, 2002.
@@ -220,3 +220,9 @@ __GC_##name: \
# define NO_CANCELLATION 1
#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/unwind-forcedunwind.c b/nptl/sysdeps/unix/sysv/linux/ia64/unwind-forcedunwind.c
index fb44b426bc..d0c77a62e6 100644
--- a/nptl/sysdeps/unix/sysv/linux/ia64/unwind-forcedunwind.c
+++ b/nptl/sysdeps/unix/sysv/linux/ia64/unwind-forcedunwind.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>.
@@ -34,5 +34,6 @@ _Unwind_GetBSP (struct _Unwind_Context *context)
{
if (__builtin_expect (libgcc_s_getbsp == NULL, 0))
pthread_cancel_init ();
+
return libgcc_s_getbsp (context);
}
diff --git a/nptl/sysdeps/unix/sysv/linux/kernel-features.h b/nptl/sysdeps/unix/sysv/linux/kernel-features.h
new file mode 100644
index 0000000000..162d73e388
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/kernel-features.h
@@ -0,0 +1,6 @@
+#include_next <kernel-features.h>
+
+/* NPTL can always assume all clone thread flags work. */
+#ifndef __ASSUME_CLONE_THREAD_FLAGS
+# define __ASSUME_CLONE_THREAD_FLAGS 1
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c b/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
index 3d1c021819..714ad49428 100644
--- a/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
+++ b/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 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.
@@ -19,7 +19,7 @@
#include <unistd.h>
#include <list.h>
-#include "fork.h"
+#include <fork.h>
#include <dl-sysdep.h>
#include <tls.h>
#include <string.h>
@@ -57,3 +57,11 @@ __libc_pthread_init (ptr, reclaim, functions)
return &__libc_multiple_threads;
#endif
}
+
+#ifdef SHARED
+libc_freeres_fn (freeres_libptread)
+{
+ if (__libc_pthread_functions.ptr_freeres != NULL)
+ __libc_pthread_functions.ptr_freeres ();
+}
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c b/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c
new file mode 100644
index 0000000000..30ef991bd0
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c
@@ -0,0 +1,113 @@
+/* Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <sys/time.h>
+#include <pthreadP.h>
+
+
+int
+__lll_robust_lock_wait (int *futex)
+{
+ int oldval = *futex;
+ int tid = THREAD_GETMEM (THREAD_SELF, tid);
+
+ /* If the futex changed meanwhile try locking again. */
+ if (oldval == 0)
+ goto try;
+
+ do
+ {
+ if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
+ return oldval;
+
+ int newval = oldval | FUTEX_WAITERS;
+ if (oldval != newval
+ && atomic_compare_and_exchange_bool_acq (futex, newval, oldval))
+ continue;
+
+ lll_futex_wait (futex, newval);
+
+ try:
+ ;
+ }
+ while ((oldval = atomic_compare_and_exchange_val_acq (futex,
+ tid | FUTEX_WAITERS,
+ 0)) != 0);
+ return 0;
+}
+
+
+int
+__lll_robust_timedlock_wait (int *futex, const struct timespec *abstime)
+{
+ /* Reject invalid timeouts. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ int tid = THREAD_GETMEM (THREAD_SELF, tid);
+ int oldval = *futex;
+
+ /* If the futex changed meanwhile try locking again. */
+ if (oldval == 0)
+ goto try;
+
+ do
+ {
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* Wait. */
+ if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
+ return oldval;
+
+ int newval = oldval | FUTEX_WAITERS;
+ if (oldval != newval
+ && atomic_compare_and_exchange_bool_acq (futex, newval, oldval))
+ continue;
+
+ lll_futex_timed_wait (futex, newval, &rt);
+
+ try:
+ ;
+ }
+ while ((oldval = atomic_compare_and_exchange_val_acq (futex,
+ tid | FUTEX_WAITERS,
+ 0)) != 0);
+
+ return 0;
+}
diff --git a/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.sym b/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.sym
new file mode 100644
index 0000000000..2f1e9da52b
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.sym
@@ -0,0 +1,6 @@
+#include <stddef.h>
+#include <pthreadP.h>
+
+--
+
+TID offsetof (struct pthread, tid)
diff --git a/nptl/sysdeps/unix/sysv/linux/mq_notify.c b/nptl/sysdeps/unix/sysv/linux/mq_notify.c
index e9c2b6e79a..2ec11bf686 100644
--- a/nptl/sysdeps/unix/sysv/linux/mq_notify.c
+++ b/nptl/sysdeps/unix/sysv/linux/mq_notify.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contribute by Ulrich Drepper <drepper@redhat.com>, 2004.
@@ -283,5 +283,5 @@ mq_notify (mqd_t mqdes, const struct sigevent *notification)
}
#else
-# include <sysdeps/generic/mq_notify.c>
+# include <rt/mq_notify.c>
#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
new file mode 100644
index 0000000000..ab95fb57ee
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h
@@ -0,0 +1,90 @@
+/* Minimum guaranteed maximum values for system limits. Linux/PPC version.
+ Copyright (C) 1993-1998,2000,2002-2004,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* The kernel header pollutes the namespace with the NR_OPEN symbol
+ and defines LINK_MAX although filesystems have different maxima. A
+ similar thing is true for OPEN_MAX: the limit can be changed at
+ runtime and therefore the macro must not be defined. Remove this
+ after including the header if necessary. */
+#ifndef NR_OPEN
+# define __undef_NR_OPEN
+#endif
+#ifndef LINK_MAX
+# define __undef_LINK_MAX
+#endif
+#ifndef OPEN_MAX
+# define __undef_OPEN_MAX
+#endif
+
+/* The kernel sources contain a file with all the needed information. */
+#include <linux/limits.h>
+
+/* Have to remove NR_OPEN? */
+#ifdef __undef_NR_OPEN
+# undef NR_OPEN
+# undef __undef_NR_OPEN
+#endif
+/* Have to remove LINK_MAX? */
+#ifdef __undef_LINK_MAX
+# undef LINK_MAX
+# undef __undef_LINK_MAX
+#endif
+/* Have to remove OPEN_MAX? */
+#ifdef __undef_OPEN_MAX
+# undef OPEN_MAX
+# undef __undef_OPEN_MAX
+#endif
+
+/* The number of data keys per process. */
+#define _POSIX_THREAD_KEYS_MAX 128
+/* This is the value this implementation supports. */
+#define PTHREAD_KEYS_MAX 1024
+
+/* Controlling the iterations of destructors for thread-specific data. */
+#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
+/* Number of iterations this implementation does. */
+#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
+
+/* The number of threads per process. */
+#define _POSIX_THREAD_THREADS_MAX 64
+/* We have no predefined limit on the number of threads. */
+#undef PTHREAD_THREADS_MAX
+
+/* Maximum amount by which a process can descrease its asynchronous I/O
+ priority level. */
+#define AIO_PRIO_DELTA_MAX 20
+
+/* Minimum size for a thread. At least two pages for systems with 64k
+ pages. */
+#define PTHREAD_STACK_MIN 131072
+
+/* Maximum number of timer expiration overruns. */
+#define DELAYTIMER_MAX 2147483647
+
+/* Maximum tty name length. */
+#define TTY_NAME_MAX 32
+
+/* Maximum login name length. This is arbitrary. */
+#define LOGIN_NAME_MAX 256
+
+/* Maximum host name length. */
+#define HOST_NAME_MAX 64
+
+/* Maximum message queue priority level. */
+#define MQ_PRIO_MAX 32768
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
index 90c0695697..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 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.
@@ -58,11 +58,25 @@ typedef union
} pthread_attr_t;
+#if __WORDSIZE == 64
+typedef struct __pthread_internal_list
+{
+ struct __pthread_internal_list *__prev;
+ struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+
/* Data structures for mutex handling. The structure of the attribute
type is deliberately not exposed. */
typedef union
{
- struct
+ struct __pthread_mutex_s
{
int __lock;
unsigned int __count;
@@ -73,10 +87,18 @@ typedef union
/* KIND must stay at this position in the structure to maintain
binary compatibility. */
int __kind;
-#if __WORDSIZE != 64
+#if __WORDSIZE == 64
+ int __spins;
+ __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV 1
+#else
unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
#endif
- int __spins;
} __data;
char __size[__SIZEOF_PTHREAD_MUTEX_T];
long int __align;
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
index 2bee000730..0136b97595 100644
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Paul Mackerras <paulus@au.ibm.com>, 2003.
@@ -13,7 +13,7 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Libr \ary; if not, write to the Free
+ License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
@@ -33,6 +33,11 @@
#define FUTEX_WAKE 1
#define FUTEX_REQUEUE 3
#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
/* Initializer for compatibility lock. */
#define LLL_MUTEX_LOCK_INITIALIZER (0)
@@ -67,6 +72,17 @@
INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
})
+#define lll_robust_mutex_dead(futexv) \
+ do \
+ { \
+ INTERNAL_SYSCALL_DECL (__err); \
+ int *__futexp = &(futexv); \
+ \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ INTERNAL_SYSCALL (futex, __err, 4, __futexp, FUTEX_WAKE, 1, 0); \
+ } \
+ while (0)
+
/* Returns non-zero if error happened, zero if success. */
#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val) \
({ \
@@ -79,16 +95,43 @@
INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
})
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, \
+ (futexp), FUTEX_WAKE_OP, (nr_wake), \
+ (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
#ifdef UP
# define __lll_acq_instr ""
# define __lll_rel_instr ""
#else
# define __lll_acq_instr "isync"
-# define __lll_rel_instr "sync"
+# ifdef _ARCH_PWR4
+/*
+ * Newer powerpc64 processors support the new "light weight" sync (lwsync)
+ * So if the build is using -mcpu=[power4,power5,power5+,970] we can
+ * safely use lwsync.
+ */
+# define __lll_rel_instr "lwsync"
+# else
+/*
+ * Older powerpc32 processors don't support the new "light weight"
+ * sync (lwsync). So the only safe option is to use normal sync
+ * for all powerpc32 applications.
+ */
+# define __lll_rel_instr "sync"
+# endif
#endif
-/* Set *futex to 1 if it is 0, atomically. Returns the old value */
-#define __lll_trylock(futex) \
+/* Set *futex to ID if it is 0, atomically. Returns the old value */
+#define __lll_robust_trylock(futex, id) \
({ int __val; \
__asm __volatile ("1: lwarx %0,0,%2\n" \
" cmpwi 0,%0,0\n" \
@@ -97,31 +140,26 @@
" bne- 1b\n" \
"2: " __lll_acq_instr \
: "=&r" (__val), "=m" (*futex) \
- : "r" (futex), "r" (1), "m" (*futex) \
+ : "r" (futex), "r" (id), "m" (*futex) \
: "cr0", "memory"); \
__val; \
})
+#define lll_robust_mutex_trylock(lock, id) __lll_robust_trylock (&(lock), id)
+
+/* Set *futex to 1 if it is 0, atomically. Returns the old value */
+#define __lll_trylock(futex) __lll_robust_trylock (futex, 1)
+
#define lll_mutex_trylock(lock) __lll_trylock (&(lock))
/* Set *futex to 2 if it is 0, atomically. Returns the old value */
-#define __lll_cond_trylock(futex) \
- ({ int __val; \
- __asm __volatile ("1: lwarx %0,0,%2\n" \
- " cmpwi 0,%0,0\n" \
- " bne 2f\n" \
- " stwcx. %3,0,%2\n" \
- " bne- 1b\n" \
- "2: " __lll_acq_instr \
- : "=&r" (__val), "=m" (*futex) \
- : "r" (futex), "r" (2), "m" (*futex) \
- : "cr0", "memory"); \
- __val; \
- })
+#define __lll_cond_trylock(futex) __lll_robust_trylock (futex, 2)
+
#define lll_mutex_cond_trylock(lock) __lll_cond_trylock (&(lock))
extern void __lll_lock_wait (int *futex) attribute_hidden;
+extern int __lll_robust_lock_wait (int *futex) attribute_hidden;
#define lll_mutex_lock(lock) \
(void) ({ \
@@ -131,6 +169,16 @@ extern void __lll_lock_wait (int *futex) attribute_hidden;
__lll_lock_wait (__futex); \
})
+#define lll_robust_mutex_lock(lock, id) \
+ ({ \
+ int *__futex = &(lock); \
+ int __val = 0; \
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \
+ 0), 0)) \
+ __val = __lll_robust_lock_wait (__futex); \
+ __val; \
+ })
+
#define lll_mutex_cond_lock(lock) \
(void) ({ \
int *__futex = &(lock); \
@@ -139,8 +187,22 @@ extern void __lll_lock_wait (int *futex) attribute_hidden;
__lll_lock_wait (__futex); \
})
+#define lll_robust_mutex_cond_lock(lock, id) \
+ ({ \
+ int *__futex = &(lock); \
+ int __val = 0; \
+ int __id = id | FUTEX_WAITERS; \
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, __id,\
+ 0), 0)) \
+ __val = __lll_robust_lock_wait (__futex); \
+ __val; \
+ })
+
+
extern int __lll_timedlock_wait
(int *futex, const struct timespec *) attribute_hidden;
+extern int __lll_robust_timedlock_wait
+ (int *futex, const struct timespec *) attribute_hidden;
#define lll_mutex_timedlock(lock, abstime) \
({ \
@@ -152,6 +214,16 @@ extern int __lll_timedlock_wait
__val; \
})
+#define lll_robust_mutex_timedlock(lock, abstime, id) \
+ ({ \
+ int *__futex = &(lock); \
+ int __val = 0; \
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \
+ 0), 0)) \
+ __val = __lll_robust_timedlock_wait (__futex, abstime); \
+ __val; \
+ })
+
#define lll_mutex_unlock(lock) \
((void) ({ \
int *__futex = &(lock); \
@@ -160,6 +232,14 @@ extern int __lll_timedlock_wait
lll_futex_wake (__futex, 1); \
}))
+#define lll_robust_mutex_unlock(lock) \
+ ((void) ({ \
+ int *__futex = &(lock); \
+ int __val = atomic_exchange_rel (__futex, 0); \
+ if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \
+ lll_futex_wake (__futex, 1); \
+ }))
+
#define lll_mutex_unlock_force(lock) \
((void) ({ \
int *__futex = &(lock); \
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S
index e19579e842..675a997e97 100644
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S
@@ -1,3 +1,9 @@
-#define RESET_PID
-#include <tcb-offsets.h>
-#include <sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S>
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <clone.S>
+#else
+# define RESET_PID
+# include_next <clone.S>
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
index 7f5ba4aeef..3752abc870 100644
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
@@ -1,5 +1,5 @@
/* Cancellable system call stubs. Linux/PowerPC version.
- Copyright (C) 2003, 2004 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 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>, 2003.
@@ -15,8 +15,8 @@
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA
+ 02110-1301 USA. */
#include <sysdep.h>
#include <tls.h>
@@ -30,7 +30,6 @@
# define PSEUDO(name, syscall_name, args) \
.section ".text"; \
ENTRY (name) \
- cfi_startproc; \
SINGLE_THREAD_P; \
bne- .Lpseudo_cancel; \
.type __##syscall_name##_nocancel,@function; \
@@ -45,6 +44,7 @@
mflr 9; \
stw 9,52(1); \
cfi_offset (lr, 4); \
+ CGOTSETUP; \
DOCARGS_##args; /* save syscall args around CENABLE. */ \
CENABLE; \
stw 3,16(1); /* store CENABLE return value (MASK). */ \
@@ -58,10 +58,10 @@
lwz 4,52(1); \
lwz 0,12(1); /* restore CR/R3. */ \
lwz 3,8(1); \
+ CGOTRESTORE; \
mtlr 4; \
mtcr 0; \
- addi 1,1,48; \
- cfi_endproc;
+ addi 1,1,48;
# define DOCARGS_0
# define UNDOCARGS_0
@@ -84,15 +84,30 @@
# define DOCARGS_6 stw 8,40(1); DOCARGS_5
# define UNDOCARGS_6 lwz 8,40(1); UNDOCARGS_5
+# define CGOTSETUP
+# define CGOTRESTORE
+
# ifdef IS_IN_libpthread
-# define CENABLE bl JUMPTARGET(__pthread_enable_asynccancel)
-# define CDISABLE bl JUMPTARGET(__pthread_disable_asynccancel)
+# define CENABLE bl __pthread_enable_asynccancel@local
+# define CDISABLE bl __pthread_disable_asynccancel@local
# elif !defined NOT_IN_libc
-# define CENABLE bl JUMPTARGET(__libc_enable_asynccancel)
-# define CDISABLE bl JUMPTARGET(__libc_disable_asynccancel)
+# define CENABLE bl __libc_enable_asynccancel@local
+# define CDISABLE bl __libc_disable_asynccancel@local
# elif defined IS_IN_librt
# define CENABLE bl JUMPTARGET(__librt_enable_asynccancel)
# define CDISABLE bl JUMPTARGET(__librt_disable_asynccancel)
+# if defined HAVE_AS_REL16 && defined PIC
+# undef CGOTSETUP
+# define CGOTSETUP \
+ bcl 20,31,1f; \
+ 1: stw 30,44(1); \
+ mflr 30; \
+ addis 30,30,_GLOBAL_OFFSET_TABLE-1b@ha; \
+ addi 30,30,_GLOBAL_OFFSET_TABLE-1b@l
+# undef CGOTRESTORE
+# define CGOTRESTORE \
+ lwz 30,44(1)
+# endif
# else
# error Unsupported library
# endif
@@ -113,3 +128,9 @@
# define NO_CANCELLATION 1
#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S
index f87adf4737..675a997e97 100644
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S
@@ -1,3 +1,9 @@
-#define RESET_PID
-#include <tcb-offsets.h>
-#include <sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S>
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <clone.S>
+#else
+# define RESET_PID
+# include_next <clone.S>
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
index 226aaafdce..707765ab58 100644
--- a/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
@@ -1,5 +1,5 @@
/* Cancellable system call stubs. Linux/PowerPC64 version.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Franz Sirl <Franz.Sirl-kernel@lauterbach.com>, 2003.
@@ -15,8 +15,8 @@
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA
+ 02110-1301 USA. */
#include <sysdep.h>
#include <tls.h>
@@ -36,7 +36,6 @@
# define PSEUDO(name, syscall_name, args) \
.section ".text"; \
ENTRY (name) \
- cfi_startproc; \
SINGLE_THREAD_P; \
bne- .Lpseudo_cancel; \
.type DASHDASHPFX(syscall_name##_nocancel),@function; \
@@ -66,8 +65,7 @@
ld 3,64(1); \
mtlr 9; \
mtcr 0; \
- addi 1,1,128; \
- cfi_endproc;
+ addi 1,1,128;
# define DOCARGS_0
# define UNDOCARGS_0
@@ -119,3 +117,9 @@
# define NO_CANCELLATION 1
#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstack.c b/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstack.c
new file mode 100644
index 0000000000..8aa971ab9a
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstack.c
@@ -0,0 +1,51 @@
+/* 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.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_setstack (attr, stackaddr, stacksize)
+ pthread_attr_t *attr;
+ void *stackaddr;
+ size_t stacksize;
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Catch invalid sizes. */
+ if (stacksize < 16384)
+ return EINVAL;
+
+#ifdef EXTRA_PARAM_CHECKS
+ EXTRA_PARAM_CHECKS;
+#endif
+
+ iattr->stacksize = stacksize;
+ iattr->stackaddr = (char *) stackaddr + stacksize;
+ iattr->flags |= ATTR_FLAG_STACKADDR;
+
+ return 0;
+}
+strong_alias (__pthread_attr_setstack, pthread_attr_setstack)
diff --git a/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c b/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c
new file mode 100644
index 0000000000..ea8c95981e
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c
@@ -0,0 +1,48 @@
+/* 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.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_setstacksize (attr, stacksize)
+ pthread_attr_t *attr;
+ size_t stacksize;
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Catch invalid sizes. */
+ if (stacksize < 16384)
+ return EINVAL;
+
+ size_t ps = __getpagesize ();
+ if (stacksize < 2 * ps)
+ stacksize = 2 * ps;
+
+ iattr->stacksize = stacksize;
+
+ return 0;
+}
+strong_alias (__pthread_attr_setstacksize, pthread_attr_setstacksize)
diff --git a/nptl/sysdeps/unix/sysv/linux/pthread-pi-defines.sym b/nptl/sysdeps/unix/sysv/linux/pthread-pi-defines.sym
new file mode 100644
index 0000000000..a1b6794260
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/pthread-pi-defines.sym
@@ -0,0 +1,6 @@
+#include <pthreadP.h>
+
+-- These PI macros are used by assembly code.
+
+MUTEX_KIND offsetof (pthread_mutex_t, __data.__kind)
+PI_BIT PTHREAD_MUTEX_PRIO_INHERIT_NP
diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c b/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c
index ca84f1c9bd..355e695ec2 100644
--- a/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c
+++ b/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
@@ -27,7 +27,7 @@
/* Defined in pthread_setaffinity.c. */
-extern size_t __kernel_cpumask_size;
+extern size_t __kernel_cpumask_size attribute_hidden;
extern int __determine_cpumask_size (pid_t tid);
diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c b/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c
new file mode 100644
index 0000000000..82c2446d55
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c
@@ -0,0 +1,111 @@
+/* pthread_getcpuclockid -- Get POSIX clockid_t for a pthread_t. Linux version
+ Copyright (C) 2000,2001,2002,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
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <pthreadP.h>
+#include <sys/time.h>
+#include <tls.h>
+#include <kernel-features.h>
+#include <kernel-posix-cpu-timers.h>
+
+
+#if !(__ASSUME_POSIX_CPU_TIMERS > 0)
+int __libc_missing_posix_cpu_timers attribute_hidden;
+#endif
+#if !(__ASSUME_POSIX_TIMERS > 0)
+int __libc_missing_posix_timers attribute_hidden;
+#endif
+
+int
+pthread_getcpuclockid (threadid, clockid)
+ pthread_t threadid;
+ clockid_t *clockid;
+{
+ struct pthread *pd = (struct pthread *) threadid;
+
+ /* Make sure the descriptor is valid. */
+ if (INVALID_TD_P (pd))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+#ifdef __NR_clock_getres
+ /* The clockid_t value is a simple computation from the TID.
+ But we do a clock_getres call to validate it if we aren't
+ yet sure we have the kernel support. */
+
+ const clockid_t tidclock = MAKE_THREAD_CPUCLOCK (pd->tid, CPUCLOCK_SCHED);
+
+# if !(__ASSUME_POSIX_CPU_TIMERS > 0)
+# if !(__ASSUME_POSIX_TIMERS > 0)
+ if (__libc_missing_posix_timers && !__libc_missing_posix_cpu_timers)
+ __libc_missing_posix_cpu_timers = 1;
+# endif
+ if (!__libc_missing_posix_cpu_timers)
+ {
+ INTERNAL_SYSCALL_DECL (err);
+ int r = INTERNAL_SYSCALL (clock_getres, err, 2, tidclock, NULL);
+ if (!INTERNAL_SYSCALL_ERROR_P (r, err))
+# endif
+ {
+ *clockid = tidclock;
+ return 0;
+ }
+
+# if !(__ASSUME_POSIX_CPU_TIMERS > 0)
+# if !(__ASSUME_POSIX_TIMERS > 0)
+ if (INTERNAL_SYSCALL_ERRNO (r, err) == ENOSYS)
+ {
+ /* The kernel doesn't support these calls at all. */
+ __libc_missing_posix_timers = 1;
+ __libc_missing_posix_cpu_timers = 1;
+ }
+ else
+# endif
+ if (INTERNAL_SYSCALL_ERRNO (r, err) == EINVAL)
+ {
+ /* The kernel doesn't support these clocks at all. */
+ __libc_missing_posix_cpu_timers = 1;
+ }
+ else
+ return INTERNAL_SYSCALL_ERRNO (r, err);
+ }
+# endif
+#endif
+
+#ifdef CLOCK_THREAD_CPUTIME_ID
+ /* We need to store the thread ID in the CLOCKID variable together
+ with a number identifying the clock. We reserve the low 3 bits
+ for the clock ID and the rest for the thread ID. This is
+ problematic if the thread ID is too large. But 29 bits should be
+ fine.
+
+ If some day more clock IDs are needed the ID part can be
+ enlarged. The IDs are entirely internal. */
+ if (pd->tid >= 1 << (8 * sizeof (*clockid) - CLOCK_IDFIELD_SIZE))
+ return ERANGE;
+
+ /* Store the number. */
+ *clockid = CLOCK_THREAD_CPUTIME_ID | (pd->tid << CLOCK_IDFIELD_SIZE);
+
+ return 0;
+#else
+ /* We don't have a timer for that. */
+ return ENOENT;
+#endif
+}
diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_kill.c b/nptl/sysdeps/unix/sysv/linux/pthread_kill.c
index 9115d6f40b..75089365c3 100644
--- a/nptl/sysdeps/unix/sysv/linux/pthread_kill.c
+++ b/nptl/sysdeps/unix/sysv/linux/pthread_kill.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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.
@@ -33,7 +33,15 @@ __pthread_kill (threadid, signo)
struct pthread *pd = (struct pthread *) threadid;
/* Make sure the descriptor is valid. */
- if (INVALID_TD_P (pd))
+ if (DEBUGGING_P && INVALID_TD_P (pd))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+ /* Force load of pd->tid into local variable or register. Otherwise
+ if a thread exits between ESRCH test and tgkill, we might return
+ EINVAL, because pd->tid would be cleared by the kernel. */
+ pid_t tid = atomic_forced_read (pd->tid);
+ if (__builtin_expect (tid <= 0, 0))
/* Not a valid thread handle. */
return ESRCH;
@@ -53,15 +61,15 @@ __pthread_kill (threadid, signo)
int val;
#if __ASSUME_TGKILL
val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
- pd->tid, signo);
+ tid, signo);
#else
# ifdef __NR_tgkill
val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
- pd->tid, signo);
+ tid, signo);
if (INTERNAL_SYSCALL_ERROR_P (val, err)
&& INTERNAL_SYSCALL_ERRNO (val, err) == ENOSYS)
# endif
- val = INTERNAL_SYSCALL (tkill, err, 2, pd->tid, signo);
+ val = INTERNAL_SYSCALL (tkill, err, 2, tid, signo);
#endif
return (INTERNAL_SYSCALL_ERROR_P (val, err)
diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c b/nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c
index 990db87416..a97351f880 100644
--- a/nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c
+++ b/nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c
@@ -1,7 +1,8 @@
#include <pthreadP.h>
-#define LLL_MUTEX_LOCK(mutex) lll_mutex_cond_lock(mutex)
-#define LLL_MUTEX_TRYLOCK(mutex) lll_mutex_cond_trylock(mutex)
+#define LLL_MUTEX_LOCK(mutex) lll_mutex_cond_lock (mutex)
+#define LLL_MUTEX_TRYLOCK(mutex) lll_mutex_cond_trylock (mutex)
+#define LLL_ROBUST_MUTEX_LOCK(mutex, id) lll_robust_mutex_cond_lock (mutex, id)
#define __pthread_mutex_lock __pthread_mutex_cond_lock
#define NO_INCR
diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c b/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c
index 5b24c694a9..3776e26e4b 100644
--- a/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c
+++ b/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
@@ -25,7 +25,7 @@
#include <shlib-compat.h>
-size_t __kernel_cpumask_size;
+size_t __kernel_cpumask_size attribute_hidden;
/* Determine the current affinity. As a side affect we learn
diff --git a/nptl/sysdeps/unix/sysv/linux/register-atfork.c b/nptl/sysdeps/unix/sysv/linux/register-atfork.c
index 9707e4663c..cb5b2b832f 100644
--- a/nptl/sysdeps/unix/sysv/linux/register-atfork.c
+++ b/nptl/sysdeps/unix/sysv/linux/register-atfork.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 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,7 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
-#include "fork.h"
+#include <fork.h>
/* Lock to protect allocation and deallocation of fork handlers. */
diff --git a/nptl/sysdeps/unix/sysv/linux/rtld-lowlevel.h b/nptl/sysdeps/unix/sysv/linux/rtld-lowlevel.h
new file mode 100644
index 0000000000..39db5a3bd4
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/rtld-lowlevel.h
@@ -0,0 +1,153 @@
+/* Defintions for lowlevel handling in ld.so.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _RTLD_LOWLEVEL_H
+#define _RTLD_LOWLEVEL_H 1
+
+#include <atomic.h>
+#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) \
+ do { \
+ while (1) \
+ { \
+ int val = word; \
+ if (val == 0) \
+ break; \
+ lll_futex_wait (&(word), val); \
+ } \
+ } while (0)
+
+
+#define __rtld_notify(word) \
+ lll_futex_wake (&(word), 1)
+
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h
index 6b3618cd57..c77031d7bb 100644
--- a/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h
+++ b/nptl/sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 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 Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
@@ -57,11 +57,25 @@ typedef union
} pthread_attr_t;
+#if __WORDSIZE == 64
+typedef struct __pthread_internal_list
+{
+ struct __pthread_internal_list *__prev;
+ struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+
/* Data structures for mutex handling. The structure of the attribute
type is not exposed on purpose. */
typedef union
{
- struct
+ struct __pthread_mutex_s
{
int __lock;
unsigned int __count;
@@ -72,10 +86,18 @@ typedef union
/* KIND must stay at this position in the structure to maintain
binary compatibility. */
int __kind;
-#if __WORDSIZE != 64
+#if __WORDSIZE == 64
+ int __spins;
+ __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV 1
+#else
unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
#endif
- int __spins;
} __data;
char __size[__SIZEOF_PTHREAD_MUTEX_T];
long int __align;
diff --git a/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h
index f4ed98a503..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 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.
@@ -30,6 +30,11 @@
#define FUTEX_WAKE 1
#define FUTEX_REQUEUE 3
#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
/* Initializer for compatibility lock. */
#define LLL_MUTEX_LOCK_INITIALIZER (0)
@@ -83,6 +88,17 @@
})
+#define lll_robust_mutex_dead(futexv) \
+ do \
+ { \
+ int *__futexp = &(futexv); \
+ \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ lll_futex_wake (__futexp, 1); \
+ } \
+ while (0)
+
+
/* Returns non-zero if error happened, zero if success. */
#define lll_futex_requeue(futex, nr_wake, nr_move, mutex, val) \
({ \
@@ -103,6 +119,27 @@
})
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(futex, nr_wake, nr_wake2, futex2) \
+ ({ \
+ register unsigned long int __r2 asm ("2") = (unsigned long int) (futex); \
+ register unsigned long int __r3 asm ("3") = FUTEX_WAKE_OP; \
+ register unsigned long int __r4 asm ("4") = (long int) (nr_wake); \
+ register unsigned long int __r5 asm ("5") = (long int) (nr_wake2); \
+ register unsigned long int __r6 asm ("6") = (unsigned long int) (futex2); \
+ register unsigned long int __r7 asm ("7") \
+ = (int) FUTEX_OP_CLEAR_WAKE_IF_GT_ONE; \
+ register unsigned long __result asm ("2"); \
+ \
+ __asm __volatile ("svc %b1" \
+ : "=d" (__result) \
+ : "i" (SYS_futex), "0" (__r2), "d" (__r3), \
+ "d" (__r4), "d" (__r5), "d" (__r6), "d" (__r7) \
+ : "cc", "memory" ); \
+ __result > -4096UL; \
+ })
+
+
#define lll_compare_and_swap(futex, oldval, newval, operation) \
do { \
__typeof (futex) __futex = (futex); \
@@ -144,7 +181,23 @@ __lll_mutex_cond_trylock (int *futex)
#define lll_mutex_cond_trylock(futex) __lll_mutex_cond_trylock (&(futex))
+static inline int
+__attribute__ ((always_inline))
+__lll_robust_mutex_trylock (int *futex, int id)
+{
+ unsigned int old;
+
+ __asm __volatile ("cs %0,%3,%1"
+ : "=d" (old), "=Q" (*futex)
+ : "0" (0), "d" (id), "m" (*futex) : "cc", "memory" );
+ return old != 0;
+}
+#define lll_robust_mutex_trylock(futex, id) \
+ __lll_robust_mutex_trylock (&(futex), id)
+
+
extern void __lll_lock_wait (int *futex) attribute_hidden;
+extern int __lll_robust_lock_wait (int *futex) attribute_hidden;
static inline void
__attribute__ ((always_inline))
@@ -155,6 +208,17 @@ __lll_mutex_lock (int *futex)
}
#define lll_mutex_lock(futex) __lll_mutex_lock (&(futex))
+static inline int
+__attribute__ ((always_inline))
+__lll_robust_mutex_lock (int *futex, int id)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_lock_wait (futex);
+ return result;
+}
+#define lll_robust_mutex_lock(futex, id) __lll_robust_mutex_lock (&(futex), id)
+
static inline void
__attribute__ ((always_inline))
__lll_mutex_cond_lock (int *futex)
@@ -164,8 +228,13 @@ __lll_mutex_cond_lock (int *futex)
}
#define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex))
+#define lll_robust_mutex_cond_lock(futex, id) \
+ __lll_robust_mutex_lock (&(futex), (id) | FUTEX_WAITERS)
+
extern int __lll_timedlock_wait
(int *futex, const struct timespec *) attribute_hidden;
+extern int __lll_robust_timedlock_wait
+ (int *futex, const struct timespec *) attribute_hidden;
static inline int
__attribute__ ((always_inline))
@@ -179,6 +248,19 @@ __lll_mutex_timedlock (int *futex, const struct timespec *abstime)
#define lll_mutex_timedlock(futex, abstime) \
__lll_mutex_timedlock (&(futex), abstime)
+static inline int
+__attribute__ ((always_inline))
+__lll_robust_mutex_timedlock (int *futex, const struct timespec *abstime,
+ int id)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_timedlock_wait (futex, abstime);
+ return result;
+}
+#define lll_robust_mutex_timedlock(futex, abstime, id) \
+ __lll_robust_mutex_timedlock (&(futex), abstime, id)
+
static inline void
__attribute__ ((always_inline))
@@ -197,6 +279,21 @@ __lll_mutex_unlock (int *futex)
static inline void
__attribute__ ((always_inline))
+__lll_robust_mutex_unlock (int *futex, int mask)
+{
+ int oldval;
+ int newval = 0;
+
+ lll_compare_and_swap (futex, oldval, newval, "slr %2,%2");
+ if (oldval & mask)
+ lll_futex_wake (futex, 1);
+}
+#define lll_robust_mutex_unlock(futex) \
+ __lll_robust_mutex_unlock(&(futex), FUTEX_WAITERS)
+
+
+static inline void
+__attribute__ ((always_inline))
__lll_mutex_unlock_force (int *futex)
{
*futex = 0;
diff --git a/nptl/sysdeps/unix/sysv/linux/s390/s390-32/clone.S b/nptl/sysdeps/unix/sysv/linux/s390/s390-32/clone.S
index 682f94dae8..675a997e97 100644
--- a/nptl/sysdeps/unix/sysv/linux/s390/s390-32/clone.S
+++ b/nptl/sysdeps/unix/sysv/linux/s390/s390-32/clone.S
@@ -1,2 +1,9 @@
-#define RESET_PID
-#include <sysdeps/unix/sysv/linux/s390/s390-32/clone.S>
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <clone.S>
+#else
+# define RESET_PID
+# include_next <clone.S>
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
index 09dac2c90b..17ab562daa 100644
--- a/nptl/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 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.
@@ -113,3 +113,9 @@ L(pseudo_end):
# define NO_CANCELLATION 1
#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/s390/s390-64/clone.S b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/clone.S
index 87ee2e1846..675a997e97 100644
--- a/nptl/sysdeps/unix/sysv/linux/s390/s390-64/clone.S
+++ b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/clone.S
@@ -1,2 +1,9 @@
-#define RESET_PID
-#include <sysdeps/unix/sysv/linux/s390/s390-64/clone.S>
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <clone.S>
+#else
+# define RESET_PID
+# include_next <clone.S>
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
index f8eb6a9ebc..77ce742495 100644
--- a/nptl/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 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.
@@ -126,3 +126,9 @@ extern int __local_multiple_threads attribute_hidden;
# define NO_CANCELLATION 1
#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h
index 5125408dcb..969686dd5a 100644
--- a/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h
+++ b/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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.
@@ -44,11 +44,17 @@ typedef union
} pthread_attr_t;
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+
/* Data structures for mutex handling. The structure of the attribute
type is not exposed on purpose. */
typedef union
{
- struct
+ struct __pthread_mutex_s
{
int __lock;
unsigned int __count;
@@ -57,7 +63,11 @@ typedef union
binary compatibility. */
int __kind;
unsigned int __nusers;
- int __spins;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
} __data;
char __size[__SIZEOF_PTHREAD_MUTEX_T];
long int __align;
diff --git a/nptl/sysdeps/unix/sysv/linux/sh/clone.S b/nptl/sysdeps/unix/sysv/linux/sh/clone.S
index 62a11972d8..675a997e97 100644
--- a/nptl/sysdeps/unix/sysv/linux/sh/clone.S
+++ b/nptl/sysdeps/unix/sysv/linux/sh/clone.S
@@ -1,2 +1,9 @@
-#define RESET_PID
-#include <sysdeps/unix/sysv/linux/sh/clone.S>
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <clone.S>
+#else
+# define RESET_PID
+# include_next <clone.S>
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S
index bcb15615e5..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 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
@@ -32,8 +32,11 @@
.type __lll_mutex_lock_wait,@function
.hidden __lll_mutex_lock_wait
.align 5
+ cfi_startproc
__lll_mutex_lock_wait:
mov.l r8, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r8, 0)
mov r4, r6
mov r5, r8
mov #0, r7 /* No timeout. */
@@ -51,14 +54,15 @@ __lll_mutex_lock_wait:
SYSCALL_INST_PAD
2:
- mov #2, r4
- XCHG (r4, @r8, r2)
+ mov #2, r6
+ XCHG (r6, @r8, r2)
tst r2, r2
bf 1b
mov.l @r15+, r8
ret
mov r2, r0
+ cfi_endproc
.size __lll_mutex_lock_wait,.-__lll_mutex_lock_wait
@@ -67,6 +71,7 @@ __lll_mutex_lock_wait:
.type __lll_mutex_timedlock_wait,@function
.hidden __lll_mutex_timedlock_wait
.align 5
+ cfi_startproc
__lll_mutex_timedlock_wait:
/* Check for a valid timeout value. */
mov.l @(4,r6), r1
@@ -75,14 +80,21 @@ __lll_mutex_timedlock_wait:
bt 3f
mov.l r10, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r10, 0)
mov.l r9, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r9, 0)
mov.l r8, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r8, 0)
mov r4, r10
mov r6, r9
mov r5, r8
/* Stack frame for the timespec and timeval structs. */
add #-8, r15
+ cfi_adjust_cfa_offset(8)
1:
/* Get current time. */
@@ -162,6 +174,7 @@ __lll_mutex_timedlock_wait:
5:
bra 6b
mov #ETIMEDOUT, r0
+ cfi_endproc
.L1k:
.word 1000
@@ -178,6 +191,7 @@ __lll_mutex_timedlock_wait:
.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
@@ -195,6 +209,7 @@ lll_unlock_wake_cb:
1:
rts
nop
+ cfi_endproc
.size lll_unlock_wake_cb,.-lll_unlock_wake_cb
#endif
@@ -203,6 +218,7 @@ lll_unlock_wake_cb:
.type __lll_mutex_unlock_wake,@function
.hidden __lll_mutex_unlock_wake
.align 5
+ cfi_startproc
__lll_mutex_unlock_wake:
mov #FUTEX_WAKE, r5
mov #1, r6 /* Wake one thread. */
@@ -214,6 +230,7 @@ __lll_mutex_unlock_wake:
SYSCALL_INST_PAD
rts
nop
+ cfi_endproc
.size __lll_mutex_unlock_wake,.-__lll_mutex_unlock_wake
@@ -222,14 +239,20 @@ __lll_mutex_unlock_wake:
.type __lll_timedwait_tid,@function
.hidden __lll_timedwait_tid
.align 5
+ cfi_startproc
__lll_timedwait_tid:
mov.l r9, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r9, 0)
mov.l r8, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r8, 0)
mov r4, r8
mov r5, r9
/* Stack frame for the timespec and timeval structs. */
add #-8, r15
+ cfi_adjust_cfa_offset(8)
2:
/* Get current time. */
@@ -292,6 +315,7 @@ __lll_timedwait_tid:
6:
bra 3b
mov #ETIMEDOUT, r0
+ cfi_endproc
.L1k2:
.word 1000
diff --git a/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h
index d9376d45a0..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 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
@@ -26,6 +26,9 @@
#define SYS_futex 240
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
/* Initializer for compatibility lock. */
@@ -62,6 +65,28 @@ extern int __lll_mutex_unlock_wake (int *__futex) attribute_hidden;
: "r0", "r1", "r2", "t", "memory"); \
__result; })
+#define lll_robust_mutex_trylock(futex, id) \
+ ({ unsigned char __result; \
+ __asm __volatile ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ nop\n\
+ mov r15,r1\n\
+ mov #-8,r15\n\
+ 0: mov.l @%1,r2\n\
+ cmp/eq r2,%3\n\
+ bf 1f\n\
+ mov.l %2,@%1\n\
+ 1: mov r1,r15\n\
+ mov #-1,%0\n\
+ negc %0,%0"\
+ : "=r" (__result) \
+ : "r" (&(futex)), \
+ "r" (id), \
+ "r" (LLL_MUTEX_LOCK_INITIALIZER) \
+ : "r0", "r1", "r2", "t", "memory"); \
+ __result; })
+
#define lll_mutex_cond_trylock(futex) \
({ unsigned char __result; \
__asm __volatile ("\
@@ -102,6 +127,25 @@ extern int __lll_mutex_unlock_wake (int *__futex) attribute_hidden;
if (__result) \
__lll_mutex_lock_wait (__result, __futex); })
+#define lll_robust_mutex_lock(futex, id) \
+ ({ int __result, val, *__futex = &(futex); \
+ __asm __volatile ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ nop\n\
+ mov r15,r1\n\
+ mov #-8,r15\n\
+ 0: mov.l @%2,%0\n\
+ tst %0,%0\n\
+ bf 1f\n\
+ mov.l %1,@%2\n\
+ 1: mov r1,r15"\
+ : "=&r" (__result) : "r" (id), "r" (__futex) \
+ : "r0", "r1", "t", "memory"); \
+ if (__result) \
+ __result = __lll_robust_mutex_lock_wait (__result, __futex); \
+ __result; })
+
/* Special version of lll_mutex_lock which causes the unlock function to
always wakeup waiters. */
#define lll_mutex_cond_lock(futex) \
@@ -122,6 +166,25 @@ extern int __lll_mutex_unlock_wake (int *__futex) attribute_hidden;
if (__result) \
__lll_mutex_lock_wait (__result, __futex); })
+#define lll_robust_mutex_cond_lock(futex, id) \
+ ({ int __result, val, *__futex = &(futex); \
+ __asm __volatile ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ nop\n\
+ mov r15,r1\n\
+ mov #-8,r15\n\
+ 0: mov.l @%2,%0\n\
+ tst %0,%0\n\
+ bf 1f\n\
+ mov.l %1,@%2\n\
+ 1: mov r1,r15"\
+ : "=&r" (__result) : "r" (id | FUTEX_WAITERS), "r" (__futex) \
+ : "r0", "r1", "t", "memory"); \
+ if (__result) \
+ __result = __lll_robust_mutex_lock_wait (__result, __futex); \
+ __result; })
+
#define lll_mutex_timedlock(futex, timeout) \
({ int __result, val, *__futex = &(futex); \
__asm __volatile ("\
@@ -141,6 +204,26 @@ extern int __lll_mutex_unlock_wake (int *__futex) attribute_hidden;
__result = __lll_mutex_timedlock_wait (__result, __futex, timeout); \
__result; })
+#define lll_robust_mutex_timedlock(futex, timeout, id) \
+ ({ int __result, val, *__futex = &(futex); \
+ __asm __volatile ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ nop\n\
+ mov r15,r1\n\
+ mov #-8,r15\n\
+ 0: mov.l @%2,%0\n\
+ tst %0,%0\n\
+ bf 1f\n\
+ mov.l %1,@%2\n\
+ 1: mov r1,r15"\
+ : "=&r" (__result) : "r" (id), "r" (__futex) \
+ : "r0", "r1", "t", "memory"); \
+ if (__result) \
+ __result = __lll_robust_mutex_timedlock_wait (__result, __futex, \
+ timeout); \
+ __result; })
+
#define lll_mutex_unlock(futex) \
(void) ({ int __result, *__futex = &(futex); \
__asm __volatile ("\
@@ -157,6 +240,37 @@ extern int __lll_mutex_unlock_wake (int *__futex) attribute_hidden;
if (__result) \
__lll_mutex_unlock_wake (__futex); })
+#define lll_robust_mutex_unlock(futex) \
+ (void) ({ int __result, *__futex = &(futex); \
+ __asm __volatile ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ mov r15,r1\n\
+ mov #-6,r15\n\
+ 0: mov.l @%1,%0\n\
+ and %2,%0\n\
+ mov.l %0,@%1\n\
+ 1: mov r1,r15"\
+ : "=&r" (__result) : "r" (__futex), "r" (FUTEX_TID_MASK) \
+ : "r0", "r1", "memory"); \
+ if (__result) \
+ __lll_mutex_unlock_wake (__futex); })
+
+#define lll_robust_mutex_dead(futex) \
+ (void) ({ int __ignore, *__futex = &(futex); \
+ __asm __volatile ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ mov r15,r1\n\
+ mov #-6,r15\n\
+ 0: mov.l @%1,%0\n\
+ or %2,%0\n\
+ mov.l %0,@%1\n\
+ 1: mov r1,r15"\
+ : "=&r" (__ignore) : "r" (__futex), "r" (FUTEX_OWNER_DIED) \
+ : "r0", "r1", "memory"); \
+ lll_futex_wake (__futex, 1); })
+
#define lll_mutex_islocked(futex) \
(futex != 0)
@@ -181,19 +295,37 @@ typedef int lll_lock_t;
# endif
#define lll_futex_wait(futex, val) \
- do { \
- int __ignore; \
+ ({ \
+ 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") = 0; \
__asm __volatile (SYSCALL_WITH_INST_PAD \
- : "=z" (__ignore) \
+ : "=z" (__status) \
: "r" (__r3), "r" (__r4), "r" (__r5), \
"r" (__r6), "r" (__r7) \
: "memory", "t"); \
- } while (0)
+ __status; \
+ })
+
+
+#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") = 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) \
diff --git a/nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S b/nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S
new file mode 100644
index 0000000000..c57d3cff18
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S
@@ -0,0 +1,224 @@
+/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <pthread-errnos.h>
+#include <lowlevelrobustlock.h>
+#include "lowlevel-atomic.h"
+
+ .text
+
+#define SYS_gettimeofday __NR_gettimeofday
+#define SYS_futex 240
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_WAITERS 0x80000000
+#define FUTEX_OWNER_DIED 0x40000000
+
+
+ .globl __lll_robust_mutex_lock_wait
+ .type __lll_robust_mutex_lock_wait,@function
+ .hidden __lll_robust_mutex_lock_wait
+ .align 5
+ cfi_startproc
+__lll_robust_mutex_lock_wait:
+ mov.l r8, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r8, 0)
+ mov r5, r8
+ mov #0, r7 /* No timeout. */
+ mov #FUTEX_WAIT, r5
+
+4:
+ mov r4, r6
+ mov.l .L_FUTEX_WAITERS, r0
+ or r0, r6
+ shlr r0 /* r0 = FUTEX_OWNER_DIED */
+ tst r0, r4
+ bf/s 3f
+ cmp/eq r4, r6
+ bt 1f
+
+ CMPXCHG (r4, @r8, r6, r2)
+ bf 2f
+
+1:
+ mov r8, r4
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+ mov.l @r8, r2
+
+2:
+ tst r2, r2
+ bf/s 4b
+ mov r2, r4
+
+ stc gbr, r1
+ mov.w .Ltidoff, r2
+ add r2, r1
+ mov.l @r1, r6
+ mov #0, r3
+ CMPXCHG (r3, @r8, r6, r4)
+ bf 4b
+ mov #0, r4
+
+3:
+ mov.l @r15+, r8
+ ret
+ mov r4, r0
+ cfi_endproc
+ .align 2
+.L_FUTEX_WAITERS:
+ .long FUTEX_WAITERS
+.Ltidoff:
+ .word TID - TLS_PRE_TCB_SIZE
+ .size __lll_robust_mutex_lock_wait,.-__lll_robust_mutex_lock_wait
+
+
+ .globl __lll_robust_mutex_timedlock_wait
+ .type __lll_robust_mutex_timedlock_wait,@function
+ .hidden __lll_robust_mutex_timedlock_wait
+ .align 5
+ cfi_startproc
+__lll_robust_mutex_timedlock_wait:
+ /* Check for a valid timeout value. */
+ mov.l @(4,r6), r1
+ mov.l .L1g, r0
+ cmp/hs r0, r1
+ bt 3f
+
+ mov.l r10, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r10, 0)
+ mov.l r9, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r9, 0)
+ mov.l r8, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r8, 0)
+ mov r4, r10
+ mov r6, r9
+ mov r5, r8
+
+ /* Stack frame for the timespec and timeval structs. */
+ add #-8, r15
+ cfi_adjust_cfa_offset(8)
+
+1:
+ /* Get current time. */
+ mov r15, r4
+ mov #0, r5
+ mov #SYS_gettimeofday, r3
+ trapa #0x12
+ SYSCALL_INST_PAD
+
+ /* Compute relative timeout. */
+ mov.l @(4,r15), r0
+ mov.w .L1k, r1
+ dmulu.l r0, r1 /* Micro seconds to nano seconds. */
+ mov.l @r9, r2
+ mov.l @(4,r9), r3
+ mov.l @r15, r0
+ sts macl, r1
+ sub r0, r2
+ clrt
+ subc r1, r3
+ bf 4f
+ mov.l .L1g, r1
+ add r1, r3
+ add #-1, r2
+4:
+ cmp/pz r2
+ bf 8f /* Time is already up. */
+
+ mov.l r2, @r15 /* Store relative timeout. */
+ mov.l r3, @(4,r15)
+
+ mov r10, r6
+ mov.l .L_FUTEX_WAITERS2, r0
+ or r0, r6
+ shlr r0 /* r0 = FUTEX_OWNER_DIED */
+ tst r0, r4
+ bf/s 6f
+ cmp/eq r4, r6
+ bt 2f
+
+ CMPXCHG (r4, @r8, r6, r2)
+ bf/s 5f
+ mov #0, r5
+
+2:
+ mov r8, r4
+ mov #FUTEX_WAIT, r5
+ mov r10, r6
+ mov r15, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+ mov r0, r5
+
+ mov.l @r8, r2
+
+5:
+ tst r2, r2
+ bf/s 7f
+ mov r2, r10
+
+ stc gbr, r1
+ mov.w .Ltidoff2, r2
+ add r2, r1
+ mov.l @r1, r4
+ mov #0, r3
+ CMPXCHG (r3, @r8, r4, r10)
+ bf 7f
+ mov #0, r0
+
+6:
+ add #8, r15
+ mov.l @r15+, r8
+ mov.l @r15+, r9
+ rts
+ mov.l @r15+, r10
+
+7:
+ /* Check whether the time expired. */
+ mov #-ETIMEDOUT, r1
+ cmp/eq r5, r1
+ bf 1b
+
+8:
+ bra 6b
+ mov #ETIMEDOUT, r0
+3:
+ rts
+ mov #EINVAL, r0
+ cfi_endproc
+ .align 2
+.L_FUTEX_WAITERS2:
+ .long FUTEX_WAITERS
+.L1g:
+ .long 1000000000
+.Ltidoff2:
+ .word TID - TLS_PRE_TCB_SIZE
+.L1k:
+ .word 1000
+ .size __lll_robust_mutex_timedlock_wait,.-__lll_robust_mutex_timedlock_wait
diff --git a/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S b/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S
index 6bd6e60ec1..56f0aa95de 100644
--- a/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S
+++ b/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 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
@@ -20,6 +20,7 @@
#include <shlib-compat.h>
#include <lowlevelcond.h>
#include <kernel-features.h>
+#include <pthread-pi-defines.h>
#include "lowlevel-atomic.h"
#define SYS_futex 240
@@ -98,6 +99,11 @@ __pthread_cond_broadcast:
bt/s 9f
add #cond_futex, r4
+ /* XXX: The kernel so far doesn't support requeue to PI futex. */
+ mov.l @(MUTEX_KIND,r9), r0
+ tst #PI_BIT, r0
+ bf 9f
+
/* Wake up all threads. */
mov #FUTEX_CMP_REQUEUE, r5
mov #1, r6
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 74206a71ec..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 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
@@ -521,6 +521,21 @@ __condvar_tw_cleanup:
mov #1, r2
mov #0, r3
+ /* We increment the wakeup_seq counter only if it is lower than
+ total_seq. If this is not the case the thread was woken and
+ then canceled. In this case we ignore the signal. */
+ mov.l @(total_seq+4,r8), r0
+ mov.l @(wakeup_seq+4,r8), r1
+ cmp/hi r1, r0
+ bt/s 6f
+ cmp/hi r0, r1
+ bt 7f
+ mov.l @(total_seq,r8), r0
+ mov.l @(wakeup_seq,r8), r1
+ cmp/hs r0, r1
+ bt 7f
+
+6:
clrt
mov.l @(wakeup_seq,r8),r0
mov.l @(wakeup_seq+4,r8),r1
@@ -532,6 +547,7 @@ __condvar_tw_cleanup:
add r2, r0
mov.l r0,@(cond_futex,r8)
+7:
clrt
mov.l @(woken_seq,r8),r0
mov.l @(woken_seq+4,r8),r1
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 2d6b685668..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 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
@@ -385,6 +385,21 @@ __condvar_w_cleanup:
mov #1, r2
mov #0, r3
+ /* We increment the wakeup_seq counter only if it is lower than
+ total_seq. If this is not the case the thread was woken and
+ then canceled. In this case we ignore the signal. */
+ mov.l @(total_seq+4,r8), r0
+ mov.l @(wakeup_seq+4,r8), r1
+ cmp/hi r1, r0
+ bt/s 6f
+ cmp/hi r0, r1
+ bt 7f
+ mov.l @(total_seq,r8), r0
+ mov.l @(wakeup_seq,r8), r1
+ cmp/hs r0, r1
+ bt 7f
+
+6:
clrt
mov.l @(wakeup_seq,r8),r0
mov.l @(wakeup_seq+4,r8),r1
@@ -396,6 +411,7 @@ __condvar_w_cleanup:
add r2, r0
mov.l r0,@(cond_futex,r8)
+7:
clrt
mov.l @(woken_seq,r8),r0
mov.l @(woken_seq+4,r8),r1
diff --git a/nptl/sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h
index 8cdcac5560..90be7bd8d0 100644
--- a/nptl/sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h
+++ b/nptl/sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h
@@ -1,4 +1,4 @@
/* 4 instruction cycles not accessing cache and TLB are needed after
trapa instruction to avoid an SH-4 silicon bug. */
#define NEED_SYSCALL_INST_PAD
-#include <sysdeps/unix/sysv/linux/sh/lowlevellock.h>
+#include_next <lowlevellock.h>
diff --git a/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
index fc3c2340b6..a8065c6a8c 100644
--- a/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -49,27 +49,32 @@
.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
.Lpseudo_cancel: \
sts.l pr,@-r15; \
- .LCFI0: \
+ cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (pr, 0); \
add _IMM16,r15; \
+ cfi_adjust_cfa_offset (16); \
SAVE_ARGS_##args; \
- .LCFI1: \
CENABLE; \
LOAD_ARGS_##args; \
add _IMP16,r15; \
- .LCFI2: \
+ cfi_adjust_cfa_offset (-16); \
lds.l @r15+,pr; \
- .LCFI3: \
+ cfi_adjust_cfa_offset (-4); \
+ cfi_restore (pr); \
DO_CALL(syscall_name, args); \
SYSCALL_INST_PAD; \
sts.l pr,@-r15; \
- .LCFI4: \
+ cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (pr, 0); \
mov.l r0,@-r15; \
- .LCFI5: \
+ cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (r0, 0); \
CDISABLE; \
mov.l @r15+,r0; \
- .LCFI6: \
+ cfi_adjust_cfa_offset (-4); \
lds.l @r15+,pr; \
- .LCFI7: \
+ cfi_adjust_cfa_offset (-4); \
+ cfi_restore (pr); \
mov r0,r1; \
mov _IMM12,r2; \
shad r2,r1; \
@@ -78,106 +83,17 @@
bf .Lpseudo_end; \
.Lsyscall_error: \
SYSCALL_ERROR_HANDLER; \
- .Lpseudo_end: \
- /* Create unwinding information for the syscall wrapper. */ \
- .section .eh_frame,"a",@progbits; \
- .Lframe1: \
- .ualong .LECIE1-.LSCIE1; \
- .LSCIE1: \
- .ualong 0x0; \
- .byte 0x1; \
- AUGMENTATION_STRING; \
- .uleb128 0x1; \
- .sleb128 -4; \
- .byte 0x11; \
- AUGMENTATION_PARAM; \
- .byte 0xc; \
- .uleb128 0xf; \
- .uleb128 0x0; \
- .align 2; \
- .LECIE1: \
- .LSFDE1: \
- .ualong .LEFDE1-.LASFDE1; \
- .LASFDE1: \
- .ualong .LASFDE1-.Lframe1; \
- START_SYMBOL_REF; \
- .ualong .Lpseudo_end - .Lpseudo_start; \
- AUGMENTATION_PARAM_FDE; \
- .byte 0x4; \
- .ualong .LCFI0-.Lpseudo_start; \
- .byte 0xe; \
- .uleb128 0x4; \
- .byte 0x91; \
- .uleb128 0x1; \
- .byte 0x4; \
- .ualong .LCFI1-.LCFI0; \
- .byte 0xe; \
- .uleb128 0x14; \
- FRAME_REG_##args; \
- .byte 0x4; \
- .ualong .LCFI2-.LCFI1; \
- .byte 0xe; \
- .uleb128 0x4; \
- .byte 0x4; \
- .ualong .LCFI3-.LCFI2; \
- .byte 0xe; \
- .uleb128 0x0; \
- .byte 0xd1; \
- .byte 0x4; \
- .ualong .LCFI4-.LCFI3; \
- .byte 0xe; \
- .uleb128 0x4; \
- .byte 0x91; \
- .uleb128 0x1; \
- .byte 0x4; \
- .ualong .LCFI5-.LCFI4; \
- .byte 0xe; \
- .uleb128 0x8; \
- .byte 0x80; \
- .uleb128 0x2; \
- .byte 0x4; \
- .ualong .LCFI6-.LCFI5; \
- .byte 0xe; \
- .uleb128 0x4; \
- .byte 0xc0; \
- .byte 0x4; \
- .ualong .LCFI7-.LCFI6; \
- .byte 0xe; \
- .uleb128 0x0; \
- .byte 0xd1; \
- .align 2; \
- .LEFDE1: \
- .previous
-
-# ifdef SHARED
-# define AUGMENTATION_STRING .string "zR"
-# define AUGMENTATION_PARAM .uleb128 1; .byte 0x1b
-# define AUGMENTATION_PARAM_FDE .uleb128 0
-# define START_SYMBOL_REF .long .Lpseudo_start-.
-# else
-# define AUGMENTATION_STRING .ascii "\0"
-# define AUGMENTATION_PARAM
-# define AUGMENTATION_PARAM_FDE
-# define START_SYMBOL_REF .long .Lpseudo_start
-# endif
-
-# define FRAME_REG_0 /* Nothing. */
-# define FRAME_REG_1 FRAME_REG_0; .byte 0x84; .uleb128 5
-# define FRAME_REG_2 FRAME_REG_1; .byte 0x85; .uleb128 4
-# define FRAME_REG_3 FRAME_REG_2; .byte 0x86; .uleb128 3
-# define FRAME_REG_4 FRAME_REG_3; .byte 0x87; .uleb128 2
-# define FRAME_REG_5 FRAME_REG_4
-# define FRAME_REG_6 FRAME_REG_5
+ .Lpseudo_end:
# undef PSEUDO_END
# define PSEUDO_END(sym) \
END (sym)
# define SAVE_ARGS_0 /* Nothing. */
-# define SAVE_ARGS_1 SAVE_ARGS_0; mov.l r4,@(0,r15)
-# define SAVE_ARGS_2 SAVE_ARGS_1; mov.l r5,@(4,r15)
-# define SAVE_ARGS_3 SAVE_ARGS_2; mov.l r6,@(8,r15)
-# define SAVE_ARGS_4 SAVE_ARGS_3; mov.l r7,@(12,r15)
+# define SAVE_ARGS_1 SAVE_ARGS_0; mov.l r4,@(0,r15); cfi_offset (r4,-4)
+# define SAVE_ARGS_2 SAVE_ARGS_1; mov.l r5,@(4,r15); cfi_offset (r5,-8)
+# define SAVE_ARGS_3 SAVE_ARGS_2; mov.l r6,@(8,r15); cfi_offset (r6,-12)
+# define SAVE_ARGS_4 SAVE_ARGS_3; mov.l r7,@(12,r15); cfi_offset (r7,-16)
# define SAVE_ARGS_5 SAVE_ARGS_4
# define SAVE_ARGS_6 SAVE_ARGS_5
@@ -245,3 +161,9 @@
# define NO_CANCELLATION 1
#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/sleep.c b/nptl/sysdeps/unix/sysv/linux/sleep.c
index c56b49b39f..2dce3210ca 100644
--- a/nptl/sysdeps/unix/sysv/linux/sleep.c
+++ b/nptl/sysdeps/unix/sysv/linux/sleep.c
@@ -1,2 +1,10 @@
-#include <nptl/pthreadP.h>
-#include <sysdeps/unix/sysv/linux/sleep.c>
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <sleep.c>
+#else
+/* This defines the CANCELLATION_P macro, which sleep.c checks for. */
+# include <pthreadP.h>
+# include_next <sleep.c>
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/smp.h b/nptl/sysdeps/unix/sysv/linux/smp.h
index 4f4d358d32..fcc34f7681 100644
--- a/nptl/sysdeps/unix/sysv/linux/smp.h
+++ b/nptl/sysdeps/unix/sysv/linux/smp.h
@@ -1,5 +1,5 @@
/* Determine whether the host has multiple processors. Linux version.
- Copyright (C) 1996, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1996, 2002, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -17,36 +17,12 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <errno.h>
-#include <fcntl.h>
-#include <string.h>
-#include <sys/sysctl.h>
-#include <not-cancel.h>
-
/* Test whether the machine has more than one processor. This is not the
best test but good enough. More complicated tests would require `malloc'
which is not available at that time. */
static inline int
is_smp_system (void)
{
- static const int sysctl_args[] = { CTL_KERN, KERN_VERSION };
- char buf[512];
- size_t reslen = sizeof (buf);
-
- /* Try reading the number using `sysctl' first. */
- if (__sysctl ((int *) sysctl_args,
- sizeof (sysctl_args) / sizeof (sysctl_args[0]),
- buf, &reslen, NULL, 0) < 0)
- {
- /* This was not successful. Now try reading the /proc filesystem. */
- int fd = open_not_cancel_2 ("/proc/sys/kernel/version", O_RDONLY);
- if (__builtin_expect (fd, 0) == -1
- || (reslen = read_not_cancel (fd, buf, sizeof (buf))) <= 0)
- /* This also didn't work. We give up and say it's a UP machine. */
- buf[0] = '\0';
-
- close_not_cancel_no_status (fd);
- }
-
- return strstr (buf, "SMP") != NULL;
+ /* Assume all machines are SMP and/or CMT and/or SMT. */
+ return 1;
}
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/Makefile b/nptl/sysdeps/unix/sysv/linux/sparc/Makefile
new file mode 100644
index 0000000000..e98c9bd866
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/Makefile
@@ -0,0 +1,2 @@
+# pull in __syscall_error routine
+libpthread-routines += sysdep
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h b/nptl/sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h
index 3c5a289445..e734c1205e 100644
--- a/nptl/sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h
@@ -1,5 +1,5 @@
/* Machine-specific pthread type layouts. SPARC version.
- Copyright (C) 2003, 2004 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 Jakub Jelinek <jakub@redhat.com>, 2003.
@@ -58,11 +58,25 @@ typedef union
} pthread_attr_t;
+#if __WORDSIZE == 64
+typedef struct __pthread_internal_list
+{
+ struct __pthread_internal_list *__prev;
+ struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+
/* Data structures for mutex handling. The structure of the attribute
type is deliberately not exposed. */
typedef union
{
- struct
+ struct __pthread_mutex_s
{
int __lock;
unsigned int __count;
@@ -73,10 +87,18 @@ typedef union
/* KIND must stay at this position in the structure to maintain
binary compatibility. */
int __kind;
-#if __WORDSIZE != 64
+#if __WORDSIZE == 64
+ int __spins;
+ __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV 1
+#else
unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
#endif
- int __spins;
} __data;
char __size[__SIZEOF_PTHREAD_MUTEX_T];
long int __align;
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h
index 4626aec524..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 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.
@@ -30,6 +30,11 @@
#define FUTEX_WAKE 1
#define FUTEX_REQUEUE 3
#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
/* Initializer for compatibility lock. */
#define LLL_MUTEX_LOCK_INITIALIZER (0)
@@ -76,15 +81,38 @@
INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
})
+#define lll_robust_mutex_dead(futexv) \
+ do \
+ { \
+ int *__futexp = &(futexv); \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ lll_futex_wake (__futexp, 1); \
+ } \
+ while (0)
+
+/* Returns non-zero if error happened, zero if success. */
#ifdef __sparc32_atomic_do_lock
-#error SPARC < v9 does not support compare and swap which is essential for futex based locking
+/* Avoid FUTEX_WAKE_OP if supporting pre-v9 CPUs. */
+# define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2) 1
+#else
+# define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, \
+ (futexp), FUTEX_WAKE_OP, (nr_wake), \
+ (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
#endif
static inline int
__attribute__ ((always_inline))
__lll_mutex_trylock (int *futex)
{
- return atomic_compare_and_exchange_val_acq (futex, 1, 0) != 0;
+ return atomic_compare_and_exchange_val_24_acq (futex, 1, 0) != 0;
}
#define lll_mutex_trylock(futex) __lll_mutex_trylock (&(futex))
@@ -92,47 +120,71 @@ static inline int
__attribute__ ((always_inline))
__lll_mutex_cond_trylock (int *futex)
{
- return atomic_compare_and_exchange_val_acq (futex, 2, 0) != 0;
+ return atomic_compare_and_exchange_val_24_acq (futex, 2, 0) != 0;
}
#define lll_mutex_cond_trylock(futex) __lll_mutex_cond_trylock (&(futex))
+static inline int
+__attribute__ ((always_inline))
+__lll_robust_mutex_trylock (int *futex, int id)
+{
+ return atomic_compare_and_exchange_val_acq (futex, id, 0) != 0;
+}
+#define lll_robust_mutex_trylock(futex, id) \
+ __lll_robust_mutex_trylock (&(futex), id)
-extern void __lll_lock_wait (int *futex) attribute_hidden;
+extern void __lll_lock_wait (int *futex) attribute_hidden;
+extern int __lll_robust_lock_wait (int *futex) attribute_hidden;
static inline void
__attribute__ ((always_inline))
__lll_mutex_lock (int *futex)
{
- int val = atomic_compare_and_exchange_val_acq (futex, 1, 0);
+ int val = atomic_compare_and_exchange_val_24_acq (futex, 1, 0);
if (__builtin_expect (val != 0, 0))
__lll_lock_wait (futex);
}
#define lll_mutex_lock(futex) __lll_mutex_lock (&(futex))
+static inline int
+__attribute__ ((always_inline))
+__lll_robust_mutex_lock (int *futex, int id)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_lock_wait (futex);
+ return result;
+}
+#define lll_robust_mutex_lock(futex, id) \
+ __lll_robust_mutex_lock (&(futex), id)
static inline void
__attribute__ ((always_inline))
__lll_mutex_cond_lock (int *futex)
{
- int val = atomic_compare_and_exchange_val_acq (futex, 2, 0);
+ int val = atomic_compare_and_exchange_val_24_acq (futex, 2, 0);
if (__builtin_expect (val != 0, 0))
__lll_lock_wait (futex);
}
#define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex))
+#define lll_robust_mutex_cond_lock(futex, id) \
+ __lll_robust_mutex_lock (&(futex), (id) | FUTEX_WAITERS)
+
extern int __lll_timedlock_wait (int *futex, const struct timespec *)
attribute_hidden;
-
+extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *)
+ attribute_hidden;
static inline int
__attribute__ ((always_inline))
__lll_mutex_timedlock (int *futex, const struct timespec *abstime)
{
- int val = atomic_compare_and_exchange_val_acq (futex, 1, 0);
+ int val = atomic_compare_and_exchange_val_24_acq (futex, 1, 0);
int result = 0;
if (__builtin_expect (val != 0, 0))
@@ -142,18 +194,39 @@ __lll_mutex_timedlock (int *futex, const struct timespec *abstime)
#define lll_mutex_timedlock(futex, abstime) \
__lll_mutex_timedlock (&(futex), abstime)
+static inline int
+__attribute__ ((always_inline))
+__lll_robust_mutex_timedlock (int *futex, const struct timespec *abstime,
+ int id)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_timedlock_wait (futex, abstime);
+ return result;
+}
+#define lll_robust_mutex_timedlock(futex, abstime, id) \
+ __lll_robust_mutex_timedlock (&(futex), abstime, id)
+
#define lll_mutex_unlock(lock) \
((void) ({ \
int *__futex = &(lock); \
- int __val = atomic_exchange_rel (__futex, 0); \
+ int __val = atomic_exchange_24_rel (__futex, 0); \
if (__builtin_expect (__val > 1, 0)) \
lll_futex_wake (__futex, 1); \
}))
+#define lll_robust_mutex_unlock(lock) \
+ ((void) ({ \
+ int *__futex = &(lock); \
+ int __val = atomic_exchange_rel (__futex, 0); \
+ if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \
+ lll_futex_wake (__futex, 1); \
+ }))
+
#define lll_mutex_unlock_force(lock) \
((void) ({ \
int *__futex = &(lock); \
- (void) atomic_exchange_rel (__futex, 0); \
+ (void) atomic_exchange_24_rel (__futex, 0); \
lll_futex_wake (__futex, 1); \
}))
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S
index da6197c00d..675a997e97 100644
--- a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S
@@ -1,2 +1,9 @@
-#define RESET_PID
-#include <sysdeps/unix/sysv/linux/sparc/sparc32/clone.S>
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <clone.S>
+#else
+# define RESET_PID
+# include_next <clone.S>
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/lowlevellock.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/lowlevellock.c
new file mode 100644
index 0000000000..a7611d6a88
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/lowlevellock.c
@@ -0,0 +1,131 @@
+/* low level locking for pthread library. SPARC version.
+ 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.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <sys/time.h>
+
+
+void
+__lll_lock_wait (int *futex)
+{
+ do
+ {
+ int oldval = atomic_compare_and_exchange_val_24_acq (futex, 2, 1);
+ if (oldval != 0)
+ lll_futex_wait (futex, 2);
+ }
+ while (atomic_compare_and_exchange_val_24_acq (futex, 2, 0) != 0);
+}
+
+
+int
+__lll_timedlock_wait (int *futex, const struct timespec *abstime)
+{
+ /* Reject invalid timeouts. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ do
+ {
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* Wait. */
+ int oldval = atomic_compare_and_exchange_val_24_acq (futex, 2, 1);
+ if (oldval != 0)
+ lll_futex_timed_wait (futex, 2, &rt);
+ }
+ while (atomic_compare_and_exchange_val_24_acq (futex, 2, 0) != 0);
+
+ return 0;
+}
+
+
+/* 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;
+
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Repeat until thread terminated. */
+ while ((tid = *tidp) != 0)
+ {
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return 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/sparc/sparc32/pt-vfork.S b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/pt-vfork.S
index 55229c9e66..fb01242b53 100644
--- a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/pt-vfork.S
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/pt-vfork.S
@@ -21,6 +21,7 @@
#include <tcb-offsets.h>
.text
+ .globl __syscall_error
ENTRY(__vfork)
ld [%g7 + PID], %o5
sub %g0, %o5, %o4
@@ -28,15 +29,17 @@ ENTRY(__vfork)
LOADSYSCALL(vfork)
ta 0x10
- bcs,a __syscall_error_handler
- st %o5, [%g7 + PID]
- SYSCALL_ERROR_HANDLER
- sub %o1, 1, %o1
+ bcc 2f
+ mov %o7, %g1
+ st %o5, [%g7 + PID]
+ call __syscall_error
+ mov %g1, %o7
+2: sub %o1, 1, %o1
andcc %o0, %o1, %o0
bne,a 1f
st %o5, [%g7 + PID]
1: retl
nop
+END(__vfork)
-PSEUDO_END (__vfork)
weak_alias (__vfork, vfork)
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_init.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_init.c
new file mode 100644
index 0000000000..bbd08d0041
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_init.c
@@ -0,0 +1,62 @@
+/* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+struct sparc_pthread_barrier
+{
+ struct pthread_barrier b;
+ unsigned char left_lock;
+ unsigned char pshared;
+};
+
+int
+pthread_barrier_init (barrier, attr, count)
+ pthread_barrier_t *barrier;
+ const pthread_barrierattr_t *attr;
+ unsigned int count;
+{
+ struct sparc_pthread_barrier *ibarrier;
+
+ if (__builtin_expect (count == 0, 0))
+ return EINVAL;
+
+ struct pthread_barrierattr *iattr = (struct pthread_barrierattr *) attr;
+ if (iattr != NULL)
+ {
+ if (iattr->pshared != PTHREAD_PROCESS_PRIVATE
+ && __builtin_expect (iattr->pshared != PTHREAD_PROCESS_SHARED, 0))
+ /* Invalid attribute. */
+ return EINVAL;
+ }
+
+ ibarrier = (struct sparc_pthread_barrier *) barrier;
+
+ /* Initialize the individual fields. */
+ ibarrier->b.lock = LLL_LOCK_INITIALIZER;
+ ibarrier->b.left = count;
+ ibarrier->b.init_count = count;
+ ibarrier->b.curr_event = 0;
+ ibarrier->left_lock = 0;
+ ibarrier->pshared = (iattr && iattr->pshared == PTHREAD_PROCESS_SHARED);
+
+ return 0;
+}
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
new file mode 100644
index 0000000000..4dfd11dcbe
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_wait.c
@@ -0,0 +1,100 @@
+/* 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.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <pthreadP.h>
+
+struct sparc_pthread_barrier
+{
+ struct pthread_barrier b;
+ unsigned char left_lock;
+ unsigned char pshared;
+};
+
+/* Wait on barrier. */
+int
+pthread_barrier_wait (barrier)
+ pthread_barrier_t *barrier;
+{
+ struct sparc_pthread_barrier *ibarrier
+ = (struct sparc_pthread_barrier *) barrier;
+ int result = 0;
+
+ /* Make sure we are alone. */
+ lll_lock (ibarrier->b.lock);
+
+ /* One more arrival. */
+ --ibarrier->b.left;
+
+ /* Are these all? */
+ if (ibarrier->b.left == 0)
+ {
+ /* Yes. Increment the event counter to avoid invalid wake-ups and
+ tell the current waiters that it is their turn. */
+ ++ibarrier->b.curr_event;
+
+ /* Wake up everybody. */
+ lll_futex_wake (&ibarrier->b.curr_event, INT_MAX);
+
+ /* This is the thread which finished the serialization. */
+ result = PTHREAD_BARRIER_SERIAL_THREAD;
+ }
+ else
+ {
+ /* The number of the event we are waiting for. The barrier's event
+ number must be bumped before we continue. */
+ unsigned int event = ibarrier->b.curr_event;
+
+ /* Before suspending, make the barrier available to others. */
+ lll_unlock (ibarrier->b.lock);
+
+ /* Wait for the event counter of the barrier to change. */
+ do
+ lll_futex_wait (&ibarrier->b.curr_event, event);
+ while (event == ibarrier->b.curr_event);
+ }
+
+ /* Make sure the init_count is stored locally or in a register. */
+ unsigned int init_count = ibarrier->b.init_count;
+
+ /* If this was the last woken thread, unlock. */
+ if (__atomic_is_v9 || ibarrier->pshared == 0)
+ {
+ if (atomic_increment_val (&ibarrier->b.left) == init_count)
+ /* We are done. */
+ lll_unlock (ibarrier->b.lock);
+ }
+ else
+ {
+ unsigned int left;
+ /* Slightly more complicated. On pre-v9 CPUs, atomic_increment_val
+ is only atomic for threads within the same process, not for
+ multiple processes. */
+ __sparc32_atomic_do_lock24 (&ibarrier->left_lock);
+ left = ++ibarrier->b.left;
+ __sparc32_atomic_do_unlock24 (&ibarrier->left_lock);
+ if (left == init_count)
+ /* We are done. */
+ lll_unlock (ibarrier->b.lock);
+ }
+
+ return result;
+}
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_init.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_init.c
new file mode 100644
index 0000000000..dffd8c7efa
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_init.c
@@ -0,0 +1,63 @@
+/* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <semaphore.h>
+#include <lowlevellock.h>
+#include <shlib-compat.h>
+#include "semaphoreP.h"
+
+struct sparc_sem
+{
+ struct sem s;
+ unsigned char lock;
+};
+
+
+int
+__new_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 sparc_sem *isem = (struct sparc_sem *) sem;
+
+ /* Use the value the user provided. */
+ isem->s.count = value;
+
+ isem->lock = 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)
+strong_alias (__new_sem_init, __old_sem_init)
+compat_symbol (libpthread, __old_sem_init, sem_init, GLIBC_2_0);
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_post.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_post.c
new file mode 100644
index 0000000000..be1cc60b11
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_post.c
@@ -0,0 +1,54 @@
+/* sem_post -- post to a POSIX semaphore. SPARC version.
+ 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.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <internaltypes.h>
+#include <semaphore.h>
+
+#include <shlib-compat.h>
+
+int
+__new_sem_post (sem_t *sem)
+{
+ int *futex = (int *) sem, nr;
+
+ if (__atomic_is_v9)
+ nr = atomic_increment_val (futex);
+ else
+ {
+ __sparc32_atomic_do_lock24 (futex + 1);
+ nr = ++*futex;
+ __sparc32_atomic_do_unlock24 (futex + 1);
+ }
+ int err = lll_futex_wake (futex, nr);
+ 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)
+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/sparc/sparc32/sem_timedwait.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_timedwait.c
new file mode 100644
index 0000000000..efcc9e9aa8
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_timedwait.c
@@ -0,0 +1,117 @@
+/* sem_timedwait -- wait on a semaphore. SPARC version.
+ 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.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <internaltypes.h>
+#include <semaphore.h>
+
+#include <pthreadP.h>
+#include <shlib-compat.h>
+
+
+int
+sem_timedwait (sem_t *sem, const struct timespec *abstime)
+{
+ /* First check for cancellation. */
+ CANCELLATION_P (THREAD_SELF);
+
+ int *futex = (int *) sem;
+ int val;
+ int err;
+
+ if (*futex > 0)
+ {
+ if (__atomic_is_v9)
+ val = atomic_decrement_if_positive (futex);
+ else
+ {
+ __sparc32_atomic_do_lock24 (futex + 1);
+ val = *futex;
+ if (val > 0)
+ *futex = val - 1;
+ __sparc32_atomic_do_unlock24 (futex + 1);
+ }
+ if (val > 0)
+ return 0;
+ }
+
+ err = -EINVAL;
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ goto error_return;
+
+ do
+ {
+ struct timeval tv;
+ struct timespec rt;
+ int sec, nsec;
+
+ /* Get the current time. */
+ __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ sec = abstime->tv_sec - tv.tv_sec;
+ nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (nsec < 0)
+ {
+ nsec += 1000000000;
+ --sec;
+ }
+
+ /* Already timed out? */
+ err = -ETIMEDOUT;
+ if (sec < 0)
+ goto error_return;
+
+ /* Do wait. */
+ rt.tv_sec = sec;
+ rt.tv_nsec = nsec;
+
+ /* Enable asynchronous cancellation. Required by the standard. */
+ int oldtype = __pthread_enable_asynccancel ();
+
+ err = lll_futex_timed_wait (futex, 0, &rt);
+
+ /* Disable asynchronous cancellation. */
+ __pthread_disable_asynccancel (oldtype);
+
+ if (err != 0 && err != -EWOULDBLOCK)
+ goto error_return;
+
+ if (__atomic_is_v9)
+ val = atomic_decrement_if_positive (futex);
+ else
+ {
+ __sparc32_atomic_do_lock24 (futex + 1);
+ val = *futex;
+ if (val > 0)
+ *futex = val - 1;
+ __sparc32_atomic_do_unlock24 (futex + 1);
+ }
+ }
+ while (val <= 0);
+
+ return 0;
+
+ error_return:
+ __set_errno (-err);
+ return -1;
+}
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_trywait.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_trywait.c
new file mode 100644
index 0000000000..429494e257
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_trywait.c
@@ -0,0 +1,59 @@
+/* sem_trywait -- wait on a semaphore. SPARC version.
+ 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.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <internaltypes.h>
+#include <semaphore.h>
+
+#include <shlib-compat.h>
+
+
+int
+__new_sem_trywait (sem_t *sem)
+{
+ int *futex = (int *) sem;
+ int val;
+
+ if (*futex > 0)
+ {
+ if (__atomic_is_v9)
+ val = atomic_decrement_if_positive (futex);
+ else
+ {
+ __sparc32_atomic_do_lock24 (futex + 1);
+ val = *futex;
+ if (val > 0)
+ *futex = val - 1;
+ __sparc32_atomic_do_unlock24 (futex + 1);
+ }
+ if (val > 0)
+ return 0;
+ }
+
+ __set_errno (EAGAIN);
+ return -1;
+}
+versioned_symbol (libpthread, __new_sem_trywait, sem_trywait, GLIBC_2_1);
+#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_1)
+strong_alias (__new_sem_trywait, __old_sem_trywait)
+compat_symbol (libpthread, __old_sem_trywait, sem_trywait, GLIBC_2_0);
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_wait.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_wait.c
new file mode 100644
index 0000000000..d9fcdcd4ee
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sem_wait.c
@@ -0,0 +1,74 @@
+/* sem_wait -- wait on a semaphore. SPARC version.
+ 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.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <internaltypes.h>
+#include <semaphore.h>
+
+#include <pthreadP.h>
+#include <shlib-compat.h>
+
+
+int
+__new_sem_wait (sem_t *sem)
+{
+ /* First check for cancellation. */
+ CANCELLATION_P (THREAD_SELF);
+
+ int *futex = (int *) sem;
+ int err;
+
+ do
+ {
+ int val;
+ if (__atomic_is_v9)
+ val = atomic_decrement_if_positive (futex);
+ else
+ {
+ __sparc32_atomic_do_lock24 (futex + 1);
+ val = *futex;
+ if (val > 0)
+ *futex = val - 1;
+ __sparc32_atomic_do_unlock24 (futex + 1);
+ }
+ if (val > 0)
+ return 0;
+
+ /* Enable asynchronous cancellation. Required by the standard. */
+ int oldtype = __pthread_enable_asynccancel ();
+
+ err = lll_futex_wait (futex, 0);
+
+ /* Disable asynchronous cancellation. */
+ __pthread_disable_asynccancel (oldtype);
+ }
+ while (err == 0 || err == -EWOULDBLOCK);
+
+ __set_errno (-err);
+ 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/sparc/sparc32/sparcv9/pthread_barrier_init.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_init.c
new file mode 100644
index 0000000000..b2b842336e
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_init.c
@@ -0,0 +1 @@
+#include "../../../../../../../pthread_barrier_init.c"
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c
new file mode 100644
index 0000000000..7613863bba
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c
@@ -0,0 +1 @@
+#include "../../../../../../pthread/pthread_barrier_wait.c"
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_init.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_init.c
new file mode 100644
index 0000000000..b2ebc4cbb5
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_init.c
@@ -0,0 +1 @@
+#include "../../../../../../../sem_init.c"
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_post.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_post.c
new file mode 100644
index 0000000000..4a6eac88f5
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_post.c
@@ -0,0 +1 @@
+#include "../../../sem_post.c"
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_timedwait.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_timedwait.c
new file mode 100644
index 0000000000..b2526db02c
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_timedwait.c
@@ -0,0 +1 @@
+#include "../../../sem_timedwait.c"
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_trywait.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_trywait.c
new file mode 100644
index 0000000000..aae46f725e
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_trywait.c
@@ -0,0 +1 @@
+#include "../../../sem_trywait.c"
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_wait.c b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_wait.c
new file mode 100644
index 0000000000..31157f636f
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_wait.c
@@ -0,0 +1 @@
+#include "../../../sem_wait.c"
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h
index 5edf4b3772..f0349906b2 100644
--- a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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 Jakub Jelinek <jakub@redhat.com>, 2002.
@@ -26,55 +26,48 @@
#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .text; \
-ENTRY(name) \
- ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1; \
- cmp %g1, 0; \
- bne 1f; \
-.type __##syscall_name##_nocancel,@function; \
-.globl __##syscall_name##_nocancel; \
-__##syscall_name##_nocancel: \
- mov SYS_ify(syscall_name), %g1; \
- ta 0x10; \
- bcs __syscall_error_handler; \
- nop; \
-.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
- .subsection 2; \
- cfi_startproc; \
-1: save %sp, -96, %sp; \
- cfi_def_cfa_register (%fp); \
- cfi_window_save; \
- cfi_register (%o7, %i7); \
- CENABLE; \
- nop; \
- mov %o0, %l0; \
- COPY_ARGS_##args \
- mov SYS_ify(syscall_name), %g1; \
- ta 0x10; \
- bcs __syscall_error_handler2; \
- mov %o0, %l1; \
- CDISABLE; \
- mov %l0, %o0; \
- jmpl %i7 + 8, %g0; \
- restore %g0, %l1, %o0; \
- cfi_endproc; \
- .previous; \
- SYSCALL_ERROR_HANDLER \
- SYSCALL_ERROR_HANDLER2
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ .globl __syscall_error; \
+ENTRY(name) \
+ ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1;\
+ cmp %g1, 0; \
+ bne 1f; \
+.type __##syscall_name##_nocancel,@function; \
+.globl __##syscall_name##_nocancel; \
+__##syscall_name##_nocancel: \
+ mov SYS_ify(syscall_name), %g1; \
+ ta 0x10; \
+ bcc 8f; \
+ mov %o7, %g1; \
+ call __syscall_error; \
+ mov %g1, %o7; \
+8: jmpl %o7 + 8, %g0; \
+ nop; \
+.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;\
+1: save %sp, -96, %sp; \
+ cfi_def_cfa_register(%fp); \
+ cfi_window_save; \
+ cfi_register(%o7, %i7); \
+ CENABLE; \
+ nop; \
+ mov %o0, %l0; \
+ COPY_ARGS_##args \
+ mov SYS_ify(syscall_name), %g1; \
+ ta 0x10; \
+ bcc 1f; \
+ mov %o0, %l1; \
+ CDISABLE; \
+ mov %l0, %o0; \
+ call __syscall_error; \
+ mov %l1, %o0; \
+ b 2f; \
+ mov -1, %l1; \
+1: CDISABLE; \
+ mov %l0, %o0; \
+2: jmpl %i7 + 8, %g0; \
+ restore %g0, %l1, %o0;
-#define SYSCALL_ERROR_HANDLER2 \
-SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler2) \
- .global __errno_location; \
- .type __errno_location,@function; \
- CDISABLE; \
- mov %l0, %o0; \
- call __errno_location; \
- nop; \
- st %l1, [%o0]; \
- jmpl %i7 + 8, %g0; \
- restore %g0, -1, %o0; \
- .previous;
# ifdef IS_IN_libpthread
# define CENABLE call __pthread_enable_asynccancel
@@ -111,3 +104,9 @@ SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler2) \
# define NO_CANCELLATION 1
#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S
index 7229608142..a8e4dd5a43 100644
--- a/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S
@@ -21,6 +21,7 @@
#include <tcb-offsets.h>
.text
+ .globl __syscall_error
ENTRY(__vfork)
ld [%g7 + PID], %o5
cmp %o5, 0
@@ -31,16 +32,18 @@ ENTRY(__vfork)
LOADSYSCALL(vfork)
ta 0x10
- bcs,a __syscall_error_handler
- st %o5, [%g7 + PID]
- SYSCALL_ERROR_HANDLER
- sub %o1, 1, %o1
+ bcc 2f
+ mov %o7, %g1
+ st %o5, [%g7 + PID]
+ call __syscall_error
+ mov %g1, %o7
+2: sub %o1, 1, %o1
andcc %o0, %o1, %o0
bne,a 1f
st %o5, [%g7 + PID]
1: retl
nop
+END(__vfork)
-PSEUDO_END (__vfork)
libc_hidden_def (__vfork)
weak_alias (__vfork, vfork)
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S b/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S
new file mode 100644
index 0000000000..675a997e97
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S
@@ -0,0 +1,9 @@
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <clone.S>
+#else
+# define RESET_PID
+# include_next <clone.S>
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/pt-vfork.S b/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/pt-vfork.S
index e9018b2e99..8941043c3a 100644
--- a/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/pt-vfork.S
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/pt-vfork.S
@@ -21,6 +21,7 @@
#include <tcb-offsets.h>
.text
+ .globl __syscall_error
ENTRY(__vfork)
ld [%g7 + PID], %o5
sub %g0, %o5, %o4
@@ -28,15 +29,17 @@ ENTRY(__vfork)
LOADSYSCALL(vfork)
ta 0x6d
- bcs,a,pn %xcc, __syscall_error_handler
- st %o5, [%g7 + PID]
- SYSCALL_ERROR_HANDLER
- sub %o1, 1, %o1
+ bcc,pt %xcc, 2f
+ mov %o7, %g1
+ st %o5, [%g7 + PID]
+ call __syscall_error
+ mov %g1, %o7
+2: sub %o1, 1, %o1
andcc %o0, %o1, %o0
bne,a,pt %icc, 1f
st %o5, [%g7 + PID]
1: retl
nop
+END(__vfork)
-PSEUDO_END (__vfork)
weak_alias (__vfork, vfork)
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h
index d8c65aeffd..2c76d01715 100644
--- a/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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 Jakub Jelinek <jakub@redhat.com>, 2002.
@@ -26,49 +26,46 @@
#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .text; \
-ENTRY(name) \
- ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1; \
- brnz,pn %g1, 1f; \
-.type __##syscall_name##_nocancel,@function; \
-.globl __##syscall_name##_nocancel; \
-__##syscall_name##_nocancel: \
- mov SYS_ify(syscall_name), %g1; \
- ta 0x6d; \
- bcs,pn %xcc, __syscall_error_handler; \
- nop; \
-.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
- .subsection 2; \
-1: save %sp, -192, %sp; \
- CENABLE; \
- nop; \
- mov %o0, %l0; \
- COPY_ARGS_##args \
- mov SYS_ify(syscall_name), %g1; \
- ta 0x6d; \
- bcs,pn %xcc, __syscall_error_handler2; \
- mov %o0, %l1; \
- CDISABLE; \
- mov %l0, %o0; \
- jmpl %i7 + 8, %g0; \
- restore %g0, %l1, %o0; \
- .previous; \
- SYSCALL_ERROR_HANDLER \
- SYSCALL_ERROR_HANDLER2
-
-#define SYSCALL_ERROR_HANDLER2 \
-SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler2) \
- .global __errno_location; \
- .type __errno_location,@function; \
- CDISABLE; \
- mov %l0, %o0; \
- call __errno_location; \
- nop; \
- st %l1, [%o0]; \
- jmpl %i7 + 8, %g0; \
- restore %g0, -1, %o0; \
- .previous;
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ .globl __syscall_error; \
+ENTRY(name) \
+ ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1;\
+ brnz,pn %g1, 1f; \
+.type __##syscall_name##_nocancel,@function; \
+.globl __##syscall_name##_nocancel; \
+__##syscall_name##_nocancel: \
+ mov SYS_ify(syscall_name), %g1; \
+ ta 0x6d; \
+ bcc,pt %xcc, 8f; \
+ mov %o7, %g1; \
+ call __syscall_error; \
+ mov %g1, %o7; \
+8: jmpl %o7 + 8, %g0; \
+ nop; \
+.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;\
+1: save %sp, -192, %sp; \
+ cfi_def_cfa_register(%fp); \
+ cfi_window_save; \
+ cfi_register(%o7, %i7); \
+ CENABLE; \
+ nop; \
+ mov %o0, %l0; \
+ COPY_ARGS_##args \
+ mov SYS_ify(syscall_name), %g1; \
+ ta 0x6d; \
+ bcc,pt %xcc, 1f; \
+ mov %o0, %l1; \
+ CDISABLE; \
+ mov %l0, %o0; \
+ call __syscall_error; \
+ mov %l1, %o0; \
+ ba,pt %xcc, 2f; \
+ mov -1, %l1; \
+1: CDISABLE; \
+ mov %l0, %o0; \
+2: jmpl %i7 + 8, %g0; \
+ restore %g0, %l1, %o0;
# ifdef IS_IN_libpthread
# define CENABLE call __pthread_enable_asynccancel
@@ -105,3 +102,9 @@ SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler2) \
# define NO_CANCELLATION 1
#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S b/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S
index d6b2455d43..5597574304 100644
--- a/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S
@@ -21,6 +21,7 @@
#include <tcb-offsets.h>
.text
+ .globl __syscall_error
ENTRY(__vfork)
ld [%g7 + PID], %o5
sethi %hi(0x80000000), %o3
@@ -31,16 +32,18 @@ ENTRY(__vfork)
LOADSYSCALL(vfork)
ta 0x6d
- bcs,a,pn %xcc, __syscall_error_handler
- st %o5, [%g7 + PID]
- SYSCALL_ERROR_HANDLER
- sub %o1, 1, %o1
+ bcc,pt %xcc, 2f
+ mov %o7, %g1
+ st %o5, [%g7 + PID]
+ call __syscall_error
+ mov %g1, %o7
+2: sub %o1, 1, %o1
andcc %o0, %o1, %o0
bne,a,pt %icc, 1f
st %o5, [%g7 + PID]
1: retl
nop
+END(__vfork)
-PSEUDO_END (__vfork)
libc_hidden_def (__vfork)
weak_alias (__vfork, vfork)
diff --git a/nptl/sysdeps/unix/sysv/linux/timer_create.c b/nptl/sysdeps/unix/sysv/linux/timer_create.c
index ca6ff6c7ef..5e99513950 100644
--- a/nptl/sysdeps/unix/sysv/linux/timer_create.c
+++ b/nptl/sysdeps/unix/sysv/linux/timer_create.c
@@ -28,6 +28,7 @@
#include <internaltypes.h>
#include <nptl/pthreadP.h>
#include "kernel-posix-timers.h"
+#include "kernel-posix-cpu-timers.h"
#ifdef __NR_timer_create
@@ -58,6 +59,12 @@ timer_create (clock_id, evp, timerid)
if (__no_posix_timers >= 0)
# endif
{
+ clockid_t syscall_clockid = (clock_id == CLOCK_PROCESS_CPUTIME_ID
+ ? MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED)
+ : clock_id == CLOCK_THREAD_CPUTIME_ID
+ ? MAKE_THREAD_CPUCLOCK (0, CPUCLOCK_SCHED)
+ : clock_id);
+
/* If the user wants notification via a thread we need to handle
this special. */
if (evp == NULL
@@ -88,7 +95,7 @@ timer_create (clock_id, evp, timerid)
}
kernel_timer_t ktimerid;
- int retval = INLINE_SYSCALL (timer_create, 3, clock_id, evp,
+ int retval = INLINE_SYSCALL (timer_create, 3, syscall_clockid, evp,
&ktimerid);
# ifndef __ASSUME_POSIX_TIMERS
@@ -196,8 +203,8 @@ timer_create (clock_id, evp, timerid)
/* Create the timer. */
INTERNAL_SYSCALL_DECL (err);
int res;
- res = INTERNAL_SYSCALL (timer_create, err, 3, clock_id, &sev,
- &newp->ktimerid);
+ res = INTERNAL_SYSCALL (timer_create, err, 3,
+ syscall_clockid, &sev, &newp->ktimerid);
if (! INTERNAL_SYSCALL_ERROR_P (res, err))
{
*timerid = (timer_t) newp;
diff --git a/nptl/sysdeps/unix/sysv/linux/timer_routines.c b/nptl/sysdeps/unix/sysv/linux/timer_routines.c
index 23c800f98e..a5eb442251 100644
--- a/nptl/sysdeps/unix/sysv/linux/timer_routines.c
+++ b/nptl/sysdeps/unix/sysv/linux/timer_routines.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 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 Ulrich Drepper <drepper@redhat.com>, 2003.
@@ -27,6 +27,13 @@
#include "kernel-posix-timers.h"
+struct thread_start_data
+{
+ void (*thrfunc) (sigval_t);
+ sigval_t sival;
+};
+
+
#ifdef __NR_timer_create
/* Helper thread to call the user-provided function. */
static void *
@@ -40,10 +47,16 @@ timer_sigev_thread (void *arg)
INTERNAL_SYSCALL_DECL (err);
INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, NULL, _NSIG / 8);
- struct timer *tk = (struct timer *) arg;
+ struct thread_start_data *td = (struct thread_start_data *) arg;
+
+ void (*thrfunc) (sigval_t) = td->thrfunc;
+ sigval_t sival = td->sival;
+
+ /* The TD object was allocated in timer_helper_thread. */
+ free (td);
/* Call the user-provided function. */
- tk->thrfunc (tk->sival);
+ thrfunc (sival);
return NULL;
}
@@ -53,10 +66,11 @@ timer_sigev_thread (void *arg)
static void *
timer_helper_thread (void *arg)
{
- /* Wait for the SIGTIMER signal and none else. */
+ /* Wait for the SIGTIMER signal, allowing the setXid signal, and
+ none else. */
sigset_t ss;
sigemptyset (&ss);
- sigaddset (&ss, SIGTIMER);
+ __sigaddset (&ss, SIGTIMER);
/* Endless loop of waiting for signals. The loop is only ended when
the thread is canceled. */
@@ -81,10 +95,19 @@ timer_helper_thread (void *arg)
if (si.si_code == SI_TIMER)
{
struct timer *tk = (struct timer *) si.si_ptr;
-
- /* That the signal we are waiting for. */
- pthread_t th;
- (void) pthread_create (&th, &tk->attr, timer_sigev_thread, tk);
+ struct thread_start_data *td = malloc (sizeof (*td));
+
+ /* There is not much we can do if the allocation fails. */
+ if (td != NULL)
+ {
+ /* That is the signal we are waiting for. */
+ td->thrfunc = tk->thrfunc;
+ td->sival = tk->sival;
+
+ pthread_t th;
+ (void) pthread_create (&th, &tk->attr, timer_sigev_thread,
+ td);
+ }
}
else if (si.si_code == SI_TKILL)
/* The thread is canceled. */
@@ -121,10 +144,11 @@ __start_helper_thread (void)
(void) pthread_attr_init (&attr);
(void) pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
- /* Block all signals in the helper thread. To do this thoroughly we
- temporarily have to block all signals here. The helper can lose
- wakeups if SIGCANCEL is not blocked throughout, but sigfillset omits
- it. So, we add it back explicitly here. */
+ /* Block all signals in the helper thread but SIGSETXID. To do this
+ thoroughly we temporarily have to block all signals here. The
+ helper can lose wakeups if SIGCANCEL is not blocked throughout,
+ but sigfillset omits it SIGSETXID. So, we add SIGCANCEL back
+ explicitly here. */
sigset_t ss;
sigset_t oss;
sigfillset (&ss);
diff --git a/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c b/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c
index 72c8d615eb..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 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.
@@ -19,7 +19,7 @@
#include <errno.h>
#include <stdlib.h>
-#include "fork.h"
+#include <fork.h>
#include <atomic.h>
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 92fb08c951..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 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.
@@ -57,11 +57,25 @@ typedef union
} pthread_attr_t;
+#if __WORDSIZE == 64
+typedef struct __pthread_internal_list
+{
+ struct __pthread_internal_list *__prev;
+ struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+
/* Data structures for mutex handling. The structure of the attribute
type is not exposed on purpose. */
typedef union
{
- struct
+ struct __pthread_mutex_s
{
int __lock;
unsigned int __count;
@@ -72,10 +86,18 @@ typedef union
/* KIND must stay at this position in the structure to maintain
binary compatibility. */
int __kind;
-#if __WORDSIZE != 64
+#if __WORDSIZE == 64
+ int __spins;
+ __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV 1
+#else
unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
#endif
- int __spins;
} __data;
char __size[__SIZEOF_PTHREAD_MUTEX_T];
long int __align;
@@ -192,4 +214,9 @@ typedef union
#endif
+#if __WORDSIZE == 32
+/* Extra attributes for the cleanup functions. */
+# define __cleanup_fct_attribute __attribute__ ((__regparm__ (1)))
+#endif
+
#endif /* bits/pthreadtypes.h */
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S b/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S
index dfa6adb3e2..675a997e97 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S
@@ -1,2 +1,9 @@
-#define RESET_PID
-#include <sysdeps/unix/sysv/linux/x86_64/clone.S>
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <clone.S>
+#else
+# define RESET_PID
+# include_next <clone.S>
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
index d5c9345558..394dec8d82 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -43,17 +43,25 @@
.hidden __lll_mutex_lock_wait
.align 16
__lll_mutex_lock_wait:
+ cfi_startproc
pushq %r10
+ cfi_adjust_cfa_offset(8)
pushq %rdx
-
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%r10, -16)
+ cfi_offset(%rdx, -24)
xorq %r10, %r10 /* No timeout. */
movl $2, %edx
- movq %r10, %rsi /* movq $FUTEX_WAIT, %rsi */
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
cmpl %edx, %eax /* NB: %edx == 2 */
jne 2f
-1: movq $SYS_futex, %rax
+1: movl $SYS_futex, %eax
syscall
2: movl %edx, %eax
@@ -63,8 +71,13 @@ __lll_mutex_lock_wait:
jnz 1b
popq %rdx
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%rdx)
popq %r10
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r10)
retq
+ cfi_endproc
.size __lll_mutex_lock_wait,.-__lll_mutex_lock_wait
@@ -74,18 +87,30 @@ __lll_mutex_lock_wait:
.hidden __lll_mutex_timedlock_wait
.align 16
__lll_mutex_timedlock_wait:
+ cfi_startproc
/* Check for a valid timeout value. */
cmpq $1000000000, 8(%rdx)
jae 3f
pushq %r8
+ cfi_adjust_cfa_offset(8)
pushq %r9
+ cfi_adjust_cfa_offset(8)
pushq %r12
+ cfi_adjust_cfa_offset(8)
pushq %r13
+ cfi_adjust_cfa_offset(8)
pushq %r14
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%r8, -16)
+ cfi_offset(%r9, -24)
+ cfi_offset(%r12, -32)
+ cfi_offset(%r13, -40)
+ cfi_offset(%r14, -48)
/* Stack frame for the timespec and timeval structs. */
subq $16, %rsp
+ cfi_adjust_cfa_offset(16)
movq %rdi, %r12
movq %rdx, %r13
@@ -93,7 +118,7 @@ __lll_mutex_timedlock_wait:
1:
/* Get current time. */
movq %rsp, %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
movq $VSYSCALL_ADDR_vgettimeofday, %rax
/* This is a regular function call, all caller-save registers
might be clobbered. */
@@ -101,7 +126,7 @@ __lll_mutex_timedlock_wait:
/* Compute relative timeout. */
movq 8(%rsp), %rax
- movq $1000, %rdi
+ movl $1000, %edi
mul %rdi /* Milli seconds to nano seconds. */
movq (%r13), %rdi
movq 8(%r13), %rsi
@@ -126,26 +151,50 @@ __lll_mutex_timedlock_wait:
je 8f
movq %rsp, %r10
- xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
movq %r12, %rdi
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
movq %rax, %rcx
8: /* NB: %edx == 2 */
xorl %eax, %eax
LOCK
- cmpxchgl %edx, (%rdi)
+ cmpxchgl %edx, (%r12)
jnz 7f
6: addq $16, %rsp
+ cfi_adjust_cfa_offset(-16)
popq %r14
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r14)
popq %r13
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r13)
popq %r12
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r12)
popq %r9
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r9)
popq %r8
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r8)
retq
+3: movl $EINVAL, %eax
+ retq
+
+ cfi_adjust_cfa_offset(56)
+ cfi_offset(%r8, -16)
+ cfi_offset(%r9, -24)
+ cfi_offset(%r12, -32)
+ cfi_offset(%r13, -40)
+ cfi_offset(%r14, -48)
/* Check whether the time expired. */
7: cmpq $-ETIMEDOUT, %rcx
je 5f
@@ -157,11 +206,9 @@ __lll_mutex_timedlock_wait:
jz 6b
jmp 1b
-3: movl $EINVAL, %eax
- retq
-
5: movl $ETIMEDOUT, %eax
jmp 6b
+ cfi_endproc
.size __lll_mutex_timedlock_wait,.-__lll_mutex_timedlock_wait
#endif
@@ -191,18 +238,28 @@ lll_unlock_wake_cb:
.hidden __lll_mutex_unlock_wake
.align 16
__lll_mutex_unlock_wake:
+ cfi_startproc
pushq %rsi
+ cfi_adjust_cfa_offset(8)
pushq %rdx
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%rsi, -16)
+ cfi_offset(%rdx, -24)
movl $0, (%rdi)
- movq $FUTEX_WAKE, %rsi
+ movl $FUTEX_WAKE, %esi
movl $1, %edx /* Wake one thread. */
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
popq %rdx
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%rdx)
popq %rsi
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%rsi)
retq
+ cfi_endproc
.size __lll_mutex_unlock_wake,.-__lll_mutex_unlock_wake
@@ -222,13 +279,13 @@ __lll_timedwait_tid:
/* Get current time. */
2: movq %rsp, %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
movq $VSYSCALL_ADDR_vgettimeofday, %rax
callq *%rax
/* Compute relative timeout. */
movq 8(%rsp), %rax
- movq $1000, %rdi
+ movl $1000, %edi
mul %rdi /* Milli seconds to nano seconds. */
movq (%r13), %rdi
movq 8(%r13), %rsi
@@ -248,9 +305,13 @@ __lll_timedwait_tid:
jz 4f
movq %rsp, %r10
- xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
movq %r12, %rdi
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
cmpl $0, (%rdi)
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
index 40c2518af6..97085bf018 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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.
@@ -35,6 +35,9 @@
#define SYS_futex 202
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
/* Initializer for compatibility lock. */
@@ -46,17 +49,130 @@
#define BUSY_WAIT_NOP asm ("rep; nop")
+#define LLL_STUB_UNWIND_INFO_START \
+ ".section .eh_frame,\"a\",@progbits\n" \
+"7:\t" ".long 9f-8f # Length of Common Information Entry\n" \
+"8:\t" ".long 0x0 # CIE Identifier Tag\n\t" \
+ ".byte 0x1 # CIE Version\n\t" \
+ ".ascii \"zR\\0\" # CIE Augmentation\n\t" \
+ ".uleb128 0x1 # CIE Code Alignment Factor\n\t" \
+ ".sleb128 -8 # CIE Data Alignment Factor\n\t" \
+ ".byte 0x10 # CIE RA Column\n\t" \
+ ".uleb128 0x1 # Augmentation size\n\t" \
+ ".byte 0x1b # FDE Encoding (pcrel sdata4)\n\t" \
+ ".byte 0x12 # DW_CFA_def_cfa_sf\n\t" \
+ ".uleb128 0x7\n\t" \
+ ".sleb128 16\n\t" \
+ ".align 8\n" \
+"9:\t" ".long 23f-10f # FDE Length\n" \
+"10:\t" ".long 10b-7b # FDE CIE offset\n\t" \
+ ".long 1b-. # FDE initial location\n\t" \
+ ".long 6b-1b # FDE address range\n\t" \
+ ".uleb128 0x0 # Augmentation size\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x10\n\t" \
+ ".uleb128 12f-11f\n" \
+"11:\t" ".byte 0x80 # DW_OP_breg16\n\t" \
+ ".sleb128 4b-1b\n"
+#define LLL_STUB_UNWIND_INFO_END \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x10\n\t" \
+ ".uleb128 14f-13f\n" \
+"13:\t" ".byte 0x80 # DW_OP_breg16\n\t" \
+ ".sleb128 4b-2b\n" \
+"14:\t" ".byte 0x40 + (3b-2b) # DW_CFA_advance_loc\n\t" \
+ ".byte 0x0e # DW_CFA_def_cfa_offset\n\t" \
+ ".uleb128 0\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x10\n\t" \
+ ".uleb128 16f-15f\n" \
+"15:\t" ".byte 0x80 # DW_OP_breg16\n\t" \
+ ".sleb128 4b-3b\n" \
+"16:\t" ".byte 0x40 + (4b-3b-1) # DW_CFA_advance_loc\n\t" \
+ ".byte 0x0e # DW_CFA_def_cfa_offset\n\t" \
+ ".uleb128 128\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x10\n\t" \
+ ".uleb128 20f-17f\n" \
+"17:\t" ".byte 0x80 # DW_OP_breg16\n\t" \
+ ".sleb128 19f-18f\n\t" \
+ ".byte 0x0d # DW_OP_const4s\n" \
+"18:\t" ".4byte 4b-.\n\t" \
+ ".byte 0x1c # DW_OP_minus\n\t" \
+ ".byte 0x0d # DW_OP_const4s\n" \
+"19:\t" ".4byte 24f-.\n\t" \
+ ".byte 0x22 # DW_OP_plus\n" \
+"20:\t" ".byte 0x40 + (5b-4b+1) # DW_CFA_advance_loc\n\t" \
+ ".byte 0x13 # DW_CFA_def_cfa_offset_sf\n\t" \
+ ".sleb128 16\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x10\n\t" \
+ ".uleb128 22f-21f\n" \
+"21:\t" ".byte 0x80 # DW_OP_breg16\n\t" \
+ ".sleb128 4b-5b\n" \
+"22:\t" ".align 8\n" \
+"23:\t" ".previous\n"
+
+/* Unwind info for
+ 1: leaq ..., %rdi
+ 2: subq $128, %rsp
+ 3: callq ...
+ 4: addq $128, %rsp
+ 5: jmp 24f
+ 6:
+ snippet. */
+#define LLL_STUB_UNWIND_INFO_5 \
+LLL_STUB_UNWIND_INFO_START \
+"12:\t" ".byte 0x40 + (2b-1b) # DW_CFA_advance_loc\n\t" \
+LLL_STUB_UNWIND_INFO_END
+
+/* Unwind info for
+ 1: leaq ..., %rdi
+ 0: movq ..., %rdx
+ 2: subq $128, %rsp
+ 3: callq ...
+ 4: addq $128, %rsp
+ 5: jmp 24f
+ 6:
+ snippet. */
+#define LLL_STUB_UNWIND_INFO_6 \
+LLL_STUB_UNWIND_INFO_START \
+"12:\t" ".byte 0x40 + (0b-1b) # DW_CFA_advance_loc\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x10\n\t" \
+ ".uleb128 26f-25f\n" \
+"25:\t" ".byte 0x80 # DW_OP_breg16\n\t" \
+ ".sleb128 4b-0b\n" \
+"26:\t" ".byte 0x40 + (2b-0b) # DW_CFA_advance_loc\n\t" \
+LLL_STUB_UNWIND_INFO_END
+
+
#define lll_futex_wait(futex, val) \
- do { \
- int __ignore; \
+ ({ \
+ int __status; \
register __typeof (val) _val asm ("edx") = (val); \
__asm __volatile ("xorq %%r10, %%r10\n\t" \
"syscall" \
- : "=a" (__ignore) \
+ : "=a" (__status) \
: "0" (SYS_futex), "D" (futex), "S" (FUTEX_WAIT), \
"d" (_val) \
: "memory", "cc", "r10", "r11", "cx"); \
- } while (0)
+ __status; \
+ })
+
+
+#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), \
+ "d" (_val), "r" (__to) \
+ : "memory", "cc", "r11", "cx"); \
+ __status; \
+ })
#define lll_futex_wake(futex, nr) \
@@ -96,6 +212,16 @@ extern int __lll_mutex_unlock_wait (int *__futex) attribute_hidden;
ret; })
+#define lll_robust_mutex_trylock(futex, id) \
+ ({ int ret; \
+ __asm __volatile (LOCK_INSTR "cmpxchgl %2, %1" \
+ : "=a" (ret), "=m" (futex) \
+ : "r" (id), "m" (futex), \
+ "0" (LLL_MUTEX_LOCK_INITIALIZER) \
+ : "memory"); \
+ ret; })
+
+
#define lll_mutex_cond_trylock(futex) \
({ int ret; \
__asm __volatile (LOCK_INSTR "cmpxchgl %2, %1" \
@@ -110,51 +236,109 @@ extern int __lll_mutex_unlock_wait (int *__futex) attribute_hidden;
(void) ({ int ignore1, ignore2, ignore3; \
__asm __volatile (LOCK_INSTR "cmpxchgl %0, %2\n\t" \
"jnz 1f\n\t" \
- ".subsection 1\n" \
- "1:\tleaq %2, %%rdi\n\t" \
- "subq $128, %%rsp\n\t" \
- "callq __lll_mutex_lock_wait\n\t" \
- "addq $128, %%rsp\n\t" \
- "jmp 2f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_mutex_lock_%=, @function\n" \
+ "_L_mutex_lock_%=:\n" \
+ "1:\tleaq %2, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_mutex_lock_wait\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_mutex_lock_%=, 6b-1b\n\t" \
".previous\n" \
- "2:" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
: "=S" (ignore1), "=&D" (ignore2), "=m" (futex),\
"=a" (ignore3) \
: "0" (1), "m" (futex), "3" (0) \
: "cx", "r11", "cc", "memory"); })
+#define lll_robust_mutex_lock(futex, id) \
+ ({ int result, ignore1, ignore2; \
+ __asm __volatile (LOCK_INSTR "cmpxchgl %0, %2\n\t" \
+ "jnz 1f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_mutex_lock_%=, @function\n" \
+ "_L_robust_mutex_lock_%=:\n" \
+ "1:\tleaq %2, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_robust_mutex_lock_wait\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_robust_mutex_lock_%=, 6b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
+ : "=S" (ignore1), "=&D" (ignore2), "=m" (futex), \
+ "=a" (result) \
+ : "0" (id), "m" (futex), "3" (0) \
+ : "cx", "r11", "cc", "memory"); \
+ result; })
+
+
#define lll_mutex_cond_lock(futex) \
(void) ({ int ignore1, ignore2, ignore3; \
__asm __volatile (LOCK_INSTR "cmpxchgl %0, %2\n\t" \
"jnz 1f\n\t" \
- ".subsection 1\n" \
- "1:\tleaq %2, %%rdi\n\t" \
- "subq $128, %%rsp\n\t" \
- "callq __lll_mutex_lock_wait\n\t" \
- "addq $128, %%rsp\n\t" \
- "jmp 2f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_mutex_cond_lock_%=, @function\n" \
+ "_L_mutex_cond_lock_%=:\n" \
+ "1:\tleaq %2, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_mutex_lock_wait\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_mutex_cond_lock_%=, 6b-1b\n\t" \
".previous\n" \
- "2:" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
: "=S" (ignore1), "=&D" (ignore2), "=m" (futex),\
"=a" (ignore3) \
: "0" (2), "m" (futex), "3" (0) \
: "cx", "r11", "cc", "memory"); })
+#define lll_robust_mutex_cond_lock(futex, id) \
+ ({ int result, ignore1, ignore2; \
+ __asm __volatile (LOCK_INSTR "cmpxchgl %0, %2\n\t" \
+ "jnz 1f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_mutex_cond_lock_%=, @function\n" \
+ "_L_robust_mutex_cond_lock_%=:\n" \
+ "1:\tleaq %2, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_robust_mutex_lock_wait\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_robust_mutex_cond_lock_%=, 6b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
+ : "=S" (ignore1), "=&D" (ignore2), "=m" (futex), \
+ "=a" (result) \
+ : "0" (id | FUTEX_WAITERS), "m" (futex), "3" (0) \
+ : "cx", "r11", "cc", "memory"); \
+ result; })
+
+
#define lll_mutex_timedlock(futex, timeout) \
({ int result, ignore1, ignore2, ignore3; \
__asm __volatile (LOCK_INSTR "cmpxchgl %2, %4\n\t" \
"jnz 1f\n\t" \
- ".subsection 1\n" \
- "1:\tleaq %4, %%rdi\n\t" \
- "movq %8, %%rdx\n\t" \
- "subq $128, %%rsp\n\t" \
- "callq __lll_mutex_timedlock_wait\n\t" \
- "addq $128, %%rsp\n\t" \
- "jmp 2f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_mutex_timedlock_%=, @function\n" \
+ "_L_mutex_timedlock_%=:\n" \
+ "1:\tleaq %4, %%rdi\n" \
+ "0:\tmovq %8, %%rdx\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_mutex_timedlock_wait\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_mutex_timedlock_%=, 6b-1b\n\t" \
".previous\n" \
- "2:" \
+ LLL_STUB_UNWIND_INFO_6 \
+ "24:" \
: "=a" (result), "=&D" (ignore1), "=S" (ignore2), \
"=&d" (ignore3), "=m" (futex) \
: "0" (0), "2" (1), "m" (futex), "m" (timeout) \
@@ -162,23 +346,83 @@ extern int __lll_mutex_unlock_wait (int *__futex) attribute_hidden;
result; })
+#define lll_robust_mutex_timedlock(futex, timeout, id) \
+ ({ int result, ignore1, ignore2, ignore3; \
+ __asm __volatile (LOCK_INSTR "cmpxchgl %2, %4\n\t" \
+ "jnz 1f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_mutex_timedlock_%=, @function\n" \
+ "_L_robust_mutex_timedlock_%=:\n" \
+ "1:\tleaq %4, %%rdi\n" \
+ "0:\tmovq %8, %%rdx\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_robust_mutex_timedlock_wait\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_robust_mutex_timedlock_%=, 6b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_6 \
+ "24:" \
+ : "=a" (result), "=&D" (ignore1), "=S" (ignore2), \
+ "=&d" (ignore3), "=m" (futex) \
+ : "0" (0), "2" (id), "m" (futex), "m" (timeout) \
+ : "memory", "cx", "cc", "r10", "r11"); \
+ result; })
+
+
#define lll_mutex_unlock(futex) \
(void) ({ int ignore; \
__asm __volatile (LOCK_INSTR "decl %0\n\t" \
"jne 1f\n\t" \
- ".subsection 1\n" \
- "1:\tleaq %0, %%rdi\n\t" \
- "subq $128, %%rsp\n\t" \
- "callq __lll_mutex_unlock_wake\n\t" \
- "addq $128, %%rsp\n\t" \
- "jmp 2f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_mutex_unlock_%=, @function\n" \
+ "_L_mutex_unlock_%=:\n" \
+ "1:\tleaq %0, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_mutex_unlock_wake\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_mutex_unlock_%=, 6b-1b\n\t" \
".previous\n" \
- "2:" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
: "=m" (futex), "=&D" (ignore) \
: "m" (futex) \
: "ax", "cx", "r11", "cc", "memory"); })
+#define lll_robust_mutex_unlock(futex) \
+ (void) ({ int ignore; \
+ __asm __volatile (LOCK_INSTR "andl %2, %0\n\t" \
+ "jne 1f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_mutex_unlock_%=, @function\n" \
+ "_L_robust_mutex_unlock_%=:\n" \
+ "1:\tleaq %0, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_mutex_unlock_wake\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_robust_mutex_unlock_%=, 6b-1b\n\t"\
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
+ : "=m" (futex), "=&D" (ignore) \
+ : "i" (FUTEX_WAITERS), "m" (futex) \
+ : "ax", "cx", "r11", "cc", "memory"); })
+
+
+#define lll_robust_mutex_dead(futex) \
+ (void) ({ int ignore; \
+ __asm __volatile (LOCK_INSTR "orl %3, (%2)\n\t" \
+ "syscall" \
+ : "=m" (futex), "=a" (ignore) \
+ : "D" (&(futex)), "i" (FUTEX_OWNER_DIED), \
+ "S" (FUTEX_WAKE), "1" (__NR_futex), \
+ "d" (1) \
+ : "cx", "r11", "cc", "memory"); })
+
+
#define lll_mutex_islocked(futex) \
(futex != LLL_MUTEX_LOCK_INITIALIZER)
@@ -237,17 +481,21 @@ extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
"je 0f\n\t" \
"lock; cmpxchgl %0, %2\n\t" \
"jnz 1f\n\t" \
- "jmp 2f\n" \
+ "jmp 24f\n" \
"0:\tcmpxchgl %0, %2\n\t" \
"jnz 1f\n\t" \
- ".subsection 1\n" \
- "1:\tleaq %2, %%rdi\n\t" \
- "subq $128, %%rsp\n\t" \
- "callq __lll_mutex_lock_wait\n\t" \
- "addq $128, %%rsp\n\t" \
- "jmp 2f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_lock_%=, @function\n" \
+ "_L_lock_%=:\n" \
+ "1:\tleaq %2, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_mutex_lock_wait\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_lock_%=, 6b-1b\n\t" \
".previous\n" \
- "2:" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
: "=S" (ignore1), "=&D" (ignore2), "=m" (futex),\
"=a" (ignore3) \
: "0" (1), "m" (futex), "3" (0) \
@@ -260,17 +508,21 @@ extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
"je 0f\n\t" \
"lock; decl %0\n\t" \
"jne 1f\n\t" \
- "jmp 2f\n" \
+ "jmp 24f\n" \
"0:\tdecl %0\n\t" \
"jne 1f\n\t" \
- ".subsection 1\n" \
- "1:\tleaq %0, %%rdi\n\t" \
- "subq $128, %%rsp\n\t" \
- "callq __lll_mutex_unlock_wake\n\t" \
- "addq $128, %%rsp\n\t" \
- "jmp 2f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_unlock_%=, @function\n" \
+ "_L_unlock_%=:\n" \
+ "1:\tleaq %0, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_mutex_unlock_wake\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_unlock_%=, 6b-1b\n\t" \
".previous\n" \
- "2:" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
: "=m" (futex), "=&D" (ignore) \
: "m" (futex) \
: "ax", "cx", "r11", "cc", "memory"); })
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
new file mode 100644
index 0000000000..69243950d7
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
@@ -0,0 +1,229 @@
+/* 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.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <pthread-errnos.h>
+#include <lowlevelrobustlock.h>
+
+ .text
+
+#ifndef LOCK
+# ifdef UP
+# define LOCK
+# else
+# define LOCK lock
+# endif
+#endif
+
+#define SYS_futex 202
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_WAITERS 0x80000000
+#define FUTEX_OWNER_DIED 0x40000000
+
+/* For the calculation see asm/vsyscall.h. */
+#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000
+
+
+ .globl __lll_robust_mutex_lock_wait
+ .type __lll_robust_mutex_lock_wait,@function
+ .hidden __lll_robust_mutex_lock_wait
+ .align 16
+__lll_robust_mutex_lock_wait:
+ cfi_startproc
+ pushq %r10
+ cfi_adjust_cfa_offset(8)
+ pushq %rdx
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%r10, -16)
+ cfi_offset(%rdx, -24)
+
+ xorq %r10, %r10 /* No timeout. */
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
+
+4: movl %eax, %edx
+ orl $FUTEX_WAITERS, %edx
+
+ testl $FUTEX_OWNER_DIED, %eax
+ jnz 3f
+
+ cmpl %edx, %eax
+ je 1f
+
+ LOCK
+ cmpxchgl %edx, (%rdi)
+ jnz 2f
+
+1: movl $SYS_futex, %eax
+ syscall
+
+ movl (%rdi), %eax
+
+2: testl %eax, %eax
+ jne 4b
+
+ movl %fs:TID, %edx
+ orl $FUTEX_WAITERS, %edx
+ LOCK
+ cmpxchgl %edx, (%rdi)
+ jnz 4b
+ /* NB: %rax == 0 */
+
+3: popq %rdx
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%rdx)
+ popq %r10
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r10)
+ retq
+ cfi_endproc
+ .size __lll_robust_mutex_lock_wait,.-__lll_robust_mutex_lock_wait
+
+
+ .globl __lll_robust_mutex_timedlock_wait
+ .type __lll_robust_mutex_timedlock_wait,@function
+ .hidden __lll_robust_mutex_timedlock_wait
+ .align 16
+__lll_robust_mutex_timedlock_wait:
+ cfi_startproc
+ /* Check for a valid timeout value. */
+ cmpq $1000000000, 8(%rdx)
+ jae 3f
+
+ pushq %r8
+ cfi_adjust_cfa_offset(8)
+ pushq %r9
+ cfi_adjust_cfa_offset(8)
+ pushq %r12
+ cfi_adjust_cfa_offset(8)
+ pushq %r13
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%r8, -16)
+ cfi_offset(%r9, -24)
+ cfi_offset(%r12, -32)
+ cfi_offset(%r13, -40)
+
+ /* Stack frame for the timespec and timeval structs. */
+ subq $24, %rsp
+ cfi_adjust_cfa_offset(24)
+
+ movq %rdi, %r12
+ movq %rdx, %r13
+
+1: movq %rax, 16(%rsp)
+
+ /* Get current time. */
+ movq %rsp, %rdi
+ xorl %esi, %esi
+ movq $VSYSCALL_ADDR_vgettimeofday, %rax
+ /* This is a regular function call, all caller-save registers
+ might be clobbered. */
+ callq *%rax
+
+ /* Compute relative timeout. */
+ movq 8(%rsp), %rax
+ movl $1000, %edi
+ mul %rdi /* Milli seconds to nano seconds. */
+ movq (%r13), %rdi
+ movq 8(%r13), %rsi
+ subq (%rsp), %rdi
+ subq %rax, %rsi
+ jns 4f
+ addq $1000000000, %rsi
+ decq %rdi
+4: testq %rdi, %rdi
+ js 8f /* Time is already up. */
+
+ /* Futex call. */
+ movq %rdi, (%rsp) /* Store relative timeout. */
+ movq %rsi, 8(%rsp)
+
+ movq 16(%rsp), %rdx
+ movl %edx, %eax
+ orl $FUTEX_WAITERS, %edx
+
+ testl $FUTEX_OWNER_DIED, %eax
+ jnz 6f
+
+ cmpl %eax, %edx
+ je 2f
+
+ LOCK
+ cmpxchgl %edx, (%r12)
+ movq $0, %rcx /* Must use mov to avoid changing cc. */
+ jnz 5f
+
+2: movq %rsp, %r10
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
+ movq %r12, %rdi
+ movl $SYS_futex, %eax
+ syscall
+ movq %rax, %rcx
+
+ movl (%r12), %eax
+
+5: testl %eax, %eax
+ jne 7f
+
+ movl %fs:TID, %edx
+ orl $FUTEX_WAITERS, %edx
+ LOCK
+ cmpxchgl %edx, (%r12)
+ jnz 7f
+
+6: addq $24, %rsp
+ cfi_adjust_cfa_offset(-24)
+ popq %r13
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r13)
+ popq %r12
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r12)
+ popq %r9
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r9)
+ popq %r8
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r8)
+ retq
+
+3: movl $EINVAL, %eax
+ retq
+
+ cfi_adjust_cfa_offset(56)
+ cfi_offset(%r8, -16)
+ cfi_offset(%r9, -24)
+ cfi_offset(%r12, -32)
+ cfi_offset(%r13, -40)
+ /* Check whether the time expired. */
+7: cmpq $-ETIMEDOUT, %rcx
+ jne 1b
+
+8: movl $ETIMEDOUT, %eax
+ jmp 6b
+ cfi_endproc
+ .size __lll_robust_mutex_timedlock_wait,.-__lll_robust_mutex_timedlock_wait
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 e1593f32ff..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 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.
@@ -63,9 +63,14 @@ pthread_barrier_wait:
/* Wait for the remaining threads. The call will return immediately
if the CURR_EVENT memory has meanwhile been changed. */
-7: xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */
+7:
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
xorq %r10, %r10
-8: movq $SYS_futex, %rax
+8: movl $SYS_futex, %eax
syscall
/* Don't return on spurious wakeups. The syscall does not change
@@ -110,8 +115,8 @@ pthread_barrier_wait:
/* Wake up all waiters. The count is a signed number in the kernel
so 0x7fffffff is the highest value. */
movl $0x7fffffff, %edx
- movq $FUTEX_WAKE, %rsi
- movq $SYS_futex, %rax
+ movl $FUTEX_WAKE, %esi
+ movl $SYS_futex, %eax
syscall
/* Increment LEFT. If this brings the count back to the
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
index e8d7bd9bb6..006de2696e 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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,6 +21,7 @@
#include <shlib-compat.h>
#include <lowlevelcond.h>
#include <kernel-features.h>
+#include <pthread-pi-defines.h>
#ifdef UP
# define LOCK
@@ -80,11 +81,15 @@ __pthread_cond_broadcast:
8: cmpq $-1, %r8
je 9f
+ /* XXX: The kernel so far doesn't support requeue to PI futex. */
+ testl $PI_BIT, MUTEX_KIND(%r8)
+ jne 9f
+
/* Wake up all threads. */
- movq $FUTEX_CMP_REQUEUE, %rsi
- movq $SYS_futex, %rax
+ movl $FUTEX_CMP_REQUEUE, %esi
+ movl $SYS_futex, %eax
movl $1, %edx
- movq $0x7fffffff, %r10
+ movl $0x7fffffff, %r10d
syscall
/* For any kind of error, which mainly is EAGAIN, we try again
@@ -128,9 +133,9 @@ __pthread_cond_broadcast:
jmp 8b
9: /* The futex requeue functionality is not available. */
- movq $0x7fffffff, %rdx
- movq $FUTEX_WAKE, %rsi
- movq $SYS_futex, %rax
+ movl $0x7fffffff, %edx
+ movl $FUTEX_WAKE, %esi
+ movl $SYS_futex, %eax
syscall
jmp 10b
.size __pthread_cond_broadcast, .-__pthread_cond_broadcast
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
index 62bb74cc1a..3dbb9e81e3 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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,7 +31,9 @@
#define SYS_futex 202
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
-#define FUTEX_REQUEUE 3
+#define FUTEX_WAKE_OP 5
+
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
#define EINVAL 22
@@ -66,9 +68,30 @@ __pthread_cond_signal:
addl $1, (%rdi)
/* Wake up one thread. */
- movq $FUTEX_WAKE, %rsi
- movq $SYS_futex, %rax
- movq $1, %rdx
+ movl $FUTEX_WAKE_OP, %esi
+ movl $SYS_futex, %eax
+ movl $1, %edx
+ movl $1, %r10d
+#if cond_lock != 0
+ addq $cond_lock, %r8
+#endif
+ movl $FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, %r9d
+ syscall
+#if cond_lock != 0
+ subq $cond_lock, %r8
+#endif
+ /* For any kind of error, we try again with WAKE.
+ The general test also covers running on old kernels. */
+ cmpq $-4095, %rax
+ jae 7f
+
+ xorl %eax, %eax
+ retq
+
+7: movl $FUTEX_WAKE, %esi
+ movl $SYS_futex, %eax
+ /* %rdx should be 1 already from $FUTEX_WAKE_OP syscall.
+ movl $1, %edx */
syscall
/* Unlock. */
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 67bec6caa7..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 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.
@@ -56,7 +56,7 @@ __pthread_cond_timedwait:
.Lsubq:
cmpq $1000000000, 8(%rdx)
- movq $EINVAL, %rax
+ movl $EINVAL, %eax
jae 18f
/* Stack frame:
@@ -102,7 +102,7 @@ __pthread_cond_timedwait:
/* Unlock the mutex. */
2: movq 16(%rsp), %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
callq __pthread_mutex_unlock_usercnt
testl %eax, %eax
@@ -141,7 +141,7 @@ __pthread_cond_timedwait:
/* Only clocks 0 and 1 are allowed so far. Both are handled in the
kernel. */
leaq 24(%rsp), %rsi
- movq $__NR_clock_gettime, %rax
+ movl $__NR_clock_gettime, %eax
syscall
# ifndef __ASSUME_POSIX_TIMERS
cmpq $-ENOSYS, %rax
@@ -155,13 +155,13 @@ __pthread_cond_timedwait:
subq 32(%rsp), %rdx
#else
leaq 24(%rsp), %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
movq $VSYSCALL_ADDR_vgettimeofday, %rax
callq *%rax
/* Compute relative timeout. */
movq 32(%rsp), %rax
- movq $1000, %rdx
+ movl $1000, %edx
mul %rdx /* Milli seconds to nano seconds. */
movq (%r13), %rcx
movq 8(%r13), %rdx
@@ -195,10 +195,14 @@ __pthread_cond_timedwait:
movl %eax, (%rsp)
leaq 24(%rsp), %r10
- xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
movq %r12, %rdx
addq $cond_futex, %rdi
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
movq %rax, %r14
@@ -237,7 +241,7 @@ __pthread_cond_timedwait:
13: incq wakeup_seq(%rdi)
incl cond_futex(%rdi)
- movq $ETIMEDOUT, %r14
+ movl $ETIMEDOUT, %r14d
jmp 14f
23: xorq %r14, %r14
@@ -256,8 +260,8 @@ __pthread_cond_timedwait:
jne 25f
addq $cond_nwaiters, %rdi
- movq $SYS_futex, %rax
- movq $FUTEX_WAKE, %rsi
+ movl $SYS_futex, %eax
+ movl $FUTEX_WAKE, %esi
movl $1, %edx
syscall
subq $cond_nwaiters, %rdi
@@ -349,13 +353,13 @@ __pthread_cond_timedwait:
#if defined __NR_clock_gettime && !defined __ASSUME_POSIX_TIMERS
/* clock_gettime not available. */
19: leaq 24(%rsp), %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
movq $VSYSCALL_ADDR_vgettimeofday, %rax
callq *%rax
/* Compute relative timeout. */
movq 32(%rsp), %rax
- movq $1000, %rdx
+ movl $1000, %edx
mul %rdx /* Milli seconds to nano seconds. */
movq (%r13), %rcx
movq 8(%r13), %rdx
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 f5de0a280c..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 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.
@@ -67,9 +67,15 @@ __condvar_cleanup:
cmpl 4(%r8), %edx
jne 3f
+ /* We increment the wakeup_seq counter only if it is lower than
+ total_seq. If this is not the case the thread was woken and
+ then canceled. In this case we ignore the signal. */
+ movq total_seq(%rdi), %rax
+ cmpq wakeup_seq(%rdi), %rax
+ jbe 6f
incq wakeup_seq(%rdi)
- incq woken_seq(%rdi)
incl cond_futex(%rdi)
+6: incq woken_seq(%rdi)
3: subl $(1 << clock_bits), cond_nwaiters(%rdi)
@@ -82,12 +88,12 @@ __condvar_cleanup:
jne 4f
addq $cond_nwaiters, %rdi
- movq $SYS_futex, %rax
- movq $FUTEX_WAKE, %rsi
+ movl $SYS_futex, %eax
+ movl $FUTEX_WAKE, %esi
movl $1, %edx
syscall
subq $cond_nwaiters, %rdi
- movq $1, %r12
+ movl $1, %r12d
4: LOCK
#if cond_lock == 0
@@ -105,9 +111,9 @@ __condvar_cleanup:
2: testq %r12, %r12
jnz 5f
addq $cond_futex, %rdi
- movq $FUTEX_WAKE, %rsi
+ movl $FUTEX_WAKE, %esi
movl $0x7fffffff, %edx
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
5: movq 16(%r8), %rdi
@@ -170,7 +176,7 @@ __pthread_cond_wait:
/* Unlock the mutex. */
2: movq 16(%rsp), %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
callq __pthread_mutex_unlock_usercnt
testl %eax, %eax
@@ -215,8 +221,12 @@ __pthread_cond_wait:
xorq %r10, %r10
movq %r12, %rdx
addq $cond_futex-cond_lock, %rdi
- movq $SYS_futex, %rax
- movq %r10, %rsi /* movq $FUTEX_WAIT, %rsi */
+ movl $SYS_futex, %eax
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
syscall
movl (%rsp), %edi
@@ -262,8 +272,8 @@ __pthread_cond_wait:
jne 17f
addq $cond_nwaiters, %rdi
- movq $SYS_futex, %rax
- movq $FUTEX_WAKE, %rsi
+ movl $SYS_futex, %eax
+ movl $FUTEX_WAKE, %esi
movl $1, %edx
syscall
subq $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 3fec0f4205..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 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.
@@ -74,17 +74,23 @@ __pthread_once:
jnz 3f /* Different for generation -> run initializer. */
/* Somebody else got here first. Wait. */
- movq %r10, %rsi /* movq $FUTEX_WAIT, %rsi */
- movq $SYS_futex, %rax
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
+ movl $SYS_futex, %eax
syscall
jmp 6b
/* Preserve the pointer to the control variable. */
3: pushq %rdi
.Lpush_rdi:
+ pushq %rdi
+.Lpush_rdi2:
.LcleanupSTART:
- callq *8(%rsp)
+ callq *16(%rsp)
.LcleanupEND:
/* Get the control variable address back. */
@@ -95,15 +101,18 @@ __pthread_once:
LOCK
incl (%rdi)
+ addq $8, %rsp
+.Ladd1:
+
/* Wake up all other threads. */
movl $0x7fffffff, %edx
movl $FUTEX_WAKE, %esi
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
4: addq $8, %rsp
-.Ladd:
- xorq %rax, %rax
+.Ladd2:
+ xorl %eax, %eax
retq
.size __pthread_once,.-__pthread_once
@@ -124,8 +133,8 @@ clear_once_control:
movl $0, (%rdi)
movl $0x7fffffff, %edx
- movq $FUTEX_WAKE, %rsi
- movq $SYS_futex, %rax
+ movl $FUTEX_WAKE, %esi
+ movl $SYS_futex, %eax
syscall
movq %r8, %rdi
@@ -220,20 +229,28 @@ clear_once_control:
.byte 14 # DW_CFA_def_cfa_offset
.uleb128 24
.byte 4 # DW_CFA_advance_loc4
- .long .Lpop_rdi-.Lpush_rdi
+ .long .Lpush_rdi2-.Lpush_rdi
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 32
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Lpop_rdi-.Lpush_rdi2
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 24
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Ladd1-.Lpop_rdi
.byte 14 # DW_CFA_def_cfa_offset
.uleb128 16
.byte 4 # DW_CFA_advance_loc4
- .long .Ladd-.Lpop_rdi
+ .long .Ladd2-.Ladd1
.byte 14 # DW_CFA_def_cfa_offset
.uleb128 8
.byte 4 # DW_CFA_advance_loc4
- .long clear_once_control-.Ladd
+ .long clear_once_control-.Ladd2
.byte 14 # DW_CFA_def_cfa_offset
- .uleb128 24
+ .uleb128 32
#if 0
.byte 4 # DW_CFA_advance_loc4
- .long .Lpop_rdi2-clear_once_control
+ .long .Lpop_rdi3-clear_once_control
.byte 14 # DW_CFA_def_cfa_offset
.uleb128 16
#endif
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 43c8cae34c..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 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.
@@ -74,8 +74,12 @@ __pthread_rwlock_rdlock:
jne 10f
11: addq $READERS_WAKEUP, %rdi
- movq %r10, %rsi /* movq $FUTEX_WAIT, %rsi */
- movq $SYS_futex, %rax
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
+ movl $SYS_futex, %eax
syscall
subq $READERS_WAKEUP, %rdi
@@ -94,7 +98,7 @@ __pthread_rwlock_rdlock:
13: decl READERS_QUEUED(%rdi)
jmp 2b
-5: xorq %rdx, %rdx
+5: xorl %edx, %edx
incl NR_READERS(%rdi)
je 8f
9: LOCK
@@ -122,7 +126,7 @@ __pthread_rwlock_rdlock:
14: cmpl %fs:TID, %eax
jne 3b
/* Deadlock detected. */
- movq $EDEADLK, %rdx
+ movl $EDEADLK, %edx
jmp 9b
6:
@@ -137,12 +141,12 @@ __pthread_rwlock_rdlock:
/* Overflow. */
8: decl NR_READERS(%rdi)
- movq $EAGAIN, %rdx
+ movl $EAGAIN, %edx
jmp 9b
/* Overflow. */
4: decl READERS_QUEUED(%rdi)
- movq $EAGAIN, %rdx
+ movl $EAGAIN, %edx
jmp 9b
10:
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 aadc90c974..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 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.
@@ -90,13 +90,13 @@ pthread_rwlock_timedrdlock:
/* Get current time. */
11: movq %rsp, %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
movq $VSYSCALL_ADDR_vgettimeofday, %rax
callq *%rax
/* Compute relative timeout. */
movq 8(%rsp), %rax
- movq $1000, %rdi
+ movl $1000, %edi
mul %rdi /* Milli seconds to nano seconds. */
movq (%r13), %rcx
movq 8(%r13), %rdi
@@ -112,11 +112,15 @@ pthread_rwlock_timedrdlock:
movq %rcx, (%rsp) /* Store relative timeout. */
movq %rdi, 8(%rsp)
- xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
movq %rsp, %r10
movl %r14d, %edx
leaq READERS_WAKEUP(%r12), %rdi
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
movq %rax, %rdx
17:
@@ -136,11 +140,11 @@ pthread_rwlock_timedrdlock:
cmpq $-ETIMEDOUT, %rdx
jne 2b
-18: movq $ETIMEDOUT, %rdx
+18: movl $ETIMEDOUT, %edx
jmp 9f
-5: xorq %rdx, %rdx
+5: xorl %edx, %edx
incl NR_READERS(%r12)
je 8f
9: LOCK
@@ -168,7 +172,7 @@ pthread_rwlock_timedrdlock:
14: cmpl %fs:TID, %eax
jne 3b
- movq $EDEADLK, %rdx
+ movl $EDEADLK, %edx
jmp 9b
6:
@@ -182,12 +186,12 @@ pthread_rwlock_timedrdlock:
/* Overflow. */
8: decl NR_READERS(%r12)
- movq $EAGAIN, %rdx
+ movl $EAGAIN, %edx
jmp 9b
/* Overflow. */
4: decl READERS_QUEUED(%r12)
- movq $EAGAIN, %rdx
+ movl $EAGAIN, %edx
jmp 9b
10:
@@ -211,6 +215,6 @@ pthread_rwlock_timedrdlock:
16: movq $-ETIMEDOUT, %rdx
jmp 17b
-19: movq $EINVAL, %rdx
+19: movl $EINVAL, %edx
jmp 9b
.size pthread_rwlock_timedrdlock,.-pthread_rwlock_timedrdlock
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 ccaef47070..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 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.
@@ -86,13 +86,13 @@ pthread_rwlock_timedwrlock:
/* Get current time. */
11: movq %rsp, %rdi
- xorq %rsi, %rsi
+ xorl %esi, %esi
movq $VSYSCALL_ADDR_vgettimeofday, %rax
callq *%rax
/* Compute relative timeout. */
movq 8(%rsp), %rax
- movq $1000, %rdi
+ movl $1000, %edi
mul %rdi /* Milli seconds to nano seconds. */
movq (%r13), %rcx
movq 8(%r13), %rdi
@@ -108,11 +108,15 @@ pthread_rwlock_timedwrlock:
movq %rcx, (%rsp) /* Store relative timeout. */
movq %rdi, 8(%rsp)
- xorq %rsi, %rsi /* movq $FUTEX_WAIT, %rsi */
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
movq %rsp, %r10
movl %r14d, %edx
leaq WRITERS_WAKEUP(%r12), %rdi
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
syscall
movq %rax, %rdx
17:
@@ -132,11 +136,11 @@ pthread_rwlock_timedwrlock:
cmpq $-ETIMEDOUT, %rdx
jne 2b
-18: movq $ETIMEDOUT, %rdx
+18: movl $ETIMEDOUT, %edx
jmp 9f
-5: xorq %rdx, %rdx
+5: xorl %edx, %edx
movl %fs:TID, %eax
movl %eax, WRITER(%r12)
9: LOCK
@@ -164,7 +168,7 @@ pthread_rwlock_timedwrlock:
14: cmpl %fs:TID, %eax
jne 3b
-20: movq $EDEADLK, %rdx
+20: movl $EDEADLK, %edx
jmp 9b
6:
@@ -178,7 +182,7 @@ pthread_rwlock_timedwrlock:
/* Overflow. */
4: decl WRITERS_QUEUED(%r12)
- movq $EAGAIN, %rdx
+ movl $EAGAIN, %edx
jmp 9b
10:
@@ -202,6 +206,6 @@ pthread_rwlock_timedwrlock:
16: movq $-ETIMEDOUT, %rdx
jmp 17b
-19: movq $EINVAL, %rdx
+19: movl $EINVAL, %edx
jmp 9b
.size pthread_rwlock_timedwrlock,.-pthread_rwlock_timedwrlock
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 ac69fc0eae..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 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,7 +56,7 @@ __pthread_rwlock_unlock:
5: movl $0, WRITER(%rdi)
- movq $1, %rsi
+ movl $1, %esi
leaq WRITERS_WAKEUP(%rdi), %r10
movq %rsi, %rdx
cmpl $0, WRITERS_QUEUED(%rdi)
@@ -78,11 +78,11 @@ __pthread_rwlock_unlock:
#endif
jne 7f
-8: movq $SYS_futex, %rax
+8: movl $SYS_futex, %eax
movq %r10, %rdi
syscall
- xorq %rax, %rax
+ xorl %eax, %eax
retq
.align 16
@@ -94,7 +94,7 @@ __pthread_rwlock_unlock:
#endif
jne 3f
-4: xorq %rax, %rax
+4: xorl %eax, %eax
retq
1:
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 1fcb07eaef..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 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.
@@ -72,8 +72,12 @@ __pthread_rwlock_wrlock:
jne 10f
11: addq $WRITERS_WAKEUP, %rdi
- movq %r10, %rsi /* movq $FUTEX_WAIT, %rsi */
- movq $SYS_futex, %rax
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
+ movl $SYS_futex, %eax
syscall
subq $WRITERS_WAKEUP, %rdi
@@ -92,7 +96,7 @@ __pthread_rwlock_wrlock:
13: decl WRITERS_QUEUED(%rdi)
jmp 2b
-5: xorq %rdx, %rdx
+5: xorl %edx, %edx
movl %fs:TID, %eax
movl %eax, WRITER(%rdi)
9: LOCK
@@ -119,7 +123,7 @@ __pthread_rwlock_wrlock:
14: cmpl %fs:TID, %eax
jne 3b
- movq $EDEADLK, %rdx
+ movl $EDEADLK, %edx
jmp 9b
6:
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 21ec6fd226..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 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.
@@ -41,8 +41,8 @@ sem_post:
LOCK
xaddl %edx, (%rdi)
- movq $SYS_futex, %rax
- movq $FUTEX_WAKE, %rsi
+ movl $SYS_futex, %eax
+ movl $FUTEX_WAKE, %esi
incl %edx
syscall
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 d90e03b55b..51136cf2dc 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -79,17 +79,14 @@ sem_timedwait:
cfi_offset(14, -24) /* %r14 */
jae 6f
-7: call __pthread_enable_asynccancel
- movl %eax, 16(%rsp)
-
- xorq %rsi, %rsi
+7: xorl %esi, %esi
movq %rsp, %rdi
movq $VSYSCALL_ADDR_vgettimeofday, %rax
callq *%rax
/* Compute relative timeout. */
movq 8(%rsp), %rax
- movq $1000, %rdi
+ movl $1000, %edi
mul %rdi /* Milli seconds to nano seconds. */
movq (%r13), %rdi
movq 8(%r13), %rsi
@@ -105,10 +102,13 @@ sem_timedwait:
movq %rdi, (%rsp) /* Store relative timeout. */
movq %rsi, 8(%rsp)
+ call __pthread_enable_asynccancel
+ movl %eax, 16(%rsp)
+
movq %rsp, %r10
movq %r12, %rdi
- xorq %rsi, %rsi
- movq $SYS_futex, %rax
+ xorl %esi, %esi
+ movl $SYS_futex, %eax
xorl %edx, %edx
syscall
movq %rax, %r14
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 31271bb94c..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 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,4 +56,3 @@ sem_trywait:
orl $-1, %eax
retq
.size sem_trywait,.-sem_trywait
- versioned_symbol(libpthread, __new_sem_trywait, sem_trywait, GLIBC_2_1)
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 76957bc139..63ecd063ab 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 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.
@@ -77,7 +77,7 @@ sem_wait:
movl %eax, %r8d
xorq %r10, %r10
- movq $SYS_futex, %rax
+ movl $SYS_futex, %eax
movq %r13, %rdi
movq %r10, %rsi
movq %r10, %rdx
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h b/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
index d47c1b80dc..3e741da794 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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 Jakub Jelinek <jakub@redhat.com>, 2002.
@@ -48,7 +48,7 @@
POPARGS_##args \
/* The return value from CENABLE is argument for CDISABLE. */ \
movq %rax, (%rsp); \
- movq $SYS_ify (syscall_name), %rax; \
+ movl $SYS_ify (syscall_name), %eax; \
syscall; \
movq (%rsp), %rdi; \
/* Save %rax since it's the error code from the syscall. */ \
@@ -136,3 +136,9 @@ extern int __local_multiple_threads attribute_hidden;
# define NO_CANCELLATION 1
#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S b/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S
index f68d40439e..9a9912ca85 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S
@@ -16,9 +16,16 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <tcb-offsets.h>
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <vfork.S>
+#else
-#define SAVE_PID \
+# include <tcb-offsets.h>
+
+# define SAVE_PID \
movl %fs:PID, %esi; \
movl $0x80000000, %ecx; \
movl %esi, %edx; \
@@ -26,10 +33,11 @@
cmove %ecx, %edx; \
movl %edx, %fs:PID
-#define RESTORE_PID \
+# define RESTORE_PID \
testq %rax, %rax; \
je 1f; \
movl %esi, %fs:PID; \
1:
-#include <sysdeps/unix/sysv/linux/x86_64/vfork.S>
+# include_next <vfork.S>
+#endif
diff --git a/nptl/sysdeps/x86_64/jmpbuf-unwind.h b/nptl/sysdeps/x86_64/jmpbuf-unwind.h
deleted file mode 100644
index 345ed557c5..0000000000
--- a/nptl/sysdeps/x86_64/jmpbuf-unwind.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* 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.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <setjmp.h>
-#include <stdint.h>
-#include <unwind.h>
-
-#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
- _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
-
-#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
- ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_RSP] - (_adj))
-
-/* We use the normal lobngjmp for unwinding. */
-#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
diff --git a/nptl/sysdeps/x86_64/tcb-offsets.sym b/nptl/sysdeps/x86_64/tcb-offsets.sym
index 8118d2df8b..a9ede75c96 100644
--- a/nptl/sysdeps/x86_64/tcb-offsets.sym
+++ b/nptl/sysdeps/x86_64/tcb-offsets.sym
@@ -10,3 +10,4 @@ CLEANUP offsetof (struct pthread, cleanup)
CLEANUP_PREV offsetof (struct _pthread_cleanup_buffer, __prev)
MUTEX_FUTEX offsetof (pthread_mutex_t, __data.__lock)
MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
+POINTER_GUARD offsetof (tcbhead_t, pointer_guard)
diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h
index 3d6111f4e3..b6385b135c 100644
--- a/nptl/sysdeps/x86_64/tls.h
+++ b/nptl/sysdeps/x86_64/tls.h
@@ -1,5 +1,5 @@
/* Definition for thread-local data handling. nptl/x86_64 version.
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,8 +20,9 @@
#ifndef _TLS_H
#define _TLS_H 1
-#include <asm/prctl.h> /* For ARCH_SET_FS. */
#ifndef __ASSEMBLER__
+# include <asm/prctl.h> /* For ARCH_SET_FS. */
+# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
# include <stdlib.h>
@@ -31,7 +32,11 @@
typedef union dtv
{
size_t counter;
- void *pointer;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
} dtv_t;
@@ -42,6 +47,10 @@ typedef struct
dtv_t *dtv;
void *self; /* Pointer to the thread descriptor. */
int multiple_threads;
+ int gscope_flag;
+ uintptr_t sysinfo;
+ uintptr_t stack_guard;
+ uintptr_t pointer_guard;
} tcbhead_t;
#else /* __ASSEMBLER__ */
@@ -77,11 +86,13 @@ typedef struct
# endif
#endif
-/* This is the size of the initial TCB. */
-# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+/* This is the size of the initial TCB. Can't be just sizeof (tcbhead_t),
+ because NPTL getpid, __libc_alloca_cutoff etc. need (almost) the whole
+ struct pthread even when not linked with -lpthread. */
+# define TLS_INIT_TCB_SIZE sizeof (struct pthread)
/* Alignment requirements for the initial TCB. */
-# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
/* This is the size of the TCB. */
# define TLS_TCB_SIZE sizeof (struct pthread)
@@ -313,6 +324,42 @@ typedef struct
__res; })
+/* Set the stack guard field in TCB head. */
+# define THREAD_SET_STACK_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
+# define THREAD_COPY_STACK_GUARD(descr) \
+ ((descr)->header.stack_guard \
+ = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
+
+
+/* Set the pointer guard field in the TCB head. */
+#define THREAD_SET_POINTER_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.pointer_guard, value)
+#define THREAD_COPY_POINTER_GUARD(descr) \
+ ((descr)->header.pointer_guard \
+ = THREAD_GETMEM (THREAD_SELF, header.pointer_guard))
+
+
+/* Get and set the global scope generation counter in the TCB head. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res; \
+ asm volatile ("xchgl %0, %%fs:%P1" \
+ : "=r" (__res) \
+ : "i" (offsetof (struct pthread, header.gscope_flag)), \
+ "0" (THREAD_GSCOPE_FLAG_UNUSED)); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ THREAD_SETMEM (THREAD_SELF, header.gscope_flag, THREAD_GSCOPE_FLAG_USED)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
#endif /* __ASSEMBLER__ */
#endif /* tls.h */
diff --git a/nptl/tpp.c b/nptl/tpp.c
new file mode 100644
index 0000000000..367dd8162a
--- /dev/null
+++ b/nptl/tpp.c
@@ -0,0 +1,172 @@
+/* Thread Priority Protect helpers.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <atomic.h>
+#include <errno.h>
+#include <pthreadP.h>
+#include <sched.h>
+#include <stdlib.h>
+
+
+int __sched_fifo_min_prio = -1;
+int __sched_fifo_max_prio = -1;
+
+void
+__init_sched_fifo_prio (void)
+{
+ __sched_fifo_max_prio = sched_get_priority_max (SCHED_FIFO);
+ atomic_write_barrier ();
+ __sched_fifo_min_prio = sched_get_priority_min (SCHED_FIFO);
+}
+
+int
+__pthread_tpp_change_priority (int previous_prio, int new_prio)
+{
+ struct pthread *self = THREAD_SELF;
+ struct priority_protection_data *tpp = THREAD_GETMEM (self, tpp);
+
+ if (tpp == NULL)
+ {
+ if (__sched_fifo_min_prio == -1)
+ __init_sched_fifo_prio ();
+
+ size_t size = sizeof *tpp;
+ size += (__sched_fifo_max_prio - __sched_fifo_min_prio + 1)
+ * sizeof (tpp->priomap[0]);
+ tpp = calloc (size, 1);
+ if (tpp == NULL)
+ return ENOMEM;
+ tpp->priomax = __sched_fifo_min_prio - 1;
+ THREAD_SETMEM (self, tpp, tpp);
+ }
+
+ assert (new_prio == -1
+ || (new_prio >= __sched_fifo_min_prio
+ && new_prio <= __sched_fifo_max_prio));
+ assert (previous_prio == -1
+ || (previous_prio >= __sched_fifo_min_prio
+ && previous_prio <= __sched_fifo_max_prio));
+
+ int priomax = tpp->priomax;
+ int newpriomax = priomax;
+ if (new_prio != -1)
+ {
+ if (tpp->priomap[new_prio - __sched_fifo_min_prio] + 1 == 0)
+ return EAGAIN;
+ ++tpp->priomap[new_prio - __sched_fifo_min_prio];
+ if (new_prio > priomax)
+ newpriomax = new_prio;
+ }
+
+ if (previous_prio != -1)
+ {
+ if (--tpp->priomap[previous_prio - __sched_fifo_min_prio] == 0
+ && priomax == previous_prio
+ && previous_prio > new_prio)
+ {
+ int i;
+ for (i = previous_prio - 1; i >= __sched_fifo_min_prio; --i)
+ if (tpp->priomap[i - __sched_fifo_min_prio])
+ break;
+ newpriomax = i;
+ }
+ }
+
+ if (priomax == newpriomax)
+ return 0;
+
+ lll_lock (self->lock);
+
+ tpp->priomax = newpriomax;
+
+ int result = 0;
+
+ if ((self->flags & ATTR_FLAG_SCHED_SET) == 0)
+ {
+ if (__sched_getparam (self->tid, &self->schedparam) != 0)
+ result = errno;
+ else
+ self->flags |= ATTR_FLAG_SCHED_SET;
+ }
+
+ if ((self->flags & ATTR_FLAG_POLICY_SET) == 0)
+ {
+ self->schedpolicy = __sched_getscheduler (self->tid);
+ if (self->schedpolicy == -1)
+ result = errno;
+ else
+ self->flags |= ATTR_FLAG_POLICY_SET;
+ }
+
+ if (result == 0)
+ {
+ struct sched_param sp = self->schedparam;
+ if (sp.sched_priority < newpriomax || sp.sched_priority < priomax)
+ {
+ if (sp.sched_priority < newpriomax)
+ sp.sched_priority = newpriomax;
+
+ if (__sched_setscheduler (self->tid, self->schedpolicy, &sp) < 0)
+ result = errno;
+ }
+ }
+
+ lll_unlock (self->lock);
+
+ return result;
+}
+
+int
+__pthread_current_priority (void)
+{
+ struct pthread *self = THREAD_SELF;
+ if ((self->flags & (ATTR_FLAG_POLICY_SET | ATTR_FLAG_SCHED_SET))
+ == (ATTR_FLAG_POLICY_SET | ATTR_FLAG_SCHED_SET))
+ return self->schedparam.sched_priority;
+
+ int result = 0;
+
+ lll_lock (self->lock);
+
+ if ((self->flags & ATTR_FLAG_SCHED_SET) == 0)
+ {
+ if (__sched_getparam (self->tid, &self->schedparam) != 0)
+ result = -1;
+ else
+ self->flags |= ATTR_FLAG_SCHED_SET;
+ }
+
+ if ((self->flags & ATTR_FLAG_POLICY_SET) == 0)
+ {
+ self->schedpolicy = __sched_getscheduler (self->tid);
+ if (self->schedpolicy == -1)
+ result = -1;
+ else
+ self->flags |= ATTR_FLAG_POLICY_SET;
+ }
+
+ if (result != -1)
+ result = self->schedparam.sched_priority;
+
+ lll_unlock (self->lock);
+
+ return result;
+}
diff --git a/nptl/tst-align3.c b/nptl/tst-align3.c
new file mode 100644
index 0000000000..64df146131
--- /dev/null
+++ b/nptl/tst-align3.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2005.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <tst-stack-align.h>
+
+static bool ok = true;
+static pthread_once_t once = PTHREAD_ONCE_INIT;
+
+static void
+once_test (void)
+{
+ puts ("in once_test");
+
+ if (TEST_STACK_ALIGN ())
+ ok = false;
+}
+
+static int
+do_test (void)
+{
+ puts ("in main");
+
+ if (TEST_STACK_ALIGN ())
+ ok = false;
+
+ if (pthread_once (&once, once_test))
+ {
+ puts ("pthread once failed");
+ return 1;
+ }
+
+ return ok ? 0 : 1;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-cancel-wrappers.sh b/nptl/tst-cancel-wrappers.sh
index d6f16d1ed2..61b9fb52de 100644
--- a/nptl/tst-cancel-wrappers.sh
+++ b/nptl/tst-cancel-wrappers.sh
@@ -1,6 +1,6 @@
#! /bin/sh
# Test whether all cancelable functions are cancelable.
-# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
@@ -26,6 +26,7 @@ C["close"]=1
C["connect"]=1
C["creat"]=1
C["fcntl"]=1
+C["fdatasync"]=1
C["fsync"]=1
C["msgrcv"]=1
C["msgsnd"]=1
diff --git a/nptl/tst-cancel17.c b/nptl/tst-cancel17.c
index 9fb089ac83..2a8c951afe 100644
--- a/nptl/tst-cancel17.c
+++ b/nptl/tst-cancel17.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
@@ -228,7 +228,7 @@ do_test (void)
size_t len2 = fpathconf (fds[1], _PC_PIPE_BUF);
size_t page_size = sysconf (_SC_PAGESIZE);
- len2 = (len2 < page_size ? page_size : len2) + sizeof (mem) + 1;
+ len2 = 20 * (len2 < page_size ? page_size : len2) + sizeof (mem) + 1;
char *mem2 = malloc (len2);
if (mem2 == NULL)
{
diff --git a/nptl/tst-cancel2.c b/nptl/tst-cancel2.c
index 6d80f8ae5e..529b5d4050 100644
--- a/nptl/tst-cancel2.c
+++ b/nptl/tst-cancel2.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -33,11 +33,7 @@ tf (void *arg)
write blocks. */
char buf[100000];
- if (write (fd[1], buf, sizeof (buf)) == sizeof (buf))
- {
- puts ("write succeeded");
- return (void *) 1l;
- }
+ while (write (fd[1], buf, sizeof (buf)) > 0);
return (void *) 42l;
}
diff --git a/nptl/tst-cancel24.cc b/nptl/tst-cancel24.cc
new file mode 100644
index 0000000000..1af709a8ca
--- /dev/null
+++ b/nptl/tst-cancel24.cc
@@ -0,0 +1,113 @@
+#include <pthread.h>
+#include <semaphore.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static volatile bool destr_called;
+static volatile bool except_caught;
+
+static pthread_barrier_t b;
+
+
+struct monitor
+{
+ // gcc is broken and would generate a warning without this dummy
+ // constructor.
+ monitor () { }
+ ~monitor() { destr_called = true; }
+};
+
+
+static void *
+tf (void *arg)
+{
+ sem_t *s = static_cast<sem_t *> (arg);
+
+ try
+ {
+ monitor m;
+
+ pthread_barrier_wait (&b);
+
+ while (1)
+ sem_wait (s);
+ }
+ catch (...)
+ {
+ except_caught = true;
+ throw;
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test ()
+{
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ sem_t s;
+ if (sem_init (&s, 0, 0) != 0)
+ {
+ puts ("sem_init failed");
+ return 1;
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, &s) != 0)
+ {
+ puts ("pthread_create failed");
+ return 1;
+ }
+
+ pthread_barrier_wait (&b);
+
+ /* There is unfortunately no better method to try to assure the
+ child thread reached the sem_wait call and is actually waiting
+ than to sleep here. */
+ sleep (1);
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cancel failed");
+ return 1;
+ }
+
+ void *res;
+ if (pthread_join (th, &res) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+
+ if (res != PTHREAD_CANCELED)
+ {
+ puts ("thread was not canceled");
+ return 1;
+ }
+
+ if (! except_caught)
+ {
+ puts ("exception not caught");
+ return 1;
+ }
+
+ if (! destr_called)
+ {
+ puts ("destructor not called");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 3
+#include "../test-skeleton.c"
diff --git a/nptl/tst-cancel25.c b/nptl/tst-cancel25.c
new file mode 100644
index 0000000000..00b99ad553
--- /dev/null
+++ b/nptl/tst-cancel25.c
@@ -0,0 +1,171 @@
+#include <pthreadP.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_barrier_t b;
+static pthread_t th2;
+
+
+static void *
+tf2 (void *arg)
+{
+ sigset_t mask;
+ if (pthread_sigmask (SIG_SETMASK, NULL, &mask) != 0)
+ {
+ puts ("pthread_sigmask failed");
+ exit (1);
+ }
+ if (sigismember (&mask, SIGCANCEL))
+ {
+ puts ("SIGCANCEL blocked in new thread");
+ exit (1);
+ }
+
+ /* Sync with the main thread so that we do not test anything else. */
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ while (1)
+ {
+ /* Just a cancelable call. */
+ struct timespec ts = { 10000, 0 };
+ nanosleep (&ts, 0);
+ }
+
+ return NULL;
+}
+
+
+static void
+unwhand (void *arg)
+{
+ if (pthread_create (&th2, NULL, tf2, NULL) != 0)
+ {
+ puts ("unwhand: create failed");
+ exit (1);
+ }
+}
+
+
+static void *
+tf (void *arg)
+{
+ pthread_cleanup_push (unwhand, NULL);
+
+ /* Sync with the main thread so that we do not test anything else. */
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ while (1)
+ {
+ /* Just a cancelable call. */
+ struct timespec ts = { 10000, 0 };
+ nanosleep (&ts, 0);
+ }
+
+ pthread_cleanup_pop (0);
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ pthread_t th1;
+ if (pthread_create (&th1, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ return 1;
+ }
+
+ /* Make sure tf1 enters nanosleep. */
+ struct timespec ts = { 0, 500000000 };
+ while (nanosleep (&ts, &ts) != 0)
+ ;
+
+ if (pthread_cancel (th1) != 0)
+ {
+ puts ("1st cancel failed");
+ return 1;
+ }
+
+ void *res;
+ if (pthread_join (th1, &res) != 0)
+ {
+ puts ("1st join failed");
+ return 1;
+ }
+ if (res != PTHREAD_CANCELED)
+ {
+ puts ("1st thread not canceled");
+ return 1;
+ }
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ return 1;
+ }
+
+ /* Make sure tf2 enters nanosleep. */
+ ts.tv_sec = 0;
+ ts.tv_nsec = 500000000;
+ while (nanosleep (&ts, &ts) != 0)
+ ;
+
+ puts ("calling pthread_cancel the second time");
+ if (pthread_cancel (th2) != 0)
+ {
+ puts ("2nd cancel failed");
+ return 1;
+ }
+
+ puts ("calling pthread_join the second time");
+ if (pthread_join (th2, &res) != 0)
+ {
+ puts ("2nd join failed");
+ return 1;
+ }
+ if (res != PTHREAD_CANCELED)
+ {
+ puts ("2nd thread not canceled");
+ return 1;
+ }
+
+ if (pthread_barrier_destroy (&b) != 0)
+ {
+ puts ("barrier_destroy failed");
+ return 0;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 4
+#include "../test-skeleton.c"
diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
index c3e527fd1c..45df6ce076 100644
--- a/nptl/tst-cancel4.c
+++ b/nptl/tst-cancel4.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -84,6 +84,8 @@ static pthread_barrier_t b2;
# define IPC_ADDVAL 0
#endif
+#define WRITE_BUFFER_SIZE 4096
+
/* Cleanup handling test. */
static int cl_called;
@@ -220,7 +222,7 @@ tf_write (void *arg)
ssize_t s;
pthread_cleanup_push (cl, NULL);
- char buf[100000];
+ char buf[WRITE_BUFFER_SIZE];
memset (buf, '\0', sizeof (buf));
s = write (fd, buf, sizeof (buf));
@@ -266,7 +268,7 @@ tf_writev (void *arg)
ssize_t s;
pthread_cleanup_push (cl, NULL);
- char buf[100000];
+ char buf[WRITE_BUFFER_SIZE];
memset (buf, '\0', sizeof (buf));
struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
s = writev (fd, iov, 1);
@@ -522,6 +524,53 @@ tf_poll (void *arg)
static void *
+tf_ppoll (void *arg)
+{
+ int fd;
+ int r;
+
+ if (arg == NULL)
+ fd = fds[0];
+ else
+ {
+ char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+ tempfd = fd = mkstemp (fname);
+ if (fd == -1)
+ printf ("%s: mkstemp failed\n", __FUNCTION__);
+ unlink (fname);
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ struct pollfd rfs[1] = { [0] = { .fd = fd, .events = POLLIN } };
+
+ int s;
+ pthread_cleanup_push (cl, NULL);
+
+ s = ppoll (rfs, 1, NULL, NULL);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: ppoll returns with %d (%s)\n", __FUNCTION__, s,
+ strerror (errno));
+
+ exit (1);
+}
+
+
+static void *
tf_wait (void *arg)
{
pid_t pid = fork ();
@@ -1522,6 +1571,47 @@ tf_fsync (void *arg)
static void *
+tf_fdatasync (void *arg)
+{
+ if (arg == NULL)
+ // XXX If somebody can provide a portable test case in which fdatasync()
+ // blocks we can enable this test to run in both rounds.
+ abort ();
+
+ tempfd = open ("Makefile", O_RDONLY);
+ if (tempfd == -1)
+ {
+ printf ("%s: cannot open Makefile\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ fdatasync (tempfd);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: fdatasync returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
tf_msync (void *arg)
{
if (arg == NULL)
@@ -2004,6 +2094,7 @@ static struct
ADD_TEST (select, 2, 0),
ADD_TEST (pselect, 2, 0),
ADD_TEST (poll, 2, 0),
+ ADD_TEST (ppoll, 2, 0),
ADD_TEST (write, 2, 0),
ADD_TEST (writev, 2, 0),
ADD_TEST (sleep, 2, 0),
@@ -2028,6 +2119,7 @@ static struct
ADD_TEST (pread, 2, 1),
ADD_TEST (pwrite, 2, 1),
ADD_TEST (fsync, 2, 1),
+ ADD_TEST (fdatasync, 2, 1),
ADD_TEST (msync, 2, 1),
ADD_TEST (sendto, 2, 1),
ADD_TEST (sendmsg, 2, 1),
@@ -2043,11 +2135,29 @@ static struct
static int
do_test (void)
{
- if (pipe (fds) != 0)
+ int val;
+ socklen_t len;
+
+ if (socketpair (AF_UNIX, SOCK_STREAM, PF_UNIX, fds) != 0)
+ {
+ perror ("socketpair");
+ exit (1);
+ }
+
+ val = 1;
+ len = sizeof(val);
+ setsockopt (fds[1], SOL_SOCKET, SO_SNDBUF, &val, sizeof(val));
+ if (getsockopt (fds[1], SOL_SOCKET, SO_SNDBUF, &val, &len) < 0)
+ {
+ perror ("getsockopt");
+ exit (1);
+ }
+ if (val >= WRITE_BUFFER_SIZE)
{
- puts ("pipe failed");
+ puts ("minimum write buffer size too large");
exit (1);
}
+ setsockopt (fds[1], SOL_SOCKET, SO_SNDBUF, &val, sizeof(val));
int result = 0;
size_t cnt;
diff --git a/nptl/tst-cond22.c b/nptl/tst-cond22.c
new file mode 100644
index 0000000000..aff38fcc8d
--- /dev/null
+++ b/nptl/tst-cond22.c
@@ -0,0 +1,160 @@
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_barrier_t b;
+static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void
+cl (void *arg)
+{
+ pthread_mutex_unlock (&m);
+}
+
+
+static void *
+tf (void *arg)
+{
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ printf ("%s: mutex_lock failed\n", __func__);
+ exit (1);
+ }
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __func__);
+ exit (1);
+ }
+ pthread_cleanup_push (cl, NULL);
+ /* We have to loop here because the cancellation might come after
+ the cond_wait call left the cancelable area and is then waiting
+ on the mutex. In this case the beginning of the second cond_wait
+ call will cause the cancellation to happen. */
+ do
+ if (pthread_cond_wait (&c, &m) != 0)
+ {
+ printf ("%s: cond_wait failed\n", __func__);
+ exit (1);
+ }
+ while (arg == NULL);
+ pthread_cleanup_pop (0);
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ printf ("%s: mutex_unlock failed\n", __func__);
+ exit (1);
+ }
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ int status = 0;
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("1st create failed");
+ return 1;
+ }
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("1st barrier_wait failed");
+ return 1;
+ }
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("1st mutex_lock failed");
+ return 1;
+ }
+ if (pthread_cond_signal (&c) != 0)
+ {
+ puts ("1st cond_signal failed");
+ return 1;
+ }
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cancel failed");
+ return 1;
+ }
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("1st mutex_unlock failed");
+ return 1;
+ }
+ void *res;
+ if (pthread_join (th, &res) != 0)
+ {
+ puts ("1st join failed");
+ return 1;
+ }
+ if (res != PTHREAD_CANCELED)
+ {
+ puts ("first thread not canceled");
+ status = 1;
+ }
+
+ printf ("cond = { %d, %x, %lld, %lld, %lld, %p, %u, %u }\n",
+ c.__data.__lock, c.__data.__futex, c.__data.__total_seq,
+ c.__data.__wakeup_seq, c.__data.__woken_seq, c.__data.__mutex,
+ c.__data.__nwaiters, c.__data.__broadcast_seq);
+
+ if (pthread_create (&th, NULL, tf, (void *) 1l) != 0)
+ {
+ puts ("2nd create failed");
+ return 1;
+ }
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("2nd barrier_wait failed");
+ return 1;
+ }
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("2nd mutex_lock failed");
+ return 1;
+ }
+ if (pthread_cond_signal (&c) != 0)
+ {
+ puts ("2nd cond_signal failed");
+ return 1;
+ }
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("2nd mutex_unlock failed");
+ return 1;
+ }
+ if (pthread_join (th, &res) != 0)
+ {
+ puts ("2nd join failed");
+ return 1;
+ }
+ if (res != NULL)
+ {
+ puts ("2nd thread canceled");
+ status = 1;
+ }
+
+ printf ("cond = { %d, %x, %lld, %lld, %lld, %p, %u, %u }\n",
+ c.__data.__lock, c.__data.__futex, c.__data.__total_seq,
+ c.__data.__wakeup_seq, c.__data.__woken_seq, c.__data.__mutex,
+ c.__data.__nwaiters, c.__data.__broadcast_seq);
+
+ return status;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-getpid1.c b/nptl/tst-getpid1.c
index 497bebed56..f9fd4fc0ca 100644
--- a/nptl/tst-getpid1.c
+++ b/nptl/tst-getpid1.c
@@ -44,10 +44,10 @@ do_test (void)
extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
size_t __child_stack_size, int __flags,
void *__arg, ...);
- char st[256 * 1024];
+ char st[256 * 1024] __attribute__ ((aligned));
pid_t p = __clone2 (f, st, sizeof (st), TEST_CLONE_FLAGS, 0);
#else
- char st[128 * 1024];
+ char st[128 * 1024] __attribute__ ((aligned));
pid_t p = clone (f, st + sizeof (st), TEST_CLONE_FLAGS, 0);
#endif
if (p == -1)
diff --git a/nptl/tst-getpid3.c b/nptl/tst-getpid3.c
new file mode 100644
index 0000000000..f1e77f6b10
--- /dev/null
+++ b/nptl/tst-getpid3.c
@@ -0,0 +1,114 @@
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static pid_t pid;
+
+static void *
+pid_thread (void *arg)
+{
+ if (pid != getpid ())
+ {
+ printf ("pid wrong in thread: should be %d, is %d\n",
+ (int) pid, (int) getpid ());
+ return (void *) 1L;
+ }
+
+ return NULL;
+}
+
+static int
+do_test (void)
+{
+ pid = getpid ();
+
+ pthread_t thr;
+ int ret = pthread_create (&thr, NULL, pid_thread, NULL);
+ if (ret)
+ {
+ printf ("pthread_create failed: %d\n", ret);
+ return 1;
+ }
+
+ void *thr_ret;
+ ret = pthread_join (thr, &thr_ret);
+ if (ret)
+ {
+ printf ("pthread_create failed: %d\n", ret);
+ return 1;
+ }
+ else if (thr_ret)
+ {
+ printf ("thread getpid failed\n");
+ return 1;
+ }
+
+ pid_t child = fork ();
+ if (child == -1)
+ {
+ printf ("fork failed: %m\n");
+ return 1;
+ }
+ else if (child == 0)
+ {
+ if (pid == getpid ())
+ {
+ puts ("pid did not change after fork");
+ exit (1);
+ }
+
+ pid = getpid ();
+ ret = pthread_create (&thr, NULL, pid_thread, NULL);
+ if (ret)
+ {
+ printf ("pthread_create failed: %d\n", ret);
+ return 1;
+ }
+
+ ret = pthread_join (thr, &thr_ret);
+ if (ret)
+ {
+ printf ("pthread_create failed: %d\n", ret);
+ return 1;
+ }
+ else if (thr_ret)
+ {
+ printf ("thread getpid failed\n");
+ return 1;
+ }
+
+ return 0;
+ }
+
+ int status;
+ if (TEMP_FAILURE_RETRY (waitpid (child, &status, 0)) != child)
+ {
+ puts ("waitpid failed");
+ kill (child, SIGKILL);
+ return 1;
+ }
+
+ if (!WIFEXITED (status))
+ {
+ if (WIFSIGNALED (status))
+ printf ("died from signal %s\n", strsignal (WTERMSIG (status)));
+ else
+ puts ("did not terminate correctly");
+ return 1;
+ }
+ if (WEXITSTATUS (status) != 0)
+ {
+ printf ("exit code %d\n", WEXITSTATUS (status));
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-initializers1-c89.c b/nptl/tst-initializers1-c89.c
new file mode 100644
index 0000000000..7c27c1d545
--- /dev/null
+++ b/nptl/tst-initializers1-c89.c
@@ -0,0 +1 @@
+#include "tst-initializers1.c"
diff --git a/nptl/tst-initializers1-c99.c b/nptl/tst-initializers1-c99.c
new file mode 100644
index 0000000000..7c27c1d545
--- /dev/null
+++ b/nptl/tst-initializers1-c99.c
@@ -0,0 +1 @@
+#include "tst-initializers1.c"
diff --git a/nptl/tst-initializers1-gnu89.c b/nptl/tst-initializers1-gnu89.c
new file mode 100644
index 0000000000..7c27c1d545
--- /dev/null
+++ b/nptl/tst-initializers1-gnu89.c
@@ -0,0 +1 @@
+#include "tst-initializers1.c"
diff --git a/nptl/tst-initializers1-gnu99.c b/nptl/tst-initializers1-gnu99.c
new file mode 100644
index 0000000000..7c27c1d545
--- /dev/null
+++ b/nptl/tst-initializers1-gnu99.c
@@ -0,0 +1 @@
+#include "tst-initializers1.c"
diff --git a/nptl/tst-initializers1.c b/nptl/tst-initializers1.c
new file mode 100644
index 0000000000..ccd27286e8
--- /dev/null
+++ b/nptl/tst-initializers1.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2005.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <pthread.h>
+
+pthread_mutex_t mtx_normal = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t mtx_recursive = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+pthread_mutex_t mtx_errorchk = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+pthread_mutex_t mtx_adaptive = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP;
+pthread_rwlock_t rwl_normal = PTHREAD_RWLOCK_INITIALIZER;
+pthread_rwlock_t rwl_writer
+ = PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP;
+pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+
+int
+main (void)
+{
+ if (mtx_normal.__data.__kind != PTHREAD_MUTEX_TIMED_NP)
+ return 1;
+ if (mtx_recursive.__data.__kind != PTHREAD_MUTEX_RECURSIVE_NP)
+ return 1;
+ if (mtx_errorchk.__data.__kind != PTHREAD_MUTEX_ERRORCHECK_NP)
+ return 1;
+ if (mtx_adaptive.__data.__kind != PTHREAD_MUTEX_ADAPTIVE_NP)
+ return 1;
+ if (rwl_normal.__data.__flags != PTHREAD_RWLOCK_PREFER_READER_NP)
+ return 1;
+ if (rwl_writer.__data.__flags
+ != PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP)
+ return 1;
+ return 0;
+}
diff --git a/nptl/tst-join5.c b/nptl/tst-join5.c
index 589fac6b5f..db005f5b71 100644
--- a/nptl/tst-join5.c
+++ b/nptl/tst-join5.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
@@ -21,120 +21,187 @@
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+
+#define wait_code() \
+ do { \
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 200000000 }; \
+ while (syscall (__NR_nanosleep, &ts, &ts) < 0) \
+ /* nothing */; \
+ } while (0)
+
+
+#ifdef WAIT_IN_CHILD
+static pthread_barrier_t b;
+#endif
static void *
tf1 (void *arg)
{
- pthread_join ((pthread_t) arg, NULL);
+#ifdef WAIT_IN_CHILD
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __func__);
+ exit (1);
+ }
- puts ("1st join returned");
+ wait_code ();
+#endif
- return (void *) 1l;
+ pthread_join ((pthread_t) arg, NULL);
+
+ exit (42);
}
static void *
tf2 (void *arg)
{
- pthread_join ((pthread_t) arg, NULL);
+#ifdef WAIT_IN_CHILD
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __func__);
+ exit (1);
+ }
- puts ("2nd join returned");
+ wait_code ();
+#endif
+ pthread_join ((pthread_t) arg, NULL);
- return (void *) 1l;
+ exit (43);
}
static int
do_test (void)
{
+#ifdef WAIT_IN_CHILD
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+#endif
+
pthread_t th;
int err = pthread_join (pthread_self (), NULL);
if (err == 0)
{
puts ("1st circular join succeeded");
- exit (1);
+ return 1;
}
if (err != EDEADLK)
{
printf ("1st circular join %d, not EDEADLK\n", err);
- exit (1);
+ return 1;
}
if (pthread_create (&th, NULL, tf1, (void *) pthread_self ()) != 0)
{
puts ("1st create failed");
- exit (1);
+ return 1;
}
+#ifndef WAIT_IN_CHILD
+ wait_code ();
+#endif
+
if (pthread_cancel (th) != 0)
{
puts ("cannot cancel 1st thread");
- exit (1);
+ return 1;
+ }
+
+#ifdef WAIT_IN_CHILD
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __func__);
+ return 1;
}
+#endif
void *r;
err = pthread_join (th, &r);
if (err != 0)
{
printf ("cannot join 1st thread: %d\n", err);
- exit (1);
+ return 1;
}
if (r != PTHREAD_CANCELED)
{
puts ("1st thread not canceled");
- exit (1);
+ return 1;
}
err = pthread_join (pthread_self (), NULL);
if (err == 0)
{
puts ("2nd circular join succeeded");
- exit (1);
+ return 1;
}
if (err != EDEADLK)
{
printf ("2nd circular join %d, not EDEADLK\n", err);
- exit (1);
+ return 1;
}
if (pthread_create (&th, NULL, tf2, (void *) pthread_self ()) != 0)
{
puts ("2nd create failed");
- exit (1);
+ return 1;
}
+#ifndef WAIT_IN_CHILD
+ wait_code ();
+#endif
+
if (pthread_cancel (th) != 0)
{
puts ("cannot cancel 2nd thread");
- exit (1);
+ return 1;
}
+#ifdef WAIT_IN_CHILD
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __func__);
+ return 1;
+ }
+#endif
+
if (pthread_join (th, &r) != 0)
{
puts ("cannot join 2nd thread");
- exit (1);
+ return 1;
}
if (r != PTHREAD_CANCELED)
{
puts ("2nd thread not canceled");
- exit (1);
+ return 1;
}
err = pthread_join (pthread_self (), NULL);
if (err == 0)
{
- puts ("2nd circular join succeeded");
- exit (1);
+ puts ("3rd circular join succeeded");
+ return 1;
}
if (err != EDEADLK)
{
- printf ("2nd circular join %d, not EDEADLK\n", err);
- exit (1);
+ printf ("3rd circular join %d, not EDEADLK\n", err);
+ return 1;
}
- exit (0);
+ return 0;
}
#define TEST_FUNCTION do_test ()
diff --git a/nptl/tst-join6.c b/nptl/tst-join6.c
new file mode 100644
index 0000000000..0c9e7c056b
--- /dev/null
+++ b/nptl/tst-join6.c
@@ -0,0 +1,2 @@
+#define WAIT_IN_CHILD 1
+#include "tst-join5.c"
diff --git a/nptl/tst-kill4.c b/nptl/tst-kill4.c
index 4e7ff5eaf4..a1b97e7b26 100644
--- a/nptl/tst-kill4.c
+++ b/nptl/tst-kill4.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
@@ -35,13 +35,30 @@ tf (void *a)
int
do_test (void)
{
+ pthread_attr_t at;
+ if (pthread_attr_init (&at) != 0)
+ {
+ puts ("attr_create failed");
+ exit (1);
+ }
+
+ /* Limit thread stack size, because if it is too large, pthread_join
+ will free it immediately rather than put it into stack cache. */
+ if (pthread_attr_setstacksize (&at, 2 * 1024 * 1024) != 0)
+ {
+ puts ("setstacksize failed");
+ exit (1);
+ }
+
pthread_t th;
- if (pthread_create (&th, NULL, tf, NULL) != 0)
+ if (pthread_create (&th, &at, tf, NULL) != 0)
{
puts ("create failed");
exit (1);
}
+ pthread_attr_destroy (&at);
+
if (pthread_join (th, NULL) != 0)
{
puts ("join failed");
diff --git a/nptl/tst-mutex1.c b/nptl/tst-mutex1.c
index 50b5ccaf0e..9453f04918 100644
--- a/nptl/tst-mutex1.c
+++ b/nptl/tst-mutex1.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -19,6 +19,12 @@
#include <pthread.h>
#include <stdio.h>
+#include <errno.h>
+
+
+#ifndef ATTR
+# define ATTR NULL
+#endif
static int
@@ -26,12 +32,24 @@ do_test (void)
{
pthread_mutex_t m;
- if (pthread_mutex_init (&m, NULL) != 0)
+ int e = pthread_mutex_init (&m, ATTR);
+ if (ATTR != NULL && e == ENOTSUP)
+ {
+ puts ("cannot support selected type of mutexes");
+ return 0;
+ }
+ else if (e != 0)
{
puts ("mutex_init failed");
return 1;
}
+ if (ATTR != NULL && pthread_mutexattr_destroy (ATTR) != 0)
+ {
+ puts ("mutexattr_destroy failed");
+ return 1;
+ }
+
if (pthread_mutex_lock (&m) != 0)
{
puts ("mutex_lock failed");
@@ -53,5 +71,7 @@ do_test (void)
return 0;
}
-#define TEST_FUNCTION do_test ()
+#ifndef TEST_FUNCTION
+# define TEST_FUNCTION do_test ()
+#endif
#include "../test-skeleton.c"
diff --git a/nptl/tst-mutex2.c b/nptl/tst-mutex2.c
index f589a1ea17..b09f569a5a 100644
--- a/nptl/tst-mutex2.c
+++ b/nptl/tst-mutex2.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -105,115 +105,134 @@ do_test (void)
if (pthread_mutexattr_init (&a) != 0)
{
puts ("mutexattr_init failed");
- exit (1);
+ return 1;
}
if (pthread_mutexattr_settype (&a, PTHREAD_MUTEX_ERRORCHECK) != 0)
{
puts ("mutexattr_settype failed");
- exit (1);
+ return 1;
}
- if (pthread_mutex_init (&m, &a) != 0)
+#ifdef ENABLE_PI
+ if (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_INHERIT) != 0)
{
+ puts ("pthread_mutexattr_setprotocol failed");
+ return 1;
+ }
+#endif
+
+ e = pthread_mutex_init (&m, &a);
+ if (e != 0)
+ {
+#ifdef ENABLE_PI
+ if (e == ENOTSUP)
+ {
+ puts ("PI mutexes unsupported");
+ return 0;
+ }
+#endif
puts ("mutex_init failed");
- exit (1);
+ return 1;
}
if (pthread_barrier_init (&b, NULL, 2) != 0)
{
puts ("barrier_init failed");
- exit (1);
+ return 1;
}
- if ((e = pthread_mutex_unlock (&m)) == 0)
+ e = pthread_mutex_unlock (&m);
+ if (e == 0)
{
puts ("1st mutex_unlock succeeded");
- exit (1);
+ return 1;
}
else if (e != EPERM)
{
puts ("1st mutex_unlock error != EPERM");
- exit (1);
+ return 1;
}
if (pthread_mutex_lock (&m) != 0)
{
puts ("mutex_lock failed");
- exit (1);
+ return 1;
}
- if ((e = pthread_mutex_lock (&m)) == 0)
+ e = pthread_mutex_lock (&m);
+ if (e == 0)
{
puts ("2nd mutex_lock succeeded");
- exit (1);
+ return 1;
}
else if (e != EDEADLK)
{
puts ("2nd mutex_lock error != EDEADLK");
- exit (1);
+ return 1;
}
pthread_t th;
if (pthread_create (&th, NULL, tf, NULL) != 0)
{
puts ("create failed");
- exit (1);
+ return 1;
}
e = pthread_barrier_wait (&b);
if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
{
puts ("1st barrier_wait failed");
- exit (1);
+ return 1;
}
if (pthread_mutex_unlock (&m) != 0)
{
puts ("2nd mutex_unlock failed");
- exit (1);
+ return 1;
}
- if ((e = pthread_mutex_unlock (&m)) == 0)
+ e = pthread_mutex_unlock (&m);
+ if (e == 0)
{
puts ("3rd mutex_unlock succeeded");
- exit (1);
+ return 1;
}
else if (e != EPERM)
{
puts ("3rd mutex_unlock error != EPERM");
- exit (1);
+ return 1;
}
e = pthread_barrier_wait (&b);
if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
{
puts ("2nd barrier_wait failed");
- exit (1);
+ return 1;
}
if (pthread_join (th, NULL) != 0)
{
puts ("join failed");
- exit (1);
+ return 1;
}
if (pthread_mutex_destroy (&m) != 0)
{
puts ("mutex_destroy failed");
- exit (1);
+ return 1;
}
if (pthread_barrier_destroy (&b) != 0)
{
puts ("barrier_destroy failed");
- exit (1);
+ return 1;
}
if (pthread_mutexattr_destroy (&a) != 0)
{
puts ("mutexattr_destroy failed");
- exit (1);
+ return 1;
}
return 0;
diff --git a/nptl/tst-mutex3.c b/nptl/tst-mutex3.c
index 8e57924ba6..2848096538 100644
--- a/nptl/tst-mutex3.c
+++ b/nptl/tst-mutex3.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -113,8 +113,25 @@ do_test (void)
return 1;
}
- if (pthread_mutex_init (&m, &a) != 0)
+#ifdef ENABLE_PI
+ if (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_INHERIT) != 0)
{
+ puts ("pthread_mutexattr_setprotocol failed");
+ return 1;
+ }
+#endif
+
+ int e;
+ e = pthread_mutex_init (&m, &a);
+ if (e != 0)
+ {
+#ifdef ENABLE_PI
+ if (e == ENOTSUP)
+ {
+ puts ("PI mutexes unsupported");
+ return 0;
+ }
+#endif
puts ("mutex_init failed");
return 1;
}
@@ -162,7 +179,7 @@ do_test (void)
return 1;
}
- int e = pthread_barrier_wait (&b);
+ e = pthread_barrier_wait (&b);
if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
{
puts ("barrier_wait failed");
diff --git a/nptl/tst-mutex4.c b/nptl/tst-mutex4.c
index 0ce7313caf..9699c2db45 100644
--- a/nptl/tst-mutex4.c
+++ b/nptl/tst-mutex4.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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.
@@ -42,6 +42,8 @@ do_test (void)
char *p;
int err;
int s;
+ pthread_barrier_t *b;
+ pthread_barrierattr_t ba;
fd = mkstemp (tmpfname);
if (fd == -1)
@@ -70,9 +72,12 @@ do_test (void)
return 1;
}
- m = (pthread_mutex_t *) (((uintptr_t) mem + __alignof (pthread_mutex_t))
+ m = (pthread_mutex_t *) (((uintptr_t) mem + __alignof (pthread_mutex_t) - 1)
& ~(__alignof (pthread_mutex_t) - 1));
- p = (char *) (m + 1);
+ b = (pthread_barrier_t *) (((uintptr_t) (m + 1)
+ + __alignof (pthread_barrier_t) - 1)
+ & ~(__alignof (pthread_barrier_t) - 1));
+ p = (char *) (b + 1);
if (pthread_mutexattr_init (&a) != 0)
{
@@ -110,8 +115,23 @@ do_test (void)
return 1;
}
- if (pthread_mutex_init (m, &a) != 0)
+#ifdef ENABLE_PI
+ if (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_INHERIT) != 0)
{
+ puts ("pthread_mutexattr_setprotocol failed");
+ return 1;
+ }
+#endif
+
+ if ((err = pthread_mutex_init (m, &a)) != 0)
+ {
+#ifdef ENABLE_PI
+ if (err == ENOTSUP)
+ {
+ puts ("PI mutexes unsupported");
+ return 0;
+ }
+#endif
puts ("mutex_init failed");
return 1;
}
@@ -128,6 +148,30 @@ do_test (void)
return 1;
}
+ if (pthread_barrierattr_init (&ba) != 0)
+ {
+ puts ("barrierattr_init failed");
+ return 1;
+ }
+
+ if (pthread_barrierattr_setpshared (&ba, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("barrierattr_setpshared failed");
+ return 1;
+ }
+
+ if (pthread_barrier_init (b, &ba, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ if (pthread_barrierattr_destroy (&ba) != 0)
+ {
+ puts ("barrierattr_destroy failed");
+ return 1;
+ }
+
err = pthread_mutex_trylock (m);
if (err == 0)
{
@@ -142,6 +186,12 @@ do_test (void)
*p = 0;
+ if (pthread_mutex_unlock (m) != 0)
+ {
+ puts ("parent: 1st mutex_unlock failed");
+ return 1;
+ }
+
puts ("going to fork now");
pid = fork ();
if (pid == -1)
@@ -151,7 +201,19 @@ do_test (void)
}
else if (pid == 0)
{
- /* Play some lock ping-pong. It's our turn to unlock first. */
+ if (pthread_mutex_lock (m) != 0)
+ {
+ puts ("child: mutex_lock failed");
+ return 1;
+ }
+
+ int e = pthread_barrier_wait (b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child: barrier_wait failed");
+ return 1;
+ }
+
if ((*p)++ != 0)
{
puts ("child: *p != 0");
@@ -160,7 +222,7 @@ do_test (void)
if (pthread_mutex_unlock (m) != 0)
{
- puts ("child: 1st mutex_unlock failed");
+ puts ("child: mutex_unlock failed");
return 1;
}
@@ -168,6 +230,13 @@ do_test (void)
}
else
{
+ int e = pthread_barrier_wait (b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("parent: barrier_wait failed");
+ return 1;
+ }
+
if (pthread_mutex_lock (m) != 0)
{
puts ("parent: 2nd mutex_lock failed");
@@ -180,6 +249,24 @@ do_test (void)
return 1;
}
+ if (pthread_mutex_unlock (m) != 0)
+ {
+ puts ("parent: 2nd mutex_unlock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_destroy (m) != 0)
+ {
+ puts ("mutex_destroy failed");
+ return 1;
+ }
+
+ if (pthread_barrier_destroy (b) != 0)
+ {
+ puts ("barrier_destroy failed");
+ return 1;
+ }
+
puts ("parent done");
}
diff --git a/nptl/tst-mutex5.c b/nptl/tst-mutex5.c
index eb35b78d36..291274fee5 100644
--- a/nptl/tst-mutex5.c
+++ b/nptl/tst-mutex5.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 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.
@@ -52,8 +52,24 @@ do_test (void)
return 1;
}
- if (pthread_mutex_init (&m, &a) != 0)
+#ifdef ENABLE_PI
+ if (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_INHERIT) != 0)
{
+ puts ("pthread_mutexattr_setprotocol failed");
+ return 1;
+ }
+#endif
+
+ err = pthread_mutex_init (&m, &a);
+ if (err != 0)
+ {
+#ifdef ENABLE_PI
+ if (err == ENOTSUP)
+ {
+ puts ("PI mutexes unsupported");
+ return 0;
+ }
+#endif
puts ("mutex_init failed");
return 1;
}
diff --git a/nptl/tst-mutex6.c b/nptl/tst-mutex6.c
index f066c62edc..de64bdb435 100644
--- a/nptl/tst-mutex6.c
+++ b/nptl/tst-mutex6.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -21,6 +21,12 @@
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
+#include <errno.h>
+
+
+#ifndef ATTR
+# define ATTR NULL
+#endif
static int
@@ -28,12 +34,24 @@ do_test (void)
{
pthread_mutex_t m;
- if (pthread_mutex_init (&m, NULL) != 0)
+ int e = pthread_mutex_init (&m, ATTR);
+ if (ATTR != NULL && e == ENOTSUP)
+ {
+ puts ("cannot support selected type of mutexes");
+ e = pthread_mutex_init (&m, NULL);
+ }
+ if (e != 0)
{
puts ("mutex_init failed");
return 1;
}
+ if (ATTR != NULL && pthread_mutexattr_destroy (ATTR) != 0)
+ {
+ puts ("mutexattr_destroy failed");
+ return 1;
+ }
+
if (pthread_mutex_lock (&m) != 0)
{
puts ("1st mutex_lock failed");
@@ -51,5 +69,7 @@ do_test (void)
}
#define EXPECTED_SIGNAL SIGALRM
-#define TEST_FUNCTION do_test ()
+#ifndef TEST_FUNCTION
+# define TEST_FUNCTION do_test ()
+#endif
#include "../test-skeleton.c"
diff --git a/nptl/tst-mutex7.c b/nptl/tst-mutex7.c
index a9b9f318cb..27e5d8eb28 100644
--- a/nptl/tst-mutex7.c
+++ b/nptl/tst-mutex7.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -17,17 +17,19 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <errno.h>
#include <pthread.h>
#include <stdio.h>
+#include <stdlib.h>
#include <time.h>
-#ifndef INIT
-# define INIT PTHREAD_MUTEX_INITIALIZER
+#ifndef TYPE
+# define TYPE PTHREAD_MUTEX_DEFAULT
#endif
-static pthread_mutex_t lock = INIT;
+static pthread_mutex_t lock;
#define ROUNDS 1000
@@ -65,6 +67,48 @@ tf (void *arg)
static int
do_test (void)
{
+ pthread_mutexattr_t a;
+
+ if (pthread_mutexattr_init (&a) != 0)
+ {
+ puts ("mutexattr_init failed");
+ exit (1);
+ }
+
+ if (pthread_mutexattr_settype (&a, TYPE) != 0)
+ {
+ puts ("mutexattr_settype failed");
+ exit (1);
+ }
+
+#ifdef ENABLE_PI
+ if (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_INHERIT) != 0)
+ {
+ puts ("pthread_mutexattr_setprotocol failed");
+ return 1;
+ }
+#endif
+
+ int e = pthread_mutex_init (&lock, &a);
+ if (e != 0)
+ {
+#ifdef ENABLE_PI
+ if (e == ENOTSUP)
+ {
+ puts ("PI mutexes unsupported");
+ return 0;
+ }
+#endif
+ puts ("mutex_init failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_destroy (&a) != 0)
+ {
+ puts ("mutexattr_destroy failed");
+ return 1;
+ }
+
pthread_attr_t at;
pthread_t th[N];
int cnt;
diff --git a/nptl/tst-mutex7a.c b/nptl/tst-mutex7a.c
index f08799ae79..30d46b81af 100644
--- a/nptl/tst-mutex7a.c
+++ b/nptl/tst-mutex7a.c
@@ -1,2 +1,2 @@
-#define INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
+#define TYPE PTHREAD_MUTEX_ADAPTIVE_NP
#include "tst-mutex7.c"
diff --git a/nptl/tst-mutex9.c b/nptl/tst-mutex9.c
index 5ea2f0ac99..f9d379343d 100644
--- a/nptl/tst-mutex9.c
+++ b/nptl/tst-mutex9.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
@@ -88,8 +88,24 @@ do_test (void)
return 1;
}
- if (pthread_mutex_init (m, &a) != 0)
+#ifdef ENABLE_PI
+ if (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_INHERIT) != 0)
{
+ puts ("pthread_mutexattr_setprotocol failed");
+ return 1;
+ }
+#endif
+
+ int e;
+ if ((e = pthread_mutex_init (m, &a)) != 0)
+ {
+#ifdef ENABLE_PI
+ if (e == ENOTSUP)
+ {
+ puts ("PI mutexes unsupported");
+ return 0;
+ }
+#endif
puts ("mutex_init failed");
return 1;
}
@@ -138,7 +154,7 @@ do_test (void)
ts.tv_nsec -= 1000000000;
}
- int e = pthread_mutex_timedlock (m, &ts);
+ e = pthread_mutex_timedlock (m, &ts);
if (e == 0)
{
puts ("child: mutex_timedlock succeeded");
diff --git a/nptl/tst-mutexpi1.c b/nptl/tst-mutexpi1.c
new file mode 100644
index 0000000000..623ede9fa5
--- /dev/null
+++ b/nptl/tst-mutexpi1.c
@@ -0,0 +1,27 @@
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutexattr_t a;
+
+static void
+prepare (void)
+{
+ if (pthread_mutexattr_init (&a) != 0)
+ {
+ puts ("mutexattr_init failed");
+ exit (1);
+ }
+
+ if (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_INHERIT) != 0)
+ {
+ puts ("mutexattr_setprotocol failed");
+ exit (1);
+ }
+}
+#define PREPARE(argc, argv) prepare ()
+
+
+#define ATTR &a
+#include "tst-mutex1.c"
diff --git a/nptl/tst-mutexpi2.c b/nptl/tst-mutexpi2.c
new file mode 100644
index 0000000000..fbe48716fd
--- /dev/null
+++ b/nptl/tst-mutexpi2.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-mutex2.c"
diff --git a/nptl/tst-mutexpi3.c b/nptl/tst-mutexpi3.c
new file mode 100644
index 0000000000..e338ebfff9
--- /dev/null
+++ b/nptl/tst-mutexpi3.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-mutex3.c"
diff --git a/nptl/tst-mutexpi4.c b/nptl/tst-mutexpi4.c
new file mode 100644
index 0000000000..177b17b475
--- /dev/null
+++ b/nptl/tst-mutexpi4.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-mutex4.c"
diff --git a/nptl/tst-mutexpi5.c b/nptl/tst-mutexpi5.c
new file mode 100644
index 0000000000..287465c23f
--- /dev/null
+++ b/nptl/tst-mutexpi5.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-mutex5.c"
diff --git a/nptl/tst-mutexpi5a.c b/nptl/tst-mutexpi5a.c
new file mode 100644
index 0000000000..2f85c94ff3
--- /dev/null
+++ b/nptl/tst-mutexpi5a.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-mutex5a.c"
diff --git a/nptl/tst-mutexpi6.c b/nptl/tst-mutexpi6.c
new file mode 100644
index 0000000000..42cda377d1
--- /dev/null
+++ b/nptl/tst-mutexpi6.c
@@ -0,0 +1,27 @@
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutexattr_t a;
+
+static void
+prepare (void)
+{
+ if (pthread_mutexattr_init (&a) != 0)
+ {
+ puts ("mutexattr_init failed");
+ exit (1);
+ }
+
+ if (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_INHERIT) != 0)
+ {
+ puts ("mutexattr_setprotocol failed");
+ exit (1);
+ }
+}
+#define PREPARE(argc, argv) prepare ()
+
+
+#define ATTR &a
+#include "tst-mutex6.c"
diff --git a/nptl/tst-mutexpi7.c b/nptl/tst-mutexpi7.c
new file mode 100644
index 0000000000..1e7e929380
--- /dev/null
+++ b/nptl/tst-mutexpi7.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-mutex7.c"
diff --git a/nptl/tst-mutexpi7a.c b/nptl/tst-mutexpi7a.c
new file mode 100644
index 0000000000..c59083cf6e
--- /dev/null
+++ b/nptl/tst-mutexpi7a.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-mutex7a.c"
diff --git a/nptl/tst-mutexpi8.c b/nptl/tst-mutexpi8.c
new file mode 100644
index 0000000000..cea60309a8
--- /dev/null
+++ b/nptl/tst-mutexpi8.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-mutex8.c"
diff --git a/nptl/tst-mutexpi9.c b/nptl/tst-mutexpi9.c
new file mode 100644
index 0000000000..3710d9e080
--- /dev/null
+++ b/nptl/tst-mutexpi9.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-mutex9.c"
diff --git a/nptl/tst-mutexpp1.c b/nptl/tst-mutexpp1.c
new file mode 100644
index 0000000000..9b7d7fe263
--- /dev/null
+++ b/nptl/tst-mutexpp1.c
@@ -0,0 +1,45 @@
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "tst-tpp.h"
+
+static pthread_mutexattr_t a;
+
+static void
+prepare (void)
+{
+ init_tpp_test ();
+
+ if (pthread_mutexattr_init (&a) != 0)
+ {
+ puts ("mutexattr_init failed");
+ exit (1);
+ }
+
+ if (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_PROTECT) != 0)
+ {
+ puts ("mutexattr_setprotocol failed");
+ exit (1);
+ }
+
+ if (pthread_mutexattr_setprioceiling (&a, 6) != 0)
+ {
+ puts ("mutexattr_setprioceiling failed");
+ exit (1);
+ }
+}
+#define PREPARE(argc, argv) prepare ()
+
+static int do_test (void);
+
+static int
+do_test_wrapper (void)
+{
+ init_tpp_test ();
+ return do_test ();
+}
+#define TEST_FUNCTION do_test_wrapper ()
+
+#define ATTR &a
+#include "tst-mutex1.c"
diff --git a/nptl/tst-mutexpp10.c b/nptl/tst-mutexpp10.c
new file mode 100644
index 0000000000..78281a4d3b
--- /dev/null
+++ b/nptl/tst-mutexpp10.c
@@ -0,0 +1,334 @@
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <limits.h>
+#include <pthread.h>
+#include <sched.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "tst-tpp.h"
+
+static int
+do_test (void)
+{
+ int ret = 0;
+
+ init_tpp_test ();
+
+ pthread_mutexattr_t ma;
+ if (pthread_mutexattr_init (&ma))
+ {
+ puts ("mutexattr_init failed");
+ return 1;
+ }
+ if (pthread_mutexattr_setprotocol (&ma, PTHREAD_PRIO_PROTECT))
+ {
+ puts ("mutexattr_setprotocol failed");
+ return 1;
+ }
+
+ int prioceiling;
+ if (pthread_mutexattr_getprioceiling (&ma, &prioceiling))
+ {
+ puts ("mutexattr_getprioceiling failed");
+ return 1;
+ }
+
+ if (prioceiling < fifo_min || prioceiling > fifo_max)
+ {
+ printf ("prioceiling %d not in %d..%d range\n",
+ prioceiling, fifo_min, fifo_max);
+ return 1;
+ }
+
+ if (fifo_max < INT_MAX
+ && pthread_mutexattr_setprioceiling (&ma, fifo_max + 1) != EINVAL)
+ {
+ printf ("mutexattr_setprioceiling %d did not fail with EINVAL\n",
+ fifo_max + 1);
+ return 1;
+ }
+
+ if (fifo_min > 0
+ && pthread_mutexattr_setprioceiling (&ma, fifo_min - 1) != EINVAL)
+ {
+ printf ("mutexattr_setprioceiling %d did not fail with EINVAL\n",
+ fifo_min - 1);
+ return 1;
+ }
+
+ if (pthread_mutexattr_setprioceiling (&ma, fifo_min))
+ {
+ puts ("mutexattr_setprioceiling failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_setprioceiling (&ma, fifo_max))
+ {
+ puts ("mutexattr_setprioceiling failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_setprioceiling (&ma, 6))
+ {
+ puts ("mutexattr_setprioceiling failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_getprioceiling (&ma, &prioceiling))
+ {
+ puts ("mutexattr_getprioceiling failed");
+ return 1;
+ }
+
+ if (prioceiling != 6)
+ {
+ printf ("mutexattr_getprioceiling returned %d != 6\n",
+ prioceiling);
+ return 1;
+ }
+
+ pthread_mutex_t m1, m2, m3;
+ int e = pthread_mutex_init (&m1, &ma);
+ if (e == ENOTSUP)
+ {
+ puts ("cannot support selected type of mutexes");
+ return 0;
+ }
+ else if (e != 0)
+ {
+ puts ("mutex_init failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_setprioceiling (&ma, 8))
+ {
+ puts ("mutexattr_setprioceiling failed");
+ return 1;
+ }
+
+ if (pthread_mutex_init (&m2, &ma))
+ {
+ puts ("mutex_init failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_setprioceiling (&ma, 5))
+ {
+ puts ("mutexattr_setprioceiling failed");
+ return 1;
+ }
+
+ if (pthread_mutex_init (&m3, &ma))
+ {
+ puts ("mutex_init failed");
+ return 1;
+ }
+
+ CHECK_TPP_PRIORITY (4, 4);
+
+ if (pthread_mutex_lock (&m1) != 0)
+ {
+ puts ("mutex_lock failed");
+ return 1;
+ }
+
+ CHECK_TPP_PRIORITY (4, 6);
+
+ if (pthread_mutex_trylock (&m2) != 0)
+ {
+ puts ("mutex_lock failed");
+ return 1;
+ }
+
+ CHECK_TPP_PRIORITY (4, 8);
+
+ if (pthread_mutex_lock (&m3) != 0)
+ {
+ puts ("mutex_lock failed");
+ return 1;
+ }
+
+ CHECK_TPP_PRIORITY (4, 8);
+
+ if (pthread_mutex_unlock (&m2) != 0)
+ {
+ puts ("mutex_unlock failed");
+ return 1;
+ }
+
+ CHECK_TPP_PRIORITY (4, 6);
+
+ if (pthread_mutex_unlock (&m1) != 0)
+ {
+ puts ("mutex_unlock failed");
+ return 1;
+ }
+
+ CHECK_TPP_PRIORITY (4, 5);
+
+ if (pthread_mutex_lock (&m2) != 0)
+ {
+ puts ("mutex_lock failed");
+ return 1;
+ }
+
+ CHECK_TPP_PRIORITY (4, 8);
+
+ if (pthread_mutex_unlock (&m2) != 0)
+ {
+ puts ("mutex_unlock failed");
+ return 1;
+ }
+
+ CHECK_TPP_PRIORITY (4, 5);
+
+ if (pthread_mutex_getprioceiling (&m1, &prioceiling))
+ {
+ puts ("mutex_getprioceiling m1 failed");
+ return 1;
+ }
+ else if (prioceiling != 6)
+ {
+ printf ("unexpected m1 prioceiling %d != 6\n", prioceiling);
+ return 1;
+ }
+
+ if (pthread_mutex_getprioceiling (&m2, &prioceiling))
+ {
+ puts ("mutex_getprioceiling m2 failed");
+ return 1;
+ }
+ else if (prioceiling != 8)
+ {
+ printf ("unexpected m2 prioceiling %d != 8\n", prioceiling);
+ return 1;
+ }
+
+ if (pthread_mutex_getprioceiling (&m3, &prioceiling))
+ {
+ puts ("mutex_getprioceiling m3 failed");
+ return 1;
+ }
+ else if (prioceiling != 5)
+ {
+ printf ("unexpected m3 prioceiling %d != 5\n", prioceiling);
+ return 1;
+ }
+
+ if (pthread_mutex_setprioceiling (&m1, 7, &prioceiling))
+ {
+ printf ("mutex_setprioceiling failed");
+ return 1;
+ }
+ else if (prioceiling != 6)
+ {
+ printf ("unexpected m1 old prioceiling %d != 6\n", prioceiling);
+ return 1;
+ }
+
+ if (pthread_mutex_getprioceiling (&m1, &prioceiling))
+ {
+ puts ("mutex_getprioceiling m1 failed");
+ return 1;
+ }
+ else if (prioceiling != 7)
+ {
+ printf ("unexpected m1 prioceiling %d != 7\n", prioceiling);
+ return 1;
+ }
+
+ CHECK_TPP_PRIORITY (4, 5);
+
+ if (pthread_mutex_unlock (&m3) != 0)
+ {
+ puts ("mutex_unlock failed");
+ return 1;
+ }
+
+ CHECK_TPP_PRIORITY (4, 4);
+
+ if (pthread_mutex_trylock (&m1) != 0)
+ {
+ puts ("mutex_lock failed");
+ return 1;
+ }
+
+ CHECK_TPP_PRIORITY (4, 7);
+
+ struct sched_param sp;
+ memset (&sp, 0, sizeof (sp));
+ sp.sched_priority = 8;
+ if (pthread_setschedparam (pthread_self (), SCHED_FIFO, &sp))
+ {
+ puts ("cannot set scheduling params");
+ return 1;
+ }
+
+ CHECK_TPP_PRIORITY (8, 8);
+
+ if (pthread_mutex_unlock (&m1) != 0)
+ {
+ puts ("mutex_unlock failed");
+ return 1;
+ }
+
+ CHECK_TPP_PRIORITY (8, 8);
+
+ if (pthread_mutex_lock (&m3) != EINVAL)
+ {
+ puts ("pthread_mutex_lock didn't fail with EINVAL");
+ return 1;
+ }
+
+ CHECK_TPP_PRIORITY (8, 8);
+
+ if (pthread_mutex_destroy (&m1) != 0)
+ {
+ puts ("mutex_destroy failed");
+ return 1;
+ }
+
+ if (pthread_mutex_destroy (&m2) != 0)
+ {
+ puts ("mutex_destroy failed");
+ return 1;
+ }
+
+ if (pthread_mutex_destroy (&m3) != 0)
+ {
+ puts ("mutex_destroy failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_destroy (&ma) != 0)
+ {
+ puts ("mutexattr_destroy failed");
+ return 1;
+ }
+
+ return ret;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-mutexpp6.c b/nptl/tst-mutexpp6.c
new file mode 100644
index 0000000000..2ddf6b45c6
--- /dev/null
+++ b/nptl/tst-mutexpp6.c
@@ -0,0 +1,45 @@
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "tst-tpp.h"
+
+static pthread_mutexattr_t a;
+
+static void
+prepare (void)
+{
+ init_tpp_test ();
+
+ if (pthread_mutexattr_init (&a) != 0)
+ {
+ puts ("mutexattr_init failed");
+ exit (1);
+ }
+
+ if (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_PROTECT) != 0)
+ {
+ puts ("mutexattr_setprotocol failed");
+ exit (1);
+ }
+
+ if (pthread_mutexattr_setprioceiling (&a, 6) != 0)
+ {
+ puts ("mutexattr_setprioceiling failed");
+ exit (1);
+ }
+}
+#define PREPARE(argc, argv) prepare ()
+
+static int do_test (void);
+
+static int
+do_test_wrapper (void)
+{
+ init_tpp_test ();
+ return do_test ();
+}
+#define TEST_FUNCTION do_test_wrapper ()
+
+#define ATTR &a
+#include "tst-mutex6.c"
diff --git a/nptl/tst-once3.c b/nptl/tst-once3.c
index 43b354a391..1a74abb530 100644
--- a/nptl/tst-once3.c
+++ b/nptl/tst-once3.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 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.
@@ -52,6 +52,8 @@ once_handler1 (void)
exit (1);
}
+ puts ("once_handler1: going to wait on cond");
+
pthread_cond_wait (&cond, &mut);
/* We should never get here. */
@@ -139,6 +141,9 @@ do_test (void)
puts ("join didn't return PTHREAD_CANCELED");
return 1;
}
+ puts ("joined successfully");
+
+ printf ("once = %d\n", *(int *) &once);
if (cl_called != 1)
{
diff --git a/nptl/tst-robust1.c b/nptl/tst-robust1.c
new file mode 100644
index 0000000000..bc48700e4a
--- /dev/null
+++ b/nptl/tst-robust1.c
@@ -0,0 +1,339 @@
+/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2005.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutex_t m1;
+static pthread_mutex_t m2;
+static pthread_barrier_t b;
+
+
+#ifndef LOCK
+# define LOCK(m) pthread_mutex_lock (m)
+#endif
+
+
+static void *
+tf (void *arg)
+{
+ long int round = (long int) arg;
+
+ if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0)
+ {
+ printf ("%ld: setcancelstate failed\n", round);
+ exit (1);
+ }
+
+ int e = LOCK (&m1);
+ if (e != 0)
+ {
+ printf ("%ld: child: mutex_lock m1 failed with error %d\n", round, e);
+ exit (1);
+ }
+
+ e = LOCK (&m2);
+ if (e != 0)
+ {
+ printf ("%ld: child: mutex_lock m2 failed with error %d\n", round, e);
+ exit (1);
+ }
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%ld: child: 1st barrier_wait failed\n", round);
+ exit (1);
+ }
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%ld: child: 2nd barrier_wait failed\n", round);
+ exit (1);
+ }
+
+ pthread_testcancel ();
+
+ printf ("%ld: testcancel returned\n", round);
+ exit (1);
+}
+
+
+static int
+do_test (void)
+{
+#ifdef PREPARE_TMO
+ PREPARE_TMO;
+#endif
+
+ pthread_mutexattr_t a;
+ if (pthread_mutexattr_init (&a) != 0)
+ {
+ puts ("mutexattr_init failed");
+ return 1;
+ }
+ if (pthread_mutexattr_setrobust_np (&a, PTHREAD_MUTEX_ROBUST_NP) != 0)
+ {
+ puts ("mutexattr_setrobust failed");
+ return 1;
+ }
+
+#ifdef ENABLE_PI
+ if (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_INHERIT) != 0)
+ {
+ puts ("pthread_mutexattr_setprotocol failed");
+ return 1;
+ }
+ else
+ {
+ int e = pthread_mutex_init (&m1, &a);
+ if (e == ENOTSUP)
+ {
+ puts ("PI robust mutexes not supported");
+ return 0;
+ }
+ else if (e != 0)
+ {
+ puts ("mutex_init m1 failed");
+ return 1;
+ }
+ pthread_mutex_destroy (&m1);
+ }
+#endif
+
+#ifndef NOT_CONSISTENT
+ if (pthread_mutex_init (&m1, &a) != 0)
+ {
+ puts ("mutex_init m1 failed");
+ return 1;
+ }
+
+ if (pthread_mutex_init (&m2, &a) != 0)
+ {
+ puts ("mutex_init m2 failed");
+ return 1;
+ }
+#endif
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ for (long int round = 1; round < 5; ++round)
+ {
+#ifdef NOT_CONSISTENT
+ if (pthread_mutex_init (&m1 , &a) != 0)
+ {
+ puts ("mutex_init m1 failed");
+ return 1;
+ }
+ if (pthread_mutex_init (&m2 , &a) != 0)
+ {
+ puts ("mutex_init m2 failed");
+ return 1;
+ }
+#endif
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, (void *) round) != 0)
+ {
+ printf ("%ld: create failed\n", round);
+ return 1;
+ }
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%ld: parent: 1st barrier_wait failed\n", round);
+ return 1;
+ }
+
+ if (pthread_cancel (th) != 0)
+ {
+ printf ("%ld: cancel failed\n", round);
+ return 1;
+ }
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%ld: parent: 2nd barrier_wait failed\n", round);
+ return 1;
+ }
+
+#ifndef AFTER_JOIN
+ if (round & 1)
+#endif
+ {
+ void *res;
+ if (pthread_join (th, &res) != 0)
+ {
+ printf ("%ld: join failed\n", round);
+ return 1;
+ }
+ if (res != PTHREAD_CANCELED)
+ {
+ printf ("%ld: thread not canceled\n", round);
+ return 1;
+ }
+ }
+
+ e = LOCK (&m1);
+ if (e == 0)
+ {
+ printf ("%ld: parent: mutex_lock m1 succeeded\n", round);
+ return 1;
+ }
+ if (e != EOWNERDEAD)
+ {
+ printf ("%ld: parent: mutex_lock m1 returned wrong code\n", round);
+ return 1;
+ }
+
+ e = LOCK (&m2);
+ if (e == 0)
+ {
+ printf ("%ld: parent: mutex_lock m2 succeeded\n", round);
+ return 1;
+ }
+ if (e != EOWNERDEAD)
+ {
+ printf ("%ld: parent: mutex_lock m2 returned wrong code\n", round);
+ return 1;
+ }
+
+#ifndef AFTER_JOIN
+ if ((round & 1) == 0)
+ {
+ void *res;
+ if (pthread_join (th, &res) != 0)
+ {
+ printf ("%ld: join failed\n", round);
+ return 1;
+ }
+ if (res != PTHREAD_CANCELED)
+ {
+ printf ("%ld: thread not canceled\n", round);
+ return 1;
+ }
+ }
+#endif
+
+#ifndef NOT_CONSISTENT
+ e = pthread_mutex_consistent_np (&m1);
+ if (e != 0)
+ {
+ printf ("%ld: mutex_consistent m1 failed with error %d\n", round, e);
+ return 1;
+ }
+
+ e = pthread_mutex_consistent_np (&m2);
+ if (e != 0)
+ {
+ printf ("%ld: mutex_consistent m2 failed with error %d\n", round, e);
+ return 1;
+ }
+#endif
+
+ e = pthread_mutex_unlock (&m1);
+ if (e != 0)
+ {
+ printf ("%ld: mutex_unlock m1 failed with %d\n", round, e);
+ return 1;
+ }
+
+ e = pthread_mutex_unlock (&m2);
+ if (e != 0)
+ {
+ printf ("%ld: mutex_unlock m2 failed with %d\n", round, e);
+ return 1;
+ }
+
+#ifdef NOT_CONSISTENT
+ e = LOCK (&m1);
+ if (e == 0)
+ {
+ printf ("%ld: locking inconsistent mutex m1 succeeded\n", round);
+ return 1;
+ }
+ if (e != ENOTRECOVERABLE)
+ {
+ printf ("%ld: locking inconsistent mutex m1 failed with error %d\n",
+ round, e);
+ return 1;
+ }
+
+ if (pthread_mutex_destroy (&m1) != 0)
+ {
+ puts ("mutex_destroy m1 failed");
+ return 1;
+ }
+
+ e = LOCK (&m2);
+ if (e == 0)
+ {
+ printf ("%ld: locking inconsistent mutex m2 succeeded\n", round);
+ return 1;
+ }
+ if (e != ENOTRECOVERABLE)
+ {
+ printf ("%ld: locking inconsistent mutex m2 failed with error %d\n",
+ round, e);
+ return 1;
+ }
+
+ if (pthread_mutex_destroy (&m2) != 0)
+ {
+ puts ("mutex_destroy m2 failed");
+ return 1;
+ }
+#endif
+ }
+
+#ifndef NOT_CONSISTENT
+ if (pthread_mutex_destroy (&m1) != 0)
+ {
+ puts ("mutex_destroy m1 failed");
+ return 1;
+ }
+
+ if (pthread_mutex_destroy (&m2) != 0)
+ {
+ puts ("mutex_destroy m2 failed");
+ return 1;
+ }
+#endif
+
+ if (pthread_mutexattr_destroy (&a) != 0)
+ {
+ puts ("mutexattr_destroy failed");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-robust2.c b/nptl/tst-robust2.c
new file mode 100644
index 0000000000..cf603feb4d
--- /dev/null
+++ b/nptl/tst-robust2.c
@@ -0,0 +1,3 @@
+#define AFTER_JOIN 1
+#define LOCK(m) pthread_mutex_trylock (m)
+#include "tst-robust1.c"
diff --git a/nptl/tst-robust3.c b/nptl/tst-robust3.c
new file mode 100644
index 0000000000..e56f2762c7
--- /dev/null
+++ b/nptl/tst-robust3.c
@@ -0,0 +1,20 @@
+#include <time.h>
+#include <sys/time.h>
+
+
+static struct timespec tmo;
+
+
+#define PREPARE_TMO \
+ do { \
+ struct timeval tv; \
+ gettimeofday (&tv, NULL); \
+ \
+ /* Define the timeout as one hour in the future. */ \
+ tmo.tv_sec = tv.tv_sec + 3600; \
+ tmo.tv_nsec = 0; \
+ } while (0)
+
+
+#define LOCK(m) pthread_mutex_timedlock (m, &tmo)
+#include "tst-robust1.c"
diff --git a/nptl/tst-robust4.c b/nptl/tst-robust4.c
new file mode 100644
index 0000000000..b9c42b85b9
--- /dev/null
+++ b/nptl/tst-robust4.c
@@ -0,0 +1,2 @@
+#define NOT_CONSISTENT 1
+#include "tst-robust1.c"
diff --git a/nptl/tst-robust5.c b/nptl/tst-robust5.c
new file mode 100644
index 0000000000..b83d3d66cb
--- /dev/null
+++ b/nptl/tst-robust5.c
@@ -0,0 +1,2 @@
+#define NOT_CONSISTENT 1
+#include "tst-robust2.c"
diff --git a/nptl/tst-robust6.c b/nptl/tst-robust6.c
new file mode 100644
index 0000000000..6713396de1
--- /dev/null
+++ b/nptl/tst-robust6.c
@@ -0,0 +1,2 @@
+#define NOT_CONSISTENT 1
+#include "tst-robust3.c"
diff --git a/nptl/tst-robust7.c b/nptl/tst-robust7.c
new file mode 100644
index 0000000000..d0bc91cc8e
--- /dev/null
+++ b/nptl/tst-robust7.c
@@ -0,0 +1,212 @@
+/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2005.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+
+
+static pthread_barrier_t b;
+static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t m;
+static bool first = true;
+
+
+static void *
+tf (void *arg)
+{
+ long int n = (long int) arg;
+
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ printf ("thread %ld: mutex_lock failed\n", n + 1);
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("thread %ld: barrier_wait failed\n", n + 1);
+ exit (1);
+ }
+
+ e = pthread_cond_wait (&c, &m);
+ if (first)
+ {
+ if (e != 0)
+ {
+ printf ("thread %ld: cond_wait failed\n", n + 1);
+ exit (1);
+ }
+ first = false;
+ }
+ else
+ {
+ if (e != EOWNERDEAD)
+ {
+ printf ("thread %ld: cond_wait did not return EOWNERDEAD\n", n + 1);
+ exit (1);
+ }
+ }
+
+ if (pthread_cancel (pthread_self ()) != 0)
+ {
+ printf ("thread %ld: cancel failed\n", n + 1);
+ exit (1);
+ }
+
+ pthread_testcancel ();
+
+ printf ("thread %ld: testcancel returned\n", n + 1);
+ exit (1);
+}
+
+
+static int
+do_test (void)
+{
+ pthread_mutexattr_t a;
+ if (pthread_mutexattr_init (&a) != 0)
+ {
+ puts ("mutexattr_init failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_setrobust_np (&a, PTHREAD_MUTEX_ROBUST_NP) != 0)
+ {
+ puts ("mutexattr_setrobust failed");
+ return 1;
+ }
+
+#ifdef ENABLE_PI
+ if (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_INHERIT) != 0)
+ {
+ puts ("pthread_mutexattr_setprotocol failed");
+ return 1;
+ }
+#endif
+
+ int e;
+ e = pthread_mutex_init (&m, &a);
+ if (e != 0)
+ {
+#ifdef ENABLE_PI
+ if (e == ENOTSUP)
+ {
+ puts ("PI robust mutexes not supported");
+ return 0;
+ }
+#endif
+ puts ("mutex_init failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_destroy (&a) != 0)
+ {
+ puts ("mutexattr_destroy failed");
+ return 1;
+ }
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+#define N 5
+ pthread_t th[N];
+ for (long int n = 0; n < N; ++n)
+ {
+ if (pthread_create (&th[n], NULL, tf, (void *) n) != 0)
+ {
+ printf ("pthread_create loop %ld failed\n", n + 1);
+ return 1;
+ }
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("parent: barrier_wait failed in round %ld\n", n + 1);
+ return 1;
+ }
+ }
+
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("parent: mutex_lock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("parent: mutex_unlock failed");
+ return 1;
+ }
+
+ if (pthread_cond_broadcast (&c) != 0)
+ {
+ puts ("cond_broadcast failed");
+ return 1;
+ }
+
+ for (int n = 0; n < N; ++n)
+ {
+ void *res;
+ if (pthread_join (th[n], &res) != 0)
+ {
+ printf ("join round %d failed\n", n + 1);
+ return 1;
+ }
+ if (res != PTHREAD_CANCELED)
+ {
+ printf ("thread %d not canceled\n", n + 1);
+ return 1;
+ }
+ }
+
+ e = pthread_mutex_lock (&m);
+ if (e == 0)
+ {
+ puts ("parent: 2nd mutex_lock succeeded");
+ return 1;
+ }
+ if (e != EOWNERDEAD)
+ {
+ puts ("parent: mutex_lock did not return EOWNERDEAD");
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("parent: 2nd mutex_unlock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_destroy (&m) != 0)
+ {
+ puts ("mutex_destroy failed");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-robust8.c b/nptl/tst-robust8.c
new file mode 100644
index 0000000000..9c636250d4
--- /dev/null
+++ b/nptl/tst-robust8.c
@@ -0,0 +1,275 @@
+#include <pthread.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+
+
+static void prepare (void);
+#define PREPARE(argc, argv) prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 5
+#include "../test-skeleton.c"
+
+
+static int fd;
+#define N 100
+
+static void
+prepare (void)
+{
+ fd = create_temp_file ("tst-robust8", NULL);
+ if (fd == -1)
+ exit (1);
+}
+
+
+#define THESIGNAL SIGKILL
+#define ROUNDS 5
+#define THREADS 9
+
+
+static const struct timespec before = { 0, 0 };
+
+
+static pthread_mutex_t *map;
+
+
+static void *
+tf (void *arg)
+{
+ long int nr = (long int) arg;
+ int fct = nr % 3;
+
+ uint8_t state[N];
+ memset (state, '\0', sizeof (state));
+
+ while (1)
+ {
+ int r = random () % N;
+ if (state[r] == 0)
+ {
+ int e;
+
+ switch (fct)
+ {
+ case 0:
+ e = pthread_mutex_lock (&map[r]);
+ if (e != 0)
+ {
+ printf ("mutex_lock of %d in thread %ld failed with %d\n",
+ r, nr, e);
+ exit (1);
+ }
+ state[r] = 1;
+ break;
+ case 1:
+ e = pthread_mutex_timedlock (&map[r], &before);
+ if (e != 0 && e != ETIMEDOUT)
+ {
+ printf ("\
+mutex_timedlock of %d in thread %ld failed with %d\n",
+ r, nr, e);
+ exit (1);
+ }
+ break;
+ default:
+ e = pthread_mutex_trylock (&map[r]);
+ if (e != 0 && e != EBUSY)
+ {
+ printf ("mutex_trylock of %d in thread %ld failed with %d\n",
+ r, nr, e);
+ exit (1);
+ }
+ break;
+ }
+
+ if (e == EOWNERDEAD)
+ pthread_mutex_consistent_np (&map[r]);
+
+ if (e == 0 || e == EOWNERDEAD)
+ state[r] = 1;
+ }
+ else
+ {
+ int e = pthread_mutex_unlock (&map[r]);
+ if (e != 0)
+ {
+ printf ("mutex_unlock of %d in thread %ld failed with %d\n",
+ r, nr, e);
+ exit (1);
+ }
+
+ state[r] = 0;
+ }
+ }
+}
+
+
+static void
+child (int round)
+{
+ for (int thread = 1; thread <= THREADS; ++thread)
+ {
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, (void *) (long int) thread) != 0)
+ {
+ printf ("cannot create thread %d in round %d\n", thread, round);
+ exit (1);
+ }
+ }
+
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = 1000000000 / ROUNDS;
+ while (nanosleep (&ts, &ts) != 0)
+ /* nothing */;
+
+ /* Time to die. */
+ kill (getpid (), THESIGNAL);
+
+ /* We better never get here. */
+ abort ();
+}
+
+
+static int
+do_test (void)
+{
+ if (ftruncate (fd, N * sizeof (pthread_mutex_t)) != 0)
+ {
+ puts ("cannot size new file");
+ return 1;
+ }
+
+ map = mmap (NULL, N * sizeof (pthread_mutex_t), PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, 0);
+ if (map == MAP_FAILED)
+ {
+ puts ("mapping failed");
+ return 1;
+ }
+
+ pthread_mutexattr_t ma;
+ if (pthread_mutexattr_init (&ma) != 0)
+ {
+ puts ("mutexattr_init failed");
+ return 0;
+ }
+ if (pthread_mutexattr_setrobust_np (&ma, PTHREAD_MUTEX_ROBUST_NP) != 0)
+ {
+ puts ("mutexattr_setrobust failed");
+ return 1;
+ }
+ if (pthread_mutexattr_setpshared (&ma, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("mutexattr_setpshared failed");
+ return 1;
+ }
+#ifdef ENABLE_PI
+ if (pthread_mutexattr_setprotocol (&ma, PTHREAD_PRIO_INHERIT) != 0)
+ {
+ puts ("pthread_mutexattr_setprotocol failed");
+ return 1;
+ }
+#endif
+
+ for (int round = 1; round <= ROUNDS; ++round)
+ {
+ for (int n = 0; n < N; ++n)
+ {
+ int e = pthread_mutex_init (&map[n], &ma);
+ if (e == ENOTSUP)
+ {
+#ifdef ENABLE_PI
+ puts ("cannot support pshared robust PI mutexes");
+#else
+ puts ("cannot support pshared robust mutexes");
+#endif
+ return 0;
+ }
+ if (e != 0)
+ {
+ printf ("mutex_init %d in round %d failed\n", n + 1, round);
+ return 1;
+ }
+ }
+
+ pid_t p = fork ();
+ if (p == -1)
+ {
+ printf ("fork in round %d failed\n", round);
+ return 1;
+ }
+ if (p == 0)
+ child (round);
+
+ int status;
+ if (TEMP_FAILURE_RETRY (waitpid (p, &status, 0)) != p)
+ {
+ printf ("waitpid in round %d failed\n", round);
+ return 1;
+ }
+ if (!WIFSIGNALED (status))
+ {
+ printf ("child did not die of a signal in round %d\n", round);
+ return 1;
+ }
+ if (WTERMSIG (status) != THESIGNAL)
+ {
+ printf ("child did not die of signal %d in round %d\n",
+ THESIGNAL, round);
+ return 1;
+ }
+
+ for (int n = 0; n < N; ++n)
+ {
+ int e = pthread_mutex_lock (&map[n]);
+ if (e != 0 && e != EOWNERDEAD)
+ {
+ printf ("mutex_lock %d failed in round %d\n", n + 1, round);
+ return 1;
+ }
+ }
+
+ for (int n = 0; n < N; ++n)
+ if (pthread_mutex_unlock (&map[n]) != 0)
+ {
+ printf ("mutex_unlock %d failed in round %d\n", n + 1, round);
+ return 1;
+ }
+
+ for (int n = 0; n < N; ++n)
+ {
+ int e = pthread_mutex_destroy (&map[n]);
+ if (e != 0)
+ {
+ printf ("mutex_destroy %d in round %d failed with %d\n",
+ n + 1, round, e);
+ printf("nusers = %d\n", (int) map[n].__data.__nusers);
+ return 1;
+ }
+ }
+ }
+
+ if (pthread_mutexattr_destroy (&ma) != 0)
+ {
+ puts ("mutexattr_destroy failed");
+ return 1;
+ }
+
+ if (munmap (map, N * sizeof (pthread_mutex_t)) != 0)
+ {
+ puts ("munmap failed");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/nptl/tst-robust9.c b/nptl/tst-robust9.c
new file mode 100644
index 0000000000..1d6ba179be
--- /dev/null
+++ b/nptl/tst-robust9.c
@@ -0,0 +1,94 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+static pthread_mutex_t m;
+
+static void *
+tf (void *data)
+{
+ int err = pthread_mutex_lock (&m);
+ if (err == EOWNERDEAD)
+ {
+ err = pthread_mutex_consistent_np (&m);
+ if (err)
+ {
+ puts ("pthread_mutex_consistent_np");
+ exit (1);
+ }
+ }
+ else if (err)
+ {
+ puts ("pthread_mutex_lock");
+ exit (1);
+ }
+ printf ("thread%ld got the lock.\n", (long int) data);
+ sleep (1);
+ /* exit without unlock */
+ return NULL;
+}
+
+static int
+do_test (void)
+{
+ int err, i;
+ pthread_t t[3];
+ pthread_mutexattr_t ma;
+
+ pthread_mutexattr_init (&ma);
+ err = pthread_mutexattr_setrobust_np (&ma, PTHREAD_MUTEX_ROBUST_NP);
+ if (err)
+ {
+ puts ("pthread_mutexattr_setrobust_np");
+ return 1;
+ }
+#ifdef ENABLE_PI
+ if (pthread_mutexattr_setprotocol (&ma, PTHREAD_PRIO_INHERIT) != 0)
+ {
+ puts ("pthread_mutexattr_setprotocol failed");
+ return 1;
+ }
+#endif
+ err = pthread_mutex_init (&m, &ma);
+#ifdef ENABLE_PI
+ if (err == ENOTSUP)
+ {
+ puts ("PI robust mutexes not supported");
+ return 0;
+ }
+#endif
+ if (err)
+ {
+ puts ("pthread_mutex_init");
+ return 1;
+ }
+
+ for (i = 0; i < sizeof (t) / sizeof (t[0]); i++)
+ {
+ err = pthread_create (&t[i], NULL, tf, (void *) (long int) i);
+ if (err)
+ {
+ puts ("pthread_create");
+ return 1;
+ }
+ }
+
+ for (i = 0; i < sizeof (t) / sizeof (t[0]); i++)
+ {
+ err = pthread_join (t[i], NULL);
+ if (err)
+ {
+ puts ("pthread_join");
+ return 1;
+ }
+ }
+ return 0;
+}
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-robustpi1.c b/nptl/tst-robustpi1.c
new file mode 100644
index 0000000000..031291b296
--- /dev/null
+++ b/nptl/tst-robustpi1.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-robust1.c"
diff --git a/nptl/tst-robustpi2.c b/nptl/tst-robustpi2.c
new file mode 100644
index 0000000000..ac411c7736
--- /dev/null
+++ b/nptl/tst-robustpi2.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-robust2.c"
diff --git a/nptl/tst-robustpi3.c b/nptl/tst-robustpi3.c
new file mode 100644
index 0000000000..7dcf691e82
--- /dev/null
+++ b/nptl/tst-robustpi3.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-robust3.c"
diff --git a/nptl/tst-robustpi4.c b/nptl/tst-robustpi4.c
new file mode 100644
index 0000000000..6c7b0aa7be
--- /dev/null
+++ b/nptl/tst-robustpi4.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-robust4.c"
diff --git a/nptl/tst-robustpi5.c b/nptl/tst-robustpi5.c
new file mode 100644
index 0000000000..a494c332f1
--- /dev/null
+++ b/nptl/tst-robustpi5.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-robust5.c"
diff --git a/nptl/tst-robustpi6.c b/nptl/tst-robustpi6.c
new file mode 100644
index 0000000000..3b1482fc22
--- /dev/null
+++ b/nptl/tst-robustpi6.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-robust6.c"
diff --git a/nptl/tst-robustpi7.c b/nptl/tst-robustpi7.c
new file mode 100644
index 0000000000..f8892f3521
--- /dev/null
+++ b/nptl/tst-robustpi7.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-robust7.c"
diff --git a/nptl/tst-robustpi8.c b/nptl/tst-robustpi8.c
new file mode 100644
index 0000000000..cbea3d6d77
--- /dev/null
+++ b/nptl/tst-robustpi8.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-robust8.c"
diff --git a/nptl/tst-robustpi9.c b/nptl/tst-robustpi9.c
new file mode 100644
index 0000000000..d059aa7d88
--- /dev/null
+++ b/nptl/tst-robustpi9.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-robust9.c"
diff --git a/nptl/tst-sem10.c b/nptl/tst-sem10.c
new file mode 100644
index 0000000000..9f6e870a85
--- /dev/null
+++ b/nptl/tst-sem10.c
@@ -0,0 +1,88 @@
+/* Copyright (C) 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2007.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+static int
+do_test (void)
+{
+ sem_t s;
+ if (sem_init (&s, 0, 0) == -1)
+ {
+ puts ("sem_init failed");
+ return 1;
+ }
+
+ struct timeval tv;
+ if (gettimeofday (&tv, NULL) != 0)
+ {
+ puts ("gettimeofday failed");
+ return 1;
+ }
+
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+ /* Set ts to yesterday. */
+ ts.tv_sec -= 86400;
+
+ int type_before;
+ if (pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &type_before) != 0)
+ {
+ puts ("first pthread_setcanceltype failed");
+ return 1;
+ }
+
+ errno = 0;
+ if (TEMP_FAILURE_RETRY (sem_timedwait (&s, &ts)) != -1)
+ {
+ puts ("sem_timedwait succeeded");
+ return 1;
+ }
+ if (errno != ETIMEDOUT)
+ {
+ printf ("sem_timedwait return errno = %d instead of ETIMEDOUT\n",
+ errno);
+ return 1;
+ }
+
+ int type_after;
+ if (pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &type_after) != 0)
+ {
+ puts ("second pthread_setcanceltype failed");
+ return 1;
+ }
+ if (type_after != PTHREAD_CANCEL_DEFERRED)
+ {
+ puts ("sem_timedwait changed cancellation type");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-signal7.c b/nptl/tst-signal7.c
new file mode 100644
index 0000000000..82ef11c2d1
--- /dev/null
+++ b/nptl/tst-signal7.c
@@ -0,0 +1,59 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2005.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <pthreadP.h>
+#include <signal.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+ int result = 0;
+
+ errno = 0;
+ if (sigaction (SIGCANCEL, NULL, NULL) == 0)
+ {
+ puts ("sigaction(SIGCANCEL) did not fail");
+ result = 1;
+ }
+ else if (errno != EINVAL)
+ {
+ puts ("sigaction(SIGCANCEL) did not set errno to EINVAL");
+ result = 1;
+ }
+
+ errno = 0;
+ if (sigaction (SIGSETXID, NULL, NULL) == 0)
+ {
+ puts ("sigaction(SIGSETXID) did not fail");
+ result = 1;
+ }
+ else if (errno != EINVAL)
+ {
+ puts ("sigaction(SIGSETXID) did not set errno to EINVAL");
+ result = 1;
+ }
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-stackguard1-static.c b/nptl/tst-stackguard1-static.c
new file mode 100644
index 0000000000..db1e21554d
--- /dev/null
+++ b/nptl/tst-stackguard1-static.c
@@ -0,0 +1 @@
+#include "tst-stackguard1.c"
diff --git a/nptl/tst-stackguard1.c b/nptl/tst-stackguard1.c
new file mode 100644
index 0000000000..77ebbfbd7e
--- /dev/null
+++ b/nptl/tst-stackguard1.c
@@ -0,0 +1,230 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2005.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <elf/stackguard-macros.h>
+#include <unistd.h>
+
+static const char *command;
+static bool child;
+static uintptr_t stack_chk_guard_copy;
+static bool stack_chk_guard_copy_set;
+static int fds[2];
+
+static void __attribute__ ((constructor))
+con (void)
+{
+ stack_chk_guard_copy = STACK_CHK_GUARD;
+ stack_chk_guard_copy_set = true;
+}
+
+static int
+uintptr_t_cmp (const void *a, const void *b)
+{
+ if (*(uintptr_t *) a < *(uintptr_t *) b)
+ return 1;
+ if (*(uintptr_t *) a > *(uintptr_t *) b)
+ return -1;
+ return 0;
+}
+
+static void *
+tf (void *arg)
+{
+ if (stack_chk_guard_copy != STACK_CHK_GUARD)
+ {
+ puts ("STACK_CHK_GUARD changed in thread");
+ return (void *) 1L;
+ }
+ return NULL;
+}
+
+static int
+do_test (void)
+{
+ if (!stack_chk_guard_copy_set)
+ {
+ puts ("constructor has not been run");
+ return 1;
+ }
+
+ if (stack_chk_guard_copy != STACK_CHK_GUARD)
+ {
+ puts ("STACK_CHK_GUARD changed between constructor and do_test");
+ return 1;
+ }
+
+ if (child)
+ {
+ int i;
+ pthread_t th[4];
+ void *ret;
+ for (i = 0; i < 4; ++i)
+ if (pthread_create (&th[i], NULL, tf, NULL))
+ {
+ puts ("thread creation failed");
+ return 1;
+ }
+ for (i = 0; i < 4; ++i)
+ if (pthread_join (th[i], &ret))
+ {
+ puts ("thread join failed");
+ return 1;
+ }
+ else if (ret != NULL)
+ return 1;
+
+ write (2, &stack_chk_guard_copy, sizeof (stack_chk_guard_copy));
+ return 0;
+ }
+
+ if (command == NULL)
+ {
+ puts ("missing --command or --child argument");
+ return 1;
+ }
+
+#define N 16
+ uintptr_t child_stack_chk_guards[N + 1];
+ child_stack_chk_guards[N] = stack_chk_guard_copy;
+ int i;
+ for (i = 0; i < N; ++i)
+ {
+ if (pipe (fds) < 0)
+ {
+ printf ("couldn't create pipe: %m\n");
+ return 1;
+ }
+
+ pid_t pid = fork ();
+ if (pid < 0)
+ {
+ printf ("fork failed: %m\n");
+ return 1;
+ }
+
+ if (!pid)
+ {
+ if (stack_chk_guard_copy != STACK_CHK_GUARD)
+ {
+ puts ("STACK_CHK_GUARD changed after fork");
+ exit (1);
+ }
+
+ close (fds[0]);
+ close (2);
+ dup2 (fds[1], 2);
+ close (fds[1]);
+
+ system (command);
+ exit (0);
+ }
+
+ close (fds[1]);
+
+ if (TEMP_FAILURE_RETRY (read (fds[0], &child_stack_chk_guards[i],
+ sizeof (uintptr_t))) != sizeof (uintptr_t))
+ {
+ puts ("could not read stack_chk_guard value from child");
+ return 1;
+ }
+
+ close (fds[0]);
+
+ pid_t termpid;
+ int status;
+ termpid = TEMP_FAILURE_RETRY (waitpid (pid, &status, 0));
+ if (termpid == -1)
+ {
+ printf ("waitpid failed: %m\n");
+ return 1;
+ }
+ else if (termpid != pid)
+ {
+ printf ("waitpid returned %ld != %ld\n",
+ (long int) termpid, (long int) pid);
+ return 1;
+ }
+ else if (!WIFEXITED (status) || WEXITSTATUS (status))
+ {
+ puts ("child hasn't exited with exit status 0");
+ return 1;
+ }
+ }
+
+ qsort (child_stack_chk_guards, N + 1, sizeof (uintptr_t), uintptr_t_cmp);
+
+ uintptr_t default_guard = 0;
+ unsigned char *p = (unsigned char *) &default_guard;
+ p[sizeof (uintptr_t) - 1] = 255;
+ p[sizeof (uintptr_t) - 2] = '\n';
+ p[0] = 0;
+
+ /* Test if the stack guard canaries are either randomized,
+ or equal to the default stack guard canary value.
+ Even with randomized stack guards it might happen
+ that the random number generator generates the same
+ values, but if that happens in more than half from
+ the 16 runs, something is very wrong. */
+ int ndifferences = 0;
+ int ndefaults = 0;
+ int npartlyrandomized = 0;
+ for (i = 0; i < N; ++i)
+ {
+ if (child_stack_chk_guards[i] != child_stack_chk_guards[i+1])
+ ndifferences++;
+ else if (child_stack_chk_guards[i] == default_guard)
+ ndefaults++;
+ else if (*(char *) &child_stack_chk_guards[i] == 0)
+ npartlyrandomized++;
+ }
+
+ printf ("differences %d defaults %d partly randomized %d\n",
+ ndifferences, ndefaults, npartlyrandomized);
+
+ if ((ndifferences + ndefaults + npartlyrandomized) < 3 * N / 4)
+ {
+ puts ("stack guard canaries are not randomized enough");
+ puts ("nor equal to the default canary value");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define OPT_COMMAND 10000
+#define OPT_CHILD 10001
+#define CMDLINE_OPTIONS \
+ { "command", required_argument, NULL, OPT_COMMAND }, \
+ { "child", no_argument, NULL, OPT_CHILD },
+#define CMDLINE_PROCESS \
+ case OPT_COMMAND: \
+ command = optarg; \
+ break; \
+ case OPT_CHILD: \
+ child = true; \
+ break;
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-tpp.h b/nptl/tst-tpp.h
new file mode 100644
index 0000000000..c5844b26dd
--- /dev/null
+++ b/nptl/tst-tpp.h
@@ -0,0 +1,94 @@
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <sched.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+/* This test is Linux specific. */
+#define CHECK_TPP_PRIORITY(normal, boosted) \
+ do \
+ { \
+ pid_t tid = syscall (__NR_gettid); \
+ \
+ struct sched_param cep_sp; \
+ int cep_policy; \
+ if (pthread_getschedparam (pthread_self (), &cep_policy, \
+ &cep_sp) != 0) \
+ { \
+ puts ("getschedparam failed"); \
+ ret = 1; \
+ } \
+ else if (cep_sp.sched_priority != (normal)) \
+ { \
+ printf ("unexpected priority %d != %d\n", \
+ cep_sp.sched_priority, (normal)); \
+ } \
+ if (syscall (__NR_sched_getparam, tid, &cep_sp) == 0 \
+ && cep_sp.sched_priority != (boosted)) \
+ { \
+ printf ("unexpected boosted priority %d != %d\n", \
+ cep_sp.sched_priority, (boosted)); \
+ ret = 1; \
+ } \
+ } \
+ while (0)
+
+int fifo_min, fifo_max;
+
+void
+init_tpp_test (void)
+{
+ fifo_min = sched_get_priority_min (SCHED_FIFO);
+ if (fifo_min < 0)
+ {
+ printf ("couldn't get min priority for SCHED_FIFO: %m\n");
+ exit (1);
+ }
+
+ fifo_max = sched_get_priority_max (SCHED_FIFO);
+ if (fifo_max < 0)
+ {
+ printf ("couldn't get max priority for SCHED_FIFO: %m\n");
+ exit (1);
+ }
+
+ if (fifo_min > 4 || fifo_max < 10)
+ {
+ printf ("%d..%d SCHED_FIFO priority interval not suitable for this test\n",
+ fifo_min, fifo_max);
+ exit (0);
+ }
+
+ struct sched_param sp;
+ memset (&sp, 0, sizeof (sp));
+ sp.sched_priority = 4;
+ int e = pthread_setschedparam (pthread_self (), SCHED_FIFO, &sp);
+ if (e != 0)
+ {
+ errno = e;
+ printf ("cannot set scheduling params: %m\n");
+ exit (0);
+ }
+}
diff --git a/nptl/tst-typesizes.c b/nptl/tst-typesizes.c
new file mode 100644
index 0000000000..db8936f5f4
--- /dev/null
+++ b/nptl/tst-typesizes.c
@@ -0,0 +1,68 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2005.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdio.h>
+#include <pthreadP.h>
+#include <semaphore.h>
+
+
+static int
+do_test (void)
+{
+ int result = 0;
+
+#define TEST_TYPE(name) \
+ printf ("%s: ", #name); \
+ if (sizeof (name) != sizeof (((name *) 0)->__size)) \
+ { \
+ printf ("expected %zu, is %zu\n", \
+ sizeof (((name *) 0)->__size), sizeof (name)); \
+ result = 1; \
+ } \
+ else \
+ puts ("OK")
+
+ TEST_TYPE (pthread_mutex_t);
+ TEST_TYPE (pthread_cond_t);
+ TEST_TYPE (pthread_rwlock_t);
+
+#define TEST_TYPE2(name, internal) \
+ printf ("%s: ", #name); \
+ if (sizeof (((name *) 0)->__size) < sizeof (internal)) \
+ { \
+ printf ("expected %zu, is %zu\n", \
+ sizeof (((name *) 0)->__size), sizeof (internal)); \
+ result = 1; \
+ } \
+ else \
+ puts ("OK")
+
+ TEST_TYPE2 (pthread_attr_t, struct pthread_attr);
+ TEST_TYPE2 (pthread_mutexattr_t, struct pthread_mutexattr);
+ TEST_TYPE2 (pthread_condattr_t, struct pthread_condattr);
+ 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 sem);
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/nptl/tst-unload.c b/nptl/tst-unload.c
index ad86518caa..4ff43bb635 100644
--- a/nptl/tst-unload.c
+++ b/nptl/tst-unload.c
@@ -3,16 +3,16 @@
Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
+ You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
diff --git a/nptl/unwind.c b/nptl/unwind.c
index 56a4238158..9a35695cb5 100644
--- a/nptl/unwind.c
+++ b/nptl/unwind.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>
and Richard Henderson <rth@redhat.com>, 2003.
@@ -23,7 +23,7 @@
#include <string.h>
#include <unistd.h>
#include "pthreadP.h"
-#include "jmpbuf-unwind.h"
+#include <jmpbuf-unwind.h>
#ifdef HAVE_FORCED_UNWIND
diff --git a/nptl/version.c b/nptl/version.c
index f2fd25fd6d..b69556e948 100644
--- a/nptl/version.c
+++ b/nptl/version.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 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.
@@ -23,7 +23,7 @@
static const char banner[] =
#include "banner.h"
-"Copyright (C) 2003 Free Software Foundation, Inc.\n\
+"Copyright (C) 2006 Free Software Foundation, Inc.\n\
This is free software; see the source for copying conditions.\n\
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\
PARTICULAR PURPOSE.\n"