summaryrefslogtreecommitdiff
path: root/libpthread
diff options
context:
space:
mode:
authorroot <root@(null).(none)>2009-05-03 17:20:00 +0200
committerroot <root@(null).(none)>2009-05-03 17:20:00 +0200
commite0faf22f31c48fb27b43c1825897d26e58feafc4 (patch)
tree65a09372b31e08a3a865bd0a88cd2718bafcd643 /libpthread
This is my initial working version.
There is a bug in boot in this version: subhurd sometimes cannot boot.
Diffstat (limited to 'libpthread')
-rw-r--r--libpthread/.cvsignore1
-rw-r--r--libpthread/CVS/Entries12
-rw-r--r--libpthread/CVS/Repository1
-rw-r--r--libpthread/CVS/Root1
-rw-r--r--libpthread/CVS/Tag1
-rw-r--r--libpthread/ChangeLog1990
-rw-r--r--libpthread/Makefile243
-rw-r--r--libpthread/TODO174
-rw-r--r--libpthread/include/CVS/Entries5
-rw-r--r--libpthread/include/CVS/Repository1
-rw-r--r--libpthread/include/CVS/Root1
-rw-r--r--libpthread/include/CVS/Tag1
-rw-r--r--libpthread/include/libc-symbols.h395
-rw-r--r--libpthread/include/pthread.h7
-rw-r--r--libpthread/include/pthread/CVS/Entries3
-rw-r--r--libpthread/include/pthread/CVS/Repository1
-rw-r--r--libpthread/include/pthread/CVS/Root1
-rw-r--r--libpthread/include/pthread/CVS/Tag1
-rw-r--r--libpthread/include/pthread/pthread.h704
-rw-r--r--libpthread/include/pthread/pthreadtypes.h136
-rw-r--r--libpthread/include/semaphore.h69
-rw-r--r--libpthread/include/set-hooks.h72
-rw-r--r--libpthread/lockfile.c65
-rw-r--r--libpthread/not-in-libc.h11
-rw-r--r--libpthread/pthread/CVS/Entries20
-rw-r--r--libpthread/pthread/CVS/Repository1
-rw-r--r--libpthread/pthread/CVS/Root1
-rw-r--r--libpthread/pthread/CVS/Tag1
-rw-r--r--libpthread/pthread/Versions15
-rw-r--r--libpthread/pthread/cthreads-compat.c100
-rw-r--r--libpthread/pthread/pt-alloc.c215
-rw-r--r--libpthread/pthread/pt-cancel.c40
-rw-r--r--libpthread/pthread/pt-cleanup.c28
-rw-r--r--libpthread/pthread/pt-create.c211
-rw-r--r--libpthread/pthread/pt-dealloc.c63
-rw-r--r--libpthread/pthread/pt-detach.c82
-rw-r--r--libpthread/pthread/pt-exit.c122
-rw-r--r--libpthread/pthread/pt-getattr.c49
-rw-r--r--libpthread/pthread/pt-initialize.c33
-rw-r--r--libpthread/pthread/pt-internal.h301
-rw-r--r--libpthread/pthread/pt-internal.h.orig282
-rw-r--r--libpthread/pthread/pt-join.c79
-rw-r--r--libpthread/pthread/pt-self.c29
-rw-r--r--libpthread/pthread/pt-setcancelstate.c42
-rw-r--r--libpthread/pthread/pt-setcanceltype.c42
-rw-r--r--libpthread/pthread/pt-sigmask.c33
-rw-r--r--libpthread/pthread/pt-spin-inlines.c34
-rw-r--r--libpthread/pthread/pt-testcancel.c31
-rw-r--r--libpthread/sysdeps/CVS/Entries6
-rw-r--r--libpthread/sysdeps/CVS/Repository1
-rw-r--r--libpthread/sysdeps/CVS/Root1
-rw-r--r--libpthread/sysdeps/CVS/Tag1
-rw-r--r--libpthread/sysdeps/generic/CVS/Entries102
-rw-r--r--libpthread/sysdeps/generic/CVS/Repository1
-rw-r--r--libpthread/sysdeps/generic/CVS/Root1
-rw-r--r--libpthread/sysdeps/generic/CVS/Tag1
-rw-r--r--libpthread/sysdeps/generic/bits/CVS/Entries15
-rw-r--r--libpthread/sysdeps/generic/bits/CVS/Repository1
-rw-r--r--libpthread/sysdeps/generic/bits/CVS/Root1
-rw-r--r--libpthread/sysdeps/generic/bits/CVS/Tag1
-rw-r--r--libpthread/sysdeps/generic/bits/barrier-attr.h32
-rw-r--r--libpthread/sysdeps/generic/bits/barrier.h39
-rw-r--r--libpthread/sysdeps/generic/bits/cancelation.h54
-rw-r--r--libpthread/sysdeps/generic/bits/condition-attr.h34
-rw-r--r--libpthread/sysdeps/generic/bits/condition.h39
-rw-r--r--libpthread/sysdeps/generic/bits/mutex-attr.h37
-rw-r--r--libpthread/sysdeps/generic/bits/mutex.h67
-rw-r--r--libpthread/sysdeps/generic/bits/once.h34
-rw-r--r--libpthread/sysdeps/generic/bits/pthread.h38
-rw-r--r--libpthread/sysdeps/generic/bits/rwlock-attr.h32
-rw-r--r--libpthread/sysdeps/generic/bits/rwlock.h46
-rw-r--r--libpthread/sysdeps/generic/bits/semaphore.h43
-rw-r--r--libpthread/sysdeps/generic/bits/thread-attr.h43
-rw-r--r--libpthread/sysdeps/generic/bits/thread-specific.h25
-rw-r--r--libpthread/sysdeps/generic/pt-atfork.c29
-rw-r--r--libpthread/sysdeps/generic/pt-attr-destroy.c27
-rw-r--r--libpthread/sysdeps/generic/pt-attr-getdetachstate.c29
-rw-r--r--libpthread/sysdeps/generic/pt-attr-getguardsize.c29
-rw-r--r--libpthread/sysdeps/generic/pt-attr-getinheritsched.c29
-rw-r--r--libpthread/sysdeps/generic/pt-attr-getschedparam.c31
-rw-r--r--libpthread/sysdeps/generic/pt-attr-getschedpolicy.c29
-rw-r--r--libpthread/sysdeps/generic/pt-attr-getscope.c29
-rw-r--r--libpthread/sysdeps/generic/pt-attr-getstack.c31
-rw-r--r--libpthread/sysdeps/generic/pt-attr-getstackaddr.c29
-rw-r--r--libpthread/sysdeps/generic/pt-attr-getstacksize.c29
-rw-r--r--libpthread/sysdeps/generic/pt-attr-init.c28
-rw-r--r--libpthread/sysdeps/generic/pt-attr-setdetachstate.c38
-rw-r--r--libpthread/sysdeps/generic/pt-attr-setguardsize.c29
-rw-r--r--libpthread/sysdeps/generic/pt-attr-setinheritsched.c38
-rw-r--r--libpthread/sysdeps/generic/pt-attr-setschedparam.c38
-rw-r--r--libpthread/sysdeps/generic/pt-attr-setschedpolicy.c42
-rw-r--r--libpthread/sysdeps/generic/pt-attr-setscope.c41
-rw-r--r--libpthread/sysdeps/generic/pt-attr-setstack.c51
-rw-r--r--libpthread/sysdeps/generic/pt-attr-setstackaddr.c29
-rw-r--r--libpthread/sysdeps/generic/pt-attr-setstacksize.c41
-rw-r--r--libpthread/sysdeps/generic/pt-attr.c41
-rw-r--r--libpthread/sysdeps/generic/pt-barrier-destroy.c27
-rw-r--r--libpthread/sysdeps/generic/pt-barrier-init.c53
-rw-r--r--libpthread/sysdeps/generic/pt-barrier-wait.c61
-rw-r--r--libpthread/sysdeps/generic/pt-barrier.c26
-rw-r--r--libpthread/sysdeps/generic/pt-barrierattr-destroy.c27
-rw-r--r--libpthread/sysdeps/generic/pt-barrierattr-getpshared.c29
-rw-r--r--libpthread/sysdeps/generic/pt-barrierattr-init.c28
-rw-r--r--libpthread/sysdeps/generic/pt-barrierattr-setpshared.c39
-rw-r--r--libpthread/sysdeps/generic/pt-cond-brdcast.c42
-rw-r--r--libpthread/sysdeps/generic/pt-cond-destroy.c27
-rw-r--r--libpthread/sysdeps/generic/pt-cond-init.c45
-rw-r--r--libpthread/sysdeps/generic/pt-cond-signal.c54
-rw-r--r--libpthread/sysdeps/generic/pt-cond-timedwait.c106
-rw-r--r--libpthread/sysdeps/generic/pt-cond-wait.c37
-rw-r--r--libpthread/sysdeps/generic/pt-cond.c29
-rw-r--r--libpthread/sysdeps/generic/pt-condattr-destroy.c27
-rw-r--r--libpthread/sysdeps/generic/pt-condattr-getclock.c31
-rw-r--r--libpthread/sysdeps/generic/pt-condattr-getpshared.c29
-rw-r--r--libpthread/sysdeps/generic/pt-condattr-init.c28
-rw-r--r--libpthread/sysdeps/generic/pt-condattr-setclock.c33
-rw-r--r--libpthread/sysdeps/generic/pt-condattr-setpshared.c39
-rw-r--r--libpthread/sysdeps/generic/pt-destroy-specific.c28
-rw-r--r--libpthread/sysdeps/generic/pt-equal.c29
-rw-r--r--libpthread/sysdeps/generic/pt-getconcurrency.c27
-rw-r--r--libpthread/sysdeps/generic/pt-getcpuclockid.c34
-rw-r--r--libpthread/sysdeps/generic/pt-getschedparam.c28
-rw-r--r--libpthread/sysdeps/generic/pt-getspecific.c27
-rw-r--r--libpthread/sysdeps/generic/pt-init-specific.c27
-rw-r--r--libpthread/sysdeps/generic/pt-key-create.c27
-rw-r--r--libpthread/sysdeps/generic/pt-key-delete.c27
-rw-r--r--libpthread/sysdeps/generic/pt-key.h22
-rw-r--r--libpthread/sysdeps/generic/pt-mutex-destroy.c35
-rw-r--r--libpthread/sysdeps/generic/pt-mutex-getprioceiling.c28
-rw-r--r--libpthread/sysdeps/generic/pt-mutex-init.c48
-rw-r--r--libpthread/sysdeps/generic/pt-mutex-lock.c37
-rw-r--r--libpthread/sysdeps/generic/pt-mutex-setprioceiling.c28
-rw-r--r--libpthread/sysdeps/generic/pt-mutex-timedlock.c173
-rw-r--r--libpthread/sysdeps/generic/pt-mutex-trylock.c104
-rw-r--r--libpthread/sysdeps/generic/pt-mutex-unlock.c104
-rw-r--r--libpthread/sysdeps/generic/pt-mutexattr-destroy.c27
-rw-r--r--libpthread/sysdeps/generic/pt-mutexattr-getprioceiling.c28
-rw-r--r--libpthread/sysdeps/generic/pt-mutexattr-getprotocol.c29
-rw-r--r--libpthread/sysdeps/generic/pt-mutexattr-getpshared.c29
-rw-r--r--libpthread/sysdeps/generic/pt-mutexattr-gettype.c28
-rw-r--r--libpthread/sysdeps/generic/pt-mutexattr-init.c28
-rw-r--r--libpthread/sysdeps/generic/pt-mutexattr-setprioceiling.c28
-rw-r--r--libpthread/sysdeps/generic/pt-mutexattr-setprotocol.c42
-rw-r--r--libpthread/sysdeps/generic/pt-mutexattr-setpshared.c39
-rw-r--r--libpthread/sysdeps/generic/pt-mutexattr-settype.c37
-rw-r--r--libpthread/sysdeps/generic/pt-mutexattr.c29
-rw-r--r--libpthread/sysdeps/generic/pt-once.c43
-rw-r--r--libpthread/sysdeps/generic/pt-rwlock-attr.c26
-rw-r--r--libpthread/sysdeps/generic/pt-rwlock-destroy.c29
-rw-r--r--libpthread/sysdeps/generic/pt-rwlock-init.c45
-rw-r--r--libpthread/sysdeps/generic/pt-rwlock-rdlock.c32
-rw-r--r--libpthread/sysdeps/generic/pt-rwlock-timedrdlock.c113
-rw-r--r--libpthread/sysdeps/generic/pt-rwlock-timedwrlock.c95
-rw-r--r--libpthread/sysdeps/generic/pt-rwlock-tryrdlock.c56
-rw-r--r--libpthread/sysdeps/generic/pt-rwlock-trywrlock.c46
-rw-r--r--libpthread/sysdeps/generic/pt-rwlock-unlock.c90
-rw-r--r--libpthread/sysdeps/generic/pt-rwlock-wrlock.c34
-rw-r--r--libpthread/sysdeps/generic/pt-rwlockattr-destroy.c27
-rw-r--r--libpthread/sysdeps/generic/pt-rwlockattr-getpshared.c29
-rw-r--r--libpthread/sysdeps/generic/pt-rwlockattr-init.c28
-rw-r--r--libpthread/sysdeps/generic/pt-rwlockattr-setpshared.c39
-rw-r--r--libpthread/sysdeps/generic/pt-setconcurrency.c34
-rw-r--r--libpthread/sysdeps/generic/pt-setschedparam.c28
-rw-r--r--libpthread/sysdeps/generic/pt-setschedprio.c27
-rw-r--r--libpthread/sysdeps/generic/pt-setspecific.c27
-rw-r--r--libpthread/sysdeps/generic/sem-close.c32
-rw-r--r--libpthread/sysdeps/generic/sem-destroy.c38
-rw-r--r--libpthread/sysdeps/generic/sem-getvalue.c33
-rw-r--r--libpthread/sysdeps/generic/sem-init.c46
-rw-r--r--libpthread/sysdeps/generic/sem-open.c32
-rw-r--r--libpthread/sysdeps/generic/sem-post.c62
-rw-r--r--libpthread/sysdeps/generic/sem-timedwait.c92
-rw-r--r--libpthread/sysdeps/generic/sem-trywait.c42
-rw-r--r--libpthread/sysdeps/generic/sem-unlink.c32
-rw-r--r--libpthread/sysdeps/generic/sem-wait.c32
-rw-r--r--libpthread/sysdeps/hurd/CVS/Entries9
-rw-r--r--libpthread/sysdeps/hurd/CVS/Repository1
-rw-r--r--libpthread/sysdeps/hurd/CVS/Root1
-rw-r--r--libpthread/sysdeps/hurd/CVS/Tag1
-rw-r--r--libpthread/sysdeps/hurd/pt-destroy-specific.c79
-rw-r--r--libpthread/sysdeps/hurd/pt-getspecific.c37
-rw-r--r--libpthread/sysdeps/hurd/pt-init-specific.c30
-rw-r--r--libpthread/sysdeps/hurd/pt-key-create.c109
-rw-r--r--libpthread/sysdeps/hurd/pt-key-delete.c45
-rw-r--r--libpthread/sysdeps/hurd/pt-key.h76
-rw-r--r--libpthread/sysdeps/hurd/pt-kill.c49
-rw-r--r--libpthread/sysdeps/hurd/pt-setspecific.c43
-rw-r--r--libpthread/sysdeps/i386/CVS/Entries3
-rw-r--r--libpthread/sysdeps/i386/CVS/Repository1
-rw-r--r--libpthread/sysdeps/i386/CVS/Root1
-rw-r--r--libpthread/sysdeps/i386/CVS/Tag1
-rw-r--r--libpthread/sysdeps/i386/bits/CVS/Entries4
-rw-r--r--libpthread/sysdeps/i386/bits/CVS/Repository1
-rw-r--r--libpthread/sysdeps/i386/bits/CVS/Root1
-rw-r--r--libpthread/sysdeps/i386/bits/CVS/Tag1
-rw-r--r--libpthread/sysdeps/i386/bits/atomic.h66
-rw-r--r--libpthread/sysdeps/i386/bits/memory.h40
-rw-r--r--libpthread/sysdeps/i386/bits/spin-lock.h103
-rw-r--r--libpthread/sysdeps/i386/machine-sp.h30
-rw-r--r--libpthread/sysdeps/i386/pt-machdep.h29
-rw-r--r--libpthread/sysdeps/l4/CVS/Entries9
-rw-r--r--libpthread/sysdeps/l4/CVS/Repository1
-rw-r--r--libpthread/sysdeps/l4/CVS/Root1
-rw-r--r--libpthread/sysdeps/l4/CVS/Tag1
-rw-r--r--libpthread/sysdeps/l4/hurd/CVS/Entries3
-rw-r--r--libpthread/sysdeps/l4/hurd/CVS/Repository1
-rw-r--r--libpthread/sysdeps/l4/hurd/CVS/Root1
-rw-r--r--libpthread/sysdeps/l4/hurd/CVS/Tag1
-rw-r--r--libpthread/sysdeps/l4/hurd/i386/CVS/Entries3
-rw-r--r--libpthread/sysdeps/l4/hurd/i386/CVS/Repository1
-rw-r--r--libpthread/sysdeps/l4/hurd/i386/CVS/Root1
-rw-r--r--libpthread/sysdeps/l4/hurd/i386/CVS/Tag1
-rw-r--r--libpthread/sysdeps/l4/hurd/i386/pt-machdep.c20
-rw-r--r--libpthread/sysdeps/l4/hurd/i386/pt-setup.c74
-rw-r--r--libpthread/sysdeps/l4/hurd/pt-sysdep.c58
-rw-r--r--libpthread/sysdeps/l4/hurd/pt-sysdep.h52
-rw-r--r--libpthread/sysdeps/l4/pt-block.c29
-rw-r--r--libpthread/sysdeps/l4/pt-docancel.c51
-rw-r--r--libpthread/sysdeps/l4/pt-stack-alloc.c70
-rw-r--r--libpthread/sysdeps/l4/pt-start.c103
-rw-r--r--libpthread/sysdeps/l4/pt-thread-alloc.c52
-rw-r--r--libpthread/sysdeps/l4/pt-thread-halt.c38
-rw-r--r--libpthread/sysdeps/l4/pt-thread-start.c92
-rw-r--r--libpthread/sysdeps/l4/pt-wakeup.c29
-rw-r--r--libpthread/sysdeps/mach/CVS/Entries11
-rw-r--r--libpthread/sysdeps/mach/CVS/Repository1
-rw-r--r--libpthread/sysdeps/mach/CVS/Root1
-rw-r--r--libpthread/sysdeps/mach/CVS/Tag1
-rw-r--r--libpthread/sysdeps/mach/bits/CVS/Entries2
-rw-r--r--libpthread/sysdeps/mach/bits/CVS/Repository1
-rw-r--r--libpthread/sysdeps/mach/bits/CVS/Root1
-rw-r--r--libpthread/sysdeps/mach/bits/CVS/Tag1
-rw-r--r--libpthread/sysdeps/mach/bits/spin-lock.h97
-rw-r--r--libpthread/sysdeps/mach/hurd/CVS/Entries9
-rw-r--r--libpthread/sysdeps/mach/hurd/CVS/Repository1
-rw-r--r--libpthread/sysdeps/mach/hurd/CVS/Root1
-rw-r--r--libpthread/sysdeps/mach/hurd/CVS/Tag1
-rw-r--r--libpthread/sysdeps/mach/hurd/i386/CVS/Entries3
-rw-r--r--libpthread/sysdeps/mach/hurd/i386/CVS/Repository1
-rw-r--r--libpthread/sysdeps/mach/hurd/i386/CVS/Root1
-rw-r--r--libpthread/sysdeps/mach/hurd/i386/CVS/Tag1
-rw-r--r--libpthread/sysdeps/mach/hurd/i386/pt-machdep.c83
-rw-r--r--libpthread/sysdeps/mach/hurd/i386/pt-setup.c108
-rw-r--r--libpthread/sysdeps/mach/hurd/i386/pt-setup.c.orig105
-rw-r--r--libpthread/sysdeps/mach/hurd/pt-attr-setstackaddr.c35
-rw-r--r--libpthread/sysdeps/mach/hurd/pt-attr-setstacksize.c35
-rw-r--r--libpthread/sysdeps/mach/hurd/pt-docancel.c64
-rw-r--r--libpthread/sysdeps/mach/hurd/pt-sigstate-destroy.c28
-rw-r--r--libpthread/sysdeps/mach/hurd/pt-sigstate-init.c37
-rw-r--r--libpthread/sysdeps/mach/hurd/pt-sigstate.c69
-rw-r--r--libpthread/sysdeps/mach/hurd/pt-sysdep.c72
-rw-r--r--libpthread/sysdeps/mach/hurd/pt-sysdep.h71
-rw-r--r--libpthread/sysdeps/mach/pt-block.c39
-rw-r--r--libpthread/sysdeps/mach/pt-spin.c36
-rw-r--r--libpthread/sysdeps/mach/pt-stack-alloc.c74
-rw-r--r--libpthread/sysdeps/mach/pt-thread-alloc.c101
-rw-r--r--libpthread/sysdeps/mach/pt-thread-dealloc.c41
-rw-r--r--libpthread/sysdeps/mach/pt-thread-halt.c43
-rw-r--r--libpthread/sysdeps/mach/pt-thread-start.c49
-rw-r--r--libpthread/sysdeps/mach/pt-timedblock.c68
-rw-r--r--libpthread/sysdeps/mach/pt-wakeup.c38
-rw-r--r--libpthread/sysdeps/posix/CVS/Entries2
-rw-r--r--libpthread/sysdeps/posix/CVS/Repository1
-rw-r--r--libpthread/sysdeps/posix/CVS/Root1
-rw-r--r--libpthread/sysdeps/posix/CVS/Tag1
-rw-r--r--libpthread/sysdeps/posix/pt-spin.c54
-rw-r--r--libpthread/tests/.cvsignore1
-rw-r--r--libpthread/tests/CVS/Entries19
-rw-r--r--libpthread/tests/CVS/Repository1
-rw-r--r--libpthread/tests/CVS/Root1
-rw-r--r--libpthread/tests/CVS/Tag1
-rw-r--r--libpthread/tests/Makefile29
-rw-r--r--libpthread/tests/test-1.c49
-rw-r--r--libpthread/tests/test-10.c46
-rw-r--r--libpthread/tests/test-11.c143
-rw-r--r--libpthread/tests/test-12.c29
-rw-r--r--libpthread/tests/test-13.c66
-rw-r--r--libpthread/tests/test-14.c44
-rw-r--r--libpthread/tests/test-15.c87
-rw-r--r--libpthread/tests/test-16.c71
-rw-r--r--libpthread/tests/test-2.c39
-rw-r--r--libpthread/tests/test-3.c55
-rw-r--r--libpthread/tests/test-4.c86
-rw-r--r--libpthread/tests/test-5.c75
-rw-r--r--libpthread/tests/test-6.c95
-rw-r--r--libpthread/tests/test-7.c66
-rw-r--r--libpthread/tests/test-8.c60
-rw-r--r--libpthread/tests/test-9.c88
288 files changed, 14458 insertions, 0 deletions
diff --git a/libpthread/.cvsignore b/libpthread/.cvsignore
new file mode 100644
index 00000000..70845e08
--- /dev/null
+++ b/libpthread/.cvsignore
@@ -0,0 +1 @@
+Makefile.in
diff --git a/libpthread/CVS/Entries b/libpthread/CVS/Entries
new file mode 100644
index 00000000..356b84d8
--- /dev/null
+++ b/libpthread/CVS/Entries
@@ -0,0 +1,12 @@
+/.cvsignore/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/ChangeLog/1.39/Fri Jul 18 14:31:06 2008//Tzhengda-soc2008-virt-branch
+/Makefile/1.10/Fri Jul 18 14:31:06 2008//Tzhengda-soc2008-virt-branch
+/TODO/1.3/Sun Jun 24 15:11:51 2007//Tzhengda-soc2008-virt-branch
+/libpthread.a/1.1/Fri Oct 11 23:57:46 2002//Tzhengda-soc2008-virt-branch
+/libpthread_pic.a/1.1/Fri Oct 11 23:57:47 2002//Tzhengda-soc2008-virt-branch
+/lockfile.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/not-in-libc.h/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+D/include////
+D/pthread////
+D/sysdeps////
+D/tests////
diff --git a/libpthread/CVS/Repository b/libpthread/CVS/Repository
new file mode 100644
index 00000000..d231a928
--- /dev/null
+++ b/libpthread/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread
diff --git a/libpthread/CVS/Root b/libpthread/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/CVS/Tag b/libpthread/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/ChangeLog b/libpthread/ChangeLog
new file mode 100644
index 00000000..0cd05f5b
--- /dev/null
+++ b/libpthread/ChangeLog
@@ -0,0 +1,1990 @@
+2008-07-18 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ * Makefile (sysdeps_headers): add pthread/pthreadtypes.h
+
+2008-06-29 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ * sysdeps/generic/pt-mutex-unlock.c (__pthread_mutex_unlock):
+ Do not use assertx and threadid.
+
+2008-06-27 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ * include/pthread/pthread.h: Do not define __need_clockid_t, include
+ <time.h>, and define clockid_t if __clockid_defined is not defined.
+ Include <pthread/pthreadtypes.h>
+ (pthread_equal): New extern inline.
+ (pthread_cleanup_push, pthread_cleanup_pop): New macros.
+ (__pthread_process_shared, __pthread_inheritsched,
+ __pthread_contentionscope, __pthread_detachstate,
+ __pthread_mutex_protocol, __pthread_mutex_type,
+ pthread_attr_t, pthread_mutex_attr_t, pthread_mutex_t,
+ pthread_condattr_t, pthread_cond_t, pthread_spinlock_t,
+ pthread_rwlockattr_t, pthread_rwlock_t, pthread_barrierattr_t,
+ pthread_barrier_t, pthread_key_t, pthread_once_t): Move enums and
+ typedefs to...
+ * include/pthread/pthreadtypes.h: ... new file.
+ * sysdeps/generic/bits/cancelation.h (pthread_cleanup_push): Rename
+ macro to __pthread_cleanup_push.
+ (pthread_cleanup_pop): Rename macro to __pthread_cleanup_pop.
+ * sysdeps/generic/bits/barrier-attr.h (__pthread_process_shared):
+ Forward-declare enum.
+ * sysdeps/generic/bits/condition-attr.h (__pthread_process_shared):
+ Likewise.
+ * sysdeps/generic/bits/mutex-attr.h (__pthread_mutex_protocol,
+ __pthread_process_shared, __pthread_mutex_type):
+ Likewise.
+ * sysdeps/generic/bits/rwlock-attr.h (__pthread_process_shared):
+ Likewise.
+ * sysdeps/generic/bits/thread-attr.h (__pthread_detachstate,
+ __pthread_inheritsched, __pthread_contentionscope):
+ Likewise.
+ * sysdeps/generic/bits/pthread.h (pthread_t): Rename type to
+ __pthread_t.
+ (pthread_equal): Rename to __pthread_equal.
+
+2008-06-27 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ * sysdeps/generic/bits/thread-barrier.h: Remove unused file.
+
+2008-06-22 Neal H. Walfield <neal@gnu.org>
+
+ * sysdeps/generic/pt-mutex-timedlock.c
+ (__pthread_mutex_timedlock_internal) [! NDEBUG]: Set MUTEX->OWNER
+ appropriately and assert that it is consistent.
+ * sysdeps/generic/pt-mutex-unlock.c (__pthread_mutex_unlock) [!
+ NDEBUG]: Set MUTEX->OWNER appropriately and assert that it is
+ consistent.
+ * sysdeps/generic/pt-mutex-trylock.c (__pthread_mutex_trylock) [!
+ NDEBUG]: Set MUTEX->OWNER.
+
+2008-06-07 Neal H. Walfield <neal@gnu.org>
+
+ * pthread/pt-internal.h (__pthread_queue_iterate): Use 1, not
+ true.
+ (__pthread_dequeuing_iterate): Likewise.
+
+2008-05-27 Neal H. Walfield <neal@gnu.org>
+
+ * pthread/pt-internal.h (__pthread_queue_iterate): Before
+ returning the current element, save its next pointer.
+ (__pthread_dequeuing_iterate): Likewise.
+
+2008-05-27 Neal H. Walfield <neal@gnu.org>
+
+ * sysdeps/mach/hurd/pt-docancel.c (__pthread_do_cancel): Fix
+ assert.
+
+2008-05-17 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ * include/pthread/pthread.h (pthread_getattr_np): New declaration.
+ * pthread/pt-getattr.c: New file.
+ * Makefile (SRCS): Add pt-getattr.c.
+
+2008-03-16 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ * include/libc-symbols.h (HAVE_ASM_PREVIOUS_DIRECTIVE): Define.
+
+2008-02-29 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ * sysdeps/l4/hurd/i386/pt-setup.c (stack_setup): Align stack on 0x10
+ for MMX operations.
+ * sysdeps/mach/hurd/i386/pt-setup.c (stack_setup): Likewise.
+
+2008-01-01 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ * include/pthread/pthread.h (pthread_spin_destroy, pthread_spin_init,
+ pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock): Use
+ __extern_inline macro instead of extern __inline.
+ * sysdeps/i386/bits/spin-lock.h (__PT_SPIN_INLINE,
+ __pthread_spin_lock): Likewise
+ * sysdeps/mach/bits/spin-lock.h (__PT_SPIN_INLINE,
+ __pthread_spin_lock): Likewise
+ * sysdeps/generic/bits/pthread.h (pthread_equal): Declare ; only
+ provide inline when __USE_EXTERN_INLINES is defined. Use __extern_inline
+ macro instead of extern __inline.
+ * sysdeps/i386/bits/memory.h (__memory_barrier): Add static to inline.
+
+2007-11-19 Thomas Schwinge <tschwinge@gnu.org>
+
+ * Makefile (CFLAGS): Don't set and instead...
+ (CPPFLAGS): ... append the inclusion stuff to these.
+
+2007-08-02 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ * sysdeps/generic/bits/mutex.h (pthread_mutex_init)
+ (pthread_mutex_destroy, __pthread_mutex_lock, __pthread_mutex_trylock)
+ (pthread_mutex_lock, pthread_mutex_trylock): Remove inline
+ definitions.
+ * sysdeps/generic/bits/rwlock.h (pthread_rwlock_init)
+ (pthread_rwlock_destroy): Likewise.
+
+2007-06-24 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ * include/semaphore.h (sem_timedwait): Declare only if __USE_XOPEN2K
+ is defined.
+ * include/pthread/pthread.h (pthread_attr_getstack)
+ (pthread_attr_setstack, pthread_mutex_timedlock)
+ (pthread_condattr_getclock, pthread_condattr_setclock)
+ (pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock)
+ (pthread_barrierattr_t, pthread_barrierattr_init)
+ (pthread_barrierattr_destroy, pthread_barrierattr_getpshared)
+ (pthread_barrierattr_setpshared, pthread_barrier_t)
+ (PTHREAD_BARRIER_SERIAL_THREAD, pthread_barrier_init)
+ (pthread_barrier_destroy, pthread_barrier_wait)
+ (pthread_getcpuclockid): Declare only if __USE_XOPEN2K is defined.
+ (pthread_mutexattr_getprioceiling, pthread_mutexattr_setprioceiling)
+ (pthread_mutexattr_getprotocol, pthread_mutexattr_setprotocol)
+ (pthread_mutexattr_gettype, pthread_mutexattr_settype)
+ (pthread_mutex_getprioceiling, pthread_mutex_setprioceiling)
+ (pthread_setconcurrency, pthread_getconcurrency): Declare only if
+ __USE_UNIX98 is defined.
+ (pthread_rwlockattr_t, pthread_rwlockattr_init)
+ (pthread_rwlockattr_destroy, pthread_rwlockattr_getpshared)
+ (pthread_rwlockattr_setpshared, pthread_rwlock_t, pthread_rwlock_init)
+ (pthread_rwlock_destroy, pthread_rwlock_rdlock)
+ (pthread_rwlock_tryrdlock, pthread_rwlock_wrlock)
+ (pthread_rwlock_trywrlock, pthread_rwlock_unlock): Declare only if
+ __USE_UNIX98 or __USE_XOPEN2K are defined.
+ (PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, PTHREAD_PRIO_PROTECT)
+ (PTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_ERRORCHECK)
+ (PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_DEFAULT):
+ Define only if __USE_UNIX98 is defined.
+ (PTHREAD_MUTEX_FAST_NP): Define for compatibility when __USE_GNU is
+ defined.
+ * sysdeps/generic/bits/rwlock.h (pthread_rwlock_init)
+ (pthread_rwlock_destroy): Declare only if __USE_UNIX98 or
+ __USE_XOPEN2K are defined.
+ * TODO: Drop that TODO item.
+
+2006-03-04 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ * sysdeps/i386/machine-sp.h (thread_stack_pointer):
+ Optimize esp read.
+ * include/pthread/pthread.h: Add the restrict keyword where
+ appropriate for full compliance.
+ * pthread/pt-internal.h: Likewise.
+ * sysdeps/generic/bits/mutex.h: Likewise.
+ * sysdeps/generic/bits/rwlock.h: Likewise.
+ * TODO: Drop that TODO item.
+
+2006-01-20 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ Do not let other libraries (like libX11) override libpthread's
+ pthread_mutex_*, pthread_rwlock_* and sem_* dynamic symbols.
+ * sysdeps/generic/pt-mutex-destroy.c
+ (pthread_mutex_destroy): Make the alias strong.
+ * sysdeps/generic/pt-mutex-init.c
+ (pthread_mutex_init): Likewise.
+ * sysdeps/generic/pt-mutex-lock.c
+ (_pthread_mutex_lock, pthread_mutex_lock): Likewise.
+ * sysdeps/generic/pt-mutex-trylock.c
+ (_pthread_mutex_trylock, pthread_mutex_trylock): Likewise.
+ * sysdeps/generic/pt-mutex-unlock.c
+ (_pthread_mutex_lock, pthread_mutex_unlock): Likewise.
+ * sysdeps/generic/pt-rwlock-destroy.c
+ (pthread_rwlock_destroy): Likewise.
+ * sysdeps/generic/pt-rwlock-init.c
+ (pthread_rwlock_init): Likewise.
+ * sysdeps/generic/sem-destroy.c (sem_destroy): Likewise.
+ * sysdeps/generic/sem-getvalue.c (sem_getvalue): Likewise.
+ * sysdeps/generic/sem-init.c (sem_init): Likewise.
+ * sysdeps/generic/sem-open.c (sem_open): Likewise.
+ * sysdeps/generic/sem-post.c (sem_post): Likewise.
+ * sysdeps/generic/sem-timedwait.c (sem_timedwait): Likewise.
+ * sysdeps/generic/sem-trywait.c (sem_trywait): Likewise.
+ * sysdeps/generic/sem-unlink.c (sem_unlink): Likewise.
+ * sysdeps/generic/sem-wait.c (sem_wait): Likewise.
+
+2006-03-27 Thomas Schwinge <tschwinge@gnu.org>
+
+ * Makefile (SRCS): Don't define two times and only list `pt-attr.c'
+ once. Reported by Jeff Bailey <jbailey@gnu.org>.
+
+2005-08-28 Neal H. Walfield <neal@gnu.org>
+
+ * include/semaphore.h: Use __restrict, not restrict.
+
+2005-05-31 Neal H. Walfield <neal@gnu.org>
+
+ * include/pthread/pthread.h: If clockid_t is still not defined
+ after including <time.h>, define it manually.
+
+2005-05-17 Neal H. Walfield <neal@gnu.org>
+
+ * include/pthread/pthread.h: Define __need_clockid_t before
+ including <time.h>.
+
+2005-05-12 Neal H. Walfield <neal@gnu.org>
+
+ * include/pthread/pthread.h (pthread_exit): Add noreturn
+ attribute.
+
+ * sysdeps/generic/bits/condition.h (__PTHREAD_COND_INITIALIZER):
+ Don't create a compound literal.
+ * sysdeps/generic/bits/mutex.h (__PTHREAD_MUTEX_INITIALIZER):
+ Don't create a compound literal.
+ (pthread_mutex_init): Don't assign to *__MUTEX directly.
+ Initialize an intermediate local variable and then copy the
+ result.
+ * sysdeps/generic/bits/rwlock.h (__PTHREAD_RWLOCK_INITIALIZER):
+ Don't create a compound literal.
+ (pthread_rwlock_init): Don't assign to *__RWLOCK directly.
+ Initialize an intermediate local variable and then copy the
+ result.
+ * sysdeps/i386/bits/spin-lock.h (__SPIN_LOCK_INITIALIZER):
+ Don't create a compound literal.
+
+ * pthread/pt-alloc.c (initialize_pthread): Cast
+ PTHREAD_MUTEX_INITIALIZER and PTHREAD_COND_INITIALIZER to create a
+ compound literal.
+ * tests/test-1.c (main): Use pthread_mutex_init, not
+ PTHREAD_MUTEX_INIT for mutex initialization
+
+ * sysdeps/generic/pt-barrier-init.c (pthread_barrier_init): Remove
+ assert. Copy ATTR if non-defaults are used.
+ * sysdeps/generic/pt-cond-init.c (pthread_cond_init): Include
+ <string.h>. Remove assert. Copy ATTR if non-defaults are used.
+ * sysdeps/generic/pt-mutex-init.c (_pthread_mutex_init): Cast
+ PTHREAD_MUTEX_INITIALIZER to create a compound literal.
+ * sysdeps/generic/pt-rwlock-init.c: Include <string.h>.
+ (_pthread_rwlock_init): Cast __PTHREAD_RWLOCK_INITIALIZER to
+ create a compound literal. Copy ATTR if non-defaults are used.
+
+ * sysdeps/generic/pt-cond-timedwait.c
+ (__pthread_cond_timedwait_internal): Check that ABSTIME->TV_NSEC
+ is valid. Don't shadow ERR. Don't return before cleaning up.
+ * sysdeps/generic/pt-mutex-timedlock.c (pthread_mutex_timedlock):
+ Move after __pthread_mutex_timedlock_internal. Check that
+ ABSTIME->TV_NSEC is valid.
+ * sysdeps/generic/pt-rwlock-timedrdlock.c
+ (pthread_rwlock_timedrdlock): Move after.
+ __pthread_rwlock_timedrdlock_internal.
+ (__pthread_rwlock_timedrdlock_internal): Check that
+ ABSTIME->TV_NSEC is valid.
+ * sysdeps/generic/pt-rwlock-timedwrlock.c
+ (pthread_rwlock_timedwrlock): Move after
+ __pthread_rwlock_timedwrlock_internal.
+ (__pthread_rwlock_timedwrlock_internal): Check that
+ ABSTIME->TV_NSEC is valid.
+ * sysdeps/generic/sem-timedwait.c (__sem_timedwait_internal):
+ Check that TIMEOUT->TV_NSEC is valid before enqueuing the thread.
+
+ * sysdeps/generic/pt-rwlock-rdlock.c
+ (__pthread_rwlock_timedrdlock_internal): Fix declaration.
+
+ * sysdeps/generic/pt-mutex-trylock.c (__pthread_mutex_trylock):
+ Don't return EDEADLK. POSIX does not allow it.
+
+ * sysdeps/mach/pt-timedblock.c (__pthread_timedblock): Calculate
+ the relative timeout without overflowing.
+
+ * sysdeps/mach/hurd/i386/pt-setup.c (stack_setup): Cast THREAD.
+
+2005-05-12 Neal H. Walfield <neal@gnu.org>
+
+ * Makefile (SRCS): Add sem-close.c, sem-destroy.c, sem-getvalue.c,
+ sem-init.c, sem-open.c, sem-post.c, sem-timedwait.c, sem-trywait.c,
+ sem-unlink.c and sem-wait.c.
+ (sysdeps_headers): Add semaphore.h and bits/semaphore.h.
+ * include/semaphore.h: New file.
+ * sysdeps/generic/sem-close.c: New file.
+ * sysdeps/generic/sem-destroy.c: New file.
+ * sysdeps/generic/sem-getvalue.c: New file.
+ * sysdeps/generic/sem-init.c: New file.
+ * sysdeps/generic/sem-open.c: New file.
+ * sysdeps/generic/sem-post.c: New file.
+ * sysdeps/generic/sem-timedwait.c: New file.
+ * sysdeps/generic/sem-trywait.c: New file.
+ * sysdeps/generic/sem-unlink.c: New file.
+ * sysdeps/generic/sem-wait.c: New file.
+ * sysdeps/generic/bits/semaphore.h: New file.
+
+2005-05-04 Neal H. Walfield <neal@gnu.org>
+
+ * Makefile (SRCS): Add pt-thread_dealloc.c.
+ * sysdeps/mach/pt-thread-dealloc.c: New file.
+ * pthread/pt-internal.h (__pthread_thread_dealloc): New
+ declaration.
+ (__pthread_thread_halt): Add parameter NEED_DEALLOC. Update
+ callers.
+ * sysdeps/mach/pt-thread-halt.c (__pthread_thread_halt): Respect
+ new NEED_DEALLOC parameter. Move code which deallocates kernel
+ resources from here ...
+ * sysdeps/mach/pt-thread-dealloc.c (__pthread_thread_dealloc):
+ ...to here.
+ * pthread/pt-create.c (__pthread_create_internal): Call
+ __pthread_thread_dealloc on failure.
+ * pthread/pt-exit.c (pthread_exit): Call __pthread_thread_dealloc.
+
+ * sysdeps/mach/pt-thread-alloc.c (create_wakeupmsg): Call
+ __mach_port_destroy to deallocate the receive right.
+ __mach_port_deallocate won't do it.
+
+ * pthread/pt-detach.c (pthread_detach): Don't call
+ __pthread_thread_halt a second time.
+
+ * sysdeps/mach/hurd/pt-sysdep.c (_cthread_init_routine): Fix
+ declaration.
+ (init_routine): Update declaration and remove gratuitous cast.
+
+2005-05-02 Neal H. Walfield <neal@gnu.org>
+
+ * pthread/pt-alloc.c (__pthread_alloc): Set the thread id to the
+ table index plus one.
+ * pthread/pt-internal.h (__pthread_getid): Index __pthread_threads
+ using THREAD - 1, not THREAD.
+ (__pthread_setid): Likewise.
+ * pthread/pt-create.c (__pthread_create_internal): Likewise.
+
+ * sysdeps/generic/pt-mutex-trylock.c (__pthread_mutex_trylock):
+ When returning EBUSY, don't forget to first unlock MUTEX->__HELD.
+
+2005-04-20 Neal H. Walfield <neal@gnu.org>
+
+ * sysdeps/generic/pt-setschedparam.c: policy's type is int, not
+ int *.
+ * include/pthread/pthread.h: Likewise.
+ Reported by Christopher `Physicman' Bodenstein <cb@physicman.net>.
+
+2005-01-21 Michael Banck <mbanck@debian.org>
+
+ * Makefile ($(libdir)/libpthread2.a): Install linker script
+ from $(srcdir) instead of current directory.
+ ($(libdir)/libpthread2_pic.a): Likewise.
+
+2005-02-08 Neal H. Walfield <neal@gnu.org>
+
+ * sysdeps/mach/pt-spin.c (__pthread_spin_lock): Make a weak alias
+ to _pthread_spin_lock.
+ * sysdeps/posix/pt-spin.c (__pthread_spin_lock): Likewise.
+
+2005-01-18 Neal H. Walfield <neal@gnu.org>
+
+ * sysdeps/mach/hurd/pt-sysdep.h (__pthread_stack_dealloc): Add
+ __always_inline__ attribute.
+ * sysdeps/l4/hurd/pt-sysdep.h (_pthread_self): Likewise.
+ (__pthread_stack_dealloc): Likewise.
+
+2005-01-12 Pietro Ferrari <pietro@bastardi.net>
+
+ * include/pthread/pthread.h (pthread_spin_destroy): Replace extern
+ inline with extern __inline.
+ (pthread_spin_init): Likewise.
+ (pthread_spin_lock): Likewise.
+ (pthread_spin_trylock): Likewise.
+ (pthread_spin_unlock): Likewise.
+ * sysdeps/mach/bits/spin-lock.h (__pthread_spin_lock): Likewise.
+ * sysdeps/i386/bits/spin-lock.h (__pthread_spin_lock): Likewise.
+ * sysdeps/generic/bits/mutex.h (__pthread_mutex_trylock):
+ Likewise.
+ (pthread_mutex_lock): Likewise.
+ (pthread_mutex_trylock): Likewise.
+ * sysdeps/generic/bits/pthread.h (pthread_equal): Likewise.
+
+2003-08-17 Marcus Brinkmann <marcus@gnu.org>
+
+ * sysdeps/hurd/pt-key.h (PTHREAD_KEY_MEMBERS): Change type of
+ THREAD_SPECIFICS to hurd_ihash_t.
+ * sysdeps/hurd/pt-setspecific.c (pthread_setspecific): Call
+ hurd_ihash_create instead ihash_create, and hurd_ihash_add instead
+ ihash_add.
+ * sysdeps/hurd/pt-getspecific.c (pthread_getspecific): Call
+ hurd_ihash_find instead of ihash_find.
+ * sysdeps/hurd/pt-destroy-specific.c (__pthread_destroy_specific):
+ Call hurd_ihash_find instead of ihash_find, hurd_ihash_remove
+ instead of ihash_remove, and hurd_ihash_free instead of
+ ihash_free.
+
+2003-08-03 Marco Gerards <metgerards@student.han.nl>
+
+ * Makefile (install): Do not install from $(srcdir).
+
+2002-11-26 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-create.c [HAVE_USELOCAL]: Include <locale.h>.
+ (entry_point) [HAVE_USELOCALE]: Initialize the thread to the
+ global locale.
+
+2002-11-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/mach/hurd/i386/pt-setup.c (__pthread_setup): Fix last
+ change.
+
+2002-11-18 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/mach/pt-wakeup.c (__pthread_wakeup): Use the size of
+ THREAD->wakeupmsg which may not be a mach_msg_header_t.
+
+ * sysdeps/generic/pt-mutex-timedlock.c
+ (__pthread_mutex_timedlock_internal): Really test for equality.
+ * sysdeps/generic/pt-rwlock-timedrdlock.c
+ (__pthread_rwlock_timedrdlock_internal): Likewise.
+ * sysdeps/generic/pt-rwlock-timedwrlock.c
+ (__pthread_rwlock_timedwrlock_internal): Likewise.
+
+ * sysdeps/generic/pt-cond-timedwait.c
+ (__pthread_cond_timedwait_internal): On timeout, remove our thread
+ structure from the wait queue if necessary.
+
+ * sysdeps/l4/pt-start.c (__pthread_start): Call L4_Myself, not
+ __mach_thread_self.
+
+ * sysdeps/mach/hurd/i386/pt-setup.c: Include <mach.h>.
+ (__pthread_setup): Do not leak references from __mach_thread_self.
+ * sysdeps/mach/hurd/pt-docancel.c (__pthread_do_cancel): Likewise.
+ * sysdeps/mach/hurd/pt-sysdep.h (_pthread_self): Likewise.
+ * sysdeps/mach/pt-thread-alloc.c (__pthread_thread_alloc): Likewise.
+ * sysdeps/mach/pt-thread-start.c (__pthread_thread_start): Likewise.
+
+ * sysdeps/mach/pt-start.c: Remove dead file.
+
+2002-11-09 Roland McGrath <roland@frob.com>
+
+ * include/pthread/pthread.h: Avoid `__thread' as an identifier,
+ since it might be a keyword.
+
+2002-11-02 Alfred M. Szmidt <ams@kemisten.nu>
+
+ * sysdeps/generic/pt-key-delete.c, sysdeps/hurd/pt-key-delete.c
+ (pthread_key_delete): Renamed from pthread_key_destroy.
+ Reported by Michael Koch <konqueror@gmx.de>
+
+2002-10-12 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/hurd/pt-destroy-specific.c (__pthread_destroy_specific):
+ Only call the destructor if there is one set.
+
+2002-10-10 Neal H. Walfield <neal@cs.uml.edu>
+
+ * libpthread.a: It is _cthread_init_routine, not _cthread_init.
+ Add -lihash.
+ * libpthread_pic.a: Likewise but add -lihash_pic.
+
+ * tests/Makefile (%-static): New rule.
+ (CHECK_PROGS): Build static test programs.
+
+2002-10-10 Neal H. Walfield <neal@cs.uml.edu>
+
+ * Makefile (install): Add $(libdir)/libpthread2.a and
+ $(libdir)/libpthread2_pic.a.
+ (.PHONY): Likewise.
+ ($(libdir)/libpthread2.a): New rule.
+ ($(libdir)/libpthread2_pic.a): Likewise.
+
+ * libpthread_pic.a: New file.
+ * libpthread.a: New file.
+
+2002-10-10 Neal H. Walfield <neal@cs.uml.edu>
+
+ * Makefile (SRCS): Remove pt-errno.c.
+ * sysdeps/mach/hurd/pt-errno.c: Removed.
+ * sysdeps/l4/hurd/pt-errno.c: Removed.
+
+2002-10-10 Neal H. Walfield <neal@cs.uml.edu>
+
+ * include/lock-intern.h: Removed. Use the one provided by glibc.
+ * Makefile (sysdeps_headers): Remove lock-intern.h.
+
+2002-10-10 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/mach/hurd/i386/pt-setup.c (stack_setup): Save the thread
+ pointer using the __hurd_threadvar routines; not a the top of the
+ stack.
+ * sysdeps/mach/hurd/pt-sysdep.h (_HURD_THREADVAR_THREAD): New
+ marcro.
+ (_pthread_self): Use __hurd_threadvar_location to access the self
+ pointer.
+ * sysdeps/mach/hurd/pt-sysdep.c (init_routine): Likewise. Update
+ the calculation of __hurd_threadvar_stack_offset.
+
+2002-10-10 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-alloc.c (alloc_init): Removed.
+ (__pthread_alloc): Allocate __pthread_threads lazily.
+
+ * sysdeps/hurd/pt-getspecific.c (pthread_getspecific): Add an
+ assert.
+
+2002-09-28 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/pt-cond-timedwait.c
+ (__pthread_cond_timedwait_internal): Add definition.
+ * sysdeps/generic/pt-rwlock-rdlock.c
+ (__pthread_rwlock_timedrdlock_internal): Define this ...
+ (__pthread_mutex_timedlock_internal): ... not this.
+ * sysdeps/generic/pt-rwlock-wrlock.c
+ (__pthread_rwlock_timedwrlock_internal): Add an extern.
+
+2002-09-28 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/mach/hurd/pt-sysdep.h (_pthread_self): Assert that
+ __pthread_threads is initialized.
+
+ (__pthread_self): Beautify.
+
+2002-09-28 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/mach/hurd/pt-sysdep.c (init_routine): Only call
+ __pthread_initialize once.
+
+2002-09-28 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/pt-cond-init.c (pthread_cond_init): Only assert
+ that ATTR->pshared is PTHREAD_PROCESS_PRIVATE if ATTR is not NULL.
+ Reported by Manuel Menal <mmenal@netcourrier.com>.
+
+2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/bits/mutex.h (__PTHREAD_MUTEX_INITIALIZER):
+ Initialize the LOCKS member of struct __pthread_mutex to 0, not
+ NULL.
+
+2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/bits/mutex.h (struct __pthread_mutex): New
+ field, cthreadcompat1: cthreads does not initialize the third
+ field of a mutex and as a result, neither does glibc. Avoid
+ this pit.
+ (__PTHREAD_MUTEX_INITIALIZER): Initialize cthreadcompat1 to 0.
+
+2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
+
+ * Makefile ($(addprefix $(includedir)/, $(sysdeps_headers))): Do
+ not prepend ${srcdir}.
+
+2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-internal.h (__pthread_enqueue): New function.
+ (__pthread_dequeue): New function.
+ (__pthread_queue_iterate): New macro.
+ (__pthread_dequeuing_iterate): New macro.
+
+ * sysdeps/generic/pt-barrier-wait.c (pthread_barrier_wait): Use
+ the new convenience functions.
+ * sysdeps/generic/pt-cond-brdcast.c (pthread_cond_broadcast):
+ Likewise.
+ * sysdeps/generic/pt-cond-signal.c (cond_signal): Likewise.
+ * sysdeps/generic/pt-cond-timedwait.c
+ (__pthread_cond_timedwait_internal): Likewise.
+ * sysdeps/generic/pt-mutex-timedlock.c
+ (__pthread_mutex_timedlock_internal): Likewise.
+ * sysdeps/generic/pt-mutex-unlock.c (__pthread_mutex_unlock):
+ Likewise.
+ * sysdeps/generic/pt-rwlock-timedrdlock.c
+ (__pthread_rwlock_timedrdlock_internal): Likewise.
+ * sysdeps/generic/pt-rwlock-timedwrlock.c
+ (__pthread_rwlock_timedwrlock_internal): Likewise.
+ * sysdeps/generic/pt-rwlock-unlock.c (pthread_rwlock_unlock):
+ Likewise.
+
+ * pthread/pt-alloc.c (initialize_pthread): Initialize the next and
+ prevp pointers to 0.
+
+2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
+
+ * tests/Makefile (CFLAGS): New variable.
+
+2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/pt-mutex-timedlock.c (pthread_mutex_timedlock):
+ Call __pthread_mutex_timedlock_internal, not
+ pthread_mutex_timedlock.
+
+2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-internal.h (__pthread_rwlock_unlock): Remove obsolete
+ definition.
+ * pthread/pt-alloc.c (__pthread_alloc): Use pthread_rwlock_wrlock
+ and pthread_rwlock_unlock, not __pthread_rwlock_wrlock and
+ __pthread_rwlock_unlock.
+ * pthread/pt-create.c (__pthread_create_internal): Use
+ pthread_rwlock_rdlock and pthread_rwlock_unlock, not
+ __pthread_rwlock_rdlock and __pthread_rwlock_unlock.
+ * sysdeps/generic/pt-cond-timedwait.c (pthread_cond_timedwait):
+ Call __pthread_cond_timedwait_internal, not
+ __pthread_cond_timedwait.
+
+2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-internal.h (__pthread_mutex_timedlock): Remove
+ definition.
+ (__pthread_rwlock_timedrdlock): Likewise.
+ (__pthread_rwlock_timedwrlock): Likewise.
+ (__pthread_cond_timedwait): Likewise.
+ * include/pthread/pthread.h (pthread_mutex_timedlock): Remove
+ verbage about GNU extension.
+ (pthread_cond_timedwait): Likewise.
+ (pthread_rwlock_timedrdlock): Likewise.
+ (pthread_rwlock_timedwrlock): Likewise.
+
+ * sysdeps/generic/pt-rwlock-timedrdlock.c
+ (__pthread_rwlock_timedrdlock_internal): Renamed from
+ __pthread_rwlock_timedrdlock.
+ (pthread_rwlock_timedrdlock): New function. Remove weak alias.
+ * sysdeps/generic/pt-rwlock-rdlock.c
+ (__pthread_mutex_timedlock_internal): New definition.
+ (pthread_rwlock_rdlock): Renamed from __pthread_rwlock_rdlock.
+ Use __pthread_rwlock_timedlock_internal. Remove weak alias.
+
+ * sysdeps/generic/pt-cond-timedwait.c
+ (__pthread_cond_timedwait_internal): Rename from
+ __pthread_cond_timedwait. Remove weak aliases.
+ (pthread_cond_timedwait): New function.
+ * sysdeps/generic/pt-cond-wait.c
+ (__pthread_cond_timedwait_internal): New definition.
+ (pthread_cond_wait): Use it.
+
+ * sysdeps/generic/pt-mutex-timedlock.c
+ (__pthread_mutex_timedlock_internal): Rename from
+ __pthread_mutex_timedlock. Remove weak alias.
+ (pthread_mutex_timedlock): New function.
+ * sysdeps/generic/pt-mutex-lock.c
+ (__pthread_mutex_timedlock_internal): New definition.
+ (__pthread_mutex_lock): Use it.
+
+ * sysdeps/generic/pt-rwlock-timedwrlock.c
+ (__pthread_rwlock_timedwrlock_internal): Rename from
+ __pthread_rwlock_timedwrlock.
+ (pthread_rwlock_timedwrlock): New function. Remove weak alias.
+ * sysdeps/generic/pt-rwlock-wrlock.c
+ (__pthread_mutex_timedlock_internal): New definition.
+ (pthread_rwlock_wrlock): Renamed from __pthread_rwlock_wrlock.
+ Use __pthread_rwlock_timedlock_internal. Remove weak alias.
+
+ * sysdeps/generic/pt-rwlock-tryrdlock.c
+ (pthread_rwlock_tryrdlock): Rename from
+ __pthread_rwlock_tryrdlock. Remove weak alias.
+ * sysdeps/generic/pt-rwlock-trywrlock.c
+ (pthread_rwlock_trywrlock): Rename from
+ __pthread_rwlock_trywrlock. Remove weak alias.
+
+ * sysdeps/hurd/pt-kill.c (pthread_kill): Rename from
+ __pthread_kill. Remove weak alias.
+ * sysdeps/generic/pt-atfork.c (pthread_atfork): Rename from
+ __pthread_atfork. Remove weak alias.
+
+2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-internal.h (__pthread_create_internal): Renamed from
+ __pthread_create. Updated all callers. Suggested by Roland
+ McGrath.
+
+2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
+
+ * Makefile: New file.
+ * tests/Makefile: New file.
+
+2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/bits/barrier.h: Include <bits/spin-lock.h>.
+ (struct __pthread_barrier): Change lock to a __pthread_spinlock_t:
+ pthread_spinlock_t may not be defined in this context.
+
+2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/bits/once.h (__PTHREAD_ONCE_INIT): Be standards
+ compliant: do not cast the result.
+
+2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-join.c (pthread_join): Fix typo in previous change.
+
+2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/bits/barrier.h (struct __pthread_barrier): Add
+ new members attr and data.
+ * sysdeps/generic/pt-barrier-init.c: Inlucde <string.h>.
+ (pthread_barrier_init): Set *BARRIER to zero.
+
+ * sysdeps/generic/bits/condition.h (__PTHREAD_COND_INITIALIZER):
+ Initialize all fields.
+
+ * sysdeps/generic/bits/mutex.h (__pthread_mutex): Rename
+ cthread_compat1 to data.
+ (pthread_mutex_destroy): Avoid
+ inline version if __MUTEX->data is not NULL.
+ (__pthread_mutex_lock): Likewise.
+ (__pthread_mutex_trylock): Likewise.
+
+ * sysdeps/generic/bits/rwlock.h: New member __attr.
+ (__PTHREAD_RWLOCK_INITIALIZER): Initialize it to zero.
+ (pthread_rwlock_destroy): Avoid inline version if __RWLOCK->__data
+ is not NULL.
+
+2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-join.c (pthread_join): Protect PTHREAD->state_lock
+ inconsistency due to cancelation.
+
+2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/bits/pthread.h (pthread_equal): Change from
+ static inline to extern inline.
+ * sysdeps/generic/pt-equal.c: New file.
+ * Makefile.am (libpthread_a_SOURCES): Add pt-equal.c.
+
+2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
+
+ * include/pthread/pthread.h (pthread_mutex_getprioceiling): New
+ definition.
+ (pthread_mutex_setprioceiling): New definition.
+ (pthread_getschedparam): New definition.
+ (pthread_setschedparam): New definition.
+ (pthread_setschedprio): New definition.
+
+ * sysdeps/generic/pt-getschedparam.c: New file.
+ * sysdeps/generic/pt-mutex-getprioceiling.c: New file.
+ * sysdeps/generic/pt-mutex-setprioceiling.c: New file.
+ * sysdeps/generic/pt-setschedparam.c: New file.
+ * sysdeps/generic/pt-setschedprio.c: New file.
+ * Makefile.am (libpthread_a_SOURCES): Add pt-getschedparam.c,
+ pt-mutex-getprioceiling.c, pt-mutex-setprioceiling.c,
+ pt-setschedparam.c and pt-setschedprio.c.
+
+2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/Makefile.glibc: Removed.
+ * pthread/pthread.patch: Removed.
+
+2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
+
+ * include/pthread/pthread.h (pthread_getcpuclockid): New
+ definition.
+ * sysdeps/generic/pt-getcpuclockid.c: New file.
+ * Makefile.am (libpthread_a_SOURCES): Add pt-getcpuclockid.c.
+
+2002-09-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * include/pthread/pthread.h (pthread_kill): New definition.
+ * sysdeps/hurd/pt-kill.c (__pthread_kill): New file.
+ * Makefile.am (libpthread_a_SOURCES): Add pt-kill.c.
+
+ * tests/Makefile.am (check_PROGRAMS): Add test-16.
+ (TEST_COUNT): Bump to 16.
+ (MOSTLYCLEANFILES): Add test-16.out.
+ (test_16_SOURCES): New variable.
+
+ * tests/test-16.c: New file.
+
+2002-09-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/pt-attr.c: Include <sched.h>.
+
+2002-09-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * tests/Makefile.am (check_PROGRAMS): Remove test-5.
+ Unintentionally checked in.
+
+2002-09-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * include/pthread/pthread.h (pthread_atfork): New definition.
+ * sysdeps/generic/pt-atfork.c: New file.
+
+ * Makefile.am (libpthread_a_SOURCES): Add pt-atfork.c.
+
+2002-09-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-internal.h (__pthread_rwlock_rdlock): New definition.
+ (__pthread_rwlock_timedrdlock): New definition.
+ (__pthread_rwlock_wrlock): New definition.
+ (__pthread_rwlock_timedwrlock): New definition.
+ (__pthread_rwlock_unlock): New definition.
+
+2002-09-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-internal.h (__pthread_timedblock): New definition.
+ * sysdeps/mach/pt-timedblock.c: New file.
+
+ * include/pthread/pthread.h (pthread_mutex_timedlock): New
+ definition.
+ (pthread_cond_timedwait): Enable unconditionally.
+ (pthread_rwlock_timedrdlock): New definition.
+ (pthread_rwlock_timedwrlock): New definition.
+
+ * sysdeps/generic/pt-mutex-timedlock.c: New file.
+ * sysdeps/generic/pt-mutex-lock.c (__pthread_mutex_lock):
+ Reimplement in terms of __pthread_mutex_timedlock.
+
+ * sysdeps/generic/pt-cond-timedwait.c: New file.
+ * sysdeps/generic/pt-cond-wait.c (pthread_cond_wait): Reimplement
+ in terms of pthread_cond_timedwait.
+
+ * sysdeps/generic/pt-rwlock-timedrdlock.c: New file.
+ * sysdeps/generic/pt-rwlock-rdlock.c
+ (__pthread_rwlock_rdlock): Reimplement in terms of
+ __pthread_rwlock_timedrdlock.
+
+ * sysdeps/generic/pt-rwlock-timedwrlock.c: New file.
+ * sysdeps/generic/pt-rwlock-wrlock.c (__pthread_rwlock_wrlock):
+ Reimplement in terms of __pthread_rwlock_timedwrlock.
+
+ * sysdeps/generic/pt-cond-signal.c (cond_signal): Clear the
+ previous pointer of the thread which we decide to wake up.
+
+ * Makefile.am (libpthread_a_SOURCES): Add pt-mutex-lock.c,
+ pt-mutex-trylock.c, pt-mutex-timedlock.c, pt-rwlock-timedrdlock.c,
+ pt-rwlock-timedwrlock.c, pt-cond-timedwait.c and pt-timedblock.c.
+
+ * tests/Makefile.am (check_PROGRAMS): Add test-13, test-14 and
+ test-15.
+ (TEST_COUNT): Bump to 15.
+ (MOSTLYCLEANFILES): Add test-13.out, test-14.out and test-15.out.
+ (test_13_SOURCES): New variable.
+ (test_14_SOURCES): New variable.
+ (test_15_SOURCES): New variable.
+ * tests/test-13.c: New file.
+ * tests/test-14.c: New file.
+ * tests/test-15.c: New file.
+
+2002-09-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * include/pthread/pthread.h: Include <bits/condition-attr.h>
+ (pthread_condattr_t): New type.
+ (pthread_condattr_init): New definition.
+ (pthread_condattr_destroy): New definition.
+ (pthread_condattr_getclock): New definition.
+ (pthread_condattr_setclock): New definition.
+ (pthread_condattr_getpshared): New definition.
+ (pthread_condattr_setpshared): New definition.
+ (pthread_cond_init): New definition.
+ (pthread_cond_destroy): New definition.
+ * pthread/pt-internal.h (__pthread_default_condattr): New
+ definition.
+
+ * sysdeps/generic/pt-cond-destroy.c: New file.
+ * sysdeps/generic/pt-cond-init.c: New file.
+ * sysdeps/generic/pt-cond.c: New file.
+ * sysdeps/generic/pt-condattr-destroy.c: New file.
+ * sysdeps/generic/pt-condattr-getclock.c: New file.
+ * sysdeps/generic/pt-condattr-getpshared.c: New file.
+ * sysdeps/generic/pt-condattr-init.c: New file.
+ * sysdeps/generic/pt-condattr-setclock.c: New file.
+ * sysdeps/generic/pt-condattr-setpshared.c: New file.
+ * sysdeps/generic/bits/condition-attr.h: New file.
+ * Makefile.am (libpthread_a_SOURCES): Add pt-cond.c,
+ pt-condattr-init.c, pt-condattr-destroy.c, pt-condattr-getclock.c,
+ pt-condattr-getpshared.c, pt-condattr-setclock.c,
+ pt-condattr-setpshared.c, pt-cond-destroy.c and pt-cond-init.c.
+ * headers.m4 (hurd_SYSDEPS): Add bits/condition-attr.h.
+
+2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/pt-cond-wait.c (pthread_cond_wait): If canceled,
+ be sure to disconnect ourself from the waiters' queue.
+
+2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/mach/hurd/pt-docancel.c (__pthread_do_cancel): Before
+ overwriting the thread's state, abort any system call in progress.
+
+2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/pt-cond-wait.c (pthread_cond_wait): Rewrite
+ cancelation support.
+
+2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/pt-cond-wait.c (pthread_cond_wait): Before
+ returning add a cancelation point.
+
+2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
+
+ * include/pthread/pthread.h (pthread_setconcurrency): New
+ definition.
+ (pthread_getconcurrency): New definition.
+
+ * pthread/pt-internal.h (__pthread_concurrency): New definition.
+
+ * sysdeps/generic/pt-getconcurrency.c: New file.
+ * sysdeps/generic/pt-setconcurrency.c: New file.
+
+ * Makefile.am (libpthread_a_SOURCES): Add pt-getconcurrency.c and
+ pt-setconcurrency.c.
+
+ * tests/Makefile.am (check_PROGRAMS): Add test-12.
+ (TEST_COUNT): Bump to 12.
+ (MOSTLYCLEANFILES): Add test-12.out.
+ (test_12_SOURCES): New variable.
+ * tests/test-12.c: New file.
+
+2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/hurd/pt-key.h (__pthread_key_lock_ready): New function.
+ Initialize the __pthread_key_lock.
+ * sysdeps/hurd/pt-key-create.c (__pthread_key_lock): Do not
+ initialize it.
+ (pthread_key_create): Do it here by calling
+ __pthread_key_lock_ready.
+ * sysdeps/hurd/pt-key-delete.c (pthread_key_destory): Call
+ __pthread_key_lock_ready.
+ * sysdeps/hurd/pt-destroy-specific.c (__pthread_destroy_specific):
+ Likewise.
+
+2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
+
+ * include/pthread/pthread.h: Include <bits/rwlock-attr.h>.
+ (pthread_rwlockattr_t): New type.
+ (pthread_rwlockattr_init): New definition.
+ (pthread_rwlockattr_destroy): New definition.
+ (pthread_rwlockattr_getpshared): New definition.
+ (pthread_rwlockattr_setpshared): New definition.
+
+ Include <bits/rwlock.h>.
+ (pthread_rwlock_t): New type.
+
+ (pthread_rwlock_init): New definition.
+ (pthread_rwlock_destroy): New definition.
+ (pthread_rwlock_rdlock): New definition.
+ (pthread_rwlock_tryrdlock): New definition.
+ (pthread_rwlock_wrlock): New definition.
+ (pthread_rwlock_trywrlock): New definition.
+ (pthread_rwlock_unlock): New definition.
+
+ * pthread/pt-internal.h (pthread_rwlock_t): Remove macro.
+ (__pthread_rwlock_rlock): Remove macro.
+ (__pthread_rwlock_wlock): Remove macro.
+ (__pthread_rwlock_unlock): Remove macro.
+
+ (__pthread_default_rwlockattr): New definition.
+
+ * pthread/pt-alloc.c (__pthread_alloc): Use
+ __pthread_rwlock_wrlock, not __pthread_rwlock_wlock.
+ * pthread/pt-create.c (__pthread_create): Use
+ __pthread_rwlock_rdlock, not __pthread_rwlock_rlock.
+
+ * sysdeps/generic/pt-rwlock-attr.c: New file.
+ * sysdeps/generic/pt-rwlock-destroy.c: New file.
+ * sysdeps/generic/pt-rwlock-init.c: New file.
+ * sysdeps/generic/pt-rwlock-rdlock.c: New file.
+ * sysdeps/generic/pt-rwlock-tryrdlock.c: New file.
+ * sysdeps/generic/pt-rwlock-trywrlock.c: New file.
+ * sysdeps/generic/pt-rwlock-unlock.c: New file.
+ * sysdeps/generic/pt-rwlock-wrlock.c: New file.
+ * sysdeps/generic/pt-rwlockattr-destroy.c: New file.
+ * sysdeps/generic/pt-rwlockattr-getpshared.c: New file.
+ * sysdeps/generic/pt-rwlockattr-init.c: New file.
+ * sysdeps/generic/pt-rwlockattr-setpshared.c: New file.
+ * sysdeps/generic/bits/rwlock-attr.h: New file.
+ * sysdeps/generic/bits/rwlock.h: New file.
+
+ * headers.m4 [hurd_SYSDEPS]: Add bits/rwlock.h and
+ bits/rwlock-attr.h.
+
+ * Makefile.am (libpthread_a_SOURCES): Add pt-rwlock-attr.c,
+ pt-rwlockattr-init.c, pt-rwlockattr-destroy.c,
+ pt-rwlockattr-getpshared.c, pt-rwlockattr-setpshared.c,
+ pt-rwlock-init.c, pt-rwlock-destroy.c, pt-rwlock-rdlock.c,
+ pt-rwlock-tryrdlock.c, pt-rwlock-trywrlock.c, pt-rwlock-wrlock.c
+ and pt-rwlock-unlock.c.
+
+ * tests/Makefile.am (check_PROGRAMS): Add test-11.
+ (TEST_COUNT): Bump to 11.
+ (MOSTLYCLEANFILES): Add test-11.out.
+ (test_11_SOURCES): New variable.
+ * tests/test-11.c: New file.
+
+2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
+
+ * Makefile.am (SYSDEPS) [L4]: Removed crt0.c.
+
+ * crt0.c: Moved to ../libc/crt0.c.
+
+2002-09-23 Neal H. Walfield <neal@cs.uml.edu>
+
+ * Makefile.am (libpthread_a_SOURCES): Add pt-mutexattr.c,
+ pt-mutexattr-destroy.c, pt-mutexattr-init.c,
+ pt-mutexattr-getprioceiling.c, pt-mutexattr-getprotocol.c,
+ pt-mutexattr-getpshared.c, pt-mutexattr-gettype.c,
+ pt-mutexattr-setprioceiling.c, pt-mutexattr-setprotocol.c,
+ pt-mutexattr-setpshared.c, pt-mutexattr-settype.c,
+ pt-mutex-init.c, pt-mutex-destroy.c and pt-mutex-trylock.c.
+
+ * headers.m4 [hurd_SYSDEPS]: Add bits/mutex-attr.h.
+
+ * include/pthread/pthread.h: Include <bits/mutex-attr.h>.
+ (__pthread_mutex_protocol): New enumeration.
+ (__pthread_mutex_type): New enumeration.
+ (pthread_mutexattr_t): New type.
+ (pthread_mutexattr_init): New definition.
+ (pthread_mutexattr_destroy): New definition.
+ (pthread_mutexattr_getprioceiling): New definition.
+ (pthread_mutexattr_setprioceiling): New definition.
+ (pthread_mutexattr_getprotocol): New definition.
+ (pthread_mutexattr_setprotocol): New definition.
+ (pthread_mutexattr_getpshared): New definition.
+ (pthread_mutexattr_setpshared): New definition.
+ (pthread_mutexattr_gettype): New definition.
+ (pthread_mutexattr_settype): New definition.
+
+ * pthread/pt-internal.h (__pthread_default_mutexattr): New
+ definition.
+
+ * sysdeps/generic/bits/mutex.h: Include <bits/mutex-attr.h>.
+ (struct __pthread_mutex): Add member OWNER and member LOCKS to
+ support error checking and recursive mutexes. Renamed __attr to
+ attr, updated users.
+ (pthread_mutexattr_t): Removed.
+ (__PTHREAD_MUTEX_INITIALIZER): Add initializers for new members.
+ (pthread_mutex_init): If ATTR, call _pthread_mutex_init.
+ (pthread_mutex_destroy): If __MUTEX has an attribute, call
+ _pthread_mutex_destroy.
+ * sysdeps/generic/pt-mutex-lock.c (__pthread_mutex_lock): Grok
+ mutex attribute.
+ * sysdeps/generic/pt-mutex-unlock.c (__pthread_mutex_unlock):
+ Likewise.
+ Add a weak alias to _pthread_mutex_unlock.
+
+ * sysdeps/generic/pt-mutex-destroy.c: New file.
+ * sysdeps/generic/pt-mutex-init.c: New file.
+ * sysdeps/generic/pt-mutex-trylock.c: New file.
+ * sysdeps/generic/pt-mutexattr-destroy.c: New file.
+ * sysdeps/generic/pt-mutexattr-getprioceiling.c: New file.
+ * sysdeps/generic/pt-mutexattr-getprotocol.c: New file.
+ * sysdeps/generic/pt-mutexattr-getpshared.c: New file.
+ * sysdeps/generic/pt-mutexattr-gettype.c: New file.
+ * sysdeps/generic/pt-mutexattr-init.c: New file.
+ * sysdeps/generic/pt-mutexattr-setprioceiling.c: New file.
+ * sysdeps/generic/pt-mutexattr-setprotocol.c: New file.
+ * sysdeps/generic/pt-mutexattr-setpshared.c: New file.
+ * sysdeps/generic/pt-mutexattr-settype.c: New file.
+ * sysdeps/generic/pt-mutexattr.c: New file.
+ * sysdeps/generic/bits/mutex-attr.h: New file.
+
+ * tests/Makefile.am (AM_LDFLAGS): Add `-u__pthread_mutex_trylock
+ -u__pthread_mutex_unlock -u__pthread_mutex_unlock'.
+ (check_PROGRAMS): Add test-9 and test-10.
+ (TEST_COUNT): Bump to 10.
+ (MOSTLYCLEANFILES): Add test-9.out and test-10.out.
+ (test_9_SOURCES): New variable.
+ (test_10_SOURCES): Likewise.
+ * tests/test-9.c: New file.
+ * tests/test-10.c: New file.
+
+2002-09-23 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-exit.c (pthread_exit): Call pthread_setcancelstate
+ correctly: NULL is not a legal value for the oldstate parameter.
+
+2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-exit.c: Remove dead code.
+ (pthread_exit): When running the cancelation handlers, disable
+ cancelation.
+
+2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
+
+ * tests/test-5.c (main): Fork a child. Do not dump a core.
+ (thr): Renamed from foo.
+
+2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-initialize.c (__pthread_init): Fully prototype it.
+
+2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
+
+ * Makefile.am (libpthread_a_SOURCES): Add pt-sigmask.c,
+ pt-stack-alloc.c, pt-thread-alloc.c, pt-thread-dealloc.c,
+ pt-thread-start.c, pt-sigstate-init.c, pt-sigstate-destroy.c
+ pt-sigstate.c.
+ Remove pt-stack.c and pt-start.c.
+
+ * pthread/pt-create.c (__pthread_create): Instead of calling
+ __pthread_start, first call __pthread_thread_alloc, then setup the
+ signal state and finally start the thread by calling
+ __pthread_thread_start.
+
+ * pthread/pt-exit.c (pthread_exit): Destroy any signal state by
+ calling __pthread_sigstate_destroy.
+
+ * pthread/pt-sigmask.c: New file.
+
+ * pthread/pt-internal.c (__pthread_thread_halt): New definition to
+ replace __pthread_halt macro. Update all callers.
+ * sysdeps/mach/hurd/pt-sysdep.h (__pthread_halt): Renamed to
+ __pthread_thread_halt and moved from here ...
+ * sysdeps/mach/pt-thread-halt.c: ... to here.
+ * sysdeps/l4/hurd/pt-sysdep.h (__pthread_halt): Renamed to
+ __pthread_thread_halt and moved from here ...
+ * sysdeps/l4/pt-thread-halt.c: ... to here.
+
+ * pthread/pt-internal.h (__pthread_start): Split into
+ __pthread_thread_alloc and __pthread_thread_start. Update all
+ callers.
+ (__pthread_thread_alloc): New definition.
+ (__pthread_thread_start): Likewise.
+ * sysdeps/l4/pt-start.c: Split file into ...
+ * sysdeps/l4/pt-thread-alloc.c: ... this ...
+ * sysdeps/l4/pt-thread-start.c: ... and this.
+ * sysdeps/mach/pt-start.c: Split file into ...
+ * sysdeps/mach/pt-thread-alloc.c: ... this ...
+ * sysdeps/mach/pt-thread-start.c: ... and this.
+
+ * sysdeps/l4/pt-stack.c: Moved from here ...
+ * sysdeps/l4/pt-stack-alloc.c: ... to here.
+ * sysdeps/mach/pt-stack.c: Moved from here ...
+ * sysdeps/mach/pt-stack-alloc.c: ... to here.
+
+ * pt-internal.h: Include <signal.h>.
+ (__pthread_sigstate_init): New definition.
+ (__pthread_sigstate_destroy): Likewise.
+ (__pthread_sigstate): Likewise.
+ * sysdeps/mach/hurd/pt-sigstate-destroy.c: New file.
+ * sysdeps/mach/hurd/pt-sigstate-init.c: New file.
+ * sysdeps/mach/hurd/pt-sigstate.c: New file.
+
+ * sysdeps/mach/hurd/i386/pt-setup.c (__pthread_setup): Setup the
+ initial thread state but only if THREAD is not the main thread.
+
+2002-09-17 Neal H. Walfield <neal@cs.uml.edu>
+
+ Get signals working.
+
+ * sysdeps/mach/hurd/pt-destroy-signal-state.c: Likewise.
+ * sysdeps/mach/hurd/pt-init-signal-state.c: Likewise.
+ * sysdeps/mach/hurd/pt-sigstate.c: Likewise.
+
+
+ * pthread/pt-internal.h: Include <signal.h>.
+ (__pthread_init_signal_state): New definition.
+ (__pthread_destroy_signal_state): Likewise.
+ (__pthread_sigstate): Likewise.
+
+ * pthread/pt-create.c (pthread_create): Call
+ __pthread_init_signal_state (and __pthread_destroy_signal_state on
+ a failure). Also set the new thread's sigmask and pending signal
+ state appropriately.
+
+ * pthread/pt-exit.c (pthread_exit): Call
+ __pthread_destroy_signal_state as appropriate.
+
+2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-alloc.c (__pthread_alloc): Factor out initialization
+ code into ...
+ (initialize_pthread): ... this new function.
+
+ (__pthread_alloc): If reusing a thread structure fails, clean up
+ the mess correctly.
+
+2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-alloc.c (__pthread_alloc): Revert last change.
+
+2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-alloc.c (__pthread_alloc): Remove assert.
+
+2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-initialize.c (__pthread_main): Removed. The added
+ convenience does not help initialization and severely complicates
+ the library if the the main thread calls pthread_exit.
+ (__pthread_init): Remove parameter, thread.
+ (__pthread_initialize): Updated to reflect new semantics.
+ * pthread/pt-alloc.c (alloc_init): Update to new semantics. Do
+ not try to initialize the main thread.
+
+ * pthread/pt-create.c (__pthread_total): The main thread is now
+ created explicitly, initialize to zero.
+
+ * pthread/pt-internal.h (__pthread_num_threads): Add definition.
+ (__pthread_main): Removed.
+
+ * pthread/pt-internal.h (__pthread_create): New definition.
+ * pthread/pt-create.c (pthread_create): Move functionality from
+ here ...
+ (__pthread_create): ... to here.
+ (pthread_create): Use __pthread_create.
+
+ * sysdeps/mach/hurd/pt-sysdep.c (init_routine): Use
+ __pthread_create directly rather than rewriting the functionality
+ here.
+ * sysdeps/l4/hurd/pt-sysdep.c (init_routine): Likewise.
+
+ * sysdeps/mach/pt-start.c (__pthread_start): Do not detect the
+ main thread using __pthread_main. If main thread, set the kernel
+ thread id.
+ * sysdeps/l4/pt-start.c (__pthread_start): Likewise.
+
+2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/l4/hurd/pt-save-self.c (__pthread_save_self): Move
+ functionality from here ...
+ * sysdeps/l4/hurd/i386/pt-setup.c (__pthread_setup): ... to here
+ where it belongs.
+
+ * sysdeps/l4/hurd/pt-sysdep.c (init_routine): Do not save pthread
+ self pointer here, it will be done automatically in
+ __pthread_setup.
+
+ __pthread_save_self is now obsolete.
+
+ * pthread/pt-internal.h (__pthread_save_self): Remove definition.
+ * sysdeps/mach/hurd/pt-save-self.c: Removed file.
+ * sysdeps/l4/hurd/pt-save-self.c: Removed file.
+ * Makefile.am (libpthread_a_SOURCES): Remove pt-save-self.c.
+
+2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-create.c (pthread_create): Do not call
+ __pthread_save_self. This is completely bogus.
+
+ * pthread/pt-internal.h: Permit _pthread_self to be a macro.
+
+ * sysdeps/mach/hurd/pt-sysdep.h (__pthread_self): Renamed from
+ _pthread_self.
+ (_pthread_self): New marcro. Do some sanity checks.
+
+2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/mach/hurd/pt-sysdep.c (init_routine): We cannot use
+ __hurd_threadvar_location with the initial stack. This is
+ completely bogus; removed. Neither can we use the TSD on the new
+ stack: once the initial thread returns to the libc initialization
+ code, libc overwrites it. Thus, we shift the TSD by a pointer and
+ use the first word of the stack to store the self pointer.
+ * sysdeps/mach/hurd/pt-sysdep.h (_HURD_THREADVAR_THREAD): Removed.
+ (_pthread_self): Update to reflect new semantics.
+ * sysdeps/mach/hurd/pt-save-self.c (__pthread_save_self):
+ Likewise.
+ * sysdeps/mach/hurd/i386/pt-setup.c (stack_setup): Likewise.
+
+2002-09-17 Neal H. Walfield <neal@cs.uml.edu>
+
+ * Makefile.am (AM_CPPFLAGS): Add -D_IO_MTSAFE_IO.
+ (SYSDEPS) [MACH]: Add lockfile.c.
+
+ * lockfile.c: Include <cthread.h>.
+
+ * tests/Makefile.am (AM_LDFLAGS): Add -u_cthreads_flockfile to
+ force the inclusion of lockfile.c.
+
+2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
+
+ * tests/test-7.c: Include <stdio.h>.
+
+2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/cthreads-compat.c (__mutex_lock_solid): New function.
+ (__mutex_unlock_solid): Likewise.
+
+ * sysdeps/mach/pt-spin.c: New file.
+ * sysdeps/mach/bits: New directory.
+ * sysdeps/mach/bits/spin-lock.h: New file.
+
+ * sysdeps/generic/bits/mutex.h: Add comments.
+
+ * sysdeps/posix/pt-spin.c (_pthread_spin_lock): Renamed from
+ __pthread_spin_lock. Update weak aliases to point to _pthread_spin
+ lock in lieu of __pthread_spin_lock.
+
+2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
+
+ * Makefile.am (AM_CPPFLAGS): Order more appropriately.
+ (VPATH): Likewise.
+
+2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/bits/spin-lock.h: Move from here ...
+ * sysdeps/i386/bits/spin-lock.h: ... to here.
+
+2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/cthreads-compat.c (__libc_getspecific): New function.
+
+2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/cthreads-compat.c (cthread_keycreate): New function.
+ (cthread_getspecific): Likewise.
+ (cthread_setspecific): Likewise.
+
+2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/bits/pthread.h (pthread_equal): Add comments.
+
+2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
+
+ * tests/test-6.c: Include <stdio.h>.
+ (main): Remove superfluous sleep.
+
+2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
+
+ * Makefile.am (libpthread_a_SOURCES): Add pt-once.c.
+ * headers.m4 [hurd_SYSDEPS]: Add bits/once.h.
+
+ * sysdeps/generic/pt-once.c: New file.
+ * sysdeps/generic/bits/once.h: New file.
+ * sysdeps/i386/bits/memory.h: New file.
+
+ * include/pthread/pthread.h: Include <bits/once.h>.
+ (PTHREAD_ONCE_INIT): New macro.
+ (pthread_once): New definition.
+
+ * tests/Makefile.am (AM_CFLAGS): Set to -Wall.
+ (check_PROGRAMS): Add test-8.
+ (TEST_COUNT): Bump to 8.
+ (MOSTLYCLEANFILES): Add test-8.out.
+ (test_8_SOURCES): New variable.
+
+ * tests/test-8.c (main): New file.
+
+2002-09-15 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/mach/pt-stack.c (__pthread_stack_alloc): If we reach the
+ end of the virtual address space, do not just fail but wrap
+ around.
+
+2002-09-15 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/pt-destroy-specific.c: New file.
+ * sysdeps/generic/pt-getspecific.c: Likewise.
+ * sysdeps/generic/pt-init-specific.c: Likewise.
+ * sysdeps/generic/pt-key-create.c: Likewise.
+ * sysdeps/generic/pt-key-delete.c: Likewise.
+ * sysdeps/generic/pt-key.h: Likewise.
+ * sysdeps/generic/pt-setspecific.c: Likewise.
+ * sysdeps/generic/bits/thread-specific.h: Likewise.
+
+ * sysdeps/hurd: New directory for files that only depend on a Hurd
+ personality (and not the underlying microkernel).
+
+ * sysdeps/hurd/pt-destroy-specific.c: New file.
+ * sysdeps/hurd/pt-getspecific.c: Likewise.
+ * sysdeps/hurd/pt-init-specific.c: Likewise.
+ * sysdeps/hurd/pt-key-create.c: Likewise.
+ * sysdeps/hurd/pt-key-delete.c: Likewise.
+ * sysdeps/hurd/pt-key.h: Likewise.
+ * sysdeps/hurd/pt-setspecific.c: Likewise.
+
+ * Makefile.am (AM_CPPFLAGS): Add -I$(srcdir)/sysdeps/hurd.
+ (VPATH): Add $(srcdir)/sysdeps/hurd.
+ (libpthread_a_SOURCES): Add pt-key.h, pt-destroy-specific.c,
+ pt-init-specific.c, pt-key-create.c, pt-key-delete.c,
+ pt-getspecific.c and pt-setspecific.c.
+
+ * headers.m4 (hurd_SYSDEPS): Add thread_specific.h.
+
+ * include/pthread/pthread.h: Include <bits/thread-specific>.
+ (pthread_key_t): New definition.
+ (pthread_key_create): Likewise.
+ (pthread_key_delete): Likewise.
+ (pthread_getspecific): Likewise.
+ (pthread_setspecific): Likewise.
+
+ * pthread/pt-internal.h: Include <pt-key.h>
+ [! PTHREAD_KEY_MEMBERS]: Define it to be empty.
+ (struct __pthread): Include the value of PTHREAD_KEY_MEMBERS.
+
+ (__pthread_init_specific): New definition.
+ (__pthread_destroy_specific): Likewise.
+
+ * pthread/pt-alloc.c (__pthread_alloc): Call
+ __pthread_init_specific.
+ * pthread/pt-exit.c (pthread_exit): Call
+ __pthread_destroy_specific.
+
+ * tests/Makefile.am (LDADD): Add -lihash.
+ (check_PROGRAMS): Add test-7.
+ (MOSTLYCLEANFILES): Add test-7.out.
+ (TEST_COUNT): Bump to 7.
+ (test_7_SOURCES): New variable.
+ * tests/test-7.c: New file.
+
+2002-09-15 Neal H. Walfield <neal@cs.uml.edu>
+
+ * tests/test-6.c: Improve test; iterate WAIT times over
+ pthread_barrier_wait rather than just once.
+
+2002-09-14 Neal H. Walfield <neal@cs.uml.edu>
+
+ Add support for barrier attributes and barriers.
+
+ * sysdeps/generic/pt-barrier-destroy.c: New file.
+ * sysdeps/generic/pt-barrier-init.c: Likewise.
+ * sysdeps/generic/pt-barrier-wait.c: Likewise.
+ * sysdeps/generic/pt-barrier.c: Likewise.
+ * sysdeps/generic/pt-barrierattr-destroy.c: Likewise.
+ * sysdeps/generic/pt-barrierattr-getpshared.c: Likewise.
+ * sysdeps/generic/pt-barrierattr-init.c: Likewise.
+ * sysdeps/generic/pt-barrierattr-setpshared.c: Likewise.
+ * sysdeps/generic/bits/barrier-attr.h: Likewise.
+ * sysdeps/generic/bits/barrier.h: Likewise.
+ * sysdeps/generic/bits/thread-barrier.h: Likewise.
+
+ * Makefile.am (libpthread_a_SOURCES): Added pt-barrier-destroy.c,
+ pt-barrier-init.c, pt-barrier-wait.c, pt-barrier.c,
+ pt-barrierattr-destroy.c, pt-barrierattr-init.c,
+ pt-barrierattr-getpshared.c and pt-barrierattr-setpshared.c.
+
+ * headers.m4 (hurd_SYSDEPS): Added bits/barrier-attr.h and
+ bits/barrier.h.
+
+ * include/pthread/pthread.h: Include <bits/barrier-attr.h> and
+ <bits/barrier.h>.
+
+ (__pthread_process_shared): New enumeration.
+ (PTHREAD_PROCESS_PRIVATE): New macro.
+ (PTHREAD_PROCESS_SHARED): Likewise.
+ (pthread_barrierattr_t): New typedef.
+
+ (pthread_barrierattr_init): New definition.
+ (pthread_barrierattr_destroy): Likewise.
+ (pthread_barrierattr_getpshared): Likewise.
+ (pthread_barrierattr_setpshared): Likewise.
+
+ (pthread_barrier_t): New typedef.
+ (PTHREAD_BARRIER_SERIAL_THREAD): New macro.
+ (pthread_barrier_init): New declaration.
+ (pthread_barrier_destroy): Likewise.
+ (pthread_barrier_wait): Likewise.
+
+ * pthread/pt-internal.h (__pthread_default_barrierattr): New
+ definition.
+
+ * tests/test-6.c: New file.
+ * tests/Makefile.am (check_PROGRAMS): Add test-6.
+ (MOSTLYCLEANFILES): Add test-6.out.
+ (test_6_SOURCES): New variable.
+ (TEST_COUNT): Update.
+
+2002-09-12 Neal H. Walfield <neal@cs.uml.edu>
+
+ * tests/Makefile.am
+ (check_PROGRAMS): Add test test-3 and test-5.
+ (MOSTLYCLEANFILES): Add test-3.out, test-4.out and test-5.out.
+ (TEST_COUNT): Change to 5.
+ (test_3_SOURCES): New variable.
+ (test_5_SOURCES): New variable.
+ (check): Fix typo.
+
+ * tests/test-3.c: New file.
+ * tests/test-4.c: New file.
+ * tests/test-5.c: New file.
+
+2002-09-12 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/mach/hurd/pt-attr-setstackaddr.c: New file.
+ * sysdeps/mach/hurd/pt-attr-setstacksize.c: New file.
+ * sysdeps/mach/hurd/i386/pt-setup.c: New file.
+
+ * sysdeps/mach/hurd/i386/pt-setup.c (stack_setup): Setup the stack
+ guard if necessary.
+
+2002-09-12 Neal H. Walfield <neal@cs.uml.edu>
+
+ Generic attributes.
+
+ * sysdeps/generic/pt-attr-destroy.c: New file.
+ * sysdeps/generic/pt-attr-getdetachstate.c: New file.
+ * sysdeps/generic/pt-attr-getguardsize.c: New file.
+ * sysdeps/generic/pt-attr-getinheritsched.c: New file.
+ * sysdeps/generic/pt-attr-getschedparam.c: New file.
+ * sysdeps/generic/pt-attr-getschedpolicy.c: New file.
+ * sysdeps/generic/pt-attr-getscope.c: New file.
+ * sysdeps/generic/pt-attr-getstack.c: New file.
+ * sysdeps/generic/pt-attr-getstackaddr.c: New file.
+ * sysdeps/generic/pt-attr-getstacksize.c: New file.
+ * sysdeps/generic/pt-attr-init.c: New file.
+ * sysdeps/generic/pt-attr-setdetachstate.c: New file.
+ * sysdeps/generic/pt-attr-setguardsize.c: New file.
+ * sysdeps/generic/pt-attr-setinheritsched.c: New file.
+ * sysdeps/generic/pt-attr-setschedparam.c: New file.
+ * sysdeps/generic/pt-attr-setschedpolicy.c: New file.
+ * sysdeps/generic/pt-attr-setscope.c: New file.
+ * sysdeps/generic/pt-attr-setstack.c: New file.
+ * sysdeps/generic/pt-attr-setstackaddr.c: New file.
+ * sysdeps/generic/pt-attr-setstacksize.c: New file.
+ * sysdeps/generic/pt-attr.c: New file.
+
+ * sysdeps/generic/bits/thread-attr.h: New file.
+
+ * Makefile.am (libpthread_a_SOURCES): Add pt-attr.c,
+ pt-attr-destroy.c, pt-attr-getdetachstate.c,
+ pt-attr-getguardsize.c, pt-attr-getinheritsched.c,
+ pt-attr-getschedparam.c, pt-attr-getschedpolicy.c,
+ pt-attr-getscope.c, pt-attr-getstack.c, pt-attr-getstackaddr.c,
+ pt-attr-getstacksize.c, pt-attr-init.c, pt-attr-setdetachstate.c,
+ pt-attr-setguardsize.c, pt-attr-setinheritsched.c,
+ pt-attr-setschedparam.c, pt-attr-setschedpolicy.c,
+ pt-attr-setscope.c, pt-attr-setstack.c, pt-attr-setstackaddr.c,
+ pt-attr-setstacksize.c and pt-attr.c.
+
+ * headers.m4: Add bits/thread-attr.h.
+
+ * include/pthread/pthread.h: Inlucde <bits/thread-attr.h>.
+ (__pthread_inheritsched): New enumeration.
+ (__pthread_contentionscop): Likewise.
+ (__pthread_detachstate): Beautify.
+
+ (pthread_attr_t): Update declaration.
+
+ (pthread_attr_init): New definition.
+ (pthread_attr_destroy): Likewise.
+ (pthread_attr_getinheritsched): Likewise.
+ (pthread_attr_setinheritsched): Likewise.
+ (pthread_attr_getschedparam): Likewise.
+ (pthread_attr_setschedparam): Likewise.
+ (pthread_attr_getschedpolicy): Likewise.
+ (pthread_attr_setschedpolicy): Likewise.
+ (pthread_attr_getscope): Likewise.
+ (pthread_attr_setscope): Likewise.
+ (pthread_attr_getstackaddr): Likewise.
+ (pthread_attr_setstackaddr): Likewise.
+ (pthread_attr_getstack): Likewise.
+ (pthread_attr_setstack): Likewise.
+ (pthread_attr_getdetachstate): Likewise.
+ (pthread_attr_setdetachstate): Likewise.
+ (pthread_attr_getguardsize): Likewise.
+ (pthread_attr_setguardsize): Likewise.
+ (pthread_attr_getstacksize): Likewise.
+ (pthread_attr_setstacksize): Likewise.
+
+ * pthread/pt-internal.h (struct __pthread): New member, guardsize.
+ (__pthread_default_attr): Make constant.
+ (struct __pthread_attr): Moved definition from here ...
+ * sysdeps/generic/bits/thread-attr.h: ... to here.
+ (struct __pthread_attr): Add new members: guardsize, inheritsched,
+ contentionscope and schedpolicy.
+
+ * pthread/pt-attr.c: Moved from here ...
+ * sysdeps/generic/pt-attr.c: ... to here.
+ (__pthread_default_attr): Initialize new members guardsize,
+ inheritsched, contentionscope and schedpolicy.
+
+ * pthread/pt-create.c (pthread_create): Make SETUP constant.
+ Sync with pthread_attr_t type change.
+ Set PTHREAD->guardsize appropriately.
+
+2002-09-12 Neal H. Walfield <neal@cs.uml.edu>
+
+ * tests/Makefile.am (AM_CPPFLAGS): Learn to spel.
+
+2002-09-12 Neal H. Walfield <neal@cs.uml.edu>
+
+ * tests/test-2.c: Implement it.
+
+2002-09-11 Neal H. Walfield <neal@cs.uml.edu>
+
+ * Makefile.am (SUBDIRS): New variable.
+
+ * tests/Makefile.am: New file.
+ * tests/test-1.c: file.
+ * tests/test-2.c: file.
+
+2002-09-11 Neal H. Walfield <neal@cs.uml.edu>
+
+ * include/libc-symbols.h: Do not define SHARED.
+ * not-in-libc.h (__mach_port_allocate): New macro.
+
+ * pthread/pt-alloc.c (__pthread_alloc): Add an assert.
+
+ * sysdeps/generic/pt-mutex-unlock.c (__pthread_mutex_unlock):
+ Simplify logic: WAKEUP is known not to be NULL after it is tested.
+
+ * sysdeps/mach/pt-start.c (create_wakeupmsg): Do not allocate a
+ reply port; use a normal port.
+ If __mach_port_insert_right fails, deallocate
+ THREAD->wakeupmsg.msgh_remote_port.
+
+2002-09-11 Neal H. Walfield <neal@cs.uml.edu>
+
+ * Makefile.am (libpthread_a_SOURCES): Add cthreads-compat.c.
+
+2002-08-26 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/mach/hurd/pt-errno.c: New file.
+
+2002-08-26 Neal H. Walfield <neal@cs.uml.edu>
+
+ * include/pthread/pthread.h (pthread_mutexattr_t): Moved from here
+ ..
+ * sysdeps/generic/bits/mutex.h: ... to here.
+
+2002-08-26 Neal H. Walfield <neal@cs.uml.edu>
+
+ * Makefile.am (SYSDEPS) [MACH]: Do not built lockfile.c.
+ (include_HEADERS): List headers to be installed. Leave commented
+ until it works with VPATH.
+
+2002-08-26 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/l4/pt-stack.c (allocate_page): Fix typo.
+
+2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/l4/pt-stack.c (allocate_page): Request the correct
+ permissions for the request memory.
+
+2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/Makefile: Moved from here ...
+ * pthread/Makefile.glibc: ... to here to avoid confusing automake.
+
+2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
+
+ * Makefile.am (AM_CPPFLAGS): Fix the include paths.
+ Implicitly include include/libc-symbols.h.
+ (SYSDEPS) [L4]: Add crt0.c.
+ (libpthread_a_SOURCES): Remove crt0.c.
+
+ (VPATH): New variable.
+ (libpthread_a_SOURCES): Depend on the VPATH; do not use absolute
+ paths.
+
+2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/pt-cond-wait.c: Doc fix thanks to Marcus
+ Brinkmann for pointing this out.
+ * sysdeps/generic/pt-mutex-lock.c: Likewise.
+
+2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/mach/hurd/pt-sysdep.h (__thread_set_pcsp): Prototype new
+ function.
+ * sysdeps/mach/hurd/i386/pt-machdep.c (__thread_set_pcsp):
+ Implement it.
+ * sysdeps/mach/pt-start.c (__pthread_start): Use it.
+
+2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/l4/pt-stack.c: Remove comment about next_stack_base.
+ This is baggage carried over from the Mach version.
+ (allocate_page): Use L4_FpageLog2 properly.
+
+2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-internal.h (struct __pthread_attr): Add schedparam
+ field.
+ * pthread/pt-attr.c (__pthread_default_attr): Initialize
+ schedparam field.
+
+2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-internal.h (__pthread_do_cancel): Add prototype.
+
+2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-alloc.c (alloc_init): Make static and use RUN_HOOK.
+ * pthread/pt-initialize.c (__pthread_initialize): Remove the hack
+ and use RUN_HOOK.
+
+2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-create.c: Include <signal.h>.
+
+2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/mach/hurd/pt-docancel.c: New file.
+ * sysdeps/mach/hurd/pt-save-self.c: New file.
+
+2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
+
+ * include/pthread/pthread.h: Include <sched.h> and <time.h>.
+ (pthread_mutexattr_t): Add prototype.
+ (pthread_mutex_init): Likewise.
+ (pthread_mutex_destroy): Likewise.
+
+ * sysdeps/generic/bits/mutex.h (pthread_mutex_init): New function.
+ (pthread_mutex_destroy): New function.
+
+ * sysdeps/generic/bits/pthread.h (pthread_equal): New function.
+
+2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-setcancelstate.c (pthread_setcancelstate): Add
+ explicit break to elide gcc warning.
+ * pthread/pt-setcanceltype.c (pthread_setcanceltype): Likewise.
+
+2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
+
+ * include/libc-symbols.h: Do not define _LIBC as we are not
+ actually compiling glibc.
+ (HAVE_ASM_WEAKEXT_DIRECTIVE): Do not define it.
+ (HAVE_ASM_SET_DIRECTIVE): Define it.
+ (HAVE_BUILTIN_EXPECT): Likewise.
+ (HAVE_GNU_LD): Likewise.
+ (HAVE_ELF): Likewise.
+ (HAVE_SECTION_QUOTES): Likewise.
+ (HAVE_VISIBILITY_ATTRIBUTE): Likewise.
+ (SHARED): Likewise.
+
+ * not-in-libc.h: New file.
+ * Makefile.am (AM_CPPFLAGS): Include not-in-libc.h implicitly.
+
+ * lockfile.c: New file.
+ * Makefile.am (SYSDEPS) [MACH]: Add lockfile.c.
+
+2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/mach/hurd/bits/pthread.h: Removed. Used the generic
+ version.
+
+2002-08-21 Neal H. Walfield <neal@cs.uml.edu>
+
+ * headers.m4: Fix typo.
+
+2002-08-21 Neal H. Walfield <neal@cs.uml.edu>
+
+ * include: Moved from libc/include except for include/sched.h and
+ include/time.h.
+ * pthread: Moved from libc/pthread.
+ * sysdeps: Moved from libc/sysdeps except for
+ sysdeps/i386/bits/atomic.h and sysdeps/hurd/hurd/threadvar.h.
+ * crt0.c: Moved from libc/crt0.c.
+
+ * sysdeps/generic/bits: Moved from include/bits except
+ include/bits/wordsize.h.
+ * include/pthread: Moved from include/pthread.
+ * include/lock-intern.h: Moved from include/lock-intern.h.
+ * include/pthread.h: Moved from include/pthread.h.
+
+ * headers.m4: New file.
+
+2002-08-19 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/l4/pt-start.c [WORKING_EXREGS]: Ideal implementation.
+
+2002-08-05 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pthread.h (PTHREAD_SPINLOCK_INITIALIZER): New
+ declaration.
+
+2002-08-03 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/l4/hurd/pt-sysdep.h (PTHREAD_SYSDEP_MEMBERS): Add
+ my_errno.
+ * sysdeps/l4/hurd/pt-errno.c: New file.
+ * Makefile.am (libc_a_SOURCES): Added sysdeps/l4/hurd/pt-errno.c.
+
+2002-07-29 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-internal.h (__pthread_save_self): New declaration.
+ Dual of _pthread_self ().
+ * sysdeps/l4/pt-save-self.c: New file.
+ * Makefile.am (libc_a_SOURCES): Added
+ sysdeps/l4/hurd/pt-save-self.c.
+
+ * pthread/pt-create.c (pthread_create): Save the new thread's
+ control block explicitly using __pthread_save_self.
+ * sysdeps/l4/hurd/pt-sysdep.c (init_routine): Replace Hurd's
+ threadvar code with __pthread_save_self.
+ * sysdeps/l4/hurd/pt-sysdep.h (_pthread_self): Likewise.
+ (_HURD_THREADVAR_THREAD): Removed macro.
+ * sysdeps/l4/hurd/i386/pt-setup.c (stack_setup): Remove Hurd's
+ threadvar code. Mechanism is now in _pthread_save_self.
+
+2002-07-29 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-internal.h (struct __pthread): Add fields
+ cancel_state, cancel_type, cancel_pending and
+ cancelation_handlers to support cancelation.
+ * pthread/pt-alloc.c (__pthread_alloc): Initialize
+ NEW->cancel_state, NEW->cancel_type, NEW->cancel_pending and
+ NEW->cancelation_handlers.
+ * pthread/pt-exit.c (pthread_exit): Run registered cleanup
+ handlers. If thread was canceled, set the status to
+ PTHREAD_CANCELED.
+ * pthread/pt-cleanup.c: New file.
+ * pthread/pt-setcancelstate.c: New file.
+ * pthread/pt-setcanceltype.c: New file.
+ * pthread/pt-testcancel.c: New file.
+ * sysdeps/l4/pt-docancel.c: New file.
+
+ * Makefile.am (libc_a_SOURCES): Add pthread/pt-cleanup.c,
+ pthread/pt-setcancelstate.c, pthread/pt-setcanceltype.c,
+ pthread/pt-testcancel.c and sysdeps/l4/pt-docancel.c.
+
+2002-07-29 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pthread.h (pthread_cleanup_push): Moved from here ...
+ * bits/cancelation.h: ... to here.
+ * pthread/pthread.h (pthread_cleanup_pop): Moved from here ...
+ * bits/cancelation.h: ... to here.
+
+ * pthread/pthread.h (pthread_cleanup_push): New definition.
+ * pthread/pthread.h (pthread_cleanup_pop): New definition.
+
+ * bits/cancelation.h: Include <assert.h>.
+ * pthread/pthread.h: Do not include <assert.h>.
+
+2002-07-29 Neal H. Walfield <neal@cs.uml.edu>
+
+ * bits/condition.h (__PTHREAD_COND_INITIALIZER): Cast result.
+ * bits/mutex.h (__PTHREAD_MUTEX_INITIALIZER): Likewise.
+ * bits/spin-lock.h (__SPIN_LOCK_INITIALIZER): Likewise.
+
+2002-07-29 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pthread.h: Include <bits/cancelation.h> and <assert.h>.
+ (PTHREAD_CANCEL_DISABLE): New macro.
+ (PTHREAD_CANCEL_ENABLE): New macro.
+ (PTHREAD_CANCEL_DEFERRED): New macro.
+ (PTHREAD_CANCEL_ASYNCHRONOUS): New macro.
+ (PTHREAD_CANCELED): New macro.
+ (pthread_setcancelstate): New definition.
+ (pthread_setcanceltype): New definition.
+ (pthread_cancel): New definition.
+ (pthread_testcancel): New definition.
+ (pthread_cleanup_push): New macro.
+ (pthread_cleanup_pop): New macro.
+ * bit/condition.h: New file.
+
+2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/l4/pt-block.c (__pthread_block): Receive from any local
+ thread, not any thread.
+
+2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * crt0.c (exit): Print the exit value for debugging purposes.
+
+2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-alloc.c (__pthread_alloc): Improve comments. When
+ allocating a new pthread, really initialize it.
+ * pthread/pt-create.c (pthread_create): Reuse the old stacks when
+ possible. If allocating the thread structure fails, do not try to
+ free anything. Clear the thread id on failure. Beautify and add
+ comments.
+
+ * pthread/pt-dealloc.c (__pthread_dealloc): Rewritten to be the
+ dual of __pthread_alloc rather than an all-in-one.
+ * pthread/pt-detach.c (pthread_detach): Factor out code that is in
+ __pthread_dealloc. Unlock PTHREAD->state_lock before calling
+ __pthread_dealloc.
+ * pthread/pt-exit.c (pthread_exit): Likewise.
+ * pthread/pt-join.c (pthread_join): Likewise.
+
+2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-internal.h: Beautify and fix comments.
+ (__pthread_setid): Get a write lock, not a read lock.
+
+2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pt-alloc.c (__pthread_alloc): (alloc_init): Make it an
+ external, not static as RUN_HOOKS does not work yet.
+ * pthread/pt-initialize.c (__pthread_initialize): Call alloc_init
+ directly as RUN_HOOK does not yet work.
+
+2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/l4/hurd/pt-sysdep.c (init_routine): Be sure that
+ __hurd_threadvar_stack_mask and __hurd_threadvar_stack_offset are
+ set before calling __pthread_setup.
+ * sysdeps/l4/hurd/i386/pt-setup.c (stack_setup): Elide hack and
+ use __hurd_threadvar_location_from-sp.
+
+2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/generic/pt-cond-wait.c (pthread_cond_wait): Add
+ comment about a race condition.
+ * sysdeps/generic/pt-mutex-lock.c (__pthread_mutex_lock):
+ Likewise.
+
+2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/l4/pt-start.c (send_startup_ipc): Use task_server (which
+ is now also the thread_server). Do smarter casting.
+ * sysdeps/l4/hurd/pt-sysdep.h (__pthread_halt): Likewise.
+
+2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
+
+ * sysdeps/l4/pt-wakeup.c: Fix comment.
+
+2002-07-24 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/Makefile: New file. Imported from Mark's pthread
+ package with local modifications.
+ * pthread/Versions: Likewise.
+ * pthread/cthreads-compat.c: Likewise.
+ * pthread/pt-alloc.c: Likewise.
+ * pthread/pt-attr.c: Likewise.
+ * pthread/pt-create.c: Likewise.
+ * pthread/pt-dealloc.c: Likewise.
+ * pthread/pt-detach.c: Likewise.
+ * pthread/pt-exit.c: Likewise.
+ * pthread/pt-initialize.c: Likewise.
+ * pthread/pt-internal.h: Likewise.
+ * pthread/pt-join.c: Likewise.
+ * pthread/pt-self.c: Likewise.
+ * pthread/pt-spin-inlines.c: Likewise.
+ * pthread/pthread.patch: Likewise.
+ * sysdeps/generic/pt-cond-brdcast.c: Likewise.
+ * sysdeps/generic/pt-cond-signal.c: Likewise.
+ * sysdeps/generic/pt-cond-wait.c: Likewise.
+ * sysdeps/generic/pt-mutex-lock.c: Likewise.
+ * sysdeps/generic/pt-mutex-unlock.c: Likewise.
+ * sysdeps/hurd/hurd/threadvar.h: Likewise.
+ * sysdeps/i386/machine-sp.h: Likewise.
+ * sysdeps/i386/pt-machdep.h: Likewise.
+ * sysdeps/i386/bits/atomic.h: Likewise.
+ * sysdeps/l4/pt-block.c: Likewise.
+ * sysdeps/l4/pt-stack.c: Likewise.
+ * sysdeps/l4/pt-start.c: Likewise.
+ * sysdeps/l4/pt-wakeup.c: Likewise.
+ * sysdeps/l4/hurd/pt-sysdep.c: Likewise.
+ * sysdeps/l4/hurd/pt-sysdep.h: Likewise.
+ * sysdeps/l4/hurd/i386/pt-machdep.c: Likewise.
+ * sysdeps/l4/hurd/i386/pt-setup.c: Likewise.
+ * sysdeps/mach/pt-block.c: Likewise.
+ * sysdeps/mach/pt-stack.c: Likewise.
+ * sysdeps/mach/pt-start.c: Likewise.
+ * sysdeps/mach/pt-wakeup.c: Likewise.
+ * sysdeps/mach/hurd/pt-sysdep.c: Likewise.
+ * sysdeps/mach/hurd/pt-sysdep.h: Likewise.
+ * sysdeps/mach/hurd/bits/pthread.h: Likewise.
+ * sysdeps/mach/hurd/i386/pt-machdep.c: Likewise.
+ * sysdeps/mach/hurd/i386/pt-setup.c: Likewise.
+ * sysdeps/posix/pt-spin.c: Likewise.
+
+ * include/libc-symbols.h: Imported from glibc with local
+ modifications for pthread port.
+ * include/set-hooks.h: Likewise.
+
+ * include/sched.h: Glue code for pthread port until a real
+ implementation is available.
+ * include/time.h: Likewise.
+
+ * Makefile.am (libc_a_SOURCES): Added most of the above c files.
+ (CFLAGS): Build up the include paths the way that glibc does.
+
+ * TODO: New file.
+
+ * crt0.c: Rewritten to include support for initializing pthreads
+ and dealing with the new stack layout.
+
+2002-07-24 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pthread.h: Define pthread_spinlock_t.
+ (pthread_spin_destroy): Use it, not __pthread_spinlock_t.
+ (pthread_spin_init): Likewise.
+ (pthread_spin_lock): Likewise.
+ (pthread_spin_trylock): Likewise.
+ (pthread_spin_unlock): Likewise.
+
+ * features.h (__USE_XOPEN2K): Define it.
+
+2002-07-24 Neal H. Walfield <neal@cs.uml.edu>
+
+ * pthread/pthread.h: New file imported from Mark's pthead package.
+
+2002-07-24 Neal H. Walfield <neal@cs.uml.edu>
+
+ * bits/condition.h: New file imported from Mark's pthead package.
+ * bits/mutex.h: Likewise.
+ * bits/pthread.h: Likewise.
+ * bits/spin-lock.h: Likewise.
+
+2002-07-23 Jeff Bailey <jbailey@outpost.dnsalias.org>
+
+ * .cvsignore: New File
+
+2002-07-21 Neal H. Walfield <neal@cs.uml.edu>
+
+ * crt0.c (_start): Put in .START section, not in the text.
+
+2002-07-17 Neal H. Walfield <neal@cs.uml.edu>
+
+ * Makefile.am (AM_CFLAGS): Library is no longer called libcrt0 but
+ libc. Adjust accordingly.
diff --git a/libpthread/Makefile b/libpthread/Makefile
new file mode 100644
index 00000000..00762203
--- /dev/null
+++ b/libpthread/Makefile
@@ -0,0 +1,243 @@
+#
+# Copyright (C) 1994, 1995, 1996, 1997, 2000, 2002, 2004, 2005, 2006, 2007,
+# 2008 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2, or (at
+# your option) any later version.
+#
+# This program 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
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+dir := libpthread
+makemode := library
+
+MICROKERNEL := mach
+SYSDEPS := lockfile.c
+
+LCLHDRS :=
+
+SRCS := pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \
+ pt-attr-getguardsize.c pt-attr-getinheritsched.c \
+ pt-attr-getschedparam.c pt-attr-getschedpolicy.c pt-attr-getscope.c \
+ pt-attr-getstack.c pt-attr-getstackaddr.c pt-attr-getstacksize.c \
+ pt-attr-init.c pt-attr-setdetachstate.c pt-attr-setguardsize.c \
+ pt-attr-setinheritsched.c pt-attr-setschedparam.c \
+ pt-attr-setschedpolicy.c pt-attr-setscope.c pt-attr-setstack.c \
+ pt-attr-setstackaddr.c pt-attr-setstacksize.c \
+ \
+ pt-barrier-destroy.c pt-barrier-init.c pt-barrier-wait.c \
+ pt-barrier.c pt-barrierattr-destroy.c pt-barrierattr-init.c \
+ pt-barrierattr-getpshared.c pt-barrierattr-setpshared.c \
+ \
+ pt-destroy-specific.c pt-init-specific.c \
+ pt-key-create.c pt-key-delete.c \
+ pt-getspecific.c pt-setspecific.c \
+ \
+ pt-once.c \
+ \
+ pt-alloc.c \
+ pt-create.c \
+ pt-getattr.c \
+ pt-equal.c \
+ pt-dealloc.c \
+ pt-detach.c \
+ pt-exit.c \
+ pt-initialize.c \
+ pt-join.c \
+ pt-self.c \
+ pt-sigmask.c \
+ pt-spin-inlines.c \
+ pt-cleanup.c \
+ pt-setcancelstate.c \
+ pt-setcanceltype.c \
+ pt-testcancel.c \
+ pt-cancel.c \
+ \
+ pt-mutexattr.c \
+ pt-mutexattr-destroy.c pt-mutexattr-init.c \
+ pt-mutexattr-getprioceiling.c pt-mutexattr-getprotocol.c \
+ pt-mutexattr-getpshared.c pt-mutexattr-gettype.c \
+ pt-mutexattr-setprioceiling.c pt-mutexattr-setprotocol.c \
+ pt-mutexattr-setpshared.c pt-mutexattr-settype.c \
+ \
+ pt-mutex-init.c pt-mutex-destroy.c \
+ pt-mutex-lock.c pt-mutex-trylock.c pt-mutex-timedlock.c \
+ pt-mutex-unlock.c \
+ pt-mutex-getprioceiling.c pt-mutex-setprioceiling.c \
+ \
+ pt-rwlock-attr.c \
+ pt-rwlockattr-init.c pt-rwlockattr-destroy.c \
+ pt-rwlockattr-getpshared.c pt-rwlockattr-setpshared.c \
+ \
+ pt-rwlock-init.c pt-rwlock-destroy.c \
+ pt-rwlock-rdlock.c pt-rwlock-tryrdlock.c \
+ pt-rwlock-trywrlock.c pt-rwlock-wrlock.c \
+ pt-rwlock-timedrdlock.c pt-rwlock-timedwrlock.c \
+ pt-rwlock-unlock.c \
+ \
+ pt-cond.c \
+ pt-condattr-init.c pt-condattr-destroy.c \
+ pt-condattr-getclock.c pt-condattr-getpshared.c \
+ pt-condattr-setclock.c pt-condattr-setpshared.c \
+ \
+ pt-cond-destroy.c pt-cond-init.c \
+ pt-cond-brdcast.c \
+ pt-cond-signal.c \
+ pt-cond-wait.c \
+ pt-cond-timedwait.c \
+ \
+ pt-stack-alloc.c \
+ pt-thread-alloc.c \
+ pt-thread-dealloc.c \
+ pt-thread-start.c \
+ pt-thread-halt.c \
+ \
+ pt-getconcurrency.c pt-setconcurrency.c \
+ \
+ pt-block.c \
+ pt-timedblock.c \
+ pt-wakeup.c \
+ pt-docancel.c \
+ pt-sysdep.c \
+ pt-setup.c \
+ pt-machdep.c \
+ pt-spin.c \
+ \
+ pt-sigstate-init.c \
+ pt-sigstate-destroy.c \
+ pt-sigstate.c \
+ \
+ pt-atfork.c \
+ pt-kill.c \
+ pt-getcpuclockid.c \
+ \
+ pt-getschedparam.c pt-setschedparam.c pt-setschedprio.c \
+ \
+ sem-close.c sem-destroy.c sem-getvalue.c sem-init.c sem-open.c \
+ sem-post.c sem-timedwait.c sem-trywait.c sem-unlink.c \
+ sem-wait.c \
+ \
+ cthreads-compat.c \
+ $(SYSDEPS)
+
+OBJS = $(addsuffix .o,$(basename $(notdir $(SRCS))))
+
+OTHERTAGS =
+
+libname = libpthread
+
+sysdeps_headers = \
+ pthread.h \
+ pthread/pthread.h \
+ pthread/pthreadtypes.h \
+ semaphore.h \
+ \
+ bits/pthread.h \
+ bits/mutex.h \
+ bits/condition.h \
+ bits/condition-attr.h \
+ bits/spin-lock.h \
+ bits/cancelation.h \
+ bits/thread-attr.h \
+ bits/barrier-attr.h \
+ bits/barrier.h \
+ bits/thread-specific.h \
+ bits/once.h \
+ bits/mutex-attr.h \
+ bits/rwlock.h \
+ bits/rwlock-attr.h \
+ bits/semaphore.h
+
+SYSDEP_PATH = $(srcdir)/sysdeps/$(MICROKERNEL)/hurd/i386 \
+ $(srcdir)/sysdeps/$(MICROKERNEL)/i386 \
+ $(srcdir)/sysdeps/$(MICROKERNEL)/hurd \
+ $(srcdir)/sysdeps/$(MICROKERNEL) \
+ $(srcdir)/sysdeps/hurd \
+ $(srcdir)/sysdeps/i386 \
+ $(srcdir)/sysdeps/generic \
+ $(srcdir)/sysdeps/posix \
+ $(srcdir)/pthread \
+ $(srcdir)/include
+
+VPATH += $(SYSDEP_PATH)
+
+HURDLIBS = ihash
+
+installhdrs :=
+installhdrsubdir := .
+
+include ../Makeconf
+
+CPPFLAGS += \
+ $(addprefix -I, $(SYSDEP_PATH)) \
+ -imacros $(srcdir)/include/libc-symbols.h \
+ -imacros $(srcdir)/not-in-libc.h
+
+
+install: install-headers $(libdir)/libpthread2.a $(libdir)/libpthread2_pic.a
+install-headers: $(addprefix $(includedir)/, $(sysdeps_headers))
+
+# XXX: If $(libdir)/libpthread2.a is installed and
+# $(libdir)/libpthread is not, we can have some issues.
+.PHONY: $(libdir)/libpthread.a $(libdir)/libpthread_pic.a
+
+# XXX: These rules are a hack. But it is better than messing with
+# ../Makeconf at the moment. Note that the linker scripts
+# $(srcdir)/libpthread.a and $(srcdir)/libpthread_pic.a get overwritten
+# when building in $(srcdir) and not a seperate build directory.
+$(libdir)/libpthread2.a: $(libdir)/libpthread.a
+ mv $< $@
+ $(INSTALL_DATA) $(srcdir)/libpthread.a $<
+
+$(libdir)/libpthread2_pic.a: $(libdir)/libpthread_pic.a
+ mv $< $@
+ $(INSTALL_DATA) $(srcdir)/libpthread_pic.a $<
+
+.PHONY: $(addprefix $(includedir)/, $(sysdeps_headers))
+
+$(addprefix $(includedir)/, $(sysdeps_headers)):
+ @set -e; \
+ t="$@"; \
+ t=$${t#$(includedir)/}; \
+ header_ok=0; \
+ for dir in $(SYSDEP_PATH); \
+ do \
+ if test -e "$$dir/$$t"; \
+ then \
+ tdir=`dirname "$@"`; \
+ if test ! -e $$tdir; \
+ then \
+ mkdir $$tdir; \
+ fi; \
+ echo $(INSTALL_DATA) "$$dir/$$t" "$@"; \
+ $(INSTALL_DATA) "$$dir/$$t" "$@"; \
+ header_ok=1; \
+ break; \
+ fi; \
+ done; \
+ if test "$${header_ok}" -ne 1; \
+ then \
+ echo; \
+ echo '*** 'The header file \`$@\' is required, but not \
+provided, by; \
+ echo '*** 'this configuration. Please report this to the \
+maintainer.; \
+ echo; \
+ false; \
+ fi
+
+# ifeq ($(VERSIONING),yes)
+#
+# # Adding this dependency gets it included in the command line,
+# # where ld will read it as a linker script.
+# $(libname).so.$(hurd-version): $(srcdir)/$(libname).map
+#
+# endif
diff --git a/libpthread/TODO b/libpthread/TODO
new file mode 100644
index 00000000..45b4cdc2
--- /dev/null
+++ b/libpthread/TODO
@@ -0,0 +1,174 @@
+-*- Mode: outline -*-
+
+* Interfaces
+** All interfaces specified by IEEE Std 1003.1-2001 are present, however,
+ pthread_kill and pthread_sigmask are defined in <pthread.h> and not
+ <signal.h> as they should be. Once we are compiled with glibc,
+ this should be eaiser.
+
+* Test cases. Can never have enough.
+
+* Ports
+ Port to other kernels (e.g. Linux and FreeBSD) and test on other
+ platforms.
+
+* Implementation details
+** pthread_atfork
+ This cannot be implemented without either changing glibc to export
+ some hooks (c.f. libc/sysdeps/mach/hurd/fork.c) or by providing a
+ custom fork implementation that wraps the origial using dlopen et
+ al.
+
+** Scheduling and priorities
+
+ We do not support scheduling right now in any way what so ever.
+
+ This affects:
+ pthread_attr_getinheritsched
+ pthread_attr_setinheritsched
+ pthread_attr_getschedparam
+ pthread_attr_setschedparam
+ pthread_attr_getschedpolicy
+ pthread_attr_setschedpolicy
+ pthread_attr_getscope
+ pthread_attr_setscope
+
+ pthread_mutexattr_getprioceiling
+ pthread_mutexattr_setprioceiling
+ pthread_mutexattr_getprotocol
+ pthread_mutexattr_setprotocol
+ pthread_mutex_getprioceiling
+ pthread_mutex_setprioceiling
+
+ pthread_setschedprio
+ pthread_getschedparam
+ pthread_setschedparam
+
+** Alternate stacks
+
+ Supporting alternate stacks (via pthread_attr_getstackaddr,
+ pthread_attr_setstackaddr, pthread_attr_getstack,
+ pthread_attr_setstack, pthread_attr_getstacksize and
+ pthread_attr_setstacksize) is no problem as long as they are of the
+ correct size and have the correct alignment. This is due to
+ limitations in the Hurd TSD implementation
+ (c.f. <hurd/threadvar.h>).
+
+** Cancelation
+*** Cancelation points
+ The only cancelation points are pthread_join, pthread_cond_wait,
+ pthead_cond_timedwait and pthread_testcancel. Need to explore if
+ the hurd_sigstate->cancel_hook (c.f. <hurd/signal.h>) provides the
+ desired semantics. If not, must either wrap the some functions
+ using dlsym or wait until integration with glibc.
+*** Async cancelation
+ We inject a new IP into the cancelled (running) thread and then
+ run the cancelation handlers
+ (c.f. sysdeps/mach/hurd/pt-docancel.c). The handlers need to have
+ access to the stack as they may use local variables. I think that
+ this method may leave the frame pointer in a corrupted state if
+ the thread was in, for instance, the middle of a function call.
+ The robustness needs to be confirmed.
+
+** Process Shared Attribute
+
+ Currently, there is no real support for the process shared
+ attribute. spinlocks work because we just use a test and set loop,
+ however, barriers, conditions mutexes and rwlocks, however, signal
+ wakeups via ports of which the names are process local.
+
+ We could have some process local data that is hashed to via the
+ address of the data structure. Then the first thread that blocks
+ per process would spin on the shared memory area and all others
+ would then block as normal. When the resource became available,
+ the first thread would signal the other local threads as necessary.
+ Alternatively, there could be some server, however, this opens a
+ new question: what can we use as an authentication agent.
+
+** Locking algorithm
+
+ When a thread blocks, it puts itself on a queue and then waits for
+ a message on a thread local port. The thread which eventually does
+ the wakeup sends a message to the waiter thereby waking it up. If
+ the wakeup is a broadcast wakeup (e.g. pthread_cond_broadcast,
+ pthread_barrier_wait and pthread_rdlock_unlock), the thread must
+ send O(N) messages where N is the number of waiting threads. If
+ all the threads instead received on a lock local (rather than
+ thread local) port then the thread which eventually does the wake
+ need just do one operation, mach_port_destroy and all of the
+ waiting threads would wakeup and get MACH_RCV_PORT_DIED back from
+ mach_msg. Note that the trade off is that the port must be
+ recreated. This needs to be benchmarked.
+
+ A possible problem with this is scheduling priorities. There may
+ be a preference for certain threads to wakeup before others
+ (especially if we are not doing a broadcast, for instance,
+ pthread_mutex_unlock and pthread_cond_signal). If we take this
+ approach, the kernel chooses which threads are awakened. If we
+ find that the kernel makes the wrong choices, we can still overcome
+ this by merging the two algorithms: have a list of ports sorted in
+ priority order and the waker does a mach_port_destroy on each as
+ appropriate.
+
+** Barriers
+
+ Barriers can be very slow and the contention can be very high. The
+ above algorithm is very appealing, however, this may be augmented
+ with an initial number of spins and yields. It is expected that
+ all of the threads reach the barrier within close succession, thus
+ queuing a message may be more expensive. This needs to be
+ benchmarked.
+
+** Clocks
+*** pthread_condattr_setclock allows a process to specify a clock for
+ use with pthread_cond_timedwaits. What is the correct default for
+ this, right now, we use CLOCK_REALTIME, however, we are really
+ using the system clock which, if I understand correctly, is
+ completely different.
+*** Could we even use other clocks? mach_msg uses a relative time against
+ the system clock.
+*** pthread_getcpuclockid just returns CLOCK_THREAD_CPUTIME_ID if defined.
+ Is this the correct behavior?
+
+** Timed Blocking
+*** pthread_cond_timedwait, pthead_mutex_timedlock, pthread_rwlock_timedrdlock
+ and pthread_rwlock_timedwrlock all take absolute times. We need
+ to convert them to relative times for mach_msg. Is there a way
+ around this? How will clock skew affect us?
+
+** weak aliases
+ Use them consistently and correctly and start by reading
+ http://sources.redhat.com/ml/libc-alpha/2002-08/msg00278.html.
+
+* L4 Specific Issues
+** Stack
+*** Size
+ The stack size is defined to be a single page in
+ sysdeps/l4/hurd/pt-sysdep.h. Once we are able to setup regions,
+ this can be expanded to two megs as suggested by the Mach version.
+ Until then, however, we need to allocate too much physical memory.
+*** Deallocation
+ __thread_stack_dealloc currently does not deallocate the stack.
+ For a proper implementation, we need a working memory manager.
+
+** Scheduling
+*** yield
+ [L4] We cannot use yield for spin locks as L4 only yields to threads of
+ priority which are greater than or equal to the yielding thread.
+ If there are threads of lower priority, they are not considered;
+ the yielding thread is just placed back on the processor. This
+ introduces priority inversion quite quickly. L4 will not add a
+ priority suppression function call. As such, we need to do
+ an ipc with a small time out and then use exponential back off to
+ do the actual waiting. This sucks.
+
+** Stub code
+ [L4] We include <task_client.h> in pt-start.c, however, we need a library
+ so we do not have to play with the corba stuff.
+
+** Root server and Task server
+*** Getting the tids.
+ pt-start.c has a wonderfully evil hack that will never work well.
+
+** Paging
+ We set the pager to the root server. Evil. Fix this in pt-start.c.
diff --git a/libpthread/include/CVS/Entries b/libpthread/include/CVS/Entries
new file mode 100644
index 00000000..81b10d25
--- /dev/null
+++ b/libpthread/include/CVS/Entries
@@ -0,0 +1,5 @@
+/libc-symbols.h/1.3/Tue Jul 1 11:43:14 2008//Tzhengda-soc2008-virt-branch
+/pthread.h/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/semaphore.h/1.4/Tue Jul 1 11:43:14 2008//Tzhengda-soc2008-virt-branch
+/set-hooks.h/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+D/pthread////
diff --git a/libpthread/include/CVS/Repository b/libpthread/include/CVS/Repository
new file mode 100644
index 00000000..ac2ebb46
--- /dev/null
+++ b/libpthread/include/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/include
diff --git a/libpthread/include/CVS/Root b/libpthread/include/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/include/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/include/CVS/Tag b/libpthread/include/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/include/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/include/libc-symbols.h b/libpthread/include/libc-symbols.h
new file mode 100644
index 00000000..54dd6e26
--- /dev/null
+++ b/libpthread/include/libc-symbols.h
@@ -0,0 +1,395 @@
+/* Support macros for making weak and strong aliases for symbols,
+ and for using symbol sets and linker warnings with GNU ld.
+ Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2008
+ 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 _LIBC_SYMBOLS_H
+#define _LIBC_SYMBOLS_H 1
+
+/* This file's macros are included implicitly in the compilation of every
+ file in the C library by -imacros.
+
+ We include config.h which is generated by configure.
+ It should define for us the following symbols:
+
+ * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
+ * ASM_GLOBAL_DIRECTIVE with `.globl' or `.global'.
+ * HAVE_GNU_LD if using GNU ld, with support for weak symbols in a.out,
+ and for symbol set and warning messages extensions in a.out and ELF.
+ * HAVE_ELF if using ELF, which supports weak symbols using `.weak'.
+ * HAVE_ASM_WEAK_DIRECTIVE if we have weak symbols using `.weak'.
+ * HAVE_ASM_WEAKEXT_DIRECTIVE if we have weak symbols using `.weakext'.
+
+ */
+
+/* This is defined for the compilation of all C library code. features.h
+ tests this to avoid inclusion of stubs.h while compiling the library,
+ before stubs.h has been generated. Some library code that is shared
+ with other packages also tests this symbol to see if it is being
+ compiled as part of the C library. We must define this before including
+ config.h, because it makes some definitions conditional on whether libc
+ itself is being compiled, or just some generator program. */
+// #define _LIBC 1
+
+/* Enable declarations of GNU extensions, since we are compiling them. */
+#define _GNU_SOURCE 1
+/* And we also need the data for the reentrant functions. */
+#define _REENTRANT 1
+
+// #include <config.h>
+#define HAVE_ASM_WEAK_DIRECTIVE
+#define HAVE_WEAK_SYMBOLS
+#define HAVE_ASM_SET_DIRECTIVE
+#define HAVE_BUILTIN_EXPECT
+#define HAVE_GNU_LD
+#define HAVE_ELF
+#define HAVE_SECTION_QUOTES
+#define HAVE_VISIBILITY_ATTRIBUTE
+#define HAVE_ASM_PREVIOUS_DIRECTIVE
+// #define SHARED
+
+/* The symbols in all the user (non-_) macros are C symbols.
+ HAVE_GNU_LD without HAVE_ELF implies a.out. */
+
+#if defined HAVE_ASM_WEAK_DIRECTIVE || defined HAVE_ASM_WEAKEXT_DIRECTIVE
+# define HAVE_WEAK_SYMBOLS
+#endif
+
+#ifndef __SYMBOL_PREFIX
+# ifdef NO_UNDERSCORES
+# define __SYMBOL_PREFIX
+# else
+# define __SYMBOL_PREFIX "_"
+# endif
+#endif
+
+#ifndef C_SYMBOL_NAME
+# ifdef NO_UNDERSCORES
+# define C_SYMBOL_NAME(name) name
+# else
+# define C_SYMBOL_NAME(name) _##name
+# endif
+#endif
+
+#ifndef ASM_LINE_SEP
+# define ASM_LINE_SEP ;
+#endif
+
+#ifndef C_SYMBOL_DOT_NAME
+# define C_SYMBOL_DOT_NAME(name) .##name
+#endif
+
+#ifndef __ASSEMBLER__
+/* GCC understands weak symbols and aliases; use its interface where
+ possible, instead of embedded assembly language. */
+
+/* Define ALIASNAME as a strong alias for NAME. */
+# define strong_alias(name, aliasname) _strong_alias(name, aliasname)
+# define _strong_alias(name, aliasname) \
+ extern __typeof (name) aliasname __attribute__ ((alias (#name)));
+
+/* This comes between the return type and function name in
+ a function definition to make that definition weak. */
+# define weak_function __attribute__ ((weak))
+# define weak_const_function __attribute__ ((weak, __const__))
+
+# ifdef HAVE_WEAK_SYMBOLS
+
+/* Define ALIASNAME as a weak alias for NAME.
+ If weak aliases are not available, this defines a strong alias. */
+# define weak_alias(name, aliasname) _weak_alias (name, aliasname)
+# define _weak_alias(name, aliasname) \
+ extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
+
+/* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */
+# define weak_extern(symbol) _weak_extern (symbol)
+# ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
+# define _weak_extern(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
+# else
+# define _weak_extern(symbol) asm (".weak " __SYMBOL_PREFIX #symbol);
+# endif
+
+# else
+
+# define weak_alias(name, aliasname) strong_alias(name, aliasname)
+# define weak_extern(symbol) /* Nothing. */
+
+# endif
+
+#else /* __ASSEMBLER__ */
+
+# ifdef HAVE_ASM_SET_DIRECTIVE
+# define strong_alias(original, alias) \
+ ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
+ .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
+# else
+# ifdef HAVE_ASM_GLOBAL_DOT_NAME
+# define strong_alias(original, alias) \
+ ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
+ C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
+ ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
+ C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
+# else
+# define strong_alias(original, alias) \
+ ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
+ C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
+# endif
+# endif
+
+# ifdef HAVE_WEAK_SYMBOLS
+# ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
+# define weak_alias(original, alias) \
+ .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
+# define weak_extern(symbol) \
+ .weakext C_SYMBOL_NAME (symbol)
+
+# else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
+
+# ifdef HAVE_ASM_GLOBAL_DOT_NAME
+# define weak_alias(original, alias) \
+ .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
+ C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
+ ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
+ C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
+# else
+# define weak_alias(original, alias) \
+ .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
+ C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
+# endif
+
+# define weak_extern(symbol) \
+ .weak C_SYMBOL_NAME (symbol)
+
+# endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
+
+# else /* ! HAVE_WEAK_SYMBOLS */
+
+# define weak_alias(original, alias) strong_alias(original, alias)
+# define weak_extern(symbol) /* Nothing */
+# endif /* ! HAVE_WEAK_SYMBOLS */
+
+#endif /* __ASSEMBLER__ */
+
+/* On some platforms we can make internal function calls (i.e., calls of
+ functions not exported) a bit faster by using a different calling
+ convention. */
+#ifndef internal_function
+# define internal_function /* empty */
+#endif
+
+/* Prepare for the case that `__builtin_expect' is not available. */
+#ifndef HAVE_BUILTIN_EXPECT
+# define __builtin_expect(expr, val) (expr)
+#endif
+
+/* Determine the return address. */
+#define RETURN_ADDRESS(nr) \
+ __builtin_extract_return_addr (__builtin_return_address (nr))
+
+/* When a reference to SYMBOL is encountered, the linker will emit a
+ warning message MSG. */
+#ifdef HAVE_GNU_LD
+# ifdef HAVE_ELF
+
+/* We want the .gnu.warning.SYMBOL section to be unallocated. */
+# ifdef HAVE_ASM_PREVIOUS_DIRECTIVE
+# define __make_section_unallocated(section_string) \
+ asm (".section " section_string "\n\t.previous");
+# elif defined HAVE_ASM_POPSECTION_DIRECTIVE
+# define __make_section_unallocated(section_string) \
+ asm (".pushsection " section_string "\n\t.popsection");
+# else
+# define __make_section_unallocated(section_string)
+# endif
+
+/* Tacking on "\n\t#" to the section name makes gcc put it's bogus
+ section attributes on what looks like a comment to the assembler. */
+# ifdef HAVE_SECTION_QUOTES
+# define link_warning(symbol, msg) \
+ __make_section_unallocated (".gnu.warning." #symbol) \
+ static const char __evoke_link_warning_##symbol[] \
+ __attribute__ ((unused, section (".gnu.warning." #symbol "\"\n\t#\""))) \
+ = msg;
+# else
+# define link_warning(symbol, msg) \
+ __make_section_unallocated (".gnu.warning." #symbol) \
+ static const char __evoke_link_warning_##symbol[] \
+ __attribute__ ((unused, section (".gnu.warning." #symbol "\n\t#"))) = msg;
+# endif
+# else /* Not ELF: a.out */
+# ifdef HAVE_XCOFF
+/* XCOFF does not support .stabs.
+ The native aix linker will remove the .stab and .stabstr sections
+ The gnu linker will have a fatal error if there is a relocation for
+ symbol in the .stab section. Silently disable this macro. */
+# define link_warning(symbol, msg)
+# else
+# define link_warning(symbol, msg) \
+ asm (".stabs \"" msg "\",30,0,0,0\n\t" \
+ ".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0\n");
+# endif /* XCOFF */
+# endif
+#else
+/* We will never be heard; they will all die horribly. */
+# define link_warning(symbol, msg)
+#endif
+
+/* A canned warning for sysdeps/stub functions. */
+#define stub_warning(name) \
+ link_warning (name, \
+ "warning: " #name " is not implemented and will always fail")
+
+/*
+
+*/
+
+#ifdef HAVE_GNU_LD
+
+/* Symbol set support macros. */
+
+# ifdef HAVE_ELF
+
+/* Make SYMBOL, which is in the text segment, an element of SET. */
+# define text_set_element(set, symbol) _elf_set_element(set, symbol)
+/* Make SYMBOL, which is in the data segment, an element of SET. */
+# define data_set_element(set, symbol) _elf_set_element(set, symbol)
+/* Make SYMBOL, which is in the bss segment, an element of SET. */
+# define bss_set_element(set, symbol) _elf_set_element(set, symbol)
+
+/* These are all done the same way in ELF.
+ There is a new section created for each set. */
+# ifdef SHARED
+/* When building a shared library, make the set section writable,
+ because it will need to be relocated at run time anyway. */
+# define _elf_set_element(set, symbol) \
+ static const void *__elf_set_##set##_element_##symbol##__ \
+ __attribute__ ((unused, section (#set))) = &(symbol)
+# else
+# define _elf_set_element(set, symbol) \
+ static const void *const __elf_set_##set##_element_##symbol##__ \
+ __attribute__ ((unused, section (#set))) = &(symbol)
+# endif
+
+/* Define SET as a symbol set. This may be required (it is in a.out) to
+ be able to use the set's contents. */
+# define symbol_set_define(set) symbol_set_declare(set)
+
+/* Declare SET for use in this module, if defined in another module. */
+# define symbol_set_declare(set) \
+ extern void *const __start_##set __attribute__ ((__weak__)); \
+ extern void *const __stop_##set __attribute__ ((__weak__)); \
+ weak_extern (__start_##set) weak_extern (__stop_##set)
+
+/* Return a pointer (void *const *) to the first element of SET. */
+# define symbol_set_first_element(set) (&__start_##set)
+
+/* Return true iff PTR (a void *const *) has been incremented
+ past the last element in SET. */
+# define symbol_set_end_p(set, ptr) ((ptr) >= &__stop_##set)
+
+# else /* Not ELF: a.out. */
+
+# ifdef HAVE_XCOFF
+/* XCOFF does not support .stabs.
+ The native aix linker will remove the .stab and .stabstr sections
+ The gnu linker will have a fatal error if there is a relocation for
+ symbol in the .stab section. Silently disable these macros. */
+# define text_set_element(set, symbol)
+# define data_set_element(set, symbol)
+# define bss_set_element(set, symbol)
+# else
+# define text_set_element(set, symbol) \
+ asm (".stabs \"" __SYMBOL_PREFIX #set "\",23,0,0," __SYMBOL_PREFIX #symbol)
+# define data_set_element(set, symbol) \
+ asm (".stabs \"" __SYMBOL_PREFIX #set "\",25,0,0," __SYMBOL_PREFIX #symbol)
+# define bss_set_element(set, symbol) ?error Must use initialized data.
+# endif /* XCOFF */
+# define symbol_set_define(set) void *const (set)[1];
+# define symbol_set_declare(set) extern void *const (set)[1];
+
+# define symbol_set_first_element(set) &(set)[1]
+# define symbol_set_end_p(set, ptr) (*(ptr) == 0)
+
+# endif /* ELF. */
+#else
+/* We cannot do anything in generial. */
+# define text_set_element(set, symbol) asm ("")
+# define data_set_element(set, symbol) asm ("")
+# define bss_set_element(set, symbol) asm ("")
+# define symbol_set_define(set) void *const (set)[1];
+# define symbol_set_declare(set) extern void *const (set)[1];
+
+# define symbol_set_first_element(set) &(set)[1]
+# define symbol_set_end_p(set, ptr) (*(ptr) == 0)
+#endif /* Have GNU ld. */
+
+#if DO_VERSIONING
+# define symbol_version(real, name, version) \
+ _symbol_version(real, name, version)
+# define default_symbol_version(real, name, version) \
+ _default_symbol_version(real, name, version)
+# ifdef __ASSEMBLER__
+# define _symbol_version(real, name, version) \
+ .symver real, name##@##version
+# define _default_symbol_version(real, name, version) \
+ .symver real, name##@##@##version
+# else
+# define _symbol_version(real, name, version) \
+ __asm__ (".symver " #real "," #name "@" #version)
+# define _default_symbol_version(real, name, version) \
+ __asm__ (".symver " #real "," #name "@@" #version)
+# endif
+#else
+# define symbol_version(real, name, version)
+# define default_symbol_version(real, name, version) \
+ strong_alias(real, name)
+#endif
+
+#if defined HAVE_VISIBILITY_ATTRIBUTE && defined SHARED
+# define attribute_hidden __attribute__ ((visibility ("hidden")))
+#else
+# define attribute_hidden
+#endif
+
+/* Handling on non-exported internal names. We have to do this only
+ for shared code. */
+#ifdef SHARED
+# define INTUSE(name) name##_internal
+# define INTDEF(name) strong_alias (name, name##_internal)
+# define INTVARDEF(name) \
+ _INTVARDEF (name, name##_internal)
+# if defined HAVE_VISIBILITY_ATTRIBUTE
+# define _INTVARDEF(name, aliasname) \
+ extern __typeof (name) aliasname __attribute__ ((alias (#name), \
+ visibility ("hidden")));
+# else
+# define _INTVARDEF(name, aliasname) \
+ extern __typeof (name) aliasname __attribute__ ((alias (#name)));
+# endif
+# define INTDEF2(name, newname) strong_alias (name, newname##_internal)
+# define INTVARDEF2(name, newname) _INTVARDEF (name, newname##_internal)
+#else
+# define INTUSE(name) name
+# define INTDEF(name)
+# define INTVARDEF(name)
+# define INTDEF2(name, newname)
+# define INTVARDEF2(name, newname)
+#endif
+
+#endif /* libc-symbols.h */
diff --git a/libpthread/include/pthread.h b/libpthread/include/pthread.h
new file mode 100644
index 00000000..1d4d3c7b
--- /dev/null
+++ b/libpthread/include/pthread.h
@@ -0,0 +1,7 @@
+#ifndef _PTHREAD_H
+#include <pthread/pthread.h>
+
+extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
+extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
+
+#endif
diff --git a/libpthread/include/pthread/CVS/Entries b/libpthread/include/pthread/CVS/Entries
new file mode 100644
index 00000000..df89a261
--- /dev/null
+++ b/libpthread/include/pthread/CVS/Entries
@@ -0,0 +1,3 @@
+/pthread.h/1.13/Tue Jul 1 11:43:14 2008//Tzhengda-soc2008-virt-branch
+/pthreadtypes.h/1.2/Tue Jul 1 11:43:14 2008//Tzhengda-soc2008-virt-branch
+D
diff --git a/libpthread/include/pthread/CVS/Repository b/libpthread/include/pthread/CVS/Repository
new file mode 100644
index 00000000..551cc7d1
--- /dev/null
+++ b/libpthread/include/pthread/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/include/pthread
diff --git a/libpthread/include/pthread/CVS/Root b/libpthread/include/pthread/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/include/pthread/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/include/pthread/CVS/Tag b/libpthread/include/pthread/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/include/pthread/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/include/pthread/pthread.h b/libpthread/include/pthread/pthread.h
new file mode 100644
index 00000000..ba9c7dc2
--- /dev/null
+++ b/libpthread/include/pthread/pthread.h
@@ -0,0 +1,704 @@
+/* Copyright (C) 2000, 2002, 2005, 2006, 2007, 2008
+ 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. */
+
+/*
+ * POSIX Threads Extension: ??? <pthread.h>
+ */
+
+#ifndef _PTHREAD_H
+#define _PTHREAD_H 1
+
+#include <features.h>
+
+#include <sched.h>
+
+__BEGIN_DECLS
+
+#include <pthread/pthreadtypes.h>
+
+#include <bits/pthread.h>
+
+/* Possible values for the process shared attribute. */
+#define PTHREAD_PROCESS_PRIVATE __PTHREAD_PROCESS_PRIVATE
+#define PTHREAD_PROCESS_SHARED __PTHREAD_PROCESS_SHARED
+
+
+/* Thread attributes. */
+
+/* Possible values for the inheritsched attribute. */
+#define PTHREAD_EXPLICIT_SCHED __PTHREAD_EXPLICIT_SCHED
+#define PTHREAD_INHERIT_SCHED __PTHREAD_INHERIT_SCHED
+
+/* Possible values for the `contentionscope' attribute. */
+#define PTHREAD_SCOPE_SYSTEM __PTHREAD_SCOPE_SYSTEM
+#define PTHREAD_SCOPE_PROCESS __PTHREAD_SCOPE_PROCESS
+
+/* Possible values for the `detachstate' attribute. */
+#define PTHREAD_CREATE_JOINABLE __PTHREAD_CREATE_JOINABLE
+#define PTHREAD_CREATE_DETACHED __PTHREAD_CREATE_DETACHED
+
+#include <bits/thread-attr.h>
+
+/* Initialize the thread attribute object in *ATTR to the default
+ values. */
+extern int pthread_attr_init (pthread_attr_t *attr);
+
+/* Destroy the thread attribute object in *ATTR. */
+extern int pthread_attr_destroy (pthread_attr_t *attr);
+
+
+/* Return the value of the inheritsched attribute in *ATTR in
+ *INHERITSCHED. */
+extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict attr,
+ int *__restrict inheritsched);
+
+/* Set the value of the inheritsched attribute in *ATTR to
+ INHERITSCHED. */
+extern int pthread_attr_setinheritsched (pthread_attr_t *attr,
+ int inheritsched);
+
+
+/* Return the value of the schedparam attribute in *ATTR in *PARAM. */
+extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict attr,
+ struct sched_param *__restrict param);
+
+/* Set the value of the schedparam attribute in *ATTR to PARAM. */
+extern int pthread_attr_setschedparam (pthread_attr_t *__restrict attr,
+ const struct sched_param *__restrict param);
+
+
+/* Return the value of the schedpolicy attribute in *ATTR to *POLICY. */
+extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict attr,
+ int *__restrict policy);
+
+/* Set the value of the schedpolicy attribute in *ATTR to POLICY. */
+extern int pthread_attr_setschedpolicy (pthread_attr_t *attr,
+ int policy);
+
+
+/* Return the value of the contentionscope attribute in *ATTR in
+ *CONTENTIONSCOPE. */
+extern int pthread_attr_getscope (const pthread_attr_t *__restrict attr,
+ int *__restrict contentionscope);
+
+/* Set the value of the contentionscope attribute in *ATTR to
+ CONTENTIONSCOPE. */
+extern int pthread_attr_setscope (pthread_attr_t *attr,
+ int contentionscope);
+
+
+/* Return the value of the stackaddr attribute in *ATTR in
+ *STACKADDR. */
+extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict attr,
+ void **__restrict stackaddr);
+
+/* Set the value of the stackaddr attribute in *ATTR to STACKADDR. */
+extern int pthread_attr_setstackaddr (pthread_attr_t *attr,
+ void *stackaddr);
+
+
+#ifdef __USE_XOPEN2K
+/* Return the value of the stackaddr and stacksize attributes in *ATTR
+ in *STACKADDR and *STACKSIZE respectively. */
+extern int pthread_attr_getstack (const pthread_attr_t *__restrict attr,
+ void **__restrict stackaddr,
+ size_t *__restrict stacksize);
+
+/* Set the value of the stackaddr and stacksize attributes in *ATTR to
+ STACKADDR and STACKSIZE respectively. */
+extern int pthread_attr_setstack (pthread_attr_t *attr,
+ void *stackaddr,
+ size_t stacksize);
+#endif
+
+
+/* Return the value of the detachstate attribute in *ATTR in
+ *DETACHSTATE. */
+extern int pthread_attr_getdetachstate (const pthread_attr_t *attr,
+ int *detachstate);
+
+/* Set the value of the detachstate attribute in *ATTR to
+ DETACHSTATE. */
+extern int pthread_attr_setdetachstate (pthread_attr_t *attr,
+ int detachstate);
+
+
+/* Return the value of the guardsize attribute in *ATTR in
+ *GUARDSIZE. */
+extern int pthread_attr_getguardsize (const pthread_attr_t *__restrict attr,
+ size_t *__restrict guardsize);
+
+/* Set the value of the guardsize attribute in *ATTR to GUARDSIZE. */
+extern int pthread_attr_setguardsize (pthread_attr_t *attr,
+ size_t guardsize);
+
+
+/* Return the value of the stacksize attribute in *ATTR in
+ *STACKSIZE. */
+extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict attr,
+ size_t *__restrict stacksize);
+
+/* Set the value of the stacksize attribute in *ATTR to STACKSIZE. */
+extern int pthread_attr_setstacksize (pthread_attr_t *attr,
+ size_t stacksize);
+
+#ifdef __USE_GNU
+/* Initialize thread attribute *ATTR with attributes corresponding to the
+ already running thread THREAD. It shall be called on an uninitialized ATTR
+ and destroyed with pthread_attr_destroy when no longer needed. */
+extern int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr);
+#endif
+
+
+/* Create a thread with attributes given by ATTR, executing
+ START_ROUTINE with argument ARG. */
+extern int pthread_create (pthread_t *__restrict __threadp,
+ __const pthread_attr_t *__restrict __attr,
+ void *(*__start_routine)(void *),
+ void *__restrict __arg);
+
+/* Terminate the current thread and make STATUS available to any
+ thread that might join us. */
+extern void pthread_exit (void *__status) __attribute__ ((noreturn));
+
+/* Make calling thread wait for termination of thread THREAD. Return
+ the exit status of the thread in *STATUS. */
+extern int pthread_join (pthread_t __threadp, void **__status);
+
+/* Indicate that the storage for THREAD can be reclaimed when it
+ terminates. */
+extern int pthread_detach (pthread_t __threadp);
+
+/* Compare thread IDs T1 and T2. Return nonzero if they are equal, 0
+ if they are not. */
+extern int pthread_equal (pthread_t __t1, pthread_t __t2);
+
+# ifdef __USE_EXTERN_INLINES
+
+__extern_inline int
+pthread_equal (pthread_t __t1, pthread_t __t2)
+{
+ return __pthread_equal (__t1, __t2);
+}
+
+# endif /* Use extern inlines. */
+
+
+/* Return the thread ID of the calling thread. */
+extern pthread_t pthread_self (void);
+
+
+/* Mutex attributes. */
+
+#define PTHREAD_PRIO_NONE_NP __PTHREAD_PRIO_NONE
+#define PTHREAD_PRIO_INHERIT_NP __PTHREAD_PRIO_INHERIT
+#define PTHREAD_PRIO_PROTECT_NP __PTHREAD_PRIO_PROTECT
+#ifdef __USE_UNIX98
+#define PTHREAD_PRIO_NONE PTHREAD_PRIO_NONE_NP
+#define PTHREAD_PRIO_INHERIT PTHREAD_PRIO_INHERIT_NP
+#define PTHREAD_PRIO_PROTECT PTHREAD_PRIO_PROTECT_NP
+#endif
+
+#define PTHREAD_MUTEX_TIMED_NP __PTHREAD_MUTEX_TIMED
+#define PTHREAD_MUTEX_ERRORCHECK_NP __PTHREAD_MUTEX_ERRORCHECK
+#define PTHREAD_MUTEX_RECURSIVE_NP __PTHREAD_MUTEX_RECURSIVE
+#ifdef __USE_UNIX98
+#define PTHREAD_MUTEX_NORMAL PTHREAD_MUTEX_TIMED_NP
+#define PTHREAD_MUTEX_ERRORCHECK PTHREAD_MUTEX_ERRORCHECK_NP
+#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP
+#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL
+#endif
+#ifdef __USE_GNU
+/* For compatibility. */
+#define PTHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_TIMED_NP
+#endif
+
+#include <bits/mutex-attr.h>
+
+/* Initialize the mutex attribute object in *ATTR to the default
+ values. */
+extern int pthread_mutexattr_init(pthread_mutexattr_t *attr);
+
+/* Destroy the mutex attribute structure in *ATTR. */
+extern int pthread_mutexattr_destroy(pthread_mutexattr_t *attr);
+
+
+#ifdef __USE_UNIX98
+/* Return the value of the prioceiling attribute in *ATTR in
+ *PRIOCEILING. */
+extern int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *__restrict attr,
+ int *__restrict prioceiling);
+
+/* Set the value of the prioceiling attribute in *ATTR to
+ PRIOCEILING. */
+extern int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr,
+ int prioceiling);
+
+
+/* Return the value of the protocol attribute in *ATTR in
+ *PROTOCOL. */
+extern int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *__restrict attr,
+ int *__restrict protocol);
+
+/* Set the value of the protocol attribute in *ATTR to PROTOCOL. */
+extern int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr,
+ int protocol);
+#endif
+
+
+/* Return the value of the process shared attribute in *ATTR in
+ *PSHARED. */
+extern int pthread_mutexattr_getpshared(const pthread_mutexattr_t *__restrict attr,
+ int *__restrict pshared);
+
+/* Set the value of the process shared attribute in *ATTR to
+ PSHARED. */
+extern int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr,
+ int pshared);
+
+
+#ifdef __USE_UNIX98
+/* Return the value of the type attribute in *ATTR in *TYPE. */
+extern int pthread_mutexattr_gettype(const pthread_mutexattr_t *__restrict attr,
+ int *__restrict type);
+
+/* Set the value of the type attribute in *ATTR to TYPE. */
+extern int pthread_mutexattr_settype(pthread_mutexattr_t *attr,
+ int type);
+#endif
+
+
+/* Mutexes. */
+
+#include <bits/mutex.h>
+
+#define PTHREAD_MUTEX_INITIALIZER __PTHREAD_MUTEX_INITIALIZER
+
+/* Create a mutex with attributes given by ATTR and store it in
+ *__MUTEX. */
+extern int pthread_mutex_init (struct __pthread_mutex *__restrict __mutex,
+ const pthread_mutexattr_t *__restrict attr);
+
+/* Destroy the mutex __MUTEX. */
+extern int pthread_mutex_destroy (struct __pthread_mutex *__mutex);
+
+/* Wait until lock for MUTEX becomes available and lock it. */
+extern int pthread_mutex_lock (pthread_mutex_t *__mutex);
+
+/* Try to lock MUTEX. */
+extern int pthread_mutex_trylock (pthread_mutex_t *__mutex);
+
+#ifdef __USE_XOPEN2K
+/* Try to lock MUTEX, block until *ABSTIME if it is already held. */
+extern int pthread_mutex_timedlock (struct __pthread_mutex *__restrict mutex,
+ const struct timespec *__restrict abstime);
+#endif
+
+/* Unlock MUTEX. */
+extern int pthread_mutex_unlock (pthread_mutex_t *__mutex);
+
+
+#ifdef __USE_UNIX98
+/* Return the priority ceiling of mutex *MUTEX in *PRIOCEILING. */
+extern int pthread_mutex_getprioceiling (const pthread_mutex_t *__restrict mutex,
+ int *__restrict prioceiling);
+
+/* After acquiring the mutex *MUTEX, set its priority ceiling to PRIO
+ and return the old priority ceiling in *OLDPRIO. Before returning,
+ release the mutex. */
+extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict mutex,
+ int prio, int *__restrict oldprio);
+#endif
+
+
+
+/* Condition attributes. */
+
+#include <bits/condition-attr.h>
+
+/* Initialize the condition attribute in *ATTR to the default
+ values. */
+extern int pthread_condattr_init (pthread_condattr_t *attr);
+
+/* Destroy the condition attribute structure in *ATTR. */
+extern int pthread_condattr_destroy (pthread_condattr_t *attr);
+
+
+#ifdef __USE_XOPEN2K
+/* Return the value of the clock attribute in *ATTR in *CLOCK_ID. */
+extern int pthread_condattr_getclock (const pthread_condattr_t *__restrict attr,
+ clockid_t *__restrict clock_id);
+
+/* Set the value of the clock attribute in *ATTR to CLOCK_ID. */
+extern int pthread_condattr_setclock (pthread_condattr_t *attr,
+ clockid_t clock_id);
+#endif
+
+
+/* Return the value of the process shared attribute in *ATTR in
+ *PSHARED. */
+extern int pthread_condattr_getpshared (const pthread_condattr_t *__restrict attr,
+ int *__restrict pshared);
+
+/* Set the value of the process shared attribute in *ATTR to
+ PSHARED. */
+extern int pthread_condattr_setpshared (pthread_condattr_t *attr,
+ int pshared);
+
+
+/* Condition variables. */
+
+#include <bits/condition.h>
+
+#define PTHREAD_COND_INITIALIZER __PTHREAD_COND_INITIALIZER
+
+extern int pthread_cond_init (pthread_cond_t *__restrict cond,
+ const pthread_condattr_t *__restrict attr);
+
+extern int pthread_cond_destroy (pthread_cond_t *cond);
+
+/* Unblock at least one of the threads that are blocked on condition
+ variable COND. */
+extern int pthread_cond_signal (pthread_cond_t *__cond);
+
+/* Unblock all threads that are blocked on condition variable COND. */
+extern int pthread_cond_broadcast (pthread_cond_t *__cond);
+
+/* Block on condition variable COND. MUTEX should be held by the
+ calling thread. On success, MUTEX will be held by the calling
+ thread. */
+extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
+ pthread_mutex_t *__restrict __mutex);
+
+/* Block on condition variable COND. MUTEX should be held by the
+ calling thread. On success, MUTEX will be held by the calling
+ thread. If the time specified by ABSTIME passes, ETIMEDOUT is
+ returned, and MUTEX will nevertheless be held. */
+extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
+ pthread_mutex_t *__restrict __mutex,
+ __const struct timespec *__restrict __abstime);
+
+
+/* Spin locks. */
+
+#ifdef __USE_XOPEN2K
+
+# include <bits/spin-lock.h>
+
+#define PTHREAD_SPINLOCK_INITIALIZER __SPIN_LOCK_INITIALIZER
+
+/* Destroy the spin lock object LOCK. */
+extern int pthread_spin_destroy (pthread_spinlock_t *__lock);
+
+/* Initialize the spin lock object LOCK. PSHARED determines whether
+ the spin lock can be operated upon by multiple processes. */
+extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared);
+
+/* Lock the spin lock object LOCK. If the lock is held by another
+ thread spin until it becomes available. */
+extern int pthread_spin_lock (pthread_spinlock_t *__lock);
+
+/* Lock the spin lock object LOCK. Fail if the lock is held by
+ another thread. */
+extern int pthread_spin_trylock (pthread_spinlock_t *__lock);
+
+/* Unlock the spin lock object LOCK. */
+extern int pthread_spin_unlock (pthread_spinlock_t *__lock);
+
+# ifdef __USE_EXTERN_INLINES
+
+__extern_inline int
+pthread_spin_destroy (pthread_spinlock_t *__lock)
+{
+ return __pthread_spin_destroy (__lock);
+}
+
+__extern_inline int
+pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
+{
+ return __pthread_spin_init (__lock, __pshared);
+}
+
+__extern_inline int
+pthread_spin_lock (pthread_spinlock_t *__lock)
+{
+ return __pthread_spin_lock (__lock);
+}
+
+__extern_inline int
+pthread_spin_trylock (pthread_spinlock_t *__lock)
+{
+ return __pthread_spin_trylock (__lock);
+}
+
+__extern_inline int
+pthread_spin_unlock (pthread_spinlock_t *__lock)
+{
+ return __pthread_spin_unlock (__lock);
+}
+
+# endif /* Use extern inlines. */
+
+#endif /* XPG6. */
+
+
+/* rwlock attributes. */
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+
+#include <bits/rwlock-attr.h>
+
+/* Initialize rwlock attribute object in *ATTR to the default
+ values. */
+extern int pthread_rwlockattr_init (pthread_rwlockattr_t *attr);
+
+/* Destroy the rwlock attribute object in *ATTR. */
+extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *attr);
+
+
+/* Return the value of the process shared attribute in *ATTR in
+ *PSHARED. */
+extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *__restrict attr,
+ int *__restrict pshared);
+
+/* Set the value of the process shared atrribute in *ATTR to
+ PSHARED. */
+extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *attr,
+ int pshared);
+
+
+/* rwlocks. */
+
+#include <bits/rwlock.h>
+
+/* Create a rwlock object with attributes given by ATTR and strore the
+ result in *RWLOCK. */
+extern int pthread_rwlock_init (pthread_rwlock_t *__restrict rwlock,
+ const pthread_rwlockattr_t *__restrict attr);
+
+/* Destroy the rwlock *RWLOCK. */
+extern int pthread_rwlock_destroy (pthread_rwlock_t *rwlock);
+
+/* Acquire the rwlock *RWLOCK for reading. */
+extern int pthread_rwlock_rdlock (pthread_rwlock_t *rwlock);
+
+/* Acquire the rwlock *RWLOCK for reading. */
+extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock);
+
+# ifdef __USE_XOPEN2K
+/* Acquire the rwlock *RWLOCK for reading blocking until *ABSTIME if
+ it is already held. */
+extern int pthread_rwlock_timedrdlock (struct __pthread_rwlock *__restrict rwlock,
+ const struct timespec *__restrict abstime);
+# endif
+
+/* Acquire the rwlock *RWLOCK for writing. */
+extern int pthread_rwlock_wrlock (pthread_rwlock_t *rwlock);
+
+/* Try to acquire the rwlock *RWLOCK for writing. */
+extern int pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock);
+
+# ifdef __USE_XOPEN2K
+/* Acquire the rwlock *RWLOCK for writing blocking until *ABSTIME if
+ it is already held. */
+extern int pthread_rwlock_timedwrlock (struct __pthread_rwlock *__restrict rwlock,
+ const struct timespec *__restrict abstime);
+# endif
+
+/* Release the lock held by the current thread on *RWLOCK. */
+extern int pthread_rwlock_unlock (pthread_rwlock_t *rwlock);
+
+#endif /* __USE_UNIX98 || __USE_XOPEN2K */
+
+
+
+/* Cancelation. */
+
+/* Register a cleanup handler. */
+extern void pthread_cleanup_push (void (*routine) (void *), void *arg);
+
+/* Unregister a cleanup handler. */
+extern void pthread_cleanup_pop (int execute);
+
+#include <bits/cancelation.h>
+
+#define pthread_cleanup_push(rt, rtarg) __pthread_cleanup_push(rt, rtarg)
+#define pthread_cleanup_pop(execute) __pthread_cleanup_pop(execute)
+
+#define PTHREAD_CANCEL_DISABLE 0
+#define PTHREAD_CANCEL_ENABLE 1
+
+/* Return the calling thread's cancelation state in *OLDSTATE and set
+ its state to STATE. */
+extern int pthread_setcancelstate (int state, int *oldstate);
+
+#define PTHREAD_CANCEL_DEFERRED 0
+#define PTHREAD_CANCEL_ASYNCHRONOUS 1
+
+/* Return the calling thread's cancelation type in *OLDTYPE and set
+ its type to TYPE. */
+extern int pthread_setcanceltype (int type, int *oldtype);
+
+/* Value returned by pthread_join if the target thread was
+ canceled. */
+#define PTHREAD_CANCELED ((void *) -1)
+
+/* Cancel THEAD. */
+extern int pthread_cancel (pthread_t thread);
+
+/* Add an explicit cancelation point. */
+extern void pthread_testcancel (void);
+
+
+/* Barriers attributes. */
+
+#ifdef __USE_XOPEN2K
+
+#include <bits/barrier-attr.h>
+
+/* Initialize barrier attribute object in *ATTR to the default
+ values. */
+extern int pthread_barrierattr_init (pthread_barrierattr_t *attr);
+
+/* Destroy the barrier attribute object in *ATTR. */
+extern int pthread_barrierattr_destroy (pthread_barrierattr_t *attr);
+
+
+/* Return the value of the process shared attribute in *ATTR in
+ *PSHARED. */
+extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t *__restrict attr,
+ int *__restrict pshared);
+
+/* Set the value of the process shared atrribute in *ATTR to
+ PSHARED. */
+extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *attr,
+ int pshared);
+
+
+/* Barriers. */
+
+#include <bits/barrier.h>
+
+/* Returned by pthread_barrier_wait to exactly one thread each time a
+ barrier is passed. */
+#define PTHREAD_BARRIER_SERIAL_THREAD -1
+
+/* Initialize barrier BARRIER. */
+extern int pthread_barrier_init (pthread_barrier_t *__restrict barrier,
+ const pthread_barrierattr_t *__restrict attr,
+ unsigned count);
+
+/* Destroy barrier BARRIER. */
+extern int pthread_barrier_destroy (pthread_barrier_t *barrier);
+
+/* Wait on barrier BARRIER. */
+extern int pthread_barrier_wait (pthread_barrier_t *barrier);
+
+#endif /* __USE_XOPEN2K */
+
+
+
+/* Thread specific data. */
+
+#include <bits/thread-specific.h>
+
+/* Create a thread specific data key in KEY visible to all threads.
+ On thread destruction, DESTRUCTOR shall be called with the thread
+ specific data associate with KEY if it is not NULL. */
+extern int pthread_key_create (pthread_key_t *key,
+ void (*destructor) (void *));
+
+/* Delete the thread specific data key KEY. The associated destructor
+ function is not called. */
+extern int pthread_key_delete (pthread_key_t key);
+
+/* Return the caller thread's thread specific value of KEY. */
+extern void *pthread_getspecific (pthread_key_t key);
+
+/* Set the caller thread's thread specific value of KEY to VALUE. */
+extern int pthread_setspecific (pthread_key_t key, const void *value);
+
+
+/* Dynamic package initialization. */
+
+#include <bits/once.h>
+
+#define PTHREAD_ONCE_INIT __PTHREAD_ONCE_INIT
+
+/* Call INIT_ROUTINE if this function has never been called with
+ *ONCE_CONTROL, otherwise do nothing. */
+extern int pthread_once (pthread_once_t *once_control,
+ void (*init_routine) (void));
+
+
+/* Concurrency. */
+
+#ifdef __USE_UNIX98
+/* Set the desired concurrency level to NEW_LEVEL. */
+extern int pthread_setconcurrency (int new_level);
+
+/* Get the current concurrency level. */
+extern int pthread_getconcurrency (void);
+#endif
+
+
+/* Forking. */
+
+/* Register the function PREPARE to be run before the process forks,
+ the function PARENT to be run after a fork in the parent and the
+ function CHILD to be run in the child after the fork. If no
+ handling is desired then any of PREPARE, PARENT and CHILD may be
+ NULL. The prepare handles will be called in the reverse order
+ which they were registered and the parent and child handlers in the
+ order in which they were registered. */
+extern int pthread_atfork (void (*prepare) (void), void (*parent) (void),
+ void (*child) (void));
+
+
+/* Signals (should be in <signal.h>). */
+
+/* Send signal SIGNO to thread THREAD. */
+extern int pthread_kill (pthread_t thread, int signo);
+
+
+/* Time. */
+
+#ifdef __USE_XOPEN2K
+/* Return the thread cpu clock. */
+extern int pthread_getcpuclockid (pthread_t thread, clockid_t *clock);
+#endif
+
+
+/* Scheduling. */
+
+/* Return thread THREAD's scheduling paramters. */
+extern int pthread_getschedparam (pthread_t thread, int *__restrict policy,
+ struct sched_param *__restrict param);
+
+/* Set thread THREAD's scheduling paramters. */
+extern int pthread_setschedparam (pthread_t thread, int policy,
+ const struct sched_param *param);
+
+/* Set thread THREAD's scheduling priority. */
+extern int pthread_setschedprio (pthread_t thread, int prio);
+
+
+__END_DECLS
+
+#endif /* pthread.h */
diff --git a/libpthread/include/pthread/pthreadtypes.h b/libpthread/include/pthread/pthreadtypes.h
new file mode 100644
index 00000000..d9c1c6be
--- /dev/null
+++ b/libpthread/include/pthread/pthreadtypes.h
@@ -0,0 +1,136 @@
+/* Copyright (C) 2000, 2002, 2005, 2008 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. */
+
+/*
+ * POSIX Threads Extension: ??? <pthreadtypes.h>
+ */
+
+#ifndef _PTHREADTYPES_H
+#define _PTHREADTYPES_H 1
+
+#include <features.h>
+
+#define __need_clockid_t
+#include <time.h>
+
+/* If we are in a mode where clockid_t is not automatically defined
+ and another header has already included <time.h> then defining
+ __need_clockid_t was not enough. */
+#ifndef __clockid_t_defined
+# define __clockid_t_defined 1
+# include <bits/types.h>
+/* Clock ID used in clock and timer functions. */
+typedef __clockid_t clockid_t;
+#endif
+
+__BEGIN_DECLS
+
+#include <bits/pthread.h>
+typedef __pthread_t pthread_t;
+
+/* Possible values for the process shared attribute. */
+enum __pthread_process_shared
+ {
+ __PTHREAD_PROCESS_PRIVATE = 0,
+ __PTHREAD_PROCESS_SHARED
+ };
+
+/* Possible values for the inheritsched attribute. */
+enum __pthread_inheritsched
+ {
+ __PTHREAD_EXPLICIT_SCHED = 0,
+ __PTHREAD_INHERIT_SCHED
+ };
+
+/* Possible values for the `contentionscope' attribute. */
+enum __pthread_contentionscope
+ {
+ __PTHREAD_SCOPE_SYSTEM = 0,
+ __PTHREAD_SCOPE_PROCESS,
+ };
+
+/* Possible values for the `detachstate' attribute. */
+enum __pthread_detachstate
+ {
+ __PTHREAD_CREATE_JOINABLE = 0,
+ __PTHREAD_CREATE_DETACHED
+ };
+
+#include <bits/thread-attr.h>
+typedef struct __pthread_attr pthread_attr_t;
+
+enum __pthread_mutex_protocol
+ {
+ __PTHREAD_PRIO_NONE= 0,
+ __PTHREAD_PRIO_INHERIT,
+ __PTHREAD_PRIO_PROTECT
+ };
+
+enum __pthread_mutex_type
+ {
+ __PTHREAD_MUTEX_TIMED,
+ __PTHREAD_MUTEX_ERRORCHECK,
+ __PTHREAD_MUTEX_RECURSIVE
+ };
+
+#include <bits/mutex-attr.h>
+typedef struct __pthread_mutexattr pthread_mutexattr_t;
+
+#include <bits/mutex.h>
+typedef struct __pthread_mutex pthread_mutex_t;
+
+#include <bits/condition-attr.h>
+typedef struct __pthread_condattr pthread_condattr_t;
+
+#include <bits/condition.h>
+typedef struct __pthread_cond pthread_cond_t;
+
+#ifdef __USE_XOPEN2K
+# include <bits/spin-lock.h>
+typedef __pthread_spinlock_t pthread_spinlock_t;
+#endif /* XPG6. */
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+
+#include <bits/rwlock-attr.h>
+typedef struct __pthread_rwlockattr pthread_rwlockattr_t;
+
+#include <bits/rwlock.h>
+typedef struct __pthread_rwlock pthread_rwlock_t;
+
+#endif /* __USE_UNIX98 || __USE_XOPEN2K */
+
+#ifdef __USE_XOPEN2K
+
+#include <bits/barrier-attr.h>
+typedef struct __pthread_barrierattr pthread_barrierattr_t;
+
+#include <bits/barrier.h>
+typedef struct __pthread_barrier pthread_barrier_t;
+
+#endif /* __USE_XOPEN2K */
+
+#include <bits/thread-specific.h>
+typedef __pthread_key pthread_key_t;
+
+#include <bits/once.h>
+typedef struct __pthread_once pthread_once_t;
+
+__END_DECLS
+
+#endif /* pthreadtypes.h */
diff --git a/libpthread/include/semaphore.h b/libpthread/include/semaphore.h
new file mode 100644
index 00000000..657e796e
--- /dev/null
+++ b/libpthread/include/semaphore.h
@@ -0,0 +1,69 @@
+/* Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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. */
+
+#ifndef _SEMAPHORE_H
+#define _SEMAPHORE_H 1
+
+#include <features.h>
+
+__BEGIN_DECLS
+
+#include <bits/semaphore.h>
+
+#define SEM_FAILED ((void *) 0)
+
+typedef struct __semaphore sem_t;
+
+/* Initialize semaphore *SEM with value VALUE. */
+extern int sem_init (sem_t *sem, int pshared, unsigned value);
+
+/* Destroy semaphore *SEM created with sem_init. */
+extern int sem_destroy (sem_t *sem);
+
+/* Store the value of semaphore *SEM in *VALUE. */
+extern int sem_getvalue (sem_t *__restrict sem, int *__restrict value);
+
+/* Perform a down operation on semaphore *SEM. */
+extern int sem_wait (sem_t *sem);
+
+/* Perform a down operation on semaphore *SEM if it can be done so
+ without blocking. */
+extern int sem_trywait (sem_t *sem);
+
+#ifdef __USE_XOPEN2K
+/* Perform a down operation on semaphore *SEM but don't wait longer
+ than TIMEOUT. */
+extern int sem_timedwait (sem_t *__restrict sem,
+ const struct timespec *__restrict timeout);
+#endif
+
+/* Perform an up operation on semaphore *SEM. */
+extern int sem_post (sem_t *sem);
+
+/* Open a named semaphore. */
+extern sem_t *sem_open (const char *name, int open_flags, ...);
+
+/* Close a semaphore returned by sem_open. */
+extern int sem_close (sem_t *sem);
+
+/* Unlink a named semaphore. */
+extern int sem_unlink (const char *name);
+
+__END_DECLS
+
+#endif /* semaphore.h */
diff --git a/libpthread/include/set-hooks.h b/libpthread/include/set-hooks.h
new file mode 100644
index 00000000..9ed71b32
--- /dev/null
+++ b/libpthread/include/set-hooks.h
@@ -0,0 +1,72 @@
+/* Macros for using symbol sets for running lists of functions.
+ Copyright (C) 1994, 1995, 1997, 2000 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 _SET_HOOKS_H
+#define _SET_HOOKS_H 1
+
+#define __need_size_t
+#include <stddef.h>
+// #include <sys/cdefs.h>
+#define __unbounded
+
+#ifdef symbol_set_define
+/* Define a hook variable called NAME. Functions put on this hook take
+ arguments described by PROTO. Use `text_set_element (NAME, FUNCTION)'
+ from gnu-stabs.h to add a function to the hook. */
+
+# define DEFINE_HOOK(NAME, PROTO) \
+ typedef void __##NAME##_hook_function_t PROTO; \
+ symbol_set_define (NAME)
+
+# define DECLARE_HOOK(NAME, PROTO) \
+ typedef void __##NAME##_hook_function_t PROTO;\
+ symbol_set_declare (NAME)
+
+/* Run all the functions hooked on the set called NAME.
+ Each function is called like this: `function ARGS'. */
+
+# define RUN_HOOK(NAME, ARGS) \
+do { \
+ void *const *__unbounded ptr; \
+ for (ptr = symbol_set_first_element (NAME); \
+ ! symbol_set_end_p (NAME, ptr); ++ptr) \
+ (*(__##NAME##_hook_function_t *) *ptr) ARGS; \
+} while (0)
+
+/* Define a hook variable with NAME and PROTO, and a function called RUNNER
+ which calls each function on the hook in turn, with ARGS. */
+
+# define DEFINE_HOOK_RUNNER(name, runner, proto, args) \
+DEFINE_HOOK (name, proto); \
+extern void runner proto; void runner proto { RUN_HOOK (name, args); }
+
+#else
+
+/* The system does not provide necessary support for this. */
+# define DEFINE_HOOK(NAME, PROTO)
+
+# define DECLARE_HOOK(NAME, PROTO)
+
+# define RUN_HOOK(NAME, ARGS)
+
+# define DEFINE_HOOK_RUNNER(name, runner, proto, args)
+
+#endif
+
+#endif /* set-hooks.h */
diff --git a/libpthread/lockfile.c b/libpthread/lockfile.c
new file mode 100644
index 00000000..040cbfb4
--- /dev/null
+++ b/libpthread/lockfile.c
@@ -0,0 +1,65 @@
+/* lockfile - Handle locking and unlocking of streams. Hurd cthreads version.
+ Copyright (C) 2000,01,02 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 <cthreads.h>
+#include <pthread.h> /* Must come before <stdio.h>! */
+#include <stdio.h>
+
+#ifdef _STDIO_USES_IOSTREAM
+
+void
+_cthreads_flockfile (_IO_FILE *fp)
+{
+ _IO_lock_lock (*fp->_lock);
+}
+
+void
+_cthreads_funlockfile (_IO_FILE *fp)
+{
+ _IO_lock_unlock (*fp->_lock);
+}
+
+int
+_cthreads_ftrylockfile (_IO_FILE *fp)
+{
+ return __libc_lock_trylock_recursive (*fp->_lock);
+}
+
+# undef _IO_flockfile
+# undef _IO_funlockfile
+# undef _IO_ftrylockfile
+# undef flockfile
+# undef funlockfile
+# undef ftrylockfile
+
+void _IO_flockfile (_IO_FILE *)
+ __attribute__ ((alias ("_cthreads_flockfile")));
+void _IO_funlockfile (_IO_FILE *)
+ __attribute__ ((alias ("_cthreads_funlockfile")));
+int _IO_ftrylockfile (_IO_FILE *)
+ __attribute__ ((alias ("_cthreads_ftrylockfile")));
+
+void flockfile (_IO_FILE *)
+ __attribute__ ((alias ("_cthreads_flockfile")));
+void funlockfile (_IO_FILE *)
+ __attribute__ ((alias ("_cthreads_funlockfile")));
+int ftrylockfile (_IO_FILE *)
+ __attribute__ ((alias ("_cthreads_ftrylockfile")));
+
+#endif /* _STDIO_USES_IOSTREAM */
diff --git a/libpthread/not-in-libc.h b/libpthread/not-in-libc.h
new file mode 100644
index 00000000..516d4d13
--- /dev/null
+++ b/libpthread/not-in-libc.h
@@ -0,0 +1,11 @@
+#define __mach_port_insert_right mach_port_insert_right
+#define __mach_port_allocate mach_port_allocate
+#define __mig_init mig_init
+#define __thread_create thread_create
+#define __thread_get_state thread_get_state
+#define __thread_resume thread_resume
+#define __thread_set_state thread_set_state
+#define __thread_terminate thread_terminate
+#define __vm_allocate vm_allocate
+#define __vm_deallocate vm_deallocate
+#define __sched_yield sched_yield
diff --git a/libpthread/pthread/CVS/Entries b/libpthread/pthread/CVS/Entries
new file mode 100644
index 00000000..7007a370
--- /dev/null
+++ b/libpthread/pthread/CVS/Entries
@@ -0,0 +1,20 @@
+/Versions/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/cthreads-compat.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-alloc.c/1.3/Thu May 12 20:55:38 2005//Tzhengda-soc2008-virt-branch
+/pt-cancel.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-cleanup.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-create.c/1.4/Wed May 4 16:04:06 2005//Tzhengda-soc2008-virt-branch
+/pt-dealloc.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-detach.c/1.2/Wed May 4 16:04:06 2005//Tzhengda-soc2008-virt-branch
+/pt-exit.c/1.2/Wed May 4 16:04:06 2005//Tzhengda-soc2008-virt-branch
+/pt-getattr.c/1.1/Sat May 17 20:07:56 2008//Tzhengda-soc2008-virt-branch
+/pt-initialize.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-internal.h/1.7/Tue Jul 1 11:43:14 2008//Tzhengda-soc2008-virt-branch
+/pt-join.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-self.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-setcancelstate.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-setcanceltype.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-sigmask.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-spin-inlines.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-testcancel.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+D
diff --git a/libpthread/pthread/CVS/Repository b/libpthread/pthread/CVS/Repository
new file mode 100644
index 00000000..11a2c33b
--- /dev/null
+++ b/libpthread/pthread/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/pthread
diff --git a/libpthread/pthread/CVS/Root b/libpthread/pthread/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/pthread/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/pthread/CVS/Tag b/libpthread/pthread/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/pthread/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/pthread/Versions b/libpthread/pthread/Versions
new file mode 100644
index 00000000..e4b4e8bf
--- /dev/null
+++ b/libpthread/pthread/Versions
@@ -0,0 +1,15 @@
+libc {
+ GLIBC_2.2 {
+ # XXX
+ __vm_deallocate; __mach_port_insert_right; __mach_reply_port;
+ __mig_init; __vm_allocate;
+
+ # functions used in inline functions or macros
+ __pthread_spin_destroy; __pthread_spin_init; __pthread_spin_lock;
+ _pthread_spin_lock; __pthread_spin_trylock; __pthread_spin_unlock;
+
+ # p*
+ pthread_spin_destroy; pthread_spin_init; pthread_spin_lock;
+ pthread_spin_trylock; pthread_spin_unlock;
+ }
+}
diff --git a/libpthread/pthread/cthreads-compat.c b/libpthread/pthread/cthreads-compat.c
new file mode 100644
index 00000000..ccea03c9
--- /dev/null
+++ b/libpthread/pthread/cthreads-compat.c
@@ -0,0 +1,100 @@
+/* Compatibility routines for cthreads.
+ Copyright (C) 2000, 2002 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 <assert.h>
+#include <pthread.h>
+
+#include <cthreads.h>
+
+void
+cthread_detach (cthread_t thread)
+{
+ int err;
+
+ err = pthread_detach ((pthread_t) thread);
+ assert_perror (err);
+}
+
+cthread_t
+cthread_fork (cthread_fn_t func, void *arg)
+{
+ pthread_t thread;
+ int err;
+
+ err = pthread_create (&thread, NULL, func, arg);
+ assert_perror (err);
+
+ return (cthread_t) thread;
+}
+
+int
+cthread_keycreate (cthread_key_t *key)
+{
+ error_t err;
+
+ err = pthread_key_create (key, 0);
+ if (err)
+ {
+ errno = err;
+ *key = CTHREAD_KEY_INVALID;
+ err = -1;
+ }
+
+ return err;
+}
+
+int
+cthread_getspecific (cthread_key_t key, void **val)
+{
+ *val = pthread_getspecific (key);
+ return 0;
+}
+
+void *
+__libc_getspecific (cthread_key_t key)
+{
+ return pthread_getspecific (key);
+}
+
+int
+cthread_setspecific (cthread_key_t key, void *val)
+{
+ error_t err;
+
+ err = pthread_setspecific (key, (const void *) val);
+ if (err)
+ {
+ errno = err;
+ err = -1;
+ }
+
+ return err;
+}
+
+void
+__mutex_lock_solid (void *lock)
+{
+ __pthread_mutex_lock (lock);
+}
+
+void
+__mutex_unlock_solid (void *lock)
+{
+ __pthread_mutex_unlock (lock);
+}
diff --git a/libpthread/pthread/pt-alloc.c b/libpthread/pthread/pt-alloc.c
new file mode 100644
index 00000000..30dcede0
--- /dev/null
+++ b/libpthread/pthread/pt-alloc.c
@@ -0,0 +1,215 @@
+/* Allocate a new thread structure.
+ Copyright (C) 2000, 2002, 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
+ 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 <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <pt-internal.h>
+
+#include <bits/atomic.h>
+
+/* This braindamage is necessary because the standard says that some
+ of the threads functions "shall fail" if "No thread could be found
+ corresponding to that specified by the given thread ID." */
+
+/* Thread ID lookup table. */
+struct __pthread **__pthread_threads;
+
+/* The size of the thread ID lookup table. */
+int __pthread_max_threads;
+
+/* The total number of thread IDs currently in use, or on the list of
+ available thread IDs. */
+int __pthread_num_threads;
+
+/* A lock for the table, and the other variables above. */
+pthread_rwlock_t __pthread_threads_lock;
+
+
+/* List of thread structures corresponding to free thread IDs. */
+__atomicptr_t __pthread_free_threads;
+
+static inline error_t
+initialize_pthread (struct __pthread *new, int recycling)
+{
+ error_t err;
+
+ err = __pthread_init_specific (new);
+ if (err)
+ return err;
+
+ new->cancel_state = PTHREAD_CANCEL_ENABLE;
+ new->cancel_type = PTHREAD_CANCEL_DEFERRED;
+ new->cancel_pending = 0;
+
+ if (recycling)
+ /* Since we are recycling PTHREAD, we can assume certains things
+ about PTHREAD's current state and save some cycles by not
+ rewriting the memory. */
+ return 0;
+
+ new->stack = 0;
+
+ new->state_lock = (pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER;
+ new->state_cond = (pthread_cond_t) PTHREAD_COND_INITIALIZER;
+
+ new->cancelation_handlers = 0;
+
+ new->next = 0;
+ new->prevp = 0;
+
+ return 0;
+}
+
+
+/* Allocate a new thread structure and its pthread thread ID (but not
+ a kernel thread). */
+int
+__pthread_alloc (struct __pthread **pthread)
+{
+ error_t err;
+
+ struct __pthread *new;
+ struct __pthread **threads;
+ struct __pthread **old_threads;
+ int max_threads;
+ int new_max_threads;
+
+ /* Try to re-use a thread structure before creating a new one. */
+ while ((new = (struct __pthread *)__pthread_free_threads))
+ {
+ if (__atomicptr_compare_and_swap (&__pthread_free_threads,
+ new, new->next))
+ {
+ /* Yes, we managed to get one. The thread number in the
+ thread structure still refers to the correct slot. */
+ err = initialize_pthread (new, 1);
+ if (err)
+ /* An error occured, however, we cannot just free NEW as
+ there may be resources attached to it. We must return
+ it to the free list. */
+ while (1)
+ {
+ new->next = (struct __pthread *)__pthread_free_threads;
+ if (__atomicptr_compare_and_swap (&__pthread_free_threads,
+ new->next, new))
+ break;
+ }
+
+ if (! err)
+ *pthread = new;
+
+ return err;
+ }
+ }
+
+ /* Allocate a new thread structure. */
+ new = malloc (sizeof (struct __pthread));
+ if (new == NULL)
+ return ENOMEM;
+
+ err = initialize_pthread (new, 0);
+ if (err)
+ {
+ free (new);
+ return err;
+ }
+
+ retry:
+ pthread_rwlock_wrlock (&__pthread_threads_lock);
+
+ if (__pthread_num_threads < __pthread_max_threads)
+ {
+ /* We have a free slot. Use the slot number plus one as the
+ thread ID for the new thread. */
+ new->thread = 1 + __pthread_num_threads++;
+ __pthread_threads[new->thread - 1] = NULL;
+
+ pthread_rwlock_unlock (&__pthread_threads_lock);
+
+ *pthread = new;
+ return 0;
+ }
+#ifdef PTHREAD_THREADS_MAX
+ else if (__pthread_num_threads >= PTHREAD_THREADS_MAX)
+ {
+ /* We have reached the limit on the number of threads per process. */
+ pthread_rwlock_unlock (&__pthread_threads_lock);
+
+ free (new);
+ return EAGAIN;
+ }
+#endif
+
+ /* We are going to enlarge the threads table. Save its current
+ size. We're going to release the lock before doing the necessary
+ memory allocation, since that's a potentially blocking operation. */
+ max_threads = __pthread_max_threads;
+
+ pthread_rwlock_unlock (&__pthread_threads_lock);
+
+ /* Allocate a new lookup table that's twice as large. */
+ new_max_threads
+ = max_threads > 0 ? max_threads * 2 : _POSIX_THREAD_THREADS_MAX;
+ threads = malloc (new_max_threads * sizeof (struct __pthread *));
+ if (threads == NULL)
+ {
+ free (new);
+ return ENOMEM;
+ }
+
+ pthread_rwlock_wrlock (&__pthread_threads_lock);
+
+ /* Check if nobody else has already enlarged the table. */
+ if (max_threads != __pthread_max_threads)
+ {
+ /* Yep, they did. */
+ pthread_rwlock_unlock (&__pthread_threads_lock);
+
+ /* Free the newly allocated table and try again to allocate a slot. */
+ free (threads);
+ goto retry;
+ }
+
+ /* Copy over the contents of the old table. */
+ memcpy (threads, __pthread_threads,
+ __pthread_max_threads * sizeof (struct __pthread *));
+
+ /* Save the location of the old table. We want to deallocate its
+ storage after we released the lock. */
+ old_threads = __pthread_threads;
+
+ /* Replace the table with the new one. */
+ __pthread_max_threads = new_max_threads;
+ __pthread_threads = threads;
+
+ /* And allocate ourselves one of the newly created slots. */
+ new->thread = 1 + __pthread_num_threads++;
+ __pthread_threads[new->thread - 1] = NULL;
+
+ pthread_rwlock_unlock (&__pthread_threads_lock);
+
+ free (old_threads);
+
+ *pthread = new;
+ return 0;
+}
diff --git a/libpthread/pthread/pt-cancel.c b/libpthread/pthread/pt-cancel.c
new file mode 100644
index 00000000..d19c557d
--- /dev/null
+++ b/libpthread/pthread/pt-cancel.c
@@ -0,0 +1,40 @@
+/* Cancel a thread.
+ Copyright (C) 2002 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 <pthread.h>
+
+#include <pt-internal.h>
+
+int
+pthread_cancel (pthread_t t)
+{
+ int err = 0;
+ struct __pthread *p;
+
+ p = __pthread_getid (t);
+ if (! p)
+ return ESRCH;
+
+ p->cancel_pending = 1;
+ if (p->cancel_state == PTHREAD_CANCEL_ENABLE
+ && p->cancel_type == PTHREAD_CANCEL_ASYNCHRONOUS)
+ err = __pthread_do_cancel (p);
+
+ return err;
+}
diff --git a/libpthread/pthread/pt-cleanup.c b/libpthread/pthread/pt-cleanup.c
new file mode 100644
index 00000000..58865aa4
--- /dev/null
+++ b/libpthread/pthread/pt-cleanup.c
@@ -0,0 +1,28 @@
+/* Add a cancelation handler to the stack.
+ Copyright (C) 2002 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 <pthread.h>
+
+#include <pt-internal.h>
+
+struct __pthread_cancelation_handler **
+__pthread_get_cleanup_stack (void)
+{
+ return &_pthread_self ()->cancelation_handlers;
+}
diff --git a/libpthread/pthread/pt-create.c b/libpthread/pthread/pt-create.c
new file mode 100644
index 00000000..045d0bc4
--- /dev/null
+++ b/libpthread/pthread/pt-create.c
@@ -0,0 +1,211 @@
+/* Thread creation.
+ Copyright (C) 2000, 2002, 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
+ 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 <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+
+#include <bits/atomic.h>
+
+#include <pt-internal.h>
+
+#ifdef HAVE_USELOCALE
+# include <locale.h>
+#endif
+
+/* The total number of pthreads currently active. This is defined
+ here since it would be really stupid to have a threads-using
+ program that doesn't call `pthread_create'. */
+__atomic_t __pthread_total;
+
+
+/* The entry-point for new threads. */
+static void
+entry_point (void *(*start_routine)(void *), void *arg)
+{
+#ifdef HAVE_USELOCALE
+ /* A fresh thread needs to be bound to the global locale. */
+ uselocale (LC_GLOBAL_LOCALE);
+#endif
+
+ pthread_exit (start_routine (arg));
+}
+
+/* Create a thread with attributes given by ATTR, executing
+ START_ROUTINE with argument ARG. */
+int
+pthread_create (pthread_t *thread, const pthread_attr_t *attr,
+ void *(*start_routine)(void *), void *arg)
+{
+ int err;
+ struct __pthread *pthread;
+
+ err = __pthread_create_internal (&pthread, attr, start_routine, arg);
+ if (! err)
+ *thread = pthread->thread;
+
+ return err;
+}
+
+/* Internal version of pthread_create. See comment in
+ pt-internal.h. */
+int
+__pthread_create_internal (struct __pthread **thread,
+ const pthread_attr_t *attr,
+ void *(*start_routine)(void *), void *arg)
+{
+ int err;
+ struct __pthread *pthread;
+ const struct __pthread_attr *setup;
+ sigset_t sigset;
+
+ /* Allocate a new thread structure. */
+ err = __pthread_alloc (&pthread);
+ if (err)
+ goto failed;
+
+ /* Use the default attributes if ATTR is NULL. */
+ setup = attr ? attr : &__pthread_default_attr;
+
+ /* Initialize the thread state. */
+ pthread->state = (setup->detachstate == PTHREAD_CREATE_DETACHED
+ ? PTHREAD_DETACHED : PTHREAD_JOINABLE);
+
+ /* If the user supplied a stack, it is not our responsibility to
+ setup a stack guard. */
+ if (setup->stackaddr)
+ pthread->guardsize = 0;
+ else
+ pthread->guardsize = (setup->guardsize <= setup->stacksize
+ ? setup->guardsize : setup->stacksize);
+
+ /* Find a stack. There are several scenarios: if a detached thread
+ kills itself, it has no way to deallocate its stack, thus it
+ leaves PTHREAD->stack set to true. We try to reuse it here,
+ however, if the user supplied a stack, we cannot use the old one.
+ Right now, we simply deallocate it. */
+ if (pthread->stack)
+ {
+ if (setup->stackaddr != __pthread_default_attr.stackaddr)
+ {
+ __pthread_stack_dealloc (pthread->stackaddr,
+ pthread->stacksize);
+ pthread->stackaddr = setup->stackaddr;
+ pthread->stacksize = setup->stacksize;
+ }
+ }
+ else
+ {
+ err = __pthread_stack_alloc (&pthread->stackaddr,
+ setup->stacksize);
+ if (err)
+ goto failed_stack_alloc;
+
+ pthread->stacksize = setup->stacksize;
+ pthread->stack = 1;
+ }
+
+ /* Allocate the kernel thread and other required resources. */
+ err = __pthread_thread_alloc (pthread);
+ if (err)
+ goto failed_thread_alloc;
+
+ pthread->tcb = _dl_allocate_tls (NULL);
+ if (!pthread->tcb)
+ goto failed_thread_tls_alloc;
+ pthread->tcb->tcb = pthread->tcb;
+
+ /* And initialize the rest of the machine context. This may include
+ additional machine- and system-specific initializations that
+ prove convenient. */
+ err = __pthread_setup (pthread, entry_point, start_routine, arg);
+ if (err)
+ goto failed_setup;
+
+ /* Initialize the system-specific signal state for the new
+ thread. */
+ err = __pthread_sigstate_init (pthread);
+ if (err)
+ goto failed_sigstate;
+
+ /* Set the new thread's signal mask and set the pending signals to
+ empty. POSIX says: "The signal mask shall be inherited from the
+ creating thread. The set of signals pending for the new thread
+ shall be empty." If the currnet thread is not a pthread then we
+ just inherit the process' sigmask. */
+ if (__pthread_num_threads == 1)
+ err = sigprocmask (0, 0, &sigset);
+ else
+ err = __pthread_sigstate (_pthread_self (), 0, 0, &sigset, 0);
+ assert_perror (err);
+
+ err = __pthread_sigstate (pthread, SIG_SETMASK, &sigset, 0, 1);
+ assert_perror (err);
+
+ /* Increase the total number of threads. We do this before actually
+ starting the new thread, since the new thread might immediately
+ call `pthread_exit' which decreases the number of threads and
+ calls `exit' if the number of threads reaches zero. Increasing
+ the number of threads from within the new thread isn't an option
+ since this thread might return and call `pthread_exit' before the
+ new thread runs. */
+ __atomic_inc (&__pthread_total);
+
+ /* Store a pointer to this thread in the thread ID lookup table. We
+ could use __thread_setid, however, we only lock for reading as no
+ other thread should be using this entry (we also assume that the
+ store is atomic). */
+ pthread_rwlock_rdlock (&__pthread_threads_lock);
+ __pthread_threads[pthread->thread - 1] = pthread;
+ pthread_rwlock_unlock (&__pthread_threads_lock);
+
+ /* At this point it is possible to guess our pthread ID. We have to
+ make sure that all functions taking a pthread_t argument can
+ handle the fact that this thread isn't really running yet. */
+
+ /* Schedule the new thread. */
+ err = __pthread_thread_start (pthread);
+ if (err)
+ goto failed_starting;
+
+ /* At this point the new thread is up and running. */
+
+ *thread = pthread;
+
+ return 0;
+
+ failed_starting:
+ __pthread_setid (pthread->thread, NULL);
+ __atomic_dec (&__pthread_total);
+ failed_sigstate:
+ __pthread_sigstate_destroy (pthread);
+ failed_setup:
+ _dl_deallocate_tls (pthread->tcb, 1);
+ failed_thread_tls_alloc:
+ __pthread_thread_dealloc (pthread);
+ __pthread_thread_halt (pthread, 0);
+ failed_thread_alloc:
+ __pthread_stack_dealloc (pthread->stackaddr, pthread->stacksize);
+ pthread->stack = 0;
+ failed_stack_alloc:
+ __pthread_dealloc (pthread);
+ failed:
+ return err;
+}
diff --git a/libpthread/pthread/pt-dealloc.c b/libpthread/pthread/pt-dealloc.c
new file mode 100644
index 00000000..1fc7a7b3
--- /dev/null
+++ b/libpthread/pthread/pt-dealloc.c
@@ -0,0 +1,63 @@
+/* Deallocate a thread structure.
+ Copyright (C) 2000 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 <assert.h>
+#include <pthread.h>
+#include <stdlib.h>
+
+#include <pt-internal.h>
+
+#include <bits/atomic.h>
+
+/* List of thread structures corresponding to free thread IDs. */
+extern __atomicptr_t __pthread_free_threads;
+
+/* Deallocate the thread structure for PTHREAD and the resources
+ associated with it. */
+void
+__pthread_dealloc (struct __pthread *pthread)
+{
+ assert (pthread->state != PTHREAD_TERMINATED);
+
+ /* Withdraw this thread from the thread ID lookup table. */
+ __pthread_setid (pthread->thread, NULL);
+
+ /* Mark the thread as terminated. We broadcast the condition
+ here to prevent pthread_join from waiting for this thread to
+ exit where it was never really started. Such a call to
+ pthread_join is completely bogus, but unfortunately allowed
+ by the standards. */
+ __pthread_mutex_lock (&pthread->state_lock);
+ pthread->state = PTHREAD_TERMINATED;
+ if (pthread->state != PTHREAD_EXITED)
+ pthread_cond_broadcast (&pthread->state_cond);
+ __pthread_mutex_unlock (&pthread->state_lock);
+
+ /* We do not actually deallocate the thread structure, but add it to
+ a list of re-usable thread structures. */
+ while (1)
+ {
+ pthread->next = (struct __pthread *)__pthread_free_threads;
+ if (__atomicptr_compare_and_swap (&__pthread_free_threads,
+ pthread->next, pthread))
+ return;
+ }
+
+ /* NOTREACHED */
+}
diff --git a/libpthread/pthread/pt-detach.c b/libpthread/pthread/pt-detach.c
new file mode 100644
index 00000000..42a84080
--- /dev/null
+++ b/libpthread/pthread/pt-detach.c
@@ -0,0 +1,82 @@
+/* Detach a thread.
+ Copyright (C) 2000, 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
+ 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 <pthread.h>
+#include <stddef.h>
+
+#include <pt-internal.h>
+
+/* Indicate that the storage for THREAD can be reclaimed when it
+ terminates. */
+int
+pthread_detach (pthread_t thread)
+{
+ struct __pthread *pthread;
+ int err = 0;
+
+ /* Lookup the thread structure for THREAD. */
+ pthread = __pthread_getid (thread);
+ if (pthread == NULL)
+ return ESRCH;
+
+ __pthread_mutex_lock (&pthread->state_lock);
+
+ switch (pthread->state)
+ {
+ case PTHREAD_JOINABLE:
+ /* THREAD still running. Mark it as detached such that its
+ resources can be reclaimed as soon as the thread exits. */
+ pthread->state = PTHREAD_DETACHED;
+
+ /* Broadcast the condition. This will make threads that are
+ waiting to join THREAD continue with hopefully disastrous
+ consequences instead of blocking indefinitely. */
+ pthread_cond_broadcast (&pthread->state_cond);
+ __pthread_mutex_unlock (&pthread->state_lock);
+ break;
+
+ case PTHREAD_EXITED:
+ /* THREAD has already exited. Make sure that nobody can
+ reference it anymore, and mark it as terminated. */
+
+ __pthread_mutex_unlock (&pthread->state_lock);
+
+ assert (pthread->stack);
+ __pthread_stack_dealloc (pthread->stackaddr, pthread->stacksize);
+ pthread->stack = 0;
+
+ __pthread_dealloc (pthread);
+ break;
+
+ case PTHREAD_TERMINATED:
+ /* Pretend THREAD wasn't there in the first place. */
+ __pthread_mutex_unlock (&pthread->state_lock);
+ err = ESRCH;
+ break;
+
+ default:
+ /* Thou shalt not detach non-joinable threads! */
+ __pthread_mutex_unlock (&pthread->state_lock);
+ err = EINVAL;
+ break;
+ }
+
+ return err;
+}
diff --git a/libpthread/pthread/pt-exit.c b/libpthread/pthread/pt-exit.c
new file mode 100644
index 00000000..7928f982
--- /dev/null
+++ b/libpthread/pthread/pt-exit.c
@@ -0,0 +1,122 @@
+/* Thread termination.
+ Copyright (C) 2000, 2002, 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
+ 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 <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <stdlib.h>
+
+#include <pt-internal.h>
+
+#include <bits/atomic.h>
+
+
+/* Terminate the current thread and make STATUS available to any
+ thread that might join us. */
+void
+pthread_exit (void *status)
+{
+ struct __pthread *self = _pthread_self ();
+ struct __pthread_cancelation_handler **handlers;
+ int oldstate;
+ int need_dealloc;
+
+ /* Run any cancelation handlers. According to POSIX, the
+ cancellation cleanup handlers should be called with cancellation
+ disabled. */
+ pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &oldstate);
+
+ for (handlers = __pthread_get_cleanup_stack ();
+ *handlers;
+ *handlers = (*handlers)->next)
+ (*handlers)->handler ((*handlers)->arg);
+
+ pthread_setcancelstate (oldstate, &oldstate);
+
+ /* Destory any thread specific data. */
+ __pthread_destroy_specific (self);
+
+ /* Destroy any signal state. */
+ __pthread_sigstate_destroy (self);
+
+ /* Decrease the number of threads. We use an atomic operation to
+ make sure that only the last thread calls `exit'. */
+ if (__atomic_dec_and_test (&__pthread_total))
+ /* We are the last thread. */
+ exit (0);
+
+ /* Note that after this point the process can be terminated at any
+ point if another thread calls `pthread_exit' and happens to be
+ the last thread. */
+
+ __pthread_mutex_lock (&self->state_lock);
+
+ if (self->cancel_state == PTHREAD_CANCEL_ENABLE && self->cancel_pending)
+ status = PTHREAD_CANCELED;
+
+ if (self->tcb)
+ _dl_deallocate_tls (self->tcb, 1);
+ __pthread_thread_dealloc (self);
+
+ switch (self->state)
+ {
+ default:
+ assert (! "Consistency error: unexpected self->state");
+ abort ();
+ break;
+
+ case PTHREAD_DETACHED:
+ /* Make sure that nobody can reference this thread anymore, and
+ mark it as terminated. Our thread ID will immediately become
+ available for re-use. For obvious reasons, we cannot
+ deallocate our own stack. However, it will eventually be
+ reused when this thread structure is recycled. */
+ __pthread_mutex_unlock (&self->state_lock);
+ need_dealloc = 1;
+
+ break;
+
+ case PTHREAD_JOINABLE:
+ /* We need to stay around for a while since another thread
+ might want to join us. */
+ self->state = PTHREAD_EXITED;
+
+ /* We need to remember the exit status. A thread joining us
+ might ask for it. */
+ self->status = status;
+
+ /* Broadcast the condition. This will wake up threads that are
+ waiting to join us. */
+ pthread_cond_broadcast (&self->state_cond);
+ __pthread_mutex_unlock (&self->state_lock);
+ need_dealloc = 0;
+
+ break;
+ }
+
+ /* Note that after this point the resources used by this thread can
+ be freed at any moment if another thread joins or detaches us.
+ This means that before freeing any resources, such a thread
+ should make sure that this thread is really halted. */
+
+ __pthread_thread_halt (self, need_dealloc);
+
+ /* NOTREACHED */
+ abort ();
+}
diff --git a/libpthread/pthread/pt-getattr.c b/libpthread/pthread/pt-getattr.c
new file mode 100644
index 00000000..24599c6e
--- /dev/null
+++ b/libpthread/pthread/pt-getattr.c
@@ -0,0 +1,49 @@
+/* Thread attributes retrieval.
+ Copyright (C) 2008 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 <assert.h>
+#include <errno.h>
+#include <pthread.h>
+
+#include <pt-internal.h>
+
+/* Initialize thread attribute *ATTR with attributes corresponding to the
+ already running thread THREAD. It shall be called on an uninitialized ATTR
+ and destroyed with pthread_attr_destroy when no longer needed. */
+int
+pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
+{
+ struct __pthread *pthread;
+
+ pthread = __pthread_getid(thread);
+ if (pthread == NULL)
+ return ESRCH;
+
+ /* Some attributes (schedparam, inheritsched, contentionscope and schedpolicy)
+ are not supported yet, so fill them with our default values. */
+ *attr = __pthread_default_attr;
+
+ attr->stackaddr = pthread->stackaddr;
+ attr->stacksize = pthread->stacksize;
+ attr->guardsize = pthread->guardsize;
+ attr->detachstate = (pthread->state == PTHREAD_DETACHED
+ ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE);
+
+ return 0;
+}
diff --git a/libpthread/pthread/pt-initialize.c b/libpthread/pthread/pt-initialize.c
new file mode 100644
index 00000000..cf32b8b5
--- /dev/null
+++ b/libpthread/pthread/pt-initialize.c
@@ -0,0 +1,33 @@
+/* Initialize pthreads library.
+ Copyright (C) 2000,02 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 <assert.h>
+#include <string.h>
+
+#include <pt-internal.h>
+#include <set-hooks.h>
+
+DEFINE_HOOK (__pthread_init, (void));
+
+/* Initialize the pthreads library. */
+void
+__pthread_initialize (void)
+{
+ RUN_HOOK (__pthread_init, ());
+}
diff --git a/libpthread/pthread/pt-internal.h b/libpthread/pthread/pt-internal.h
new file mode 100644
index 00000000..cf746969
--- /dev/null
+++ b/libpthread/pthread/pt-internal.h
@@ -0,0 +1,301 @@
+/* Internal defenitions for pthreads library.
+ Copyright (C) 2000, 2005, 2006, 2008 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. */
+
+#ifndef _PT_INTERNAL_H
+#define _PT_INTERNAL_H 1
+
+#include <pthread.h>
+#include <stddef.h>
+#include <sched.h>
+#include <signal.h>
+#include <assert.h>
+
+#include <bits/atomic.h>
+
+#include <pt-key.h>
+
+#include <pt-sysdep.h>
+#include <pt-machdep.h>
+
+/* Thread state. */
+enum pthread_state
+{
+ PTHREAD_JOINABLE = 0,
+ PTHREAD_DETACHED,
+ PTHREAD_EXITED,
+ PTHREAD_TERMINATED
+};
+
+#ifndef PTHREAD_KEY_MEMBERS
+# define PTHREAD_KEY_MEMBERS
+#endif
+
+#ifndef PTHREAD_SYSDEP_MEMBERS
+# define PTHREAD_SYSDEP_MEMBERS
+#endif
+
+/* Type of the TCB. */
+typedef struct
+{
+ void *tcb; /* Points to this structure. */
+ void *dtv; /* Vector of pointers to TLS data. */
+ thread_t self; /* This thread's control port. */
+} tcbhead_t;
+
+/* This structure describes a POSIX thread. */
+struct __pthread
+{
+ /* Thread ID. */
+ pthread_t thread;
+
+ /* Cancellation. */
+ int cancel_state;
+ int cancel_type;
+ int cancel_pending;
+ struct __pthread_cancelation_handler *cancelation_handlers;
+
+ /* Thread stack. */
+ void *stackaddr;
+ size_t stacksize;
+ size_t guardsize; /* Included in STACKSIZE (i.e. total
+ stack memory is STACKSIZE, not
+ STACKSIZE + GUARDSIZE). */
+ int stack; /* Nonzero if the stack was allocated. */
+
+ /* Exit status. */
+ void *status;
+
+ /* Thread state. */
+ enum pthread_state state;
+ pthread_mutex_t state_lock; /* Locks the state. */
+ pthread_cond_t state_cond; /* Signalled when the state changes. */
+
+ /* Thread context. */
+ struct pthread_mcontext mcontext;
+
+ PTHREAD_KEY_MEMBERS
+
+ PTHREAD_SYSDEP_MEMBERS
+
+ tcbhead_t *tcb;
+
+ struct __pthread *next, **prevp;
+};
+
+/* Enqueue an element THREAD on the queue *HEAD. */
+static inline void
+__pthread_enqueue (struct __pthread **head, struct __pthread *thread)
+{
+ assert (thread->prevp == 0);
+
+ thread->next = *head;
+ thread->prevp = head;
+ if (*head)
+ (*head)->prevp = &thread->next;
+ *head = thread;
+}
+
+/* Dequeue the element THREAD from the queue it is connected to. */
+static inline void
+__pthread_dequeue (struct __pthread *thread)
+{
+ assert (thread);
+
+ if (thread->next)
+ thread->next->prevp = thread->prevp;
+ *thread->prevp = thread->next;
+ thread->prevp = 0;
+}
+
+/* Iterate over QUEUE storing each element in ELEMENT. */
+#define __pthread_queue_iterate(queue, element) \
+ for (struct __pthread *__pdi_next = (queue); \
+ ((element) = __pdi_next) \
+ && ((__pdi_next = __pdi_next->next), \
+ 1); \
+ )
+
+/* Iterate over QUEUE dequeuing each element, storing it in
+ ELEMENT. */
+#define __pthread_dequeuing_iterate(queue, element) \
+ for (struct __pthread *__pdi_next = (queue); \
+ ((element) = __pdi_next) \
+ && ((__pdi_next = __pdi_next->next), \
+ ((element)->prevp = 0), \
+ 1); \
+ )
+
+/* The total number of threads currently active. */
+extern __atomic_t __pthread_total;
+
+/* The total number of thread IDs currently in use, or on the list of
+ available thread IDs. */
+extern int __pthread_num_threads;
+
+/* Concurrency hint. */
+extern int __pthread_concurrency;
+
+/* Array of __pthread structures and its lock. Indexed by the pthread
+ id minus one. (Why not just use the pthread id? Because some
+ brain-dead users of the pthread interface incorrectly assume that 0
+ is an invalid pthread id.) */
+extern struct __pthread **__pthread_threads;
+extern pthread_rwlock_t __pthread_threads_lock;
+
+#define __pthread_getid(thread) \
+ ({ struct __pthread *__t; \
+ pthread_rwlock_rdlock (&__pthread_threads_lock); \
+ __t = __pthread_threads[thread - 1]; \
+ pthread_rwlock_unlock (&__pthread_threads_lock); \
+ __t; })
+
+#define __pthread_setid(thread, pthread) \
+ pthread_rwlock_wrlock (&__pthread_threads_lock); \
+ __pthread_threads[thread - 1] = pthread; \
+ pthread_rwlock_unlock (&__pthread_threads_lock);
+
+/* Similar to pthread_self, but returns the thread descriptor instead
+ of the thread ID. */
+#ifndef _pthread_self
+extern struct __pthread *_pthread_self (void);
+#endif
+
+
+/* Initialize the pthreads library. */
+extern void __pthread_initialize (void);
+
+/* Internal version of pthread_create. Rather than return the new
+ tid, we return the whole __pthread structure in *PTHREAD. */
+extern int __pthread_create_internal (struct __pthread **__restrict pthread,
+ const pthread_attr_t *__restrict attr,
+ void *(*start_routine)(void *),
+ void *__restrict arg);
+
+/* Allocate a new thread structure and a pthread thread ID (but not a
+ kernel thread or a stack). */
+extern int __pthread_alloc (struct __pthread **thread);
+
+/* Deallocate the thread structure. This is the dual of
+ __pthread_alloc (N.B. it does not call __pthread_stack_alloc nor
+ __pthread_thread_halt). */
+extern void __pthread_dealloc (struct __pthread *thread);
+
+
+/* Allocate a stack of size STACKSIZE. The stack base shall be
+ returned in *STACKADDR. */
+extern int __pthread_stack_alloc (void **stackaddr, size_t stacksize);
+
+/* Deallocate the stack STACKADDR of size STACKSIZE. */
+extern void __pthread_stack_dealloc (void *stackaddr, size_t stacksize);
+
+
+/* Setup thread THREAD's context. */
+extern int __pthread_setup (struct __pthread *__restrict thread,
+ void (*entry_point)(void *(*)(void *),
+ void *),
+ void *(*start_routine)(void *),
+ void *__restrict arg);
+
+
+/* Allocate a kernel thread (and any miscellaneous system dependent
+ resources) for THREAD; it must not be placed on the run queue. */
+extern int __pthread_thread_alloc (struct __pthread *thread);
+
+/* Deallocate any kernel resources associated with THREAD except don't
+ halt the thread itself. On return, the thread will be marked as
+ dead and __pthread_halt will be called. */
+extern void __pthread_thread_dealloc (struct __pthread *thread);
+
+/* Start THREAD making it eligible to run. */
+extern int __pthread_thread_start (struct __pthread *thread);
+
+/* Stop the kernel thread associated with THREAD. If NEED_DEALLOC is
+ true, the function must call __pthread_dealloc on THREAD.
+
+ NB: The thread executing this function may be the thread which is
+ being halted, thus the last action should be halting the thread
+ itself. */
+extern void __pthread_thread_halt (struct __pthread *thread,
+ int need_dealloc);
+
+
+/* Block THREAD. */
+extern void __pthread_block (struct __pthread *thread);
+
+/* Block THREAD until *ABSTIME is reached. */
+extern error_t __pthread_timedblock (struct __pthread *__restrict thread,
+ const struct timespec *__restrict abstime);
+
+/* Wakeup THREAD. */
+extern void __pthread_wakeup (struct __pthread *thread);
+
+
+/* Perform a cancelation. */
+extern int __pthread_do_cancel (struct __pthread *thread);
+
+
+/* Initialize the thread specific data structures. THREAD must be the
+ calling thread. */
+extern error_t __pthread_init_specific (struct __pthread *thread);
+
+/* Call the destructors on all of the thread specific data in THREAD.
+ THREAD must be the calling thread. */
+extern void __pthread_destroy_specific (struct __pthread *thread);
+
+
+/* Initialize newly create thread *THREAD's signal state data
+ structures. */
+extern error_t __pthread_sigstate_init (struct __pthread *thread);
+
+/* Destroy the signal state data structures associcated with thread
+ *THREAD. */
+extern void __pthread_sigstate_destroy (struct __pthread *thread);
+
+/* Modify thread *THREAD's signal state. */
+extern error_t __pthread_sigstate (struct __pthread *__restrict thread, int how,
+ const sigset_t *__restrict set,
+ sigset_t *__restrict oset,
+ int clear_pending);
+
+
+/* Default thread attributes. */
+extern const struct __pthread_attr __pthread_default_attr;
+
+/* Default barrier attributes. */
+extern const struct __pthread_barrierattr __pthread_default_barrierattr;
+
+/* Default mutex attributes. */
+extern const struct __pthread_mutexattr __pthread_default_mutexattr;
+
+/* Default rdlock attributes. */
+const struct __pthread_rwlockattr __pthread_default_rwlockattr;
+
+/* Default condition attributes. */
+const struct __pthread_condattr __pthread_default_condattr;
+
+
+/* From glibc. */
+
+/* Dynamic linker TLS allocation. */
+extern void *_dl_allocate_tls(void *);
+
+/* Dynamic linker TLS deallocation. */
+extern void _dl_deallocate_tls(void *, int);
+
+#endif /* pt-internal.h */
diff --git a/libpthread/pthread/pt-internal.h.orig b/libpthread/pthread/pt-internal.h.orig
new file mode 100644
index 00000000..e7c85fda
--- /dev/null
+++ b/libpthread/pthread/pt-internal.h.orig
@@ -0,0 +1,282 @@
+/* Internal defenitions for pthreads library.
+ Copyright (C) 2000, 2005, 2006, 2008 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. */
+
+#ifndef _PT_INTERNAL_H
+#define _PT_INTERNAL_H 1
+
+#include <pthread.h>
+#include <stddef.h>
+#include <sched.h>
+#include <signal.h>
+#include <assert.h>
+
+#include <bits/atomic.h>
+
+#include <pt-key.h>
+
+#include <pt-sysdep.h>
+#include <pt-machdep.h>
+
+/* Thread state. */
+enum pthread_state
+{
+ PTHREAD_JOINABLE = 0,
+ PTHREAD_DETACHED,
+ PTHREAD_EXITED,
+ PTHREAD_TERMINATED
+};
+
+#ifndef PTHREAD_KEY_MEMBERS
+# define PTHREAD_KEY_MEMBERS
+#endif
+
+#ifndef PTHREAD_SYSDEP_MEMBERS
+# define PTHREAD_SYSDEP_MEMBERS
+#endif
+
+/* This structure describes a POSIX thread. */
+struct __pthread
+{
+ /* Thread ID. */
+ pthread_t thread;
+
+ /* Cancellation. */
+ int cancel_state;
+ int cancel_type;
+ int cancel_pending;
+ struct __pthread_cancelation_handler *cancelation_handlers;
+
+ /* Thread stack. */
+ void *stackaddr;
+ size_t stacksize;
+ size_t guardsize; /* Included in STACKSIZE (i.e. total
+ stack memory is STACKSIZE, not
+ STACKSIZE + GUARDSIZE). */
+ int stack; /* Nonzero if the stack was allocated. */
+
+ /* Exit status. */
+ void *status;
+
+ /* Thread state. */
+ enum pthread_state state;
+ pthread_mutex_t state_lock; /* Locks the state. */
+ pthread_cond_t state_cond; /* Signalled when the state changes. */
+
+ /* Thread context. */
+ struct pthread_mcontext mcontext;
+
+ PTHREAD_KEY_MEMBERS
+
+ PTHREAD_SYSDEP_MEMBERS
+
+ struct __pthread *next, **prevp;
+};
+
+/* Enqueue an element THREAD on the queue *HEAD. */
+static inline void
+__pthread_enqueue (struct __pthread **head, struct __pthread *thread)
+{
+ assert (thread->prevp == 0);
+
+ thread->next = *head;
+ thread->prevp = head;
+ if (*head)
+ (*head)->prevp = &thread->next;
+ *head = thread;
+}
+
+/* Dequeue the element THREAD from the queue it is connected to. */
+static inline void
+__pthread_dequeue (struct __pthread *thread)
+{
+ assert (thread);
+
+ if (thread->next)
+ thread->next->prevp = thread->prevp;
+ *thread->prevp = thread->next;
+ thread->prevp = 0;
+}
+
+/* Iterate over QUEUE storing each element in ELEMENT. */
+#define __pthread_queue_iterate(queue, element) \
+ for (struct __pthread *__pdi_next = (queue); \
+ ((element) = __pdi_next) \
+ && ((__pdi_next = __pdi_next->next), \
+ 1); \
+ )
+
+/* Iterate over QUEUE dequeuing each element, storing it in
+ ELEMENT. */
+#define __pthread_dequeuing_iterate(queue, element) \
+ for (struct __pthread *__pdi_next = (queue); \
+ ((element) = __pdi_next) \
+ && ((__pdi_next = __pdi_next->next), \
+ ((element)->prevp = 0), \
+ 1); \
+ )
+
+/* The total number of threads currently active. */
+extern __atomic_t __pthread_total;
+
+/* The total number of thread IDs currently in use, or on the list of
+ available thread IDs. */
+extern int __pthread_num_threads;
+
+/* Concurrency hint. */
+extern int __pthread_concurrency;
+
+/* Array of __pthread structures and its lock. Indexed by the pthread
+ id minus one. (Why not just use the pthread id? Because some
+ brain-dead users of the pthread interface incorrectly assume that 0
+ is an invalid pthread id.) */
+extern struct __pthread **__pthread_threads;
+extern pthread_rwlock_t __pthread_threads_lock;
+
+#define __pthread_getid(thread) \
+ ({ struct __pthread *__t; \
+ pthread_rwlock_rdlock (&__pthread_threads_lock); \
+ __t = __pthread_threads[thread - 1]; \
+ pthread_rwlock_unlock (&__pthread_threads_lock); \
+ __t; })
+
+#define __pthread_setid(thread, pthread) \
+ pthread_rwlock_wrlock (&__pthread_threads_lock); \
+ __pthread_threads[thread - 1] = pthread; \
+ pthread_rwlock_unlock (&__pthread_threads_lock);
+
+/* Similar to pthread_self, but returns the thread descriptor instead
+ of the thread ID. */
+#ifndef _pthread_self
+extern struct __pthread *_pthread_self (void);
+#endif
+
+
+/* Initialize the pthreads library. */
+extern void __pthread_initialize (void);
+
+/* Internal version of pthread_create. Rather than return the new
+ tid, we return the whole __pthread structure in *PTHREAD. */
+extern int __pthread_create_internal (struct __pthread **__restrict pthread,
+ const pthread_attr_t *__restrict attr,
+ void *(*start_routine)(void *),
+ void *__restrict arg);
+
+/* Allocate a new thread structure and a pthread thread ID (but not a
+ kernel thread or a stack). */
+extern int __pthread_alloc (struct __pthread **thread);
+
+/* Deallocate the thread structure. This is the dual of
+ __pthread_alloc (N.B. it does not call __pthread_stack_alloc nor
+ __pthread_thread_halt). */
+extern void __pthread_dealloc (struct __pthread *thread);
+
+
+/* Allocate a stack of size STACKSIZE. The stack base shall be
+ returned in *STACKADDR. */
+extern int __pthread_stack_alloc (void **stackaddr, size_t stacksize);
+
+/* Deallocate the stack STACKADDR of size STACKSIZE. */
+extern void __pthread_stack_dealloc (void *stackaddr, size_t stacksize);
+
+
+/* Setup thread THREAD's context. */
+extern int __pthread_setup (struct __pthread *__restrict thread,
+ void (*entry_point)(void *(*)(void *),
+ void *),
+ void *(*start_routine)(void *),
+ void *__restrict arg);
+
+
+/* Allocate a kernel thread (and any miscellaneous system dependent
+ resources) for THREAD; it must not be placed on the run queue. */
+extern int __pthread_thread_alloc (struct __pthread *thread);
+
+/* Deallocate any kernel resources associated with THREAD except don't
+ halt the thread itself. On return, the thread will be marked as
+ dead and __pthread_halt will be called. */
+extern void __pthread_thread_dealloc (struct __pthread *thread);
+
+/* Start THREAD making it eligible to run. */
+extern int __pthread_thread_start (struct __pthread *thread);
+
+/* Stop the kernel thread associated with THREAD. If NEED_DEALLOC is
+ true, the function must call __pthread_dealloc on THREAD.
+
+ NB: The thread executing this function may be the thread which is
+ being halted, thus the last action should be halting the thread
+ itself. */
+extern void __pthread_thread_halt (struct __pthread *thread,
+ int need_dealloc);
+
+
+/* Block THREAD. */
+extern void __pthread_block (struct __pthread *thread);
+
+/* Block THREAD until *ABSTIME is reached. */
+extern error_t __pthread_timedblock (struct __pthread *__restrict thread,
+ const struct timespec *__restrict abstime);
+
+/* Wakeup THREAD. */
+extern void __pthread_wakeup (struct __pthread *thread);
+
+
+/* Perform a cancelation. */
+extern int __pthread_do_cancel (struct __pthread *thread);
+
+
+/* Initialize the thread specific data structures. THREAD must be the
+ calling thread. */
+extern error_t __pthread_init_specific (struct __pthread *thread);
+
+/* Call the destructors on all of the thread specific data in THREAD.
+ THREAD must be the calling thread. */
+extern void __pthread_destroy_specific (struct __pthread *thread);
+
+
+/* Initialize newly create thread *THREAD's signal state data
+ structures. */
+extern error_t __pthread_sigstate_init (struct __pthread *thread);
+
+/* Destroy the signal state data structures associcated with thread
+ *THREAD. */
+extern void __pthread_sigstate_destroy (struct __pthread *thread);
+
+/* Modify thread *THREAD's signal state. */
+extern error_t __pthread_sigstate (struct __pthread *__restrict thread, int how,
+ const sigset_t *__restrict set,
+ sigset_t *__restrict oset,
+ int clear_pending);
+
+
+/* Default thread attributes. */
+extern const struct __pthread_attr __pthread_default_attr;
+
+/* Default barrier attributes. */
+extern const struct __pthread_barrierattr __pthread_default_barrierattr;
+
+/* Default mutex attributes. */
+extern const struct __pthread_mutexattr __pthread_default_mutexattr;
+
+/* Default rdlock attributes. */
+const struct __pthread_rwlockattr __pthread_default_rwlockattr;
+
+/* Default condition attributes. */
+const struct __pthread_condattr __pthread_default_condattr;
+
+#endif /* pt-internal.h */
diff --git a/libpthread/pthread/pt-join.c b/libpthread/pthread/pt-join.c
new file mode 100644
index 00000000..698b6c9f
--- /dev/null
+++ b/libpthread/pthread/pt-join.c
@@ -0,0 +1,79 @@
+/* Wait for thread termination.
+ Copyright (C) 2000 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 <pthread.h>
+#include <stddef.h>
+
+#include <pt-internal.h>
+
+/* Make calling thread wait for termination of thread THREAD. Return
+ the exit status of the thread in *STATUS. */
+int
+pthread_join (pthread_t thread, void **status)
+{
+ struct __pthread *pthread;
+ int err = 0;
+
+ /* Lookup the thread structure for THREAD. */
+ pthread = __pthread_getid (thread);
+ if (pthread == NULL)
+ return ESRCH;
+
+ __pthread_mutex_lock (&pthread->state_lock);
+ pthread_cleanup_push (__pthread_mutex_unlock, &pthread->state_lock);
+
+ while (pthread->state == PTHREAD_JOINABLE)
+ pthread_cond_wait (&pthread->state_cond, &pthread->state_lock);
+
+ pthread_cleanup_pop (0);
+
+ switch (pthread->state)
+ {
+ case PTHREAD_EXITED:
+ __pthread_mutex_unlock (&pthread->state_lock);
+
+ /* THREAD has already exited. Salvage its exit status. */
+ if (status)
+ *status = pthread->status;
+
+ /* Make sure nobody can reference it anymore, and mark it as
+ terminated. */
+ assert (pthread->stack);
+ __pthread_stack_dealloc (pthread->stackaddr, pthread->stacksize);
+ pthread->stack = 0;
+
+ __pthread_dealloc (pthread);
+ break;
+
+ case PTHREAD_TERMINATED:
+ /* Pretend THREAD wasn't there in the first place. */
+ __pthread_mutex_unlock (&pthread->state_lock);
+ err = ESRCH;
+ break;
+
+ default:
+ /* Thou shalt not join non-joinable threads! */
+ __pthread_mutex_unlock (&pthread->state_lock);
+ err = EINVAL;
+ break;
+ }
+
+ return err;
+}
diff --git a/libpthread/pthread/pt-self.c b/libpthread/pthread/pt-self.c
new file mode 100644
index 00000000..e14fe1eb
--- /dev/null
+++ b/libpthread/pthread/pt-self.c
@@ -0,0 +1,29 @@
+/* Get calling thread's ID.
+ Copyright (C) 2000 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 <pthread.h>
+
+#include <pt-internal.h>
+
+/* Return the thread ID of the calling thread. */
+pthread_t
+pthread_self (void)
+{
+ return _pthread_self()->thread;
+}
diff --git a/libpthread/pthread/pt-setcancelstate.c b/libpthread/pthread/pt-setcancelstate.c
new file mode 100644
index 00000000..ded58922
--- /dev/null
+++ b/libpthread/pthread/pt-setcancelstate.c
@@ -0,0 +1,42 @@
+/* Set the cancel state for the calling thread.
+ Copyright (C) 2002 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 <pthread.h>
+
+#include <pt-internal.h>
+
+int
+pthread_setcancelstate (int state, int *oldstate)
+{
+ struct __pthread *p = _pthread_self ();
+
+ switch (state)
+ {
+ default:
+ return EINVAL;
+ case PTHREAD_CANCEL_ENABLE:
+ case PTHREAD_CANCEL_DISABLE:
+ break;
+ }
+
+ *oldstate = p->cancel_state;
+ p->cancel_state = state;
+
+ return 0;
+}
diff --git a/libpthread/pthread/pt-setcanceltype.c b/libpthread/pthread/pt-setcanceltype.c
new file mode 100644
index 00000000..9511c991
--- /dev/null
+++ b/libpthread/pthread/pt-setcanceltype.c
@@ -0,0 +1,42 @@
+/* Set the cancel type for the calling thread.
+ Copyright (C) 2002 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 <pthread.h>
+
+#include <pt-internal.h>
+
+int
+pthread_setcanceltype (int type, int *oldtype)
+{
+ struct __pthread *p = _pthread_self ();
+
+ switch (type)
+ {
+ default:
+ return EINVAL;
+ case PTHREAD_CANCEL_DEFERRED:
+ case PTHREAD_CANCEL_ASYNCHRONOUS:
+ break;
+ }
+
+ *oldtype = p->cancel_type;
+ p->cancel_type = type;
+
+ return 0;
+}
diff --git a/libpthread/pthread/pt-sigmask.c b/libpthread/pthread/pt-sigmask.c
new file mode 100644
index 00000000..1b53873e
--- /dev/null
+++ b/libpthread/pthread/pt-sigmask.c
@@ -0,0 +1,33 @@
+/* Get or set a thread's signal mask.
+ Copyright (C) 2000 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 <pthread.h>
+#include <signal.h>
+
+#include <pt-internal.h>
+
+int
+pthread_sigmask (int how, const sigset_t *set,
+ sigset_t *oset)
+{
+ struct __pthread *self = _pthread_self ();
+
+ /* Do not clear SELF's pending signals. */
+ return __pthread_sigstate (self, how, set, oset, 0);
+}
diff --git a/libpthread/pthread/pt-spin-inlines.c b/libpthread/pthread/pt-spin-inlines.c
new file mode 100644
index 00000000..cfb21dd3
--- /dev/null
+++ b/libpthread/pthread/pt-spin-inlines.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 2000 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. */
+
+/* <bits/spin-lock.h> declares some extern inline functions. These
+ functions are declared additionally here for use when inlining is
+ not possible. */
+
+#define _FORCE_INLINES
+#define __PT_SPIN_INLINE /* empty */
+
+#include <pthread.h>
+
+/* Weak aliases for the spin lock functions. Note that
+ pthread_spin_lock is left out deliberately. We already provide an
+ implementation for it in pt-spin.c. */
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy);
+weak_alias (__pthread_spin_init, pthread_spin_init);
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock);
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock);
diff --git a/libpthread/pthread/pt-testcancel.c b/libpthread/pthread/pt-testcancel.c
new file mode 100644
index 00000000..01f1ac9c
--- /dev/null
+++ b/libpthread/pthread/pt-testcancel.c
@@ -0,0 +1,31 @@
+/* Add an explicit cancelation point.
+ Copyright (C) 2002 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 <pthread.h>
+
+#include <pt-internal.h>
+
+void
+pthread_testcancel (void)
+{
+ struct __pthread *p = _pthread_self ();
+
+ if (p->cancel_state == PTHREAD_CANCEL_ENABLE && p->cancel_pending)
+ pthread_exit (PTHREAD_CANCELED);
+}
diff --git a/libpthread/sysdeps/CVS/Entries b/libpthread/sysdeps/CVS/Entries
new file mode 100644
index 00000000..e7d44b09
--- /dev/null
+++ b/libpthread/sysdeps/CVS/Entries
@@ -0,0 +1,6 @@
+D/generic////
+D/hurd////
+D/i386////
+D/l4////
+D/mach////
+D/posix////
diff --git a/libpthread/sysdeps/CVS/Repository b/libpthread/sysdeps/CVS/Repository
new file mode 100644
index 00000000..9e7e5b3d
--- /dev/null
+++ b/libpthread/sysdeps/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps
diff --git a/libpthread/sysdeps/CVS/Root b/libpthread/sysdeps/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/CVS/Tag b/libpthread/sysdeps/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/generic/CVS/Entries b/libpthread/sysdeps/generic/CVS/Entries
new file mode 100644
index 00000000..98d62f3f
--- /dev/null
+++ b/libpthread/sysdeps/generic/CVS/Entries
@@ -0,0 +1,102 @@
+/pt-atfork.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-destroy.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-getdetachstate.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-getguardsize.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-getinheritsched.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-getschedparam.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-getschedpolicy.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-getscope.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-getstack.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-getstackaddr.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-getstacksize.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-init.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-setdetachstate.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-setguardsize.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-setinheritsched.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-setschedparam.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-setschedpolicy.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-setscope.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-setstack.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-setstackaddr.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-setstacksize.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-attr.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-barrier-destroy.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-barrier-init.c/1.2/Thu May 12 20:55:38 2005//Tzhengda-soc2008-virt-branch
+/pt-barrier-wait.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-barrier.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-barrierattr-destroy.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-barrierattr-getpshared.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-barrierattr-init.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-barrierattr-setpshared.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-cond-brdcast.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-cond-destroy.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-cond-init.c/1.2/Thu May 12 20:55:38 2005//Tzhengda-soc2008-virt-branch
+/pt-cond-signal.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-cond-timedwait.c/1.3/Thu May 12 20:55:38 2005//Tzhengda-soc2008-virt-branch
+/pt-cond-wait.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-cond.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-condattr-destroy.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-condattr-getclock.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-condattr-getpshared.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-condattr-init.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-condattr-setclock.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-condattr-setpshared.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-destroy-specific.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-equal.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-getconcurrency.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-getcpuclockid.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-getschedparam.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-getspecific.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-init-specific.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-key-create.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-key-delete.c/1.2/Sat Nov 2 23:41:51 2002//Tzhengda-soc2008-virt-branch
+/pt-key.h/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-mutex-destroy.c/1.3/Tue Jul 1 11:43:15 2008//Tzhengda-soc2008-virt-branch
+/pt-mutex-getprioceiling.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-mutex-init.c/1.4/Tue Jul 1 11:43:15 2008//Tzhengda-soc2008-virt-branch
+/pt-mutex-lock.c/1.3/Tue Jul 1 11:43:15 2008//Tzhengda-soc2008-virt-branch
+/pt-mutex-setprioceiling.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-mutex-timedlock.c/1.4/Sun Jun 22 09:05:31 2008//Tzhengda-soc2008-virt-branch
+/pt-mutex-trylock.c/1.6/Tue Jul 1 11:43:15 2008//Tzhengda-soc2008-virt-branch
+/pt-mutex-unlock.c/1.5/Tue Jul 1 11:43:15 2008//Tzhengda-soc2008-virt-branch
+/pt-mutexattr-destroy.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-mutexattr-getprioceiling.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-mutexattr-getprotocol.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-mutexattr-getpshared.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-mutexattr-gettype.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-mutexattr-init.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-mutexattr-setprioceiling.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-mutexattr-setprotocol.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-mutexattr-setpshared.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-mutexattr-settype.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-mutexattr.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-once.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-rwlock-attr.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-rwlock-destroy.c/1.3/Tue Jul 1 11:43:15 2008//Tzhengda-soc2008-virt-branch
+/pt-rwlock-init.c/1.4/Tue Jul 1 11:43:15 2008//Tzhengda-soc2008-virt-branch
+/pt-rwlock-rdlock.c/1.2/Thu May 12 20:55:38 2005//Tzhengda-soc2008-virt-branch
+/pt-rwlock-timedrdlock.c/1.3/Thu May 12 20:55:38 2005//Tzhengda-soc2008-virt-branch
+/pt-rwlock-timedwrlock.c/1.3/Thu May 12 20:55:38 2005//Tzhengda-soc2008-virt-branch
+/pt-rwlock-tryrdlock.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-rwlock-trywrlock.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-rwlock-unlock.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-rwlock-wrlock.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-rwlockattr-destroy.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-rwlockattr-getpshared.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-rwlockattr-init.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-rwlockattr-setpshared.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-setconcurrency.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-setschedparam.c/1.2/Wed Apr 20 15:26:52 2005//Tzhengda-soc2008-virt-branch
+/pt-setschedprio.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/pt-setspecific.c/1.1/Thu Oct 10 23:05:06 2002//Tzhengda-soc2008-virt-branch
+/sem-close.c/1.2/Sat Jan 20 13:07:06 2007//Tzhengda-soc2008-virt-branch
+/sem-destroy.c/1.3/Tue Jul 1 11:43:15 2008//Tzhengda-soc2008-virt-branch
+/sem-getvalue.c/1.3/Tue Jul 1 11:43:15 2008//Tzhengda-soc2008-virt-branch
+/sem-init.c/1.3/Tue Jul 1 11:43:15 2008//Tzhengda-soc2008-virt-branch
+/sem-open.c/1.3/Tue Jul 1 11:43:15 2008//Tzhengda-soc2008-virt-branch
+/sem-post.c/1.3/Tue Jul 1 11:43:15 2008//Tzhengda-soc2008-virt-branch
+/sem-timedwait.c/1.4/Tue Jul 1 11:43:15 2008//Tzhengda-soc2008-virt-branch
+/sem-trywait.c/1.3/Tue Jul 1 11:43:15 2008//Tzhengda-soc2008-virt-branch
+/sem-unlink.c/1.3/Tue Jul 1 11:43:15 2008//Tzhengda-soc2008-virt-branch
+/sem-wait.c/1.3/Tue Jul 1 11:43:16 2008//Tzhengda-soc2008-virt-branch
+D/bits////
diff --git a/libpthread/sysdeps/generic/CVS/Repository b/libpthread/sysdeps/generic/CVS/Repository
new file mode 100644
index 00000000..df04e6a6
--- /dev/null
+++ b/libpthread/sysdeps/generic/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps/generic
diff --git a/libpthread/sysdeps/generic/CVS/Root b/libpthread/sysdeps/generic/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/generic/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/generic/CVS/Tag b/libpthread/sysdeps/generic/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/generic/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/generic/bits/CVS/Entries b/libpthread/sysdeps/generic/bits/CVS/Entries
new file mode 100644
index 00000000..13c50c38
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/CVS/Entries
@@ -0,0 +1,15 @@
+/barrier-attr.h/1.3/Tue Jul 1 11:43:16 2008//Tzhengda-soc2008-virt-branch
+/barrier.h/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/cancelation.h/1.3/Tue Jul 1 11:43:16 2008//Tzhengda-soc2008-virt-branch
+/condition-attr.h/1.3/Tue Jul 1 11:43:16 2008//Tzhengda-soc2008-virt-branch
+/condition.h/1.2/Thu May 12 20:55:38 2005//Tzhengda-soc2008-virt-branch
+/mutex-attr.h/1.3/Tue Jul 1 11:43:16 2008//Tzhengda-soc2008-virt-branch
+/mutex.h/1.6/Tue Jul 1 11:43:16 2008//Tzhengda-soc2008-virt-branch
+/once.h/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pthread.h/1.5/Tue Jul 1 11:43:16 2008//Tzhengda-soc2008-virt-branch
+/rwlock-attr.h/1.3/Tue Jul 1 11:43:16 2008//Tzhengda-soc2008-virt-branch
+/rwlock.h/1.6/Tue Jul 1 11:43:16 2008//Tzhengda-soc2008-virt-branch
+/semaphore.h/1.1/Thu May 12 11:50:42 2005//Tzhengda-soc2008-virt-branch
+/thread-attr.h/1.3/Tue Jul 1 11:43:16 2008//Tzhengda-soc2008-virt-branch
+/thread-specific.h/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+D
diff --git a/libpthread/sysdeps/generic/bits/CVS/Repository b/libpthread/sysdeps/generic/bits/CVS/Repository
new file mode 100644
index 00000000..565a3470
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps/generic/bits
diff --git a/libpthread/sysdeps/generic/bits/CVS/Root b/libpthread/sysdeps/generic/bits/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/generic/bits/CVS/Tag b/libpthread/sysdeps/generic/bits/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/generic/bits/barrier-attr.h b/libpthread/sysdeps/generic/bits/barrier-attr.h
new file mode 100644
index 00000000..a9900b71
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/barrier-attr.h
@@ -0,0 +1,32 @@
+/* Thread barrier attribute type. Generic version.
+ Copyright (C) 2002, 2008 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. */
+
+#ifndef _BITS_BARRIER_ATTR_H
+#define _BITS_BARRIER_ATTR_H 1
+
+enum __pthread_process_shared;
+
+/* This structure describes the attributes of a POSIX thread barrier.
+ Note that not all of them are supported on all systems. */
+struct __pthread_barrierattr
+{
+ enum __pthread_process_shared pshared;
+};
+
+#endif /* bits/barrier-attr.h */
diff --git a/libpthread/sysdeps/generic/bits/barrier.h b/libpthread/sysdeps/generic/bits/barrier.h
new file mode 100644
index 00000000..5e559312
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/barrier.h
@@ -0,0 +1,39 @@
+/* Thread barrier attribute type. Generic version.
+ Copyright (C) 2002 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. */
+
+#ifndef _BITS_BARRIER_H
+#define _BITS_BARRIER_H 1
+
+#include <bits/spin-lock.h>
+
+/* This structure describes the attributes of a POSIX barrier. */
+struct __pthread_barrier
+{
+ __pthread_spinlock_t lock;
+ struct __pthread *queue; /* List of waiters. */
+ unsigned pending; /* Number of that still need to wait on
+ barrier. */
+ unsigned count; /* Number of threads that must wait before
+ barrier is passed. */
+ struct __pthread_barrierattr *attr;
+ void *data;
+};
+
+
+#endif /* bits/barrier.h */
diff --git a/libpthread/sysdeps/generic/bits/cancelation.h b/libpthread/sysdeps/generic/bits/cancelation.h
new file mode 100644
index 00000000..f446d595
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/cancelation.h
@@ -0,0 +1,54 @@
+/* Cancelation. Generic version.
+ Copyright (C) 2002, 2008 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. */
+
+#ifndef _BITS_CANCELATION_H
+#define _BITS_CANCELATION_H 1
+
+#include <assert.h>
+
+struct __pthread_cancelation_handler
+{
+ void (*handler)(void *);
+ void *arg;
+ struct __pthread_cancelation_handler *next;
+};
+
+/* Returns the thread local location of the cleanup handler stack. */
+struct __pthread_cancelation_handler **__pthread_get_cleanup_stack (void);
+
+#define __pthread_cleanup_push(rt, rtarg) \
+ { \
+ struct __pthread_cancelation_handler **__handlers \
+ = __pthread_get_cleanup_stack (); \
+ struct __pthread_cancelation_handler __handler = \
+ { \
+ handler: (rt), \
+ arg: (rtarg), \
+ next: *__handlers \
+ }; \
+ *__handlers = &__handler;
+
+#define __pthread_cleanup_pop(execute) \
+ if (execute) \
+ __handler.handler (__handler.arg); \
+ assert (*__handlers == &__handler); \
+ *__handlers = __handler.next; \
+ }
+
+#endif /* _BITS_CANCELATION_H */
diff --git a/libpthread/sysdeps/generic/bits/condition-attr.h b/libpthread/sysdeps/generic/bits/condition-attr.h
new file mode 100644
index 00000000..a1311286
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/condition-attr.h
@@ -0,0 +1,34 @@
+/* Condition attribute type. Generic version.
+ Copyright (C) 2002, 2008 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. */
+
+#ifndef _BITS_CONDITION_ATTR_H
+#define _BITS_CONDITION_ATTR_H 1
+
+#include <time.h>
+
+enum __pthread_process_shared;
+
+/* User visible part of a condition attribute variable. */
+struct __pthread_condattr
+ {
+ enum __pthread_process_shared pshared;
+ clockid_t clock;
+ };
+
+#endif /* bits/condition.h */
diff --git a/libpthread/sysdeps/generic/bits/condition.h b/libpthread/sysdeps/generic/bits/condition.h
new file mode 100644
index 00000000..f3b09be4
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/condition.h
@@ -0,0 +1,39 @@
+/* Condition type. Generic version.
+ Copyright (C) 2000, 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
+ 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. */
+
+#ifndef _BITS_CONDITION_H
+#define _BITS_CONDITION_H 1
+
+#include <bits/spin-lock.h>
+
+/* User visible part of a condition variable. */
+struct __pthread_cond
+ {
+ __pthread_spinlock_t __lock;
+ struct __pthread *__queue;
+ struct __pthread_condattr *__attr;
+ struct __pthread_condimpl *__impl;
+ void *__data;
+ };
+
+/* Initializer for a condition variable. */
+#define __PTHREAD_COND_INITIALIZER \
+ { __SPIN_LOCK_INITIALIZER, NULL, NULL, NULL, NULL }
+
+#endif /* bits/condition.h */
diff --git a/libpthread/sysdeps/generic/bits/mutex-attr.h b/libpthread/sysdeps/generic/bits/mutex-attr.h
new file mode 100644
index 00000000..7a5c45c2
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/mutex-attr.h
@@ -0,0 +1,37 @@
+/* Mutex attribute type. Generic version.
+ Copyright (C) 2002, 2008 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. */
+
+#ifndef _BITS_MUTEX_ATTR_H
+#define _BITS_MUTEX_ATTR_H 1
+
+enum __pthread_mutex_protocol;
+enum __pthread_process_shared;
+enum __pthread_mutex_type;
+
+/* This structure describes the attributes of a POSIX mutex
+ attribute. */
+struct __pthread_mutexattr
+{
+ int prioceiling;
+ enum __pthread_mutex_protocol protocol;
+ enum __pthread_process_shared pshared;
+ enum __pthread_mutex_type mutex_type;
+};
+
+#endif /* bits/mutex-attr.h */
diff --git a/libpthread/sysdeps/generic/bits/mutex.h b/libpthread/sysdeps/generic/bits/mutex.h
new file mode 100644
index 00000000..b44fa6df
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/mutex.h
@@ -0,0 +1,67 @@
+/* Mutex type. Generic version.
+ Copyright (C) 2000, 2002, 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
+ 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. */
+
+#ifndef _BITS_MUTEX_H
+
+#ifndef __need_pthread_mutex
+# define _BITS_MUTEX_H 1
+#endif
+
+#ifndef __pthread_mutex_defined
+# if defined __need_pthread_mutex || defined _BITS_MUTEX_H
+# undef __need_pthread_mutex
+# define __pthread_mutex_defined
+
+# include <bits/spin-lock.h>
+# include <bits/mutex-attr.h>
+
+/* User visible part of a mutex. */
+struct __pthread_mutex
+ {
+ __pthread_spinlock_t __held;
+ __pthread_spinlock_t __lock;
+ /* In cthreads, mutex_init does not initialized thre third
+ pointer, as such, we cannot rely on its value for anything. */
+ char *cthreadscompat1;
+ struct __pthread *__queue;
+ struct __pthread_mutexattr *attr;
+ void *data;
+ /* Up to this point, we are completely compatible with cthreads
+ and what libc expects. */
+ void *owner;
+ unsigned locks;
+ /* If NULL then the default attributes apply. */
+ };
+
+/* Initializer for a mutex. N.B. this also happens to be compatible
+ with the cthread mutex initializer. */
+# define __PTHREAD_MUTEX_INITIALIZER \
+ { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0, 0 }
+
+# endif
+#endif /* Not __pthread_mutex_defined. */
+
+#ifdef _BITS_MUTEX_H
+
+#include <errno.h>
+#include <stddef.h>
+
+#endif
+
+#endif /* bits/mutex.h */
diff --git a/libpthread/sysdeps/generic/bits/once.h b/libpthread/sysdeps/generic/bits/once.h
new file mode 100644
index 00000000..7f572faf
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/once.h
@@ -0,0 +1,34 @@
+/* Dynamic package initialization data structures. Generic version.
+ Copyright (C) 2002 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. */
+
+#ifndef _BITS_ONCE_H
+#define _BITS_ONCE_H 1
+
+#include <bits/spin-lock.h>
+
+struct __pthread_once
+{
+ int run;
+ __pthread_spinlock_t lock;
+};
+
+#define __PTHREAD_ONCE_INIT \
+ { 0, __SPIN_LOCK_INITIALIZER }
+
+#endif /* bits/once.h */
diff --git a/libpthread/sysdeps/generic/bits/pthread.h b/libpthread/sysdeps/generic/bits/pthread.h
new file mode 100644
index 00000000..80e6b096
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/pthread.h
@@ -0,0 +1,38 @@
+/* Pthread data structures. Generic version.
+ Copyright (C) 2002, 2008 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. */
+
+#ifndef _BITS_PTHREAD_H
+#define _BITS_PTHREAD_H 1
+
+typedef int __pthread_t;
+
+/* Return true if __T1 and __T2 both name the same thread. Otherwise,
+ false. */
+extern int
+__pthread_equal (__pthread_t __t1, __pthread_t __t2);
+
+#ifdef __USE_EXTERN_INLINES
+__extern_inline int
+__pthread_equal (__pthread_t __t1, __pthread_t __t2)
+{
+ return __t1 == __t2;
+}
+#endif
+
+#endif /* bits/pthread.h */
diff --git a/libpthread/sysdeps/generic/bits/rwlock-attr.h b/libpthread/sysdeps/generic/bits/rwlock-attr.h
new file mode 100644
index 00000000..dba99f1d
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/rwlock-attr.h
@@ -0,0 +1,32 @@
+/* Thread rwlock attribute type. Generic version.
+ Copyright (C) 2002, 2008 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. */
+
+#ifndef _BITS_RWLOCK_ATTR_H
+#define _BITS_RWLOCK_ATTR_H 1
+
+enum __pthread_process_shared;
+
+/* This structure describes the attributes of a POSIX thread rwlock.
+ Note that not all of them are supported on all systems. */
+struct __pthread_rwlockattr
+{
+ enum __pthread_process_shared pshared;
+};
+
+#endif /* bits/rwlock-attr.h */
diff --git a/libpthread/sysdeps/generic/bits/rwlock.h b/libpthread/sysdeps/generic/bits/rwlock.h
new file mode 100644
index 00000000..3d600ec3
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/rwlock.h
@@ -0,0 +1,46 @@
+/* rwlock type. Generic version.
+ Copyright (C) 2002, 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
+ 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. */
+
+#ifndef _BITS_RWLOCK_H
+#define _BITS_RWLOCK_H
+
+#include <bits/spin-lock.h>
+
+/* User visible part of a rwlock. If __held is not held and readers
+ is 0, then the lock is unlocked. If __held is held and readers is
+ 0, then the lock is held by a writer. If __held is held and
+ readers is greater than 0, then the lock is held by READERS
+ readers. */
+struct __pthread_rwlock
+ {
+ __pthread_spinlock_t __held;
+ __pthread_spinlock_t __lock;
+ int readers;
+ struct __pthread *readerqueue;
+ struct __pthread *writerqueue;
+ struct __pthread_rwlockattr *__attr;
+ void *__data;
+ };
+
+/* Initializer for a rwlock. */
+#define __PTHREAD_RWLOCK_INITIALIZER \
+ { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0 }
+
+
+#endif /* bits/rwlock.h */
diff --git a/libpthread/sysdeps/generic/bits/semaphore.h b/libpthread/sysdeps/generic/bits/semaphore.h
new file mode 100644
index 00000000..b53f47e3
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/semaphore.h
@@ -0,0 +1,43 @@
+/* Semaphore type. Generic version.
+ Copyright (C) 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
+ 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. */
+
+#ifndef _BITS_SEMAPHORE_H
+#define _BITS_SEMAPHORE_H 1
+
+#ifndef _SEMAPHORE_H
+#error Never include <bits/semaphore.h> directly.
+#endif
+
+#include <pthread.h>
+
+/* User visible part of a semaphore. */
+struct __semaphore
+ {
+ __pthread_spinlock_t __lock;
+ struct __pthread *__queue;
+ int __pshared;
+ int __value;
+ void *__data;
+ };
+
+/* Initializer for a semaphore. */
+#define __SEMAPHORE_INITIALIZER(pshared, value) \
+ { __SPIN_LOCK_INITIALIZER, NULL, (pshared), (value), NULL }
+
+#endif /* bits/mutex.h */
diff --git a/libpthread/sysdeps/generic/bits/thread-attr.h b/libpthread/sysdeps/generic/bits/thread-attr.h
new file mode 100644
index 00000000..c3a93fde
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/thread-attr.h
@@ -0,0 +1,43 @@
+/* Thread attribute type. Generic version.
+ Copyright (C) 2000, 2002, 2008 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. */
+
+#ifndef _BITS_THREAD_ATTR_H
+#define _BITS_THREAD_ATTR_H 1
+
+#include <sched.h>
+
+enum __pthread_detachstate;
+enum __pthread_inheritsched;
+enum __pthread_contentionscope;
+
+/* This structure describes the attributes of a POSIX thread. Note
+ that not all of them are supported on all systems. */
+struct __pthread_attr
+{
+ struct sched_param schedparam;
+ void *stackaddr;
+ size_t stacksize;
+ size_t guardsize;
+ enum __pthread_detachstate detachstate;
+ enum __pthread_inheritsched inheritsched;
+ enum __pthread_contentionscope contentionscope;
+ int schedpolicy;
+};
+
+#endif /* bits/thread-attr.h */
diff --git a/libpthread/sysdeps/generic/bits/thread-specific.h b/libpthread/sysdeps/generic/bits/thread-specific.h
new file mode 100644
index 00000000..b42d99e7
--- /dev/null
+++ b/libpthread/sysdeps/generic/bits/thread-specific.h
@@ -0,0 +1,25 @@
+/* Thread specific data. Generic version.
+ Copyright (C) 2002 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. */
+
+#ifndef _BITS_THREAD_SPECIFIC_H
+#define _BITS_THREAD_SPECIFIC_H 1
+
+typedef int __pthread_key;
+
+#endif /* bits/thread-specific.h */
diff --git a/libpthread/sysdeps/generic/pt-atfork.c b/libpthread/sysdeps/generic/pt-atfork.c
new file mode 100644
index 00000000..32e1e78c
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-atfork.c
@@ -0,0 +1,29 @@
+/* Register fork handlers. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_atfork (void (*prepare) (void),
+ void (*parent) (void),
+ void (*child) (void))
+{
+ return ENOSYS;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-destroy.c b/libpthread/sysdeps/generic/pt-attr-destroy.c
new file mode 100644
index 00000000..c4b9aa54
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-destroy.c
@@ -0,0 +1,27 @@
+/* pthread_attr_destroy. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_destroy (pthread_attr_t *attr)
+{
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-getdetachstate.c b/libpthread/sysdeps/generic/pt-attr-getdetachstate.c
new file mode 100644
index 00000000..be406f1d
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-getdetachstate.c
@@ -0,0 +1,29 @@
+/* pthread_attr_getdetachstate. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_getdetachstate (const pthread_attr_t *attr,
+ int *detachstate)
+{
+ *detachstate = attr->detachstate;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-getguardsize.c b/libpthread/sysdeps/generic/pt-attr-getguardsize.c
new file mode 100644
index 00000000..c1d9f13e
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-getguardsize.c
@@ -0,0 +1,29 @@
+/* pthread_attr_getguardsize. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_getguardsize (const pthread_attr_t *attr,
+ size_t *guardsize)
+{
+ *guardsize = attr->guardsize;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-getinheritsched.c b/libpthread/sysdeps/generic/pt-attr-getinheritsched.c
new file mode 100644
index 00000000..cca4e3d7
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-getinheritsched.c
@@ -0,0 +1,29 @@
+/* pthread_attr_getinheritsched. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_getinheritsched (const pthread_attr_t *attr,
+ int *inheritsched)
+{
+ *inheritsched = attr->inheritsched;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-getschedparam.c b/libpthread/sysdeps/generic/pt-attr-getschedparam.c
new file mode 100644
index 00000000..25afebd0
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-getschedparam.c
@@ -0,0 +1,31 @@
+/* pthread_attr_getschedparam. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <sched.h>
+
+#include <pt-internal.h>
+
+int
+pthread_attr_getschedparam (const pthread_attr_t *attr,
+ struct sched_param *param)
+{
+ *param = attr->schedparam;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-getschedpolicy.c b/libpthread/sysdeps/generic/pt-attr-getschedpolicy.c
new file mode 100644
index 00000000..4349a238
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-getschedpolicy.c
@@ -0,0 +1,29 @@
+/* pthread_attr_getschedpolicy. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_getschedpolicy (const pthread_attr_t *attr,
+ int *policy)
+{
+ *policy = attr->schedpolicy;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-getscope.c b/libpthread/sysdeps/generic/pt-attr-getscope.c
new file mode 100644
index 00000000..97198fa5
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-getscope.c
@@ -0,0 +1,29 @@
+/* pthread_attr_getscope. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_getscope (const pthread_attr_t *attr,
+ int *contentionscope)
+{
+ *contentionscope = attr->contentionscope;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-getstack.c b/libpthread/sysdeps/generic/pt-attr-getstack.c
new file mode 100644
index 00000000..7beb79f0
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-getstack.c
@@ -0,0 +1,31 @@
+/* pthread_attr_getstack. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_getstack (const pthread_attr_t *attr,
+ void **stackaddr,
+ size_t *stacksize)
+{
+ pthread_attr_getstackaddr (attr, stackaddr);
+ pthread_attr_getstacksize (attr, stacksize);
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-getstackaddr.c b/libpthread/sysdeps/generic/pt-attr-getstackaddr.c
new file mode 100644
index 00000000..d43eeff7
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-getstackaddr.c
@@ -0,0 +1,29 @@
+/* pthread_attr_getstackaddr. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_getstackaddr (const pthread_attr_t *attr,
+ void **stackaddr)
+{
+ *stackaddr = attr->stackaddr;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-getstacksize.c b/libpthread/sysdeps/generic/pt-attr-getstacksize.c
new file mode 100644
index 00000000..c1bc6617
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-getstacksize.c
@@ -0,0 +1,29 @@
+/* pthread_attr_getstacksize. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_getstacksize (const pthread_attr_t *attr,
+ size_t *stacksize)
+{
+ *stacksize = attr->stacksize;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-init.c b/libpthread/sysdeps/generic/pt-attr-init.c
new file mode 100644
index 00000000..6a930e30
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-init.c
@@ -0,0 +1,28 @@
+/* pthread_attr_init. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_init (pthread_attr_t *attr)
+{
+ *attr = __pthread_default_attr;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-setdetachstate.c b/libpthread/sysdeps/generic/pt-attr-setdetachstate.c
new file mode 100644
index 00000000..688ba5d6
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-setdetachstate.c
@@ -0,0 +1,38 @@
+/* pthread_attr_setdetachstate. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_setdetachstate (pthread_attr_t *attr,
+ int detachstate)
+{
+ switch (detachstate)
+ {
+ case PTHREAD_CREATE_DETACHED:
+ case PTHREAD_CREATE_JOINABLE:
+ attr->detachstate = detachstate;
+ break;
+ default:
+ return EINVAL;
+ }
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-setguardsize.c b/libpthread/sysdeps/generic/pt-attr-setguardsize.c
new file mode 100644
index 00000000..b2ba0f0f
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-setguardsize.c
@@ -0,0 +1,29 @@
+/* pthread_attr_setguardsize. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_setguardsize (pthread_attr_t *attr,
+ size_t guardsize)
+{
+ attr->guardsize = guardsize;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-setinheritsched.c b/libpthread/sysdeps/generic/pt-attr-setinheritsched.c
new file mode 100644
index 00000000..e9012c58
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-setinheritsched.c
@@ -0,0 +1,38 @@
+/* pthread_attr_setinheritsched. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_setinheritsched (pthread_attr_t *attr,
+ int inheritsched)
+{
+ switch (inheritsched)
+ {
+ case PTHREAD_INHERIT_SCHED:
+ case PTHREAD_EXPLICIT_SCHED:
+ attr->inheritsched = inheritsched;
+ break;
+ default:
+ return EINVAL;
+ }
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-setschedparam.c b/libpthread/sysdeps/generic/pt-attr-setschedparam.c
new file mode 100644
index 00000000..18a575ec
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-setschedparam.c
@@ -0,0 +1,38 @@
+/* pthread_attr_getschedparam. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <sched.h>
+#include <string.h>
+
+#include <pt-internal.h>
+
+int
+pthread_attr_setschedparam (pthread_attr_t *attr,
+ const struct sched_param *param)
+{
+ if (memcmp (param, &__pthread_default_attr.schedparam,
+ sizeof *param) == 0)
+ {
+ attr->schedparam = *param;
+ return 0;
+ }
+
+ return ENOTSUP;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-setschedpolicy.c b/libpthread/sysdeps/generic/pt-attr-setschedpolicy.c
new file mode 100644
index 00000000..e481d04c
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-setschedpolicy.c
@@ -0,0 +1,42 @@
+/* pthread_attr_getschedpolicy. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_setschedpolicy (pthread_attr_t *attr,
+ int policy)
+{
+ switch (policy)
+ {
+ case SCHED_OTHER:
+ attr->schedpolicy = policy;
+ break;
+
+ case SCHED_FIFO:
+ case SCHED_RR:
+ return ENOTSUP;
+
+ default:
+ return EINVAL;
+ }
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-setscope.c b/libpthread/sysdeps/generic/pt-attr-setscope.c
new file mode 100644
index 00000000..c74a4f67
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-setscope.c
@@ -0,0 +1,41 @@
+/* pthread_attr_setscope. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_setscope (pthread_attr_t *attr,
+ int contentionscope)
+{
+ if (contentionscope == __pthread_default_attr.contentionscope)
+ {
+ attr->contentionscope = contentionscope;
+ return 0;
+ }
+
+ switch (contentionscope)
+ {
+ case PTHREAD_SCOPE_PROCESS:
+ case PTHREAD_SCOPE_SYSTEM:
+ return ENOTSUP;
+ default:
+ return EINVAL;
+ }
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-setstack.c b/libpthread/sysdeps/generic/pt-attr-setstack.c
new file mode 100644
index 00000000..360d27a3
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-setstack.c
@@ -0,0 +1,51 @@
+/* pthread_attr_setstack. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+int
+pthread_attr_setstack (pthread_attr_t *attr,
+ void *stackaddr,
+ size_t stacksize)
+{
+ int err;
+ size_t s;
+
+ /* pthread_attr_setstack should always succeed, thus we set the size
+ first as it is more discriminating. */
+ pthread_attr_getstacksize (attr, &s);
+
+ err = pthread_attr_setstacksize (attr, stacksize);
+ if (err)
+ return err;
+
+ err = pthread_attr_setstackaddr (attr, stackaddr);
+ if (err)
+ {
+ int e = pthread_attr_setstacksize (attr, s);
+ assert_perror (e);
+
+ return err;
+ }
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-setstackaddr.c b/libpthread/sysdeps/generic/pt-attr-setstackaddr.c
new file mode 100644
index 00000000..431f2d0c
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-setstackaddr.c
@@ -0,0 +1,29 @@
+/* pthread_attr_setstackaddr. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_setstackaddr (pthread_attr_t *attr,
+ void *stackaddr)
+{
+ attr->stackaddr = stackaddr;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr-setstacksize.c b/libpthread/sysdeps/generic/pt-attr-setstacksize.c
new file mode 100644
index 00000000..d0e51022
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr-setstacksize.c
@@ -0,0 +1,41 @@
+/* pthread_attr_setstacksize. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_attr_setstacksize (pthread_attr_t *attr,
+ size_t stacksize)
+{
+ if (stacksize == __pthread_default_attr.stacksize)
+ {
+ attr->stacksize = stacksize;
+
+ /* The guard size cannot be larger than the stack itself, as
+ such, if the new stack size is smaller than the guard size,
+ we squash the guard size. */
+ if (attr->guardsize > attr->stacksize)
+ attr->guardsize = attr->stacksize;
+
+ return 0;
+ }
+
+ return ENOTSUP;
+}
diff --git a/libpthread/sysdeps/generic/pt-attr.c b/libpthread/sysdeps/generic/pt-attr.c
new file mode 100644
index 00000000..769f292a
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-attr.c
@@ -0,0 +1,41 @@
+/* Default attributes. Generic version.
+ Copyright (C) 2000,02 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 <pthread.h>
+#include <sched.h>
+#include <stddef.h>
+#include <limits.h>
+
+#include <pt-internal.h>
+
+const struct __pthread_attr __pthread_default_attr =
+{
+ schedparam: { sched_priority: 0 },
+ stacksize: PTHREAD_STACK_DEFAULT,
+ stackaddr: NULL,
+#ifdef PAGESIZE
+ guardsize: PAGESIZE,
+#else
+ guardsize: 0,
+#endif /* PAGESIZE */
+ detachstate: PTHREAD_CREATE_JOINABLE,
+ inheritsched: PTHREAD_EXPLICIT_SCHED,
+ contentionscope: PTHREAD_SCOPE_SYSTEM,
+ schedpolicy: SCHED_OTHER
+};
diff --git a/libpthread/sysdeps/generic/pt-barrier-destroy.c b/libpthread/sysdeps/generic/pt-barrier-destroy.c
new file mode 100644
index 00000000..01b938b4
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-barrier-destroy.c
@@ -0,0 +1,27 @@
+/* pthread_barrier_destroy. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_barrier_destroy (pthread_barrier_t *barrier)
+{
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-barrier-init.c b/libpthread/sysdeps/generic/pt-barrier-init.c
new file mode 100644
index 00000000..c42b3bb6
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-barrier-init.c
@@ -0,0 +1,53 @@
+/* pthread_barrier_init. Generic version.
+ Copyright (C) 2002, 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
+ 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 <pthread.h>
+#include <string.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+int
+pthread_barrier_init (pthread_barrier_t *barrier,
+ const pthread_barrierattr_t *attr,
+ unsigned count)
+{
+ if (count == 0)
+ return EINVAL;
+
+ memset (barrier, 0, sizeof *barrier);
+
+ barrier->lock = PTHREAD_SPINLOCK_INITIALIZER;
+ barrier->pending = count;
+ barrier->count = count;
+
+ if (! attr
+ || memcmp (attr, &__pthread_default_barrierattr, sizeof (*attr) == 0))
+ /* Use the default attributes. */
+ return 0;
+
+ /* Non-default attributes. */
+
+ barrier->attr = malloc (sizeof *attr);
+ if (! barrier->attr)
+ return ENOMEM;
+
+ *barrier->attr = *attr;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-barrier-wait.c b/libpthread/sysdeps/generic/pt-barrier-wait.c
new file mode 100644
index 00000000..f1de250a
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-barrier-wait.c
@@ -0,0 +1,61 @@
+/* pthread_barrier_wait. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+int
+pthread_barrier_wait (pthread_barrier_t *barrier)
+{
+ __pthread_spin_lock (&barrier->lock);
+ if (-- barrier->pending == 0)
+ {
+ barrier->pending = barrier->count;
+
+ if (barrier->count > 1)
+ {
+ struct __pthread *wakeup;
+
+ wakeup = barrier->queue;
+ barrier->queue = NULL;
+ __pthread_spin_unlock (&barrier->lock);
+
+ /* We can safely walk the list of waiting threads without
+ holding the lock since it is decoupled from the barrier
+ variable now. */
+ __pthread_dequeuing_iterate (wakeup, wakeup)
+ __pthread_wakeup (wakeup);
+ }
+
+ return PTHREAD_BARRIER_SERIAL_THREAD;
+ }
+ else
+ {
+ struct __pthread *self = _pthread_self ();
+
+ /* Add ourselves to the list of waiters. */
+ __pthread_enqueue (&barrier->queue, self);
+ __pthread_spin_unlock (&barrier->lock);
+
+ __pthread_block (self);
+ return 0;
+ }
+}
diff --git a/libpthread/sysdeps/generic/pt-barrier.c b/libpthread/sysdeps/generic/pt-barrier.c
new file mode 100644
index 00000000..d772719f
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-barrier.c
@@ -0,0 +1,26 @@
+/* Default barrier attributes. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+const struct __pthread_barrierattr __pthread_default_barrierattr =
+{
+ pshared: PTHREAD_PROCESS_PRIVATE
+};
diff --git a/libpthread/sysdeps/generic/pt-barrierattr-destroy.c b/libpthread/sysdeps/generic/pt-barrierattr-destroy.c
new file mode 100644
index 00000000..eb396347
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-barrierattr-destroy.c
@@ -0,0 +1,27 @@
+/* pthread_barrierattr_destroy. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_barrierattr_destroy (pthread_barrierattr_t *attr)
+{
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-barrierattr-getpshared.c b/libpthread/sysdeps/generic/pt-barrierattr-getpshared.c
new file mode 100644
index 00000000..ed2cdd24
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-barrierattr-getpshared.c
@@ -0,0 +1,29 @@
+/* pthread_barrierattr_getpshared. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_barrierattr_getpshared (const pthread_barrierattr_t *attr,
+ int *pshared)
+{
+ *pshared = attr->pshared;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-barrierattr-init.c b/libpthread/sysdeps/generic/pt-barrierattr-init.c
new file mode 100644
index 00000000..45f16cc8
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-barrierattr-init.c
@@ -0,0 +1,28 @@
+/* pthread_barrierattr_init. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_barrierattr_init (pthread_barrierattr_t *attr)
+{
+ *attr = __pthread_default_barrierattr;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-barrierattr-setpshared.c b/libpthread/sysdeps/generic/pt-barrierattr-setpshared.c
new file mode 100644
index 00000000..84ef2df8
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-barrierattr-setpshared.c
@@ -0,0 +1,39 @@
+/* pthread_barrierattr_setpshared. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_barrierattr_setpshared (pthread_barrierattr_t *attr,
+ int pshared)
+{
+ switch (pshared)
+ {
+ case PTHREAD_PROCESS_PRIVATE:
+ attr->pshared = pshared;
+ return 0;
+
+ case PTHREAD_PROCESS_SHARED:
+ return ENOTSUP;
+
+ default:
+ return EINVAL;
+ }
+}
diff --git a/libpthread/sysdeps/generic/pt-cond-brdcast.c b/libpthread/sysdeps/generic/pt-cond-brdcast.c
new file mode 100644
index 00000000..3f55e33e
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-cond-brdcast.c
@@ -0,0 +1,42 @@
+/* Broadcast a condition. Generic version.
+ Copyright (C) 2000, 2002 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 <pthread.h>
+
+#include <pt-internal.h>
+
+/* Unblock all threads that are blocked on condition variable COND. */
+int
+pthread_cond_broadcast (pthread_cond_t *cond)
+{
+ struct __pthread *wakeup;
+
+ __pthread_spin_lock (&cond->__lock);
+
+ wakeup = cond->__queue;
+ cond->__queue = NULL;
+ __pthread_spin_unlock (&cond->__lock);
+
+ /* We can safely walk the list of waiting threads without holding
+ the lock since it is now decoupled from the condition. */
+ __pthread_dequeuing_iterate (wakeup, wakeup)
+ __pthread_wakeup (wakeup);
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-cond-destroy.c b/libpthread/sysdeps/generic/pt-cond-destroy.c
new file mode 100644
index 00000000..eba47784
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-cond-destroy.c
@@ -0,0 +1,27 @@
+/* pthread_cond_destroy. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_cond_destroy (pthread_cond_t *cond)
+{
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-cond-init.c b/libpthread/sysdeps/generic/pt-cond-init.c
new file mode 100644
index 00000000..b9e9fb7a
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-cond-init.c
@@ -0,0 +1,45 @@
+/* pthread_cond_init. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <assert.h>
+#include <string.h>
+
+#include <pt-internal.h>
+
+int
+pthread_cond_init (pthread_cond_t *cond,
+ const pthread_condattr_t *attr)
+{
+ *cond = (pthread_cond_t) __PTHREAD_COND_INITIALIZER;
+
+ if (! attr
+ || memcmp (attr, &__pthread_default_condattr, sizeof (*attr) == 0))
+ /* Use the default attributes. */
+ return 0;
+
+ /* Non-default attributes. */
+
+ cond->__attr = malloc (sizeof *attr);
+ if (! cond->__attr)
+ return ENOMEM;
+
+ *cond->__attr = *attr;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-cond-signal.c b/libpthread/sysdeps/generic/pt-cond-signal.c
new file mode 100644
index 00000000..c5e1bc1d
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-cond-signal.c
@@ -0,0 +1,54 @@
+/* Signal a condition. Generic version.
+ Copyright (C) 2000 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 <pthread.h>
+
+#include <pt-internal.h>
+
+static int
+cond_signal (struct __pthread_cond *cond, int *unblocked)
+{
+ struct __pthread *wakeup;
+
+ __pthread_spin_lock (&cond->__lock);
+ wakeup = cond->__queue;
+ if (wakeup)
+ __pthread_dequeue (wakeup);
+ __pthread_spin_unlock (&cond->__lock);
+
+ if (wakeup)
+ {
+ /* We found a thread waiting for the condition to be signalled.
+ Wake it up! */
+ __pthread_wakeup (wakeup);
+ *unblocked = 1;
+ }
+
+ return 0;
+}
+
+/* Unblock at least one of the threads that are blocked on condition
+ variable COND. */
+int
+pthread_cond_signal (pthread_cond_t *cond)
+{
+ int unblocked = 0;
+
+ return cond_signal (cond, &unblocked);
+}
diff --git a/libpthread/sysdeps/generic/pt-cond-timedwait.c b/libpthread/sysdeps/generic/pt-cond-timedwait.c
new file mode 100644
index 00000000..c10bdb30
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-cond-timedwait.c
@@ -0,0 +1,106 @@
+/* Wait on a condition. Generic version.
+ Copyright (C) 2000, 2002, 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
+ 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 <pthread.h>
+
+#include <pt-internal.h>
+
+extern int __pthread_cond_timedwait_internal (pthread_cond_t *cond,
+ pthread_mutex_t *mutex,
+ const struct timespec *abstime);
+
+int
+pthread_cond_timedwait (pthread_cond_t *cond,
+ pthread_mutex_t *mutex,
+ const struct timespec *abstime)
+{
+ return __pthread_cond_timedwait_internal (cond, mutex, abstime);
+}
+
+/* Block on condition variable COND until ABSTIME. As a GNU
+ extension, if ABSTIME is NULL, then wait forever. MUTEX should be
+ held by the calling thread. On return, MUTEX will be held by the
+ calling thread. */
+int
+__pthread_cond_timedwait_internal (pthread_cond_t *cond,
+ pthread_mutex_t *mutex,
+ const struct timespec *abstime)
+{
+ error_t err;
+ int canceltype;
+
+ void cleanup (void *arg)
+ {
+ struct __pthread *self = _pthread_self ();
+
+ __pthread_spin_lock (&cond->__lock);
+ if (self->prevp)
+ __pthread_dequeue (self);
+ __pthread_spin_unlock (&cond->__lock);
+
+ pthread_setcanceltype (canceltype, &canceltype);
+ __pthread_mutex_lock (mutex);
+ }
+
+ if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000))
+ return EINVAL;
+
+ struct __pthread *self = _pthread_self ();
+
+ /* Add ourselves to the list of waiters. */
+ __pthread_spin_lock (&cond->__lock);
+ __pthread_enqueue (&cond->__queue, self);
+ __pthread_spin_unlock (&cond->__lock);
+
+ __pthread_mutex_unlock (mutex);
+
+ /* Enter async cancelation mode. If cancelation is disabled, then
+ this does not change anything which is exactly what we want. */
+ pthread_cleanup_push (cleanup, 0);
+ pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &canceltype);
+
+ if (abstime)
+ {
+ err = __pthread_timedblock (self, abstime);
+ if (err)
+ /* We timed out. We may need to disconnect ourself from the
+ waiter queue.
+
+ FIXME: What do we do if we get a wakeup message before we
+ disconnect ourself? It may remain until the next time we
+ block. */
+ {
+ assert (err == ETIMEDOUT);
+
+ __pthread_spin_lock (&mutex->__lock);
+ if (self->prevp)
+ __pthread_dequeue (self);
+ __pthread_spin_unlock (&mutex->__lock);
+ }
+ }
+ else
+ {
+ err = 0;
+ __pthread_block (self);
+ }
+
+ pthread_cleanup_pop (1);
+
+ return err;
+}
diff --git a/libpthread/sysdeps/generic/pt-cond-wait.c b/libpthread/sysdeps/generic/pt-cond-wait.c
new file mode 100644
index 00000000..a03476df
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-cond-wait.c
@@ -0,0 +1,37 @@
+/* Wait on a condition. Generic version.
+ Copyright (C) 2000,02 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 <pthread.h>
+
+#include <pt-internal.h>
+
+/* Implemented in pt-cond-timedwait.c. */
+extern int __pthread_cond_timedwait_internal (pthread_cond_t *cond,
+ pthread_mutex_t *mutex,
+ const struct timespec *abstime);
+
+
+/* Block on condition variable COND. MUTEX should be held by the
+ calling thread. On return, MUTEX will be held by the calling
+ thread. */
+int
+pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex)
+{
+ return __pthread_cond_timedwait_internal (cond, mutex, 0);
+}
diff --git a/libpthread/sysdeps/generic/pt-cond.c b/libpthread/sysdeps/generic/pt-cond.c
new file mode 100644
index 00000000..033e767f
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-cond.c
@@ -0,0 +1,29 @@
+/* Default condition attributes. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <time.h>
+
+#include <pt-internal.h>
+
+const struct __pthread_condattr __pthread_default_condattr =
+{
+ pshared: PTHREAD_PROCESS_PRIVATE,
+ clock: CLOCK_REALTIME
+};
diff --git a/libpthread/sysdeps/generic/pt-condattr-destroy.c b/libpthread/sysdeps/generic/pt-condattr-destroy.c
new file mode 100644
index 00000000..c8fd71b9
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-condattr-destroy.c
@@ -0,0 +1,27 @@
+/* pthread_condattr_destroy. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_condattr_destroy (pthread_condattr_t *cond)
+{
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-condattr-getclock.c b/libpthread/sysdeps/generic/pt-condattr-getclock.c
new file mode 100644
index 00000000..5b9f8893
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-condattr-getclock.c
@@ -0,0 +1,31 @@
+/* pthread_condattr_getclock. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <time.h>
+
+#include <pt-internal.h>
+
+int
+pthread_condattr_getclock (const pthread_condattr_t *attr,
+ clockid_t *clock)
+{
+ *clock = attr->clock;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-condattr-getpshared.c b/libpthread/sysdeps/generic/pt-condattr-getpshared.c
new file mode 100644
index 00000000..c072a507
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-condattr-getpshared.c
@@ -0,0 +1,29 @@
+/* pthread_condattr_getpshared. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_condattr_getpshared (const pthread_condattr_t *attr,
+ int *pshared)
+{
+ *pshared = attr->pshared;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-condattr-init.c b/libpthread/sysdeps/generic/pt-condattr-init.c
new file mode 100644
index 00000000..cf9e1989
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-condattr-init.c
@@ -0,0 +1,28 @@
+/* pthread_condattr_init. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_condattr_init (pthread_condattr_t *attr)
+{
+ *attr = __pthread_default_condattr;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-condattr-setclock.c b/libpthread/sysdeps/generic/pt-condattr-setclock.c
new file mode 100644
index 00000000..984c17e2
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-condattr-setclock.c
@@ -0,0 +1,33 @@
+/* pthread_condattr_setclock. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_condattr_setclock (pthread_condattr_t *attr, clockid_t clock)
+{
+ if (__pthread_default_condattr.clock == clock)
+ {
+ attr->clock = clock;
+ return 0;
+ }
+
+ return EINVAL;
+}
diff --git a/libpthread/sysdeps/generic/pt-condattr-setpshared.c b/libpthread/sysdeps/generic/pt-condattr-setpshared.c
new file mode 100644
index 00000000..b9f0af83
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-condattr-setpshared.c
@@ -0,0 +1,39 @@
+/* pthread_condattr_setpshared. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_condattr_setpshared (pthread_condattr_t *attr,
+ int pshared)
+{
+ switch (pshared)
+ {
+ case PTHREAD_PROCESS_PRIVATE:
+ attr->pshared = pshared;
+ return 0;
+
+ case PTHREAD_PROCESS_SHARED:
+ return ENOTSUP;
+
+ default:
+ return EINVAL;
+ }
+}
diff --git a/libpthread/sysdeps/generic/pt-destroy-specific.c b/libpthread/sysdeps/generic/pt-destroy-specific.c
new file mode 100644
index 00000000..b627f872
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-destroy-specific.c
@@ -0,0 +1,28 @@
+/* __pthread_destory_specific. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+void
+__pthread_destory_specifc (struct __pthread *thread)
+{
+ /* Not support, thus there cannot be any. */
+ return;
+}
diff --git a/libpthread/sysdeps/generic/pt-equal.c b/libpthread/sysdeps/generic/pt-equal.c
new file mode 100644
index 00000000..8fbc519c
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-equal.c
@@ -0,0 +1,29 @@
+/* Default attributes. Generic version.
+ Copyright (C) 2000,02 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 <pthread.h>
+#include <pt-internal.h>
+
+/* Return true if __T1 and __T2 both name the same thread. Otherwise,
+ false. */
+int
+pthread_equal (pthread_t __t1, pthread_t __t2)
+{
+ return __t1 == __t2;
+}
diff --git a/libpthread/sysdeps/generic/pt-getconcurrency.c b/libpthread/sysdeps/generic/pt-getconcurrency.c
new file mode 100644
index 00000000..b55c8eef
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-getconcurrency.c
@@ -0,0 +1,27 @@
+/* Get the current level of desired concurrency. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_getconcurrency (void)
+{
+ return __pthread_concurrency;
+}
diff --git a/libpthread/sysdeps/generic/pt-getcpuclockid.c b/libpthread/sysdeps/generic/pt-getcpuclockid.c
new file mode 100644
index 00000000..81f6aabd
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-getcpuclockid.c
@@ -0,0 +1,34 @@
+/* Return a thread's cpu clockid. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <time.h>
+
+#include <pt-internal.h>
+
+int
+pthread_getcpuclockid (pthread_t thread, clockid_t *clock)
+{
+#ifdef CLOCK_THREAD_CPUTIME_ID
+ *clock = CLOCK_THREAD_CPUTIME_ID;
+ return 0;
+#else
+ return ENOSYS;
+#endif
+}
diff --git a/libpthread/sysdeps/generic/pt-getschedparam.c b/libpthread/sysdeps/generic/pt-getschedparam.c
new file mode 100644
index 00000000..c128d02e
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-getschedparam.c
@@ -0,0 +1,28 @@
+/* Get the scheduling parameters for a thread. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_getschedparam (pthread_t thread, int *policy,
+ struct sched_param *param)
+{
+ return ENOSYS;
+}
diff --git a/libpthread/sysdeps/generic/pt-getspecific.c b/libpthread/sysdeps/generic/pt-getspecific.c
new file mode 100644
index 00000000..2a7c4a9e
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-getspecific.c
@@ -0,0 +1,27 @@
+/* pthread_getspecific. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_getspecific (pthread_key_t key)
+{
+ return EINVAL;
+}
diff --git a/libpthread/sysdeps/generic/pt-init-specific.c b/libpthread/sysdeps/generic/pt-init-specific.c
new file mode 100644
index 00000000..00744fb6
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-init-specific.c
@@ -0,0 +1,27 @@
+/* __pthread_init_specific. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+error_t
+__pthread_init_specific (struct __pthread *thread)
+{
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-key-create.c b/libpthread/sysdeps/generic/pt-key-create.c
new file mode 100644
index 00000000..7ef4b991
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-key-create.c
@@ -0,0 +1,27 @@
+/* pthread_key_create. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_key_create (pthread_key_t *key, void (*destructor) (void *))
+{
+ return ENOSYS;
+}
diff --git a/libpthread/sysdeps/generic/pt-key-delete.c b/libpthread/sysdeps/generic/pt-key-delete.c
new file mode 100644
index 00000000..6c86f8e2
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-key-delete.c
@@ -0,0 +1,27 @@
+/* pthread_key_delete. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_key_delete (pthread_key_t key)
+{
+ return ENOSYS;
+}
diff --git a/libpthread/sysdeps/generic/pt-key.h b/libpthread/sysdeps/generic/pt-key.h
new file mode 100644
index 00000000..544eb20f
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-key.h
@@ -0,0 +1,22 @@
+/* pthread_key internal declatations. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+
+#define PTHREAD_KEY_MEMBERS
diff --git a/libpthread/sysdeps/generic/pt-mutex-destroy.c b/libpthread/sysdeps/generic/pt-mutex-destroy.c
new file mode 100644
index 00000000..71fc692f
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutex-destroy.c
@@ -0,0 +1,35 @@
+/* Destroy a mutex. Generic version.
+ Copyright (C) 2000, 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
+ 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 <pthread.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+int
+_pthread_mutex_destroy (pthread_mutex_t *mutex)
+{
+ if (mutex->attr)
+ free (mutex->attr);
+
+ return 0;
+}
+
+strong_alias (_pthread_mutex_destroy, pthread_mutex_destroy);
diff --git a/libpthread/sysdeps/generic/pt-mutex-getprioceiling.c b/libpthread/sysdeps/generic/pt-mutex-getprioceiling.c
new file mode 100644
index 00000000..eb51639b
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutex-getprioceiling.c
@@ -0,0 +1,28 @@
+/* Get a mutex' priority ceiling. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_mutex_getprioceiling (const pthread_mutex_t *mutex,
+ int *prioceiling)
+{
+ return ENOSYS;
+}
diff --git a/libpthread/sysdeps/generic/pt-mutex-init.c b/libpthread/sysdeps/generic/pt-mutex-init.c
new file mode 100644
index 00000000..94076730
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutex-init.c
@@ -0,0 +1,48 @@
+/* Initialize a mutex. Generic version.
+ Copyright (C) 2000, 2002, 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 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 <pthread.h>
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+int
+_pthread_mutex_init (pthread_mutex_t *mutex,
+ const pthread_mutexattr_t *attr)
+{
+ *mutex = (pthread_mutex_t) __PTHREAD_MUTEX_INITIALIZER;
+
+ if (! attr
+ || memcmp (attr, &__pthread_default_mutexattr, sizeof (*attr) == 0))
+ /* Use the default attributes. */
+ return 0;
+
+ /* Non-default attributes. */
+
+ mutex->attr = malloc (sizeof *attr);
+ if (! mutex->attr)
+ return ENOMEM;
+
+ *mutex->attr = *attr;
+ return 0;
+}
+
+strong_alias (_pthread_mutex_init, pthread_mutex_init);
diff --git a/libpthread/sysdeps/generic/pt-mutex-lock.c b/libpthread/sysdeps/generic/pt-mutex-lock.c
new file mode 100644
index 00000000..528e593f
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutex-lock.c
@@ -0,0 +1,37 @@
+/* Lock a mutex. Generic version.
+ Copyright (C) 2000, 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
+ 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 <pthread.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+/* Implemented in pt-mutex-timedlock.c. */
+extern int __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex,
+ const struct timespec *abstime);
+
+/* Lock MUTEX, block if we can't get it. */
+int
+__pthread_mutex_lock (struct __pthread_mutex *mutex)
+{
+ return __pthread_mutex_timedlock_internal (mutex, 0);
+}
+
+strong_alias (__pthread_mutex_lock, _pthread_mutex_lock);
+strong_alias (__pthread_mutex_lock, pthread_mutex_lock);
diff --git a/libpthread/sysdeps/generic/pt-mutex-setprioceiling.c b/libpthread/sysdeps/generic/pt-mutex-setprioceiling.c
new file mode 100644
index 00000000..9fa8e50d
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutex-setprioceiling.c
@@ -0,0 +1,28 @@
+/* Set a mutex' priority ceiling. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_mutex_setprioceiling (pthread_mutex_t *mutex, int prio,
+ int *oldprio)
+{
+ return ENOSYS;
+}
diff --git a/libpthread/sysdeps/generic/pt-mutex-timedlock.c b/libpthread/sysdeps/generic/pt-mutex-timedlock.c
new file mode 100644
index 00000000..265a4530
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutex-timedlock.c
@@ -0,0 +1,173 @@
+/* Lock a mutex with a timeout. Generic version.
+ Copyright (C) 2000, 2002, 2005, 2008 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 <pthread.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+#define LOSE do { * (int *) 0 = 0; } while (1)
+
+/* Try to lock MUTEX, block until *ABSTIME if it is already held. As
+ a GNU extension, if TIMESPEC is NULL then wait forever. */
+int
+__pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex,
+ const struct timespec *abstime)
+{
+ struct __pthread *self;
+
+ __pthread_spin_lock (&mutex->__lock);
+ if (__pthread_spin_trylock (&mutex->__held) == 0)
+ /* Successfully acquired the lock. */
+ {
+#ifndef NDEBUG
+ self = _pthread_self ();
+ if (self)
+ /* The main thread may take a lock before the library is fully
+ initialized, in particular, before the main thread has a
+ TCB. */
+ {
+ assert (! mutex->owner);
+ mutex->owner = _pthread_self ();
+ }
+#endif
+
+ if (mutex->attr)
+ switch (mutex->attr->mutex_type)
+ {
+ case PTHREAD_MUTEX_NORMAL:
+ break;
+
+ case PTHREAD_MUTEX_RECURSIVE:
+ mutex->locks = 1;
+ case PTHREAD_MUTEX_ERRORCHECK:
+ mutex->owner = _pthread_self ();
+ break;
+
+ default:
+ LOSE;
+ }
+
+ __pthread_spin_unlock (&mutex->__lock);
+ return 0;
+ }
+
+ /* The lock is busy. */
+
+ self = _pthread_self ();
+ assert (self);
+
+ if (mutex->attr)
+ {
+ switch (mutex->attr->mutex_type)
+ {
+ case PTHREAD_MUTEX_NORMAL:
+ assert (mutex->owner != self);
+ break;
+
+ case PTHREAD_MUTEX_ERRORCHECK:
+ if (mutex->owner == self)
+ {
+ __pthread_spin_unlock (&mutex->__lock);
+ return EDEADLK;
+ }
+ break;
+
+ case PTHREAD_MUTEX_RECURSIVE:
+ if (mutex->owner == self)
+ {
+ mutex->locks ++;
+ __pthread_spin_unlock (&mutex->__lock);
+ return 0;
+ }
+ break;
+
+ default:
+ LOSE;
+ }
+ }
+ else
+ assert (mutex->owner != self);
+
+ assert (mutex->owner);
+
+ if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000))
+ return EINVAL;
+
+ /* Add ourselves to the queue. */
+ __pthread_enqueue (&mutex->__queue, self);
+ __pthread_spin_unlock (&mutex->__lock);
+
+ /* Block the thread. */
+ if (abstime)
+ {
+ error_t err;
+
+ err = __pthread_timedblock (self, abstime);
+ if (err)
+ /* We timed out. We may need to disconnect ourself from the
+ waiter queue.
+
+ FIXME: What do we do if we get a wakeup message before we
+ disconnect ourself? It may remain until the next time we
+ block. */
+ {
+ assert (err == ETIMEDOUT);
+
+ __pthread_spin_lock (&mutex->__lock);
+ if (self->prevp)
+ __pthread_dequeue (self);
+ __pthread_spin_unlock (&mutex->__lock);
+
+ return err;
+ }
+ }
+ else
+ __pthread_block (self);
+
+#ifndef NDEBUG
+ assert (mutex->owner == self);
+#endif
+
+ if (mutex->attr)
+ switch (mutex->attr->mutex_type)
+ {
+ case PTHREAD_MUTEX_NORMAL:
+ break;
+
+ case PTHREAD_MUTEX_RECURSIVE:
+ assert (mutex->locks == 0);
+ mutex->locks = 1;
+ case PTHREAD_MUTEX_ERRORCHECK:
+ mutex->owner = self;
+ break;
+
+ default:
+ LOSE;
+ }
+
+ return 0;
+}
+
+int
+pthread_mutex_timedlock (struct __pthread_mutex *mutex,
+ const struct timespec *abstime)
+{
+ return __pthread_mutex_timedlock_internal (mutex, abstime);
+}
diff --git a/libpthread/sysdeps/generic/pt-mutex-trylock.c b/libpthread/sysdeps/generic/pt-mutex-trylock.c
new file mode 100644
index 00000000..d523205e
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutex-trylock.c
@@ -0,0 +1,104 @@
+/* Try to Lock a mutex. Generic version.
+ Copyright (C) 2002, 2005, 2006, 2008 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 <pthread.h>
+
+#include <pt-internal.h>
+
+#define LOSE do { * (int *) 0 = 0; } while (1)
+
+/* Lock MUTEX, return EBUSY if we can't get it. */
+int
+__pthread_mutex_trylock (struct __pthread_mutex *mutex)
+{
+ int err;
+ struct __pthread *self;
+
+ __pthread_spin_lock (&mutex->__lock);
+ if (__pthread_spin_trylock (&mutex->__held) == 0)
+ /* Acquired the lock. */
+ {
+#ifndef NDEBUG
+ self = _pthread_self ();
+ if (self)
+ /* The main thread may take a lock before the library is fully
+ initialized, in particular, before the main thread has a
+ TCB. */
+ {
+ assert (! mutex->owner);
+ mutex->owner = _pthread_self ();
+ }
+#endif
+
+ if (mutex->attr)
+ switch (mutex->attr->mutex_type)
+ {
+ case PTHREAD_MUTEX_NORMAL:
+ break;
+
+ case PTHREAD_MUTEX_RECURSIVE:
+ mutex->locks = 1;
+ case PTHREAD_MUTEX_ERRORCHECK:
+ mutex->owner = _pthread_self ();
+ break;
+
+ default:
+ LOSE;
+ }
+
+ __pthread_spin_unlock (&mutex->__lock);
+ return 0;
+ }
+
+ err = EBUSY;
+
+ if (mutex->attr)
+ {
+ self = _pthread_self ();
+ switch (mutex->attr->mutex_type)
+ {
+ case PTHREAD_MUTEX_NORMAL:
+ break;
+
+ case PTHREAD_MUTEX_ERRORCHECK:
+ /* We could check if MUTEX->OWNER is SELF, however, POSIX
+ does not permit pthread_mutex_trylock to return EDEADLK
+ instead of EBUSY, only pthread_mutex_lock. */
+ break;
+
+ case PTHREAD_MUTEX_RECURSIVE:
+ if (mutex->owner == self)
+ {
+ mutex->locks ++;
+ err = 0;
+ }
+ break;
+
+ default:
+ LOSE;
+ }
+ }
+
+ __pthread_spin_unlock (&mutex->__lock);
+
+ return err;
+}
+
+strong_alias (__pthread_mutex_trylock, _pthread_mutex_trylock);
+strong_alias (__pthread_mutex_trylock, pthread_mutex_trylock);
diff --git a/libpthread/sysdeps/generic/pt-mutex-unlock.c b/libpthread/sysdeps/generic/pt-mutex-unlock.c
new file mode 100644
index 00000000..4352042e
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutex-unlock.c
@@ -0,0 +1,104 @@
+/* Unlock a mutex. Generic version.
+ Copyright (C) 2000, 2002, 2006, 2008 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 <pthread.h>
+
+#include <pt-internal.h>
+
+#define LOSE do { * (int *) 0 = 0; } while (1)
+
+/* Unlock MUTEX, rescheduling a waiting thread. */
+int
+__pthread_mutex_unlock (pthread_mutex_t *mutex)
+{
+ struct __pthread *wakeup;
+
+ __pthread_spin_lock (&mutex->__lock);
+
+ if (! mutex->attr || mutex->attr->mutex_type == PTHREAD_MUTEX_NORMAL)
+ {
+#ifndef NDEBUG
+ if (_pthread_self ())
+ {
+ assert (mutex->owner);
+#if 0
+ assertx (mutex->owner == _pthread_self (),
+ "%p(%x) != %p(%x)",
+ mutex->owner,
+ ((struct __pthread *) mutex->owner)->threadid,
+ _pthread_self (),
+ _pthread_self ()->threadid);
+#else
+ assert (mutex->owner == _pthread_self ());
+#endif
+ mutex->owner = NULL;
+ }
+#endif
+ }
+ else
+ switch (mutex->attr->mutex_type)
+ {
+ case PTHREAD_MUTEX_ERRORCHECK:
+ case PTHREAD_MUTEX_RECURSIVE:
+ if (mutex->owner != _pthread_self ())
+ {
+ __pthread_spin_unlock (&mutex->__lock);
+ return EPERM;
+ }
+
+ if (mutex->attr->mutex_type == PTHREAD_MUTEX_RECURSIVE)
+ if (--mutex->locks > 0)
+ {
+ __pthread_spin_unlock (&mutex->__lock);
+ return 0;
+ }
+
+ mutex->owner = 0;
+ break;
+
+ default:
+ LOSE;
+ }
+
+
+ if (mutex->__queue == NULL)
+ {
+ __pthread_spin_unlock (&mutex->__held);
+ __pthread_spin_unlock (&mutex->__lock);
+ return 0;
+ }
+
+ wakeup = mutex->__queue;
+ __pthread_dequeue (wakeup);
+
+#ifndef NDEBUG
+ mutex->owner = wakeup;
+#endif
+
+ /* We do not unlock MUTEX->held: we are transferring the ownership
+ to the thread that we are waking up. */
+
+ __pthread_spin_unlock (&mutex->__lock);
+ __pthread_wakeup (wakeup);
+
+ return 0;
+}
+
+strong_alias (__pthread_mutex_unlock, _pthread_mutex_unlock);
+strong_alias (__pthread_mutex_unlock, pthread_mutex_unlock);
diff --git a/libpthread/sysdeps/generic/pt-mutexattr-destroy.c b/libpthread/sysdeps/generic/pt-mutexattr-destroy.c
new file mode 100644
index 00000000..fe7e95d2
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutexattr-destroy.c
@@ -0,0 +1,27 @@
+/* pthread_mutexattr_destroy. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_mutexattr_destroy (pthread_mutexattr_t *attr)
+{
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-mutexattr-getprioceiling.c b/libpthread/sysdeps/generic/pt-mutexattr-getprioceiling.c
new file mode 100644
index 00000000..d03d7192
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutexattr-getprioceiling.c
@@ -0,0 +1,28 @@
+/* pthread_mutexattr_getprioceiling. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *attr,
+ int *prioceiling)
+{
+ return ENOSYS;
+}
diff --git a/libpthread/sysdeps/generic/pt-mutexattr-getprotocol.c b/libpthread/sysdeps/generic/pt-mutexattr-getprotocol.c
new file mode 100644
index 00000000..d75021a3
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutexattr-getprotocol.c
@@ -0,0 +1,29 @@
+/* pthread_mutexattr_getprotocol. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_mutexattr_getprotocol (const pthread_mutexattr_t *attr,
+ int *protocol)
+{
+ *protocol = attr->protocol;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-mutexattr-getpshared.c b/libpthread/sysdeps/generic/pt-mutexattr-getpshared.c
new file mode 100644
index 00000000..0dad13b8
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutexattr-getpshared.c
@@ -0,0 +1,29 @@
+/* pthread_mutexattr_getpshared. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_mutexattr_getpshared (const pthread_mutexattr_t *attr,
+ int *pshared)
+{
+ *pshared = attr->pshared;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-mutexattr-gettype.c b/libpthread/sysdeps/generic/pt-mutexattr-gettype.c
new file mode 100644
index 00000000..ff2caea4
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutexattr-gettype.c
@@ -0,0 +1,28 @@
+/* pthread_mutexattr_gettype. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_mutexattr_gettype (const pthread_mutexattr_t *attr, int *type)
+{
+ *type = attr->mutex_type;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-mutexattr-init.c b/libpthread/sysdeps/generic/pt-mutexattr-init.c
new file mode 100644
index 00000000..2f23673c
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutexattr-init.c
@@ -0,0 +1,28 @@
+/* pthread_mutexattr_init. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_mutexattr_init (pthread_mutexattr_t *attr)
+{
+ *attr = __pthread_default_mutexattr;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-mutexattr-setprioceiling.c b/libpthread/sysdeps/generic/pt-mutexattr-setprioceiling.c
new file mode 100644
index 00000000..a9bbd327
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutexattr-setprioceiling.c
@@ -0,0 +1,28 @@
+/* pthread_mutexattr_setprioceiling. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_mutexattr_setprioceiling (pthread_mutexattr_t *attr,
+ int prioceiling)
+{
+ return ENOSYS;
+}
diff --git a/libpthread/sysdeps/generic/pt-mutexattr-setprotocol.c b/libpthread/sysdeps/generic/pt-mutexattr-setprotocol.c
new file mode 100644
index 00000000..9a0d1b1f
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutexattr-setprotocol.c
@@ -0,0 +1,42 @@
+/* pthread_mutexattr_setprotocol. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_mutexattr_setprotocol (pthread_mutexattr_t *attr,
+ int protocol)
+{
+ if (protocol == __pthread_default_mutexattr.protocol)
+ {
+ attr->protocol = protocol;
+ return 0;
+ }
+
+ switch (protocol)
+ {
+ case PTHREAD_PRIO_NONE:
+ case PTHREAD_PRIO_INHERIT:
+ case PTHREAD_PRIO_PROTECT:
+ return ENOTSUP;
+ default:
+ return EINVAL;
+ }
+}
diff --git a/libpthread/sysdeps/generic/pt-mutexattr-setpshared.c b/libpthread/sysdeps/generic/pt-mutexattr-setpshared.c
new file mode 100644
index 00000000..bcbc4d91
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutexattr-setpshared.c
@@ -0,0 +1,39 @@
+/* pthread_mutexattr_setpshared. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_mutexattr_setpshared (pthread_mutexattr_t *attr,
+ int pshared)
+{
+ switch (pshared)
+ {
+ case PTHREAD_PROCESS_PRIVATE:
+ attr->pshared = pshared;
+ return 0;
+
+ case PTHREAD_PROCESS_SHARED:
+ return ENOTSUP;
+
+ default:
+ return EINVAL;
+ }
+}
diff --git a/libpthread/sysdeps/generic/pt-mutexattr-settype.c b/libpthread/sysdeps/generic/pt-mutexattr-settype.c
new file mode 100644
index 00000000..e7ae213a
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutexattr-settype.c
@@ -0,0 +1,37 @@
+/* pthread_mutexattr_settype. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_mutexattr_settype (pthread_mutexattr_t *attr, int type)
+{
+ switch (type)
+ {
+ case PTHREAD_MUTEX_NORMAL:
+ case PTHREAD_MUTEX_ERRORCHECK:
+ case PTHREAD_MUTEX_RECURSIVE:
+ attr->mutex_type = type;
+ return 0;
+
+ default:
+ return EINVAL;
+ }
+}
diff --git a/libpthread/sysdeps/generic/pt-mutexattr.c b/libpthread/sysdeps/generic/pt-mutexattr.c
new file mode 100644
index 00000000..647db241
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-mutexattr.c
@@ -0,0 +1,29 @@
+/* Default mutex attributes. Generic version.
+ Copyright (C) 2000,02 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 <pthread.h>
+#include <pt-internal.h>
+
+const struct __pthread_mutexattr __pthread_default_mutexattr =
+{
+ prioceiling: 0,
+ protocol: PTHREAD_PRIO_NONE,
+ pshared: PTHREAD_PROCESS_PRIVATE,
+ mutex_type: PTHREAD_MUTEX_DEFAULT
+};
diff --git a/libpthread/sysdeps/generic/pt-once.c b/libpthread/sysdeps/generic/pt-once.c
new file mode 100644
index 00000000..5be5e484
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-once.c
@@ -0,0 +1,43 @@
+/* pthread_once. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <bits/memory.h>
+
+#include <pt-internal.h>
+
+int
+pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
+{
+ if (once_control->run == 0)
+ {
+ __pthread_spin_lock (&once_control->lock);
+
+ if (once_control->run == 0)
+ {
+ init_routine ();
+ __memory_barrier ();
+ once_control->run = 1;
+ }
+
+ __pthread_spin_unlock (&once_control->lock);
+ }
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-rwlock-attr.c b/libpthread/sysdeps/generic/pt-rwlock-attr.c
new file mode 100644
index 00000000..1587feef
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-rwlock-attr.c
@@ -0,0 +1,26 @@
+/* Default rwlock attributes. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+const struct __pthread_rwlockattr __pthread_default_rwlockattr =
+{
+ pshared: PTHREAD_PROCESS_PRIVATE
+};
diff --git a/libpthread/sysdeps/generic/pt-rwlock-destroy.c b/libpthread/sysdeps/generic/pt-rwlock-destroy.c
new file mode 100644
index 00000000..045eebd8
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-rwlock-destroy.c
@@ -0,0 +1,29 @@
+/* Destroy a rwlock. Generic version.
+ 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
+ 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+_pthread_rwlock_destroy (pthread_rwlock_t *rwlock)
+{
+ return 0;
+}
+
+strong_alias (_pthread_rwlock_destroy, pthread_rwlock_destroy);
diff --git a/libpthread/sysdeps/generic/pt-rwlock-init.c b/libpthread/sysdeps/generic/pt-rwlock-init.c
new file mode 100644
index 00000000..c9ff9b28
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-rwlock-init.c
@@ -0,0 +1,45 @@
+/* Initialize a rwlock. Generic version.
+ Copyright (C) 2002, 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 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 <pthread.h>
+#include <string.h>
+#include <pt-internal.h>
+
+int
+_pthread_rwlock_init (pthread_rwlock_t *rwlock,
+ const pthread_rwlockattr_t *attr)
+{
+ *rwlock = (pthread_rwlock_t) __PTHREAD_RWLOCK_INITIALIZER;
+
+ if (! attr
+ || memcmp (attr, &__pthread_default_rwlockattr, sizeof (*attr) == 0))
+ /* Use the default attributes. */
+ return 0;
+
+ /* Non-default attributes. */
+
+ rwlock->__attr = malloc (sizeof *attr);
+ if (! rwlock->__attr)
+ return ENOMEM;
+
+ *rwlock->__attr = *attr;
+ return 0;
+}
+
+strong_alias (_pthread_rwlock_init, pthread_rwlock_init);
diff --git a/libpthread/sysdeps/generic/pt-rwlock-rdlock.c b/libpthread/sysdeps/generic/pt-rwlock-rdlock.c
new file mode 100644
index 00000000..480cf489
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-rwlock-rdlock.c
@@ -0,0 +1,32 @@
+/* Acquire a rwlock for reading. Generic version.
+ Copyright (C) 2002, 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
+ 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 <pthread.h>
+#include <pt-internal.h>
+
+/* Implemented in pt-rwlock-timedrdlock.c. */
+extern int __pthread_rwlock_timedrdlock_internal (struct __pthread_rwlock *rwlock,
+ const struct timespec *abstime);
+
+/* Acquire RWLOCK for reading, block if we can't get it. */
+int
+pthread_rwlock_rdlock (struct __pthread_rwlock *rwlock)
+{
+ return __pthread_rwlock_timedrdlock_internal (rwlock, 0);
+}
diff --git a/libpthread/sysdeps/generic/pt-rwlock-timedrdlock.c b/libpthread/sysdeps/generic/pt-rwlock-timedrdlock.c
new file mode 100644
index 00000000..ba610fa5
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-rwlock-timedrdlock.c
@@ -0,0 +1,113 @@
+/* Acquire a rwlock for reading. Generic version.
+ Copyright (C) 2002, 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
+ 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 <pthread.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+/* Acquire the rwlock *RWLOCK for reading blocking until *ABSTIME if
+ it is already held. As a GNU extension, if TIMESPEC is NULL then
+ wait forever. */
+int
+__pthread_rwlock_timedrdlock_internal (struct __pthread_rwlock *rwlock,
+ const struct timespec *abstime)
+{
+ struct __pthread *self;
+
+ __pthread_spin_lock (&rwlock->__lock);
+ if (__pthread_spin_trylock (&rwlock->__held) == 0)
+ /* Successfully acquired the lock. */
+ {
+ assert (rwlock->readerqueue == 0);
+ assert (rwlock->writerqueue == 0);
+ assert (rwlock->readers == 0);
+
+ rwlock->readers = 1;
+ __pthread_spin_unlock (&rwlock->__lock);
+ return 0;
+ }
+ else
+ /* Lock is held, but is held by a reader? */
+ if (rwlock->readers > 0)
+ /* Just add ourself to number of readers. */
+ {
+ assert (rwlock->readerqueue == 0);
+ rwlock->readers ++;
+ __pthread_spin_unlock (&rwlock->__lock);
+ return 0;
+ }
+
+ /* The lock is busy. */
+
+ /* Better be blocked by a writer. */
+ assert (rwlock->readers == 0);
+
+ if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000))
+ return EINVAL;
+
+ self = _pthread_self ();
+
+ /* Add ourself to the queue. */
+ __pthread_enqueue (&rwlock->readerqueue, self);
+ __pthread_spin_unlock (&rwlock->__lock);
+
+ /* Block the thread. */
+ if (abstime)
+ {
+ error_t err;
+
+ err = __pthread_timedblock (self, abstime);
+ if (err)
+ /* We timed out. We may need to disconnect ourself from the
+ waiter queue.
+
+ FIXME: What do we do if we get a wakeup message before we
+ disconnect ourself? It may remain until the next time we
+ block. */
+ {
+ assert (err == ETIMEDOUT);
+
+ __pthread_spin_lock (&rwlock->__lock);
+ if (self->prevp)
+ /* Disconnect ourself. */
+ __pthread_dequeue (self);
+ __pthread_spin_unlock (&rwlock->__lock);
+
+ return err;
+ }
+ }
+ else
+ __pthread_block (self);
+
+
+ /* The reader count has already been increment by whoever woke us
+ up. */
+
+ assert (rwlock->readers > 0);
+
+ return 0;
+}
+
+int
+pthread_rwlock_timedrdlock (struct __pthread_rwlock *rwlock,
+ const struct timespec *abstime)
+{
+ return __pthread_rwlock_timedrdlock_internal (rwlock, abstime);
+}
diff --git a/libpthread/sysdeps/generic/pt-rwlock-timedwrlock.c b/libpthread/sysdeps/generic/pt-rwlock-timedwrlock.c
new file mode 100644
index 00000000..04eab51f
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-rwlock-timedwrlock.c
@@ -0,0 +1,95 @@
+/* Acquire a rwlock for writing. Generic version.
+ Copyright (C) 2002, 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
+ 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 <pthread.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+/* Acquire RWLOCK for writing blocking until *ABSTIME if we cannot get
+ it. As a special GNU extension, if ABSTIME is NULL then the wait
+ shall not time out. */
+int
+__pthread_rwlock_timedwrlock_internal (struct __pthread_rwlock *rwlock,
+ const struct timespec *abstime)
+{
+ struct __pthread *self;
+
+ __pthread_spin_lock (&rwlock->__lock);
+ if (__pthread_spin_trylock (&rwlock->__held) == 0)
+ /* Successfully acquired the lock. */
+ {
+ assert (rwlock->readerqueue == 0);
+ assert (rwlock->writerqueue == 0);
+ assert (rwlock->readers == 0);
+
+ __pthread_spin_unlock (&rwlock->__lock);
+ return 0;
+ }
+
+ /* The lock is busy. */
+
+ if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000))
+ return EINVAL;
+
+ self = _pthread_self ();
+
+ /* Add ourselves to the queue. */
+ __pthread_enqueue (&rwlock->writerqueue, self);
+ __pthread_spin_unlock (&rwlock->__lock);
+
+ /* Block the thread. */
+ if (abstime)
+ {
+ error_t err;
+
+ err = __pthread_timedblock (self, abstime);
+ if (err)
+ /* We timed out. We may need to disconnect ourself from the
+ waiter queue.
+
+ FIXME: What do we do if we get a wakeup message before we
+ disconnect ourself? It may remain until the next time we
+ block. */
+ {
+ assert (err == ETIMEDOUT);
+
+ __pthread_spin_lock (&rwlock->__lock);
+ if (self->prevp)
+ /* Disconnect ourself. */
+ __pthread_dequeue (self);
+ __pthread_spin_unlock (&rwlock->__lock);
+
+ return err;
+ }
+ }
+ else
+ __pthread_block (self);
+
+ assert (rwlock->readers == 0);
+
+ return 0;
+}
+
+int
+pthread_rwlock_timedwrlock (struct __pthread_rwlock *rwlock,
+ const struct timespec *abstime)
+{
+ return __pthread_rwlock_timedwrlock_internal (rwlock, abstime);
+}
diff --git a/libpthread/sysdeps/generic/pt-rwlock-tryrdlock.c b/libpthread/sysdeps/generic/pt-rwlock-tryrdlock.c
new file mode 100644
index 00000000..2419efb1
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-rwlock-tryrdlock.c
@@ -0,0 +1,56 @@
+/* Try to acquire a rwlock for reading. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+/* Try to acquire RWLOCK. */
+int
+pthread_rwlock_tryrdlock (struct __pthread_rwlock *rwlock)
+{
+ __pthread_spin_lock (&rwlock->__lock);
+ if (__pthread_spin_trylock (&rwlock->__held) == 0)
+ /* Successfully acquired the lock. */
+ {
+ assert (rwlock->readerqueue == 0);
+ assert (rwlock->writerqueue == 0);
+ assert (rwlock->readers == 0);
+
+ rwlock->readers = 1;
+ __pthread_spin_unlock (&rwlock->__lock);
+ return 0;
+ }
+ else
+ /* Lock is held, but is held by a reader? */
+ if (rwlock->readers > 0)
+ {
+ assert (rwlock->readerqueue == 0);
+ rwlock->readers ++;
+ __pthread_spin_unlock (&rwlock->__lock);
+ return 0;
+ }
+
+ /* The lock is busy. */
+
+ __pthread_spin_unlock (&rwlock->__lock);
+
+ return EBUSY;
+}
diff --git a/libpthread/sysdeps/generic/pt-rwlock-trywrlock.c b/libpthread/sysdeps/generic/pt-rwlock-trywrlock.c
new file mode 100644
index 00000000..6b9c5b56
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-rwlock-trywrlock.c
@@ -0,0 +1,46 @@
+/* Try to acquire a rwlock for writing. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+/* Try to acquire RWLOCK for writing. */
+int
+pthread_rwlock_trywrlock (struct __pthread_rwlock *rwlock)
+{
+ __pthread_spin_lock (&rwlock->__lock);
+ if (__pthread_spin_trylock (&rwlock->__held) == 0)
+ /* Successfully acquired the lock. */
+ {
+ assert (rwlock->readerqueue == 0);
+ assert (rwlock->writerqueue == 0);
+ assert (rwlock->readers == 0);
+
+ __pthread_spin_unlock (&rwlock->__lock);
+ return 0;
+ }
+
+ /* The lock is busy. */
+
+ __pthread_spin_unlock (&rwlock->__lock);
+
+ return EBUSY;
+}
diff --git a/libpthread/sysdeps/generic/pt-rwlock-unlock.c b/libpthread/sysdeps/generic/pt-rwlock-unlock.c
new file mode 100644
index 00000000..fb23a0b9
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-rwlock-unlock.c
@@ -0,0 +1,90 @@
+/* Unlock a rwlock. Generic version.
+ Copyright (C) 2000,02 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 <pthread.h>
+
+#include <pt-internal.h>
+
+/* Unlock *RWLOCK, rescheduling a waiting writer thread or, if there
+ are no threads waiting for a write lock, rescheduling the reader
+ threads. */
+int
+pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
+{
+ struct __pthread *wakeup;
+
+ __pthread_spin_lock (&rwlock->__lock);
+
+ assert (__pthread_spin_trylock (&rwlock->__held) == EBUSY);
+
+ if (rwlock->readers > 1)
+ /* There are other readers. */
+ {
+ rwlock->readers --;
+ __pthread_spin_unlock (&rwlock->__lock);
+ return 0;
+ }
+
+ if (rwlock->readers == 1)
+ /* Last reader. */
+ rwlock->readers = 0;
+
+
+ /* Wake someone else up. Try the writer queue first, then the
+ reader queue if that is empty. */
+
+ if (rwlock->writerqueue)
+ {
+ wakeup = rwlock->writerqueue;
+ __pthread_dequeue (wakeup);
+
+ /* We do not unlock RWLOCK->held: we are transferring the ownership
+ to the thread that we are waking up. */
+
+ __pthread_spin_unlock (&rwlock->__lock);
+ __pthread_wakeup (wakeup);
+
+ return 0;
+ }
+
+ if (rwlock->readerqueue)
+ {
+ __pthread_queue_iterate (rwlock->readerqueue, wakeup)
+ rwlock->readers ++;
+
+ wakeup = rwlock->readerqueue;
+ rwlock->readerqueue = 0;
+
+ __pthread_spin_unlock (&rwlock->__lock);
+
+ /* We can safely walk the list of waiting threads without holding
+ the lock since it is now decoupled from the rwlock. */
+ __pthread_dequeuing_iterate (wakeup, wakeup)
+ __pthread_wakeup (wakeup);
+
+ return 0;
+ }
+
+
+ /* Noone is waiting. Just unlock it. */
+
+ __pthread_spin_unlock (&rwlock->__held);
+ __pthread_spin_unlock (&rwlock->__lock);
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-rwlock-wrlock.c b/libpthread/sysdeps/generic/pt-rwlock-wrlock.c
new file mode 100644
index 00000000..be85b906
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-rwlock-wrlock.c
@@ -0,0 +1,34 @@
+/* Acquire a rwlock for writing. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+/* Implemented in pt-rwlock-timedwrlock.c. */
+extern int __pthread_rwlock_timedwrlock_internal (struct __pthread_rwlock *rwlock,
+ const struct timespec *abstime);
+
+/* Acquire RWLOCK for writing. */
+int
+pthread_rwlock_wrlock (struct __pthread_rwlock *rwlock)
+{
+ return __pthread_rwlock_timedwrlock_internal (rwlock, 0);
+}
diff --git a/libpthread/sysdeps/generic/pt-rwlockattr-destroy.c b/libpthread/sysdeps/generic/pt-rwlockattr-destroy.c
new file mode 100644
index 00000000..eabfcbe8
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-rwlockattr-destroy.c
@@ -0,0 +1,27 @@
+/* pthread_rwlockattr_destroy. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_rwlockattr_destroy (pthread_rwlockattr_t *attr)
+{
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-rwlockattr-getpshared.c b/libpthread/sysdeps/generic/pt-rwlockattr-getpshared.c
new file mode 100644
index 00000000..e8752c0c
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-rwlockattr-getpshared.c
@@ -0,0 +1,29 @@
+/* pthread_rwlockattr_getpshared. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *attr,
+ int *pshared)
+{
+ *pshared = attr->pshared;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-rwlockattr-init.c b/libpthread/sysdeps/generic/pt-rwlockattr-init.c
new file mode 100644
index 00000000..34da6bf0
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-rwlockattr-init.c
@@ -0,0 +1,28 @@
+/* pthread_rwlockattr_init. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_rwlockattr_init (pthread_rwlockattr_t *attr)
+{
+ *attr = __pthread_default_rwlockattr;
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-rwlockattr-setpshared.c b/libpthread/sysdeps/generic/pt-rwlockattr-setpshared.c
new file mode 100644
index 00000000..a861d034
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-rwlockattr-setpshared.c
@@ -0,0 +1,39 @@
+/* pthread_rwlockattr_setpshared. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_rwlockattr_setpshared (pthread_rwlockattr_t *attr,
+ int pshared)
+{
+ switch (pshared)
+ {
+ case PTHREAD_PROCESS_PRIVATE:
+ attr->pshared = pshared;
+ return 0;
+
+ case PTHREAD_PROCESS_SHARED:
+ return ENOTSUP;
+
+ default:
+ return EINVAL;
+ }
+}
diff --git a/libpthread/sysdeps/generic/pt-setconcurrency.c b/libpthread/sysdeps/generic/pt-setconcurrency.c
new file mode 100644
index 00000000..cd55b1ba
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-setconcurrency.c
@@ -0,0 +1,34 @@
+/* Set the desired level of concurrency. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int __pthread_concurrency;
+
+int
+pthread_setconcurrency (int new_level)
+{
+ if (new_level < 0)
+ return EINVAL;
+
+ __pthread_concurrency = new_level;
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/generic/pt-setschedparam.c b/libpthread/sysdeps/generic/pt-setschedparam.c
new file mode 100644
index 00000000..a70b0796
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-setschedparam.c
@@ -0,0 +1,28 @@
+/* Set the scheduling parameters for a thread. Generic version.
+ Copyright (C) 2002, 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
+ 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_setschedparam (pthread_t thread, int policy,
+ const struct sched_param *param)
+{
+ return ENOSYS;
+}
diff --git a/libpthread/sysdeps/generic/pt-setschedprio.c b/libpthread/sysdeps/generic/pt-setschedprio.c
new file mode 100644
index 00000000..60668eb1
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-setschedprio.c
@@ -0,0 +1,27 @@
+/* Set the scheduling priority of a thread. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_setschedprio (pthread_t thread, int prio)
+{
+ return ENOSYS;
+}
diff --git a/libpthread/sysdeps/generic/pt-setspecific.c b/libpthread/sysdeps/generic/pt-setspecific.c
new file mode 100644
index 00000000..d520c5df
--- /dev/null
+++ b/libpthread/sysdeps/generic/pt-setspecific.c
@@ -0,0 +1,27 @@
+/* pthread_setspecific. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+int
+pthread_setspecific (pthread_key_t key, const void *value)
+{
+ return EINVAL;
+}
diff --git a/libpthread/sysdeps/generic/sem-close.c b/libpthread/sysdeps/generic/sem-close.c
new file mode 100644
index 00000000..9f48032f
--- /dev/null
+++ b/libpthread/sysdeps/generic/sem-close.c
@@ -0,0 +1,32 @@
+/* Close a named semaphore. Generic version.
+ Copyright (C) 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
+ 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 <semaphore.h>
+#include <errno.h>
+
+#include <pt-internal.h>
+
+int
+__sem_close (sem_t *sem)
+{
+ errno = EOPNOTSUPP;
+ return -1;
+}
+
+strong_alias (__sem_close, sem_close);
diff --git a/libpthread/sysdeps/generic/sem-destroy.c b/libpthread/sysdeps/generic/sem-destroy.c
new file mode 100644
index 00000000..6486599c
--- /dev/null
+++ b/libpthread/sysdeps/generic/sem-destroy.c
@@ -0,0 +1,38 @@
+/* Destroy a semaphore. Generic version.
+ Copyright (C) 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 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 <semaphore.h>
+#include <errno.h>
+
+#include <pt-internal.h>
+
+int
+__sem_destroy (sem_t *sem)
+{
+ if (sem->__queue)
+ /* There are threads waiting on *SEM. */
+ {
+ errno = EBUSY;
+ return -1;
+ }
+
+ return 0;
+}
+
+strong_alias (__sem_destroy, sem_destroy);
diff --git a/libpthread/sysdeps/generic/sem-getvalue.c b/libpthread/sysdeps/generic/sem-getvalue.c
new file mode 100644
index 00000000..7762089b
--- /dev/null
+++ b/libpthread/sysdeps/generic/sem-getvalue.c
@@ -0,0 +1,33 @@
+/* Get the value of a semaphore. Generic version.
+ Copyright (C) 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 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 <semaphore.h>
+#include <pt-internal.h>
+
+int
+__sem_getvalue (sem_t *restrict sem, int *restrict value)
+{
+ __pthread_spin_lock (&sem->__lock);
+ *value = sem->__value;
+ __pthread_spin_unlock (&sem->__lock);
+
+ return 0;
+}
+
+strong_alias (__sem_getvalue, sem_getvalue);
diff --git a/libpthread/sysdeps/generic/sem-init.c b/libpthread/sysdeps/generic/sem-init.c
new file mode 100644
index 00000000..d2414f5d
--- /dev/null
+++ b/libpthread/sysdeps/generic/sem-init.c
@@ -0,0 +1,46 @@
+/* Initialize a semaphore. Generic version.
+ Copyright (C) 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 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 <semaphore.h>
+#include <errno.h>
+
+#include <pt-internal.h>
+
+int
+__sem_init (sem_t *sem, int pshared, unsigned value)
+{
+ if (pshared != 0)
+ {
+ errno = EOPNOTSUPP;
+ return -1;
+ }
+
+#ifdef SEM_VALUE_MAX
+ if (value > SEM_VALUE_MAX)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+#endif
+
+ *sem = (sem_t) __SEMAPHORE_INITIALIZER (pshared, value);
+ return 0;
+}
+
+strong_alias (__sem_init, sem_init);
diff --git a/libpthread/sysdeps/generic/sem-open.c b/libpthread/sysdeps/generic/sem-open.c
new file mode 100644
index 00000000..bae87ed0
--- /dev/null
+++ b/libpthread/sysdeps/generic/sem-open.c
@@ -0,0 +1,32 @@
+/* Open a named semaphore. Generic version.
+ Copyright (C) 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 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 <semaphore.h>
+#include <errno.h>
+
+#include <pt-internal.h>
+
+sem_t *
+__sem_open (const char *name, int open_flags, ...)
+{
+ errno = EOPNOTSUPP;
+ return SEM_FAILED;
+}
+
+strong_alias (__sem_open, sem_open);
diff --git a/libpthread/sysdeps/generic/sem-post.c b/libpthread/sysdeps/generic/sem-post.c
new file mode 100644
index 00000000..6d438bf2
--- /dev/null
+++ b/libpthread/sysdeps/generic/sem-post.c
@@ -0,0 +1,62 @@
+/* Post a semaphore. Generic version.
+ Copyright (C) 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 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 <semaphore.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+int
+__sem_post (sem_t *sem)
+{
+ struct __pthread *wakeup;
+
+ __pthread_spin_lock (&sem->__lock);
+ if (sem->__value > 0)
+ /* Do a quick up. */
+ {
+ assert (! sem->__queue);
+ sem->__value ++;
+ __pthread_spin_unlock (&sem->__lock);
+ return 0;
+ }
+
+ if (! sem->__queue)
+ /* No one waiting. */
+ {
+ sem->__value = 1;
+ __pthread_spin_unlock (&sem->__lock);
+ return 0;
+ }
+
+ /* Wake someone up. */
+
+ /* First dequeue someone. */
+ wakeup = sem->__queue;
+ __pthread_dequeue (wakeup);
+
+ /* Then drop the lock and transfer control. */
+ __pthread_spin_unlock (&sem->__lock);
+
+ __pthread_wakeup (wakeup);
+
+ return 0;
+}
+
+strong_alias (__sem_post, sem_post);
diff --git a/libpthread/sysdeps/generic/sem-timedwait.c b/libpthread/sysdeps/generic/sem-timedwait.c
new file mode 100644
index 00000000..f9040009
--- /dev/null
+++ b/libpthread/sysdeps/generic/sem-timedwait.c
@@ -0,0 +1,92 @@
+/* Wait on a semaphore with a timeout. Generic version.
+ Copyright (C) 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 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 <semaphore.h>
+#include <error.h>
+#include <errno.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+int
+__sem_timedwait_internal (sem_t *restrict sem,
+ const struct timespec *restrict timeout)
+{
+ struct __pthread *self;
+
+ __pthread_spin_lock (&sem->__lock);
+ if (sem->__value > 0)
+ /* Successful down. */
+ {
+ sem->__value --;
+ __pthread_spin_unlock (&sem->__lock);
+ return 0;
+ }
+
+ if (timeout && (timeout->tv_nsec < 0 || timeout->tv_nsec >= 1000000000))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* Add ourselves to the queue. */
+ self = _pthread_self ();
+
+ __pthread_enqueue (&sem->__queue, self);
+ __pthread_spin_unlock (&sem->__lock);
+
+ /* Block the thread. */
+ if (timeout)
+ {
+ error_t err;
+
+ err = __pthread_timedblock (self, timeout);
+ if (err)
+ /* We timed out. We may need to disconnect ourself from the
+ waiter queue.
+
+ FIXME: What do we do if we get a wakeup message before we
+ disconnect ourself? It may remain until the next time we
+ block. */
+ {
+ assert (err == ETIMEDOUT);
+
+ __pthread_spin_lock (&sem->__lock);
+ if (self->prevp)
+ __pthread_dequeue (self);
+ __pthread_spin_unlock (&sem->__lock);
+
+ errno = err;
+ return -1;
+ }
+ }
+ else
+ __pthread_block (self);
+
+ return 0;
+}
+
+int
+__sem_timedwait (sem_t *restrict sem,
+ const struct timespec *restrict timeout)
+{
+ return __sem_timedwait_internal (sem, timeout);
+}
+
+strong_alias (__sem_timedwait, sem_timedwait);
diff --git a/libpthread/sysdeps/generic/sem-trywait.c b/libpthread/sysdeps/generic/sem-trywait.c
new file mode 100644
index 00000000..437e2822
--- /dev/null
+++ b/libpthread/sysdeps/generic/sem-trywait.c
@@ -0,0 +1,42 @@
+/* Lock a semaphore if it does not require blocking. Generic version.
+ Copyright (C) 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 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 <semaphore.h>
+#include <errno.h>
+
+#include <pt-internal.h>
+
+int
+__sem_trywait (sem_t *sem)
+{
+ __pthread_spin_lock (&sem->__lock);
+ if (sem->__value > 0)
+ /* Successful down. */
+ {
+ sem->__value --;
+ __pthread_spin_unlock (&sem->__lock);
+ return 0;
+ }
+ __pthread_spin_unlock (&sem->__lock);
+
+ errno = EAGAIN;
+ return -1;
+}
+
+strong_alias (__sem_trywait, sem_trywait);
diff --git a/libpthread/sysdeps/generic/sem-unlink.c b/libpthread/sysdeps/generic/sem-unlink.c
new file mode 100644
index 00000000..570ed614
--- /dev/null
+++ b/libpthread/sysdeps/generic/sem-unlink.c
@@ -0,0 +1,32 @@
+/* Unlink a named semaphore. Generic version.
+ Copyright (C) 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 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 <semaphore.h>
+#include <errno.h>
+
+#include <pt-internal.h>
+
+int
+__sem_unlink (const char *name)
+{
+ errno = EOPNOTSUPP;
+ return -1;
+}
+
+strong_alias (__sem_unlink, sem_unlink);
diff --git a/libpthread/sysdeps/generic/sem-wait.c b/libpthread/sysdeps/generic/sem-wait.c
new file mode 100644
index 00000000..8347480c
--- /dev/null
+++ b/libpthread/sysdeps/generic/sem-wait.c
@@ -0,0 +1,32 @@
+/* Wait on a semaphore. Generic version.
+ Copyright (C) 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 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 <semaphore.h>
+#include <pt-internal.h>
+
+extern int __sem_timedwait_internal (sem_t *restrict sem,
+ const struct timespec *restrict timeout);
+
+int
+__sem_wait (sem_t *sem)
+{
+ return __sem_timedwait_internal (sem, 0);
+}
+
+strong_alias (__sem_wait, sem_wait);
diff --git a/libpthread/sysdeps/hurd/CVS/Entries b/libpthread/sysdeps/hurd/CVS/Entries
new file mode 100644
index 00000000..1e6dc2ce
--- /dev/null
+++ b/libpthread/sysdeps/hurd/CVS/Entries
@@ -0,0 +1,9 @@
+/pt-destroy-specific.c/1.3/Mon Mar 1 09:58:44 2004//Tzhengda-soc2008-virt-branch
+/pt-getspecific.c/1.2/Mon Mar 1 09:58:44 2004//Tzhengda-soc2008-virt-branch
+/pt-init-specific.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-key-create.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-key-delete.c/1.2/Sat Nov 2 23:41:51 2002//Tzhengda-soc2008-virt-branch
+/pt-key.h/1.2/Mon Mar 1 09:58:44 2004//Tzhengda-soc2008-virt-branch
+/pt-kill.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-setspecific.c/1.2/Mon Mar 1 09:58:44 2004//Tzhengda-soc2008-virt-branch
+D
diff --git a/libpthread/sysdeps/hurd/CVS/Repository b/libpthread/sysdeps/hurd/CVS/Repository
new file mode 100644
index 00000000..81891d23
--- /dev/null
+++ b/libpthread/sysdeps/hurd/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps/hurd
diff --git a/libpthread/sysdeps/hurd/CVS/Root b/libpthread/sysdeps/hurd/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/hurd/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/hurd/CVS/Tag b/libpthread/sysdeps/hurd/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/hurd/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/hurd/pt-destroy-specific.c b/libpthread/sysdeps/hurd/pt-destroy-specific.c
new file mode 100644
index 00000000..23c7fbc0
--- /dev/null
+++ b/libpthread/sysdeps/hurd/pt-destroy-specific.c
@@ -0,0 +1,79 @@
+/* __pthread_destory_specific. Hurd version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <stdlib.h>
+#include <hurd/ihash.h>
+
+#include <pt-internal.h>
+
+void
+__pthread_destroy_specific (struct __pthread *thread)
+{
+ error_t err;
+ int i;
+ int seen_one;
+
+ /* Check if there is any thread specific data. */
+ if (! thread->thread_specifics)
+ return;
+
+ __pthread_key_lock_ready ();
+
+ /* Iterate and call the destructors on any thread specific data. */
+ for (;;)
+ {
+ seen_one = 0;
+
+ __pthread_mutex_lock (&__pthread_key_lock);
+
+ for (i = 0; i < __pthread_key_count; i ++)
+ {
+ void *value;
+
+ if (__pthread_key_destructors[i] == PTHREAD_KEY_INVALID)
+ break;
+
+ value = hurd_ihash_find (thread->thread_specifics, i);
+ if (value)
+ {
+ err = hurd_ihash_remove (thread->thread_specifics, i);
+ assert (err == 1);
+
+ if (__pthread_key_destructors[i])
+ {
+ seen_one = 1;
+ __pthread_key_destructors[i] (value);
+ }
+ }
+ }
+
+ __pthread_mutex_unlock (&__pthread_key_lock);
+
+ if (! seen_one)
+ break;
+
+ /* This may take a very long time. Let those blocking on
+ pthread_key_create or pthread_key_delete make progress. */
+ sched_yield ();
+ }
+
+ hurd_ihash_free (thread->thread_specifics);
+ thread->thread_specifics = 0;
+}
diff --git a/libpthread/sysdeps/hurd/pt-getspecific.c b/libpthread/sysdeps/hurd/pt-getspecific.c
new file mode 100644
index 00000000..30605984
--- /dev/null
+++ b/libpthread/sysdeps/hurd/pt-getspecific.c
@@ -0,0 +1,37 @@
+/* pthread_getspecific. Hurd version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <hurd/ihash.h>
+
+#include <pt-internal.h>
+
+void *
+pthread_getspecific (pthread_key_t key)
+{
+ struct __pthread *self;
+
+ assert (key < __pthread_key_count);
+
+ self = _pthread_self ();
+ if (! self->thread_specifics)
+ return 0;
+
+ return hurd_ihash_find (self->thread_specifics, key);
+}
diff --git a/libpthread/sysdeps/hurd/pt-init-specific.c b/libpthread/sysdeps/hurd/pt-init-specific.c
new file mode 100644
index 00000000..c1bacbcb
--- /dev/null
+++ b/libpthread/sysdeps/hurd/pt-init-specific.c
@@ -0,0 +1,30 @@
+/* __pthread_init_specific. Hurd version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <stdlib.h>
+
+#include <pt-internal.h>
+
+error_t
+__pthread_init_specific (struct __pthread *thread)
+{
+ thread->thread_specifics = 0;
+ return 0;
+}
diff --git a/libpthread/sysdeps/hurd/pt-key-create.c b/libpthread/sysdeps/hurd/pt-key-create.c
new file mode 100644
index 00000000..b3e01412
--- /dev/null
+++ b/libpthread/sysdeps/hurd/pt-key-create.c
@@ -0,0 +1,109 @@
+/* pthread_key_create. Hurd version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+pthread_mutex_t __pthread_key_lock;
+
+void (**__pthread_key_destructors) (void *arg);
+int __pthread_key_size;
+int __pthread_key_count;
+int __pthread_key_invalid_count;
+
+int
+pthread_key_create (pthread_key_t *key, void (*destructor) (void *))
+{
+ /* Where to look for the next key slot. */
+ static int index;
+
+ __pthread_key_lock_ready ();
+
+ __pthread_mutex_lock (&__pthread_key_lock);
+
+ do_search:
+ /* Use the search hint and try to find a free slot. */
+ for (; index < __pthread_key_count
+ && __pthread_key_destructors[index] != PTHREAD_KEY_INVALID;
+ index ++)
+ ;
+
+ /* See if we actually found a free element. */
+ if (index < __pthread_key_count)
+ {
+ assert (__pthread_key_destructors[index] == PTHREAD_KEY_INVALID);
+ assert (__pthread_key_invalid_count > 0);
+
+ __pthread_key_invalid_count --;
+ __pthread_key_destructors[index] = destructor;
+ *key = index ++;
+
+ __pthread_mutex_unlock (&__pthread_key_lock);
+ return 0;
+ }
+
+ assert (index == __pthread_key_count);
+
+ /* No space at the end. */
+ if (__pthread_key_size == __pthread_key_count)
+ {
+ /* See if it is worth looking for a free element. */
+ if (__pthread_key_invalid_count > 4
+ && __pthread_key_invalid_count > __pthread_key_size / 8)
+ {
+ index = 0;
+ goto do_search;
+ }
+
+
+ /* Resize the array. */
+ {
+ void *t;
+ int newsize;
+
+ if (__pthread_key_size == 0)
+ newsize = 8;
+ else
+ newsize = __pthread_key_size * 2;
+
+ t = realloc (__pthread_key_destructors,
+ newsize * sizeof (*__pthread_key_destructors));
+ if (! t)
+ {
+ __pthread_mutex_unlock (&__pthread_key_lock);
+ return ENOMEM;
+ }
+
+ __pthread_key_size = newsize;
+ __pthread_key_destructors = t;
+ }
+ }
+
+ __pthread_key_destructors[index] = destructor;
+ *key = index;
+
+ index ++;
+ __pthread_key_count ++;
+
+ __pthread_mutex_unlock (&__pthread_key_lock);
+ return 0;
+}
diff --git a/libpthread/sysdeps/hurd/pt-key-delete.c b/libpthread/sysdeps/hurd/pt-key-delete.c
new file mode 100644
index 00000000..2426bb11
--- /dev/null
+++ b/libpthread/sysdeps/hurd/pt-key-delete.c
@@ -0,0 +1,45 @@
+/* pthread_key_delete. Hurd version.
+ Copyright (C) 2002 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 <pthread.h>
+
+#include <pt-internal.h>
+
+int
+pthread_key_delete (pthread_key_t key)
+{
+ error_t err = 0;
+
+ __pthread_key_lock_ready ();
+
+ __pthread_mutex_lock (&__pthread_key_lock);
+
+ if (key < 0 || key >= __pthread_key_count
+ || __pthread_key_destructors[key] == PTHREAD_KEY_INVALID)
+ err = EINVAL;
+ else
+ {
+ __pthread_key_destructors[key] = PTHREAD_KEY_INVALID;
+ __pthread_key_invalid_count ++;
+ }
+
+ __pthread_mutex_unlock (&__pthread_key_lock);
+
+ return err;
+}
diff --git a/libpthread/sysdeps/hurd/pt-key.h b/libpthread/sysdeps/hurd/pt-key.h
new file mode 100644
index 00000000..494e01d7
--- /dev/null
+++ b/libpthread/sysdeps/hurd/pt-key.h
@@ -0,0 +1,76 @@
+/* pthread_key internal declatations for the Hurd version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <hurd/ihash.h>
+
+#define PTHREAD_KEY_MEMBERS \
+ hurd_ihash_t thread_specifics;
+
+#define PTHREAD_KEY_INVALID (void *) (-1)
+
+
+/* __PTHREAD_KEY_DESTRUCTORS is an array of destructors with
+ __PTHREAD_KEY_SIZE elements. If an element with index less than
+ __PTHREAD_KEY_COUNT is invalid, it shall contain the value
+ PTHREAD_KEY_INVALID which shall be distinct from NULL.
+
+ Normally, we just add new keys to the end of the array and realloc
+ it as necessary. The pthread_key_create routine may decide to
+ rescan the array if __PTHREAD_KEY_FREE is large. */
+extern void (**__pthread_key_destructors) (void *arg);
+extern int __pthread_key_size;
+extern int __pthread_key_count;
+/* Number of invalid elements in the array. Does not include elements
+ for which memory has been allocated but which have not yet been
+ used (i.e. those elements with indexes greater than
+ __PTHREAD_KEY_COUNT). */
+extern int __pthread_key_invalid_count;
+
+/* Protects the above variables. This must be a recursive lock: the
+ destructors may call pthread_key_delete. */
+extern pthread_mutex_t __pthread_key_lock;
+
+#include <assert.h>
+
+static inline void
+__pthread_key_lock_ready (void)
+{
+ static pthread_once_t o = PTHREAD_ONCE_INIT;
+
+ void do_init (void)
+ {
+ int err;
+ pthread_mutexattr_t attr;
+
+ err = pthread_mutexattr_init (&attr);
+ assert_perror (err);
+
+ err = pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
+ assert_perror (err);
+
+ err = pthread_mutex_init (&__pthread_key_lock, &attr);
+ assert_perror (err);
+
+ err = pthread_mutexattr_destroy (&attr);
+ assert_perror (err);
+ }
+
+ pthread_once (&o, do_init);
+}
diff --git a/libpthread/sysdeps/hurd/pt-kill.c b/libpthread/sysdeps/hurd/pt-kill.c
new file mode 100644
index 00000000..f970e065
--- /dev/null
+++ b/libpthread/sysdeps/hurd/pt-kill.c
@@ -0,0 +1,49 @@
+/* pthread_kill. Hurd version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <assert.h>
+#include <signal.h>
+#include <hurd/signal.h>
+
+#include <pt-internal.h>
+
+int
+pthread_kill (pthread_t thread, int sig)
+{
+ struct __pthread *pthread;
+ struct hurd_signal_detail detail;
+ struct hurd_sigstate *ss;
+
+ /* Lookup the thread structure for THREAD. */
+ pthread = __pthread_getid (thread);
+ if (pthread == NULL)
+ return ESRCH;
+
+ ss = _hurd_thread_sigstate (pthread->kernel_thread);
+ assert (ss);
+
+ detail.exc = 0;
+ detail.code = sig;
+ detail.error = 0;
+
+ _hurd_raise_signal (ss, sig, &detail);
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/hurd/pt-setspecific.c b/libpthread/sysdeps/hurd/pt-setspecific.c
new file mode 100644
index 00000000..89ca4d7f
--- /dev/null
+++ b/libpthread/sysdeps/hurd/pt-setspecific.c
@@ -0,0 +1,43 @@
+/* pthread_setspecific. Generic version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <hurd/ihash.h>
+
+#include <pt-internal.h>
+
+int
+pthread_setspecific (pthread_key_t key, const void *value)
+{
+ error_t err;
+ struct __pthread *self = _pthread_self ();
+
+ if (! self->thread_specifics)
+ {
+ err = hurd_ihash_create (&self->thread_specifics, HURD_IHASH_NO_LOCP);
+ if (err)
+ return ENOMEM;
+ }
+
+ err = hurd_ihash_add (self->thread_specifics, key, (void *) value);
+ if (err)
+ return ENOMEM;
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/i386/CVS/Entries b/libpthread/sysdeps/i386/CVS/Entries
new file mode 100644
index 00000000..2f9b7418
--- /dev/null
+++ b/libpthread/sysdeps/i386/CVS/Entries
@@ -0,0 +1,3 @@
+/machine-sp.h/1.3/Tue Jul 1 11:43:17 2008//Tzhengda-soc2008-virt-branch
+/pt-machdep.h/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+D/bits////
diff --git a/libpthread/sysdeps/i386/CVS/Repository b/libpthread/sysdeps/i386/CVS/Repository
new file mode 100644
index 00000000..61a58d3a
--- /dev/null
+++ b/libpthread/sysdeps/i386/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps/i386
diff --git a/libpthread/sysdeps/i386/CVS/Root b/libpthread/sysdeps/i386/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/i386/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/i386/CVS/Tag b/libpthread/sysdeps/i386/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/i386/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/i386/bits/CVS/Entries b/libpthread/sysdeps/i386/bits/CVS/Entries
new file mode 100644
index 00000000..500bd95c
--- /dev/null
+++ b/libpthread/sysdeps/i386/bits/CVS/Entries
@@ -0,0 +1,4 @@
+/atomic.h/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/memory.h/1.3/Tue Jul 1 11:43:17 2008//Tzhengda-soc2008-virt-branch
+/spin-lock.h/1.5/Tue Jul 1 11:43:17 2008//Tzhengda-soc2008-virt-branch
+D
diff --git a/libpthread/sysdeps/i386/bits/CVS/Repository b/libpthread/sysdeps/i386/bits/CVS/Repository
new file mode 100644
index 00000000..9ddbe855
--- /dev/null
+++ b/libpthread/sysdeps/i386/bits/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps/i386/bits
diff --git a/libpthread/sysdeps/i386/bits/CVS/Root b/libpthread/sysdeps/i386/bits/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/i386/bits/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/i386/bits/CVS/Tag b/libpthread/sysdeps/i386/bits/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/i386/bits/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/i386/bits/atomic.h b/libpthread/sysdeps/i386/bits/atomic.h
new file mode 100644
index 00000000..0dfc1f60
--- /dev/null
+++ b/libpthread/sysdeps/i386/bits/atomic.h
@@ -0,0 +1,66 @@
+/* Atomic operations. i386 version.
+ Copyright (C) 2000 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. */
+
+#ifndef _BITS_ATOMIC_H
+#define _BITS_ATOMIC_H 1
+
+typedef __volatile int __atomic_t;
+
+static inline void
+__atomic_inc (__atomic_t *__var)
+{
+ __asm__ __volatile ("lock; incl %0" : "=m" (*__var) : "m" (*__var));
+}
+
+static inline void
+__atomic_dec (__atomic_t *__var)
+{
+ __asm__ __volatile ("lock; decl %0" : "=m" (*__var) : "m" (*__var));
+}
+
+static inline int
+__atomic_dec_and_test (__atomic_t *__var)
+{
+ unsigned char __ret;
+
+ __asm__ __volatile ("lock; decl %0; sete %1"
+ : "=m" (*__var), "=qm" (__ret) : "m" (*__var));
+ return __ret != 0;
+}
+
+/* We assume that an __atomicptr_t is only used for pointers to
+ word-aligned objects, and use the lowest bit for a simple lock. */
+typedef __volatile int * __atomicptr_t;
+
+/* Actually we don't implement that yet, and assume that we run on
+ something that has the i486 instruction set. */
+static inline int
+__atomicptr_compare_and_swap (__atomicptr_t *__ptr, void *__oldval,
+ void * __newval)
+{
+ char __ret;
+ int __dummy;
+
+ __asm__ __volatile ("lock; cmpxchgl %3, %1; sete %0"
+ : "=q" (__ret), "=m" (*__ptr), "=a" (__dummy)
+ : "r" (__newval), "m" (*__ptr), "a" (__oldval));
+ return __ret;
+}
+
+#endif
diff --git a/libpthread/sysdeps/i386/bits/memory.h b/libpthread/sysdeps/i386/bits/memory.h
new file mode 100644
index 00000000..e47a8e2d
--- /dev/null
+++ b/libpthread/sysdeps/i386/bits/memory.h
@@ -0,0 +1,40 @@
+/* Memory barrier operations. i386 version.
+ Copyright (C) 2002, 2008 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. */
+
+#ifndef _BITS_MEMORY_H
+#define _BITS_MEMORY_H 1
+
+/* Prevent read and write reordering across this function. */
+static inline void
+__memory_barrier (void)
+{
+ int i;
+
+ /* Any lock'ed instruction will do. We just do a simple
+ increment. */
+ __asm__ __volatile ("lock; incl %0" : "=m" (i) : "m" (i));
+}
+
+/* Prevent read reordering across this function. */
+#define __memory_read_barrier __memory_barrier
+
+/* Prevent write reordering across this function. */
+#define __memory_write_barrier __memory_barrier
+
+#endif
diff --git a/libpthread/sysdeps/i386/bits/spin-lock.h b/libpthread/sysdeps/i386/bits/spin-lock.h
new file mode 100644
index 00000000..30b0c64b
--- /dev/null
+++ b/libpthread/sysdeps/i386/bits/spin-lock.h
@@ -0,0 +1,103 @@
+/* Machine-specific definitions for spin locks. i386 version.
+ Copyright (C) 2000, 2005, 2008 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. */
+
+/*
+ * Never include this file directly; use <pthread.h> or <cthreads.h> instead.
+ */
+
+#ifndef _BITS_SPIN_LOCK_H
+#define _BITS_SPIN_LOCK_H 1
+
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* The type of a spin lock object. */
+typedef __volatile int __pthread_spinlock_t;
+
+/* Initializer for a spin lock object. */
+# define __SPIN_LOCK_INITIALIZER (0)
+
+#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES
+
+# ifndef __EBUSY
+# include <errno.h>
+# define __EBUSY EBUSY
+# endif
+
+# ifndef __PT_SPIN_INLINE
+# define __PT_SPIN_INLINE __extern_inline
+# endif
+
+__PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock);
+
+__PT_SPIN_INLINE int
+__pthread_spin_destroy (__pthread_spinlock_t *__lock)
+{
+ return 0;
+}
+
+__PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock,
+ int __pshared);
+
+__PT_SPIN_INLINE int
+__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared)
+{
+ *__lock = __SPIN_LOCK_INITIALIZER;
+ return 0;
+}
+
+__PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock);
+
+__PT_SPIN_INLINE int
+__pthread_spin_trylock (__pthread_spinlock_t *__lock)
+{
+ int __locked;
+ __asm__ __volatile ("xchgl %0, %1"
+ : "=&r" (__locked), "=m" (*__lock) : "0" (1));
+ return __locked ? __EBUSY : 0;
+}
+
+__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock);
+extern int _pthread_spin_lock (__pthread_spinlock_t *__lock);
+
+__extern_inline int
+__pthread_spin_lock (__pthread_spinlock_t *__lock)
+{
+ if (__pthread_spin_trylock (__lock))
+ return _pthread_spin_lock (__lock);
+ return 0;
+}
+
+__PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock);
+
+__PT_SPIN_INLINE int
+__pthread_spin_unlock (__pthread_spinlock_t *__lock)
+{
+ int __unlocked;
+ __asm__ __volatile ("xchgl %0, %1"
+ : "=&r" (__unlocked), "=m" (*__lock) : "0" (0));
+ return 0;
+}
+
+#endif /* Use extern inlines or force inlines. */
+
+__END_DECLS
+
+#endif /* bits/spin-lock.h */
diff --git a/libpthread/sysdeps/i386/machine-sp.h b/libpthread/sysdeps/i386/machine-sp.h
new file mode 100644
index 00000000..cef6ab72
--- /dev/null
+++ b/libpthread/sysdeps/i386/machine-sp.h
@@ -0,0 +1,30 @@
+/* Machine-specific function to return the stack pointer. i386 version.
+ Copyright (C) 1994, 1997, 2001, 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. */
+
+#ifndef _MACHINE_SP_H
+#define _MACHINE_SP_H
+
+/* Return the current stack pointer. */
+
+#define __thread_stack_pointer() ({ \
+ register void *__sp__ asm("esp"); \
+ __sp__; \
+})
+
+#endif /* machine-sp.h */
diff --git a/libpthread/sysdeps/i386/pt-machdep.h b/libpthread/sysdeps/i386/pt-machdep.h
new file mode 100644
index 00000000..6d456367
--- /dev/null
+++ b/libpthread/sysdeps/i386/pt-machdep.h
@@ -0,0 +1,29 @@
+/* Machine dependent pthreads internal defenitions. i386 version.
+ Copyright (C) 2000 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. */
+
+#ifndef _PT_MACHDEP_H
+#define _PT_MACHDEP_H 1
+
+struct pthread_mcontext
+{
+ void *pc;
+ void *sp;
+};
+
+#endif /* pt-machdep.h */
diff --git a/libpthread/sysdeps/l4/CVS/Entries b/libpthread/sysdeps/l4/CVS/Entries
new file mode 100644
index 00000000..2566f6f3
--- /dev/null
+++ b/libpthread/sysdeps/l4/CVS/Entries
@@ -0,0 +1,9 @@
+/pt-block.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-docancel.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-stack-alloc.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-start.c/1.2/Mon Nov 18 22:20:58 2002//Tzhengda-soc2008-virt-branch
+/pt-thread-alloc.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-thread-halt.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-thread-start.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-wakeup.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+D/hurd////
diff --git a/libpthread/sysdeps/l4/CVS/Repository b/libpthread/sysdeps/l4/CVS/Repository
new file mode 100644
index 00000000..a9735deb
--- /dev/null
+++ b/libpthread/sysdeps/l4/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps/l4
diff --git a/libpthread/sysdeps/l4/CVS/Root b/libpthread/sysdeps/l4/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/l4/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/l4/CVS/Tag b/libpthread/sysdeps/l4/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/l4/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/l4/hurd/CVS/Entries b/libpthread/sysdeps/l4/hurd/CVS/Entries
new file mode 100644
index 00000000..280c2c1f
--- /dev/null
+++ b/libpthread/sysdeps/l4/hurd/CVS/Entries
@@ -0,0 +1,3 @@
+/pt-sysdep.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-sysdep.h/1.2/Tue Jan 18 10:08:52 2005//Tzhengda-soc2008-virt-branch
+D/i386////
diff --git a/libpthread/sysdeps/l4/hurd/CVS/Repository b/libpthread/sysdeps/l4/hurd/CVS/Repository
new file mode 100644
index 00000000..751f5e08
--- /dev/null
+++ b/libpthread/sysdeps/l4/hurd/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps/l4/hurd
diff --git a/libpthread/sysdeps/l4/hurd/CVS/Root b/libpthread/sysdeps/l4/hurd/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/l4/hurd/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/l4/hurd/CVS/Tag b/libpthread/sysdeps/l4/hurd/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/l4/hurd/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/l4/hurd/i386/CVS/Entries b/libpthread/sysdeps/l4/hurd/i386/CVS/Entries
new file mode 100644
index 00000000..867e57ea
--- /dev/null
+++ b/libpthread/sysdeps/l4/hurd/i386/CVS/Entries
@@ -0,0 +1,3 @@
+/pt-machdep.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-setup.c/1.3/Tue Jul 1 11:43:17 2008//Tzhengda-soc2008-virt-branch
+D
diff --git a/libpthread/sysdeps/l4/hurd/i386/CVS/Repository b/libpthread/sysdeps/l4/hurd/i386/CVS/Repository
new file mode 100644
index 00000000..c8d46d8c
--- /dev/null
+++ b/libpthread/sysdeps/l4/hurd/i386/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps/l4/hurd/i386
diff --git a/libpthread/sysdeps/l4/hurd/i386/CVS/Root b/libpthread/sysdeps/l4/hurd/i386/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/l4/hurd/i386/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/l4/hurd/i386/CVS/Tag b/libpthread/sysdeps/l4/hurd/i386/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/l4/hurd/i386/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/l4/hurd/i386/pt-machdep.c b/libpthread/sysdeps/l4/hurd/i386/pt-machdep.c
new file mode 100644
index 00000000..dbf5cd7e
--- /dev/null
+++ b/libpthread/sysdeps/l4/hurd/i386/pt-machdep.c
@@ -0,0 +1,20 @@
+/* Machine dependent pthreads code. Hurd/i386 version.
+ Copyright (C) 2000 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. */
+
+/* Nothing to do. */
diff --git a/libpthread/sysdeps/l4/hurd/i386/pt-setup.c b/libpthread/sysdeps/l4/hurd/i386/pt-setup.c
new file mode 100644
index 00000000..6540ee5b
--- /dev/null
+++ b/libpthread/sysdeps/l4/hurd/i386/pt-setup.c
@@ -0,0 +1,74 @@
+/* Setup thread stack. Hurd/i386 version.
+ Copyright (C) 2000, 2002, 2008 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 <l4/l4.h>
+
+#include <pt-internal.h>
+
+/* The stack layout used on the i386 is:
+
+ -----------------
+ | ARG |
+ -----------------
+ | START_ROUTINE |
+ -----------------
+ | 0 |
+ ----------------- */
+
+/* Set up the stack for THREAD, such that it appears as if
+ START_ROUTINE and ARG were passed to the new thread's entry-point.
+ Return the stack pointer for the new thread. We also take the
+ opportunity to install THREAD in our utcb. */
+static void *
+stack_setup (struct __pthread *thread,
+ void *(*start_routine)(void *), void *arg)
+{
+ L4_Word_t *top;
+
+ /* Calculate top of the new stack. */
+ top = (L4_Word_t *) ((L4_Word_t) thread->stackaddr + thread->stacksize);
+
+ if (start_routine)
+ {
+ /* Set up call frame. */
+ top -= 2*sizeof(L4_Word_t);
+ top = (unsigned long) top & ~0xf;
+ top[1] = (L4_Word_t) arg; /* Argument to START_ROUTINE. */
+ top[0] = (L4_Word_t) start_routine;
+ *--top = 0; /* Fake return address. */
+ }
+
+ return top;
+}
+
+int
+__pthread_setup (struct __pthread *thread,
+ void (*entry_point)(void *(*)(void *), void *),
+ void *(*start_routine)(void *), void *arg)
+{
+ thread->mcontext.pc = entry_point;
+ thread->mcontext.sp = stack_setup (thread, start_routine, arg);
+
+ if (L4_SameThreads (thread->threadid, L4_Myself ()))
+ L4_Set_MyUserDefinedHandle (thread);
+ else
+ L4_Set_UserDefinedHandle (thread->threadid, thread);
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/l4/hurd/pt-sysdep.c b/libpthread/sysdeps/l4/hurd/pt-sysdep.c
new file mode 100644
index 00000000..265592ca
--- /dev/null
+++ b/libpthread/sysdeps/l4/hurd/pt-sysdep.c
@@ -0,0 +1,58 @@
+/* System dependent pthreads code. Hurd version.
+ Copyright (C) 2000 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 <assert.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include <pt-internal.h>
+
+/* Forward. */
+static void *init_routine (void);
+
+/* OK, the name of this variable isn't really appropriate, but I don't
+ want to change it yet. */
+void *(*_pthread_init_routine)(void) = &init_routine;
+
+/* This function is called from the Hurd-specific startup code. It
+ should return a new stack pointer for the main thread. The caller
+ will switch to this new stack before doing anything serious. */
+static void *
+init_routine (void)
+{
+ struct __pthread *thread;
+ int err;
+
+ /* Initialize the library. */
+ __pthread_initialize ();
+
+ /* Create the pthread structure for the main thread (i.e. us). */
+ err = __pthread_create_internal (&thread, 0, 0, 0);
+ assert_perror (err);
+
+ __pthread_initialize ();
+
+ /* Decrease the number of threads, to take into account that the
+ signal thread (which will be created by the startup code when we
+ return from here) shouldn't be seen as a user thread. */
+#warning Need to implement the signal thread.
+ // __pthread_total--;
+
+ return (void *) thread->mcontext.sp;
+}
diff --git a/libpthread/sysdeps/l4/hurd/pt-sysdep.h b/libpthread/sysdeps/l4/hurd/pt-sysdep.h
new file mode 100644
index 00000000..87175330
--- /dev/null
+++ b/libpthread/sysdeps/l4/hurd/pt-sysdep.h
@@ -0,0 +1,52 @@
+/* Internal defenitions for pthreads library.
+ Copyright (C) 2000, 2002 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. */
+
+#ifndef _PT_SYSDEP_H
+#define _PT_SYSDEP_H 1
+
+#include <l4/l4.h>
+#include <task_client.h>
+#include <machine/vmparam.h>
+
+/* XXX */
+#define _POSIX_THREAD_THREADS_MAX 64
+
+/* The default stack size. */
+#define PTHREAD_STACK_DEFAULT (PAGE_SIZE)
+
+#define PTHREAD_SYSDEP_MEMBERS \
+ L4_ThreadId_t threadid; \
+ L4_Word_t my_errno;
+
+extern inline struct __pthread *
+__attribute__((__always_inline__))
+_pthread_self (void)
+{
+ return (struct __pthread *) L4_MyUserDefinedHandle ();
+}
+
+extern inline void
+__pthread_stack_dealloc (void *stackaddr, size_t stacksize)
+__attribute__((__always_inline__))
+{
+ /* XXX: can only implement this once we have a working memory manager. */
+ return;
+}
+
+#endif /* pt-sysdep.h */
diff --git a/libpthread/sysdeps/l4/pt-block.c b/libpthread/sysdeps/l4/pt-block.c
new file mode 100644
index 00000000..050c6947
--- /dev/null
+++ b/libpthread/sysdeps/l4/pt-block.c
@@ -0,0 +1,29 @@
+/* Block a thread. L4 version.
+ Copyright (C) 2002 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 <l4/l4.h>
+
+#include <pt-internal.h>
+
+/* Block THREAD. */
+void
+__pthread_block (struct __pthread *thread)
+{
+ L4_Receive (L4_anylocalthread);
+}
diff --git a/libpthread/sysdeps/l4/pt-docancel.c b/libpthread/sysdeps/l4/pt-docancel.c
new file mode 100644
index 00000000..9a3bb26c
--- /dev/null
+++ b/libpthread/sysdeps/l4/pt-docancel.c
@@ -0,0 +1,51 @@
+/* Cancel a thread.
+ Copyright (C) 2002 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 <pthread.h>
+
+#include <pt-internal.h>
+
+static void
+call_exit (void)
+{
+ pthread_exit (0);
+}
+
+int
+__pthread_do_cancel (struct __pthread *p)
+{
+ assert (p->cancel_pending = 1);
+ assert (p->cancel_state == PTHREAD_CANCEL_ENABLE);
+
+ if (L4_SameThreads (L4_Myself (), p->threadid))
+ call_exit ();
+ else
+ {
+ L4_Word_t dummy;
+ L4_ThreadId_t dummy_id;
+
+ /* Change the ip of the target thread to make it exit. */
+ L4_ExchangeRegisters (p->threadid, (1 << 4), 0, call_exit,
+ 0, 0, L4_nilthread,
+ &dummy, &dummy, &dummy, &dummy, &dummy,
+ &dummy_id);
+ }
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/l4/pt-stack-alloc.c b/libpthread/sysdeps/l4/pt-stack-alloc.c
new file mode 100644
index 00000000..e28d5310
--- /dev/null
+++ b/libpthread/sysdeps/l4/pt-stack-alloc.c
@@ -0,0 +1,70 @@
+/* Allocate a new stack. L4 Hurd version.
+ Copyright (C) 2000 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 <l4/l4.h>
+#include <errno.h>
+
+#include <pt-internal.h>
+
+#define __pthread_stacksize __pthread_default_attr.stacksize
+
+#include <l4/sigma0.h>
+#include <hurd/debug.h>
+
+static void *
+allocate_page (void)
+{
+ L4_Fpage_t p;
+ /* The Kernel Interface page. */
+ static L4_KernelInterfacePage_t *kip;
+
+ if (! kip)
+ kip = L4_GetKernelInterface ();
+
+#define sigma0_tid() (L4_GlobalId (kip->ThreadInfo.X.UserBase, 1))
+ p = L4_Sigma0_GetPage (sigma0_tid (),
+ L4_Fpage_Set_Attrs (L4_FpageLog2 (-1UL << 10,
+ PAGE_SHIFT),
+ L4_FullyAccessible));
+ p.raw &= ~0x3ff;
+
+ printf ("%s: Allocated page %x\n",
+ __FUNCTION__, p.raw);
+
+ return (void *) p.raw;
+}
+
+
+/* Allocate a new stack of size STACKSIZE. If successfull, store the
+ address of the newly allocated stack in *STACKADDR and return 0.
+ Otherwise return an error code (EINVAL for an invalid stack size,
+ EAGAIN if the system lacked the necessary resources to allocate a
+ new stack). */
+int
+__pthread_stack_alloc (void **stackaddr, size_t stacksize)
+{
+ if (stacksize != __pthread_stacksize)
+ return EINVAL;
+
+ *stackaddr = allocate_page ();
+ if (! *stackaddr)
+ return EAGAIN;
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/l4/pt-start.c b/libpthread/sysdeps/l4/pt-start.c
new file mode 100644
index 00000000..fb4e27be
--- /dev/null
+++ b/libpthread/sysdeps/l4/pt-start.c
@@ -0,0 +1,103 @@
+/* Start thread. L4 Hurd version.
+ Copyright (C) 2002 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 <assert.h>
+#include <errno.h>
+#include <string.h>
+
+#include <pt-internal.h>
+
+#include "task_client.h"
+
+extern L4_ThreadId_t __system_pager;
+extern L4_ThreadId_t __task_server;
+
+#ifndef WORKING_EXREGS
+static void
+send_startup_ipc (L4_ThreadId_t id, L4_Word_t ip, L4_Word_t sp)
+{
+ L4_Msg_t msg;
+
+ printf ("%s: Sending startup message to %x, "
+ "(ip=%x, sp=%x)\n",
+ __FUNCTION__, * (L4_Word_t *) &id, ip, sp);
+
+ L4_Clear (&msg);
+#ifdef HAVE_PROPAGATION
+ L4_Set_VirtualSender (pager_tid);
+ L4_Set_Propagation (&msg.tag);
+#endif
+ L4_Append_Word (&msg, ip);
+ L4_Append_Word (&msg, sp);
+#ifndef HAVE_PROPAGATION
+ L4_Append_Word (&msg, *(L4_Word_t *) &id);
+ id = __system_pager;
+#if 0
+ DODEBUG (2, printf ("%s: Redirecting start request to pager (%x).\n",
+ __FUNCTION__, * (L4_Word_t *) &id));
+#endif
+#endif
+ L4_LoadMsg (&msg);
+ L4_Send (id);
+}
+#endif
+
+/* Start THREAD. We allocate all system-specific resources, including
+ a kernel thread, set it up, and get it running. */
+int
+__pthread_start (struct __pthread *thread)
+{
+ error_t err;
+
+ if (__pthread_num_threads == 1)
+ /* The main thread is already running: do nothing. */
+ {
+ assert (__pthread_total == 1);
+ thread->threadid = L4_Myself ();
+ }
+ else
+ {
+ CORBA_Environment env;
+
+ env = idl4_default_environment;
+ err = thread_create (__task_server,
+ L4_Version (L4_Myself ()),
+ * (L4_Word_t *) &__system_pager,
+ (L4_Word_t *) &thread->threadid, &env);
+ if (err)
+ return EAGAIN;
+
+ env = idl4_default_environment;
+ err = thread_resume (__task_server,
+ * (L4_Word_t *) &thread->threadid,
+ &env);
+ assert (! err);
+
+#ifndef WORKING_EXREGS
+ L4_AbortIpc_and_stop (thread->threadid);
+ L4_Start_SpIp (thread->threadid, (L4_Word_t) thread->mcontext.sp,
+ (L4_Word_t) thread->mcontext.pc);
+#endif
+ send_startup_ipc (thread->threadid, (L4_Word_t) thread->mcontext.pc,
+ (L4_Word_t) thread->mcontext.sp);
+
+ }
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/l4/pt-thread-alloc.c b/libpthread/sysdeps/l4/pt-thread-alloc.c
new file mode 100644
index 00000000..a9d5e212
--- /dev/null
+++ b/libpthread/sysdeps/l4/pt-thread-alloc.c
@@ -0,0 +1,52 @@
+/* Start thread. L4 version.
+ Copyright (C) 2002 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 <assert.h>
+#include <errno.h>
+#include <string.h>
+
+#include <pt-internal.h>
+
+/* Start THREAD. Get the kernel thread scheduled and running. */
+int
+__pthread_thread_start (struct __pthread *thread)
+{
+ error_t err;
+
+ /* The main thread is already running of course. */
+ if (__pthread_num_threads == 1)
+ {
+ assert (__pthread_total == 1);
+ thread->thread_id = L4_Myself ();
+ }
+ else
+ {
+ CORBA_Environment env;
+
+ env = idl4_default_environment;
+ err = thread_create (__task_server,
+ L4_Version (L4_Myself ()),
+ * (L4_Word_t *) &__system_pager,
+ (L4_Word_t *) &thread->threadid, &env);
+ if (err)
+ return EAGAIN;
+ }
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/l4/pt-thread-halt.c b/libpthread/sysdeps/l4/pt-thread-halt.c
new file mode 100644
index 00000000..04d622f4
--- /dev/null
+++ b/libpthread/sysdeps/l4/pt-thread-halt.c
@@ -0,0 +1,38 @@
+/* Deallocate the kernel thread resources. Mach version.
+ Copyright (C) 2000,02 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 <assert.h>
+#include <errno.h>
+#include <mach.h>
+
+#include <pt-internal.h>
+
+extern L4_ThreadId_t __task_server;
+
+/* Deallocate the kernel thread resources associated with THREAD. */
+void
+__pthread_thread_halt (struct __pthread *thread)
+{
+ CORBA_Environment env = idl4_default_environment;
+ L4_Word_t *t = (L4_Word_t *) &thread->threadid;
+
+ assert (*t);
+ assert (thread_terminate (__task_server, *t, &env));
+ *t = 0;
+}
diff --git a/libpthread/sysdeps/l4/pt-thread-start.c b/libpthread/sysdeps/l4/pt-thread-start.c
new file mode 100644
index 00000000..c428d290
--- /dev/null
+++ b/libpthread/sysdeps/l4/pt-thread-start.c
@@ -0,0 +1,92 @@
+/* Start thread. L4 version.
+ Copyright (C) 2002 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 <assert.h>
+#include <errno.h>
+#include <string.h>
+
+#include <pt-internal.h>
+
+#include "task_client.h"
+
+extern L4_ThreadId_t __system_pager;
+extern L4_ThreadId_t __task_server;
+
+#ifndef WORKING_EXREGS
+static void
+send_startup_ipc (L4_ThreadId_t id, L4_Word_t ip, L4_Word_t sp)
+{
+ L4_Msg_t msg;
+
+ printf ("%s: Sending startup message to %x, "
+ "(ip=%x, sp=%x)\n",
+ __FUNCTION__, * (L4_Word_t *) &id, ip, sp);
+
+ L4_Clear (&msg);
+#ifdef HAVE_PROPAGATION
+ L4_Set_VirtualSender (pager_tid);
+ L4_Set_Propagation (&msg.tag);
+#endif
+ L4_Append_Word (&msg, ip);
+ L4_Append_Word (&msg, sp);
+#ifndef HAVE_PROPAGATION
+ L4_Append_Word (&msg, *(L4_Word_t *) &id);
+ id = __system_pager;
+#if 0
+ DODEBUG (2, printf ("%s: Redirecting start request to pager (%x).\n",
+ __FUNCTION__, * (L4_Word_t *) &id));
+#endif
+#endif
+ L4_LoadMsg (&msg);
+ L4_Send (id);
+}
+#endif
+
+/* Start THREAD. Get the kernel thread scheduled and running. */
+int
+__pthread_thread_start (struct __pthread *thread)
+{
+ error_t err;
+
+ /* The main thread is already running of course. */
+ if (__pthread_num_threads == 1)
+ {
+ assert (__pthread_total == 1);
+ assert (thread->thread_id == L4_Myself ());
+ }
+ else
+ {
+ env = idl4_default_environment;
+ err = thread_resume (__task_server,
+ * (L4_Word_t *) &thread->threadid,
+ &env);
+ assert (! err);
+
+#ifndef WORKING_EXREGS
+ L4_AbortIpc_and_stop (thread->threadid);
+ L4_Start_SpIp (thread->threadid, (L4_Word_t) thread->mcontext.sp,
+ (L4_Word_t) thread->mcontext.pc);
+#endif
+ send_startup_ipc (thread->threadid, (L4_Word_t) thread->mcontext.pc,
+ (L4_Word_t) thread->mcontext.sp);
+
+ }
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/l4/pt-wakeup.c b/libpthread/sysdeps/l4/pt-wakeup.c
new file mode 100644
index 00000000..7b00e4f6
--- /dev/null
+++ b/libpthread/sysdeps/l4/pt-wakeup.c
@@ -0,0 +1,29 @@
+/* Wakeup a thread. L4 version.
+ Copyright (C) 2002 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 <l4/l4.h>
+
+#include <pt-internal.h>
+
+/* Wakeup THREAD. */
+void
+__pthread_wakeup (struct __pthread *thread)
+{
+ L4_Send (thread->threadid);
+}
diff --git a/libpthread/sysdeps/mach/CVS/Entries b/libpthread/sysdeps/mach/CVS/Entries
new file mode 100644
index 00000000..910bd7e9
--- /dev/null
+++ b/libpthread/sysdeps/mach/CVS/Entries
@@ -0,0 +1,11 @@
+/pt-block.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-spin.c/1.2/Tue Feb 8 14:42:03 2005//Tzhengda-soc2008-virt-branch
+/pt-stack-alloc.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-thread-alloc.c/1.3/Wed May 4 16:04:06 2005//Tzhengda-soc2008-virt-branch
+/pt-thread-dealloc.c/1.1/Wed May 4 16:04:06 2005//Tzhengda-soc2008-virt-branch
+/pt-thread-halt.c/1.2/Wed May 4 16:04:06 2005//Tzhengda-soc2008-virt-branch
+/pt-thread-start.c/1.2/Mon Nov 18 22:20:58 2002//Tzhengda-soc2008-virt-branch
+/pt-timedblock.c/1.2/Thu May 12 20:55:37 2005//Tzhengda-soc2008-virt-branch
+/pt-wakeup.c/1.2/Mon Nov 18 22:20:58 2002//Tzhengda-soc2008-virt-branch
+D/bits////
+D/hurd////
diff --git a/libpthread/sysdeps/mach/CVS/Repository b/libpthread/sysdeps/mach/CVS/Repository
new file mode 100644
index 00000000..23602bb1
--- /dev/null
+++ b/libpthread/sysdeps/mach/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps/mach
diff --git a/libpthread/sysdeps/mach/CVS/Root b/libpthread/sysdeps/mach/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/mach/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/mach/CVS/Tag b/libpthread/sysdeps/mach/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/mach/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/mach/bits/CVS/Entries b/libpthread/sysdeps/mach/bits/CVS/Entries
new file mode 100644
index 00000000..1488d083
--- /dev/null
+++ b/libpthread/sysdeps/mach/bits/CVS/Entries
@@ -0,0 +1,2 @@
+/spin-lock.h/1.4/Tue Jul 1 11:43:18 2008//Tzhengda-soc2008-virt-branch
+D
diff --git a/libpthread/sysdeps/mach/bits/CVS/Repository b/libpthread/sysdeps/mach/bits/CVS/Repository
new file mode 100644
index 00000000..e78fe18d
--- /dev/null
+++ b/libpthread/sysdeps/mach/bits/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps/mach/bits
diff --git a/libpthread/sysdeps/mach/bits/CVS/Root b/libpthread/sysdeps/mach/bits/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/mach/bits/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/mach/bits/CVS/Tag b/libpthread/sysdeps/mach/bits/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/mach/bits/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/mach/bits/spin-lock.h b/libpthread/sysdeps/mach/bits/spin-lock.h
new file mode 100644
index 00000000..0cbf11ed
--- /dev/null
+++ b/libpthread/sysdeps/mach/bits/spin-lock.h
@@ -0,0 +1,97 @@
+/* Definitions of user-visible names for spin locks.
+ Copyright (C) 1994, 1997, 2002, 2008 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 _BITS_SPIN_LOCK_H
+#define _BITS_SPIN_LOCK_H 1
+
+#include <features.h>
+#include <machine-lock.h> /* This does all the work. */
+
+__BEGIN_DECLS
+
+/* The type of a spin lock object. */
+typedef __spin_lock_t __pthread_spinlock_t;
+
+/* Initializer for a spin lock object. */
+#ifndef __SPIN_LOCK_INITIALIZER
+#error __SPIN_LOCK_INITIALIZER undefined: should be defined by <lock-intern.h>.
+#endif
+
+#if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES
+
+# ifndef __EBUSY
+# include <errno.h>
+# define __EBUSY EBUSY
+# endif
+
+# ifndef __PT_SPIN_INLINE
+# define __PT_SPIN_INLINE __extern_inline
+# endif
+
+__PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock);
+
+__PT_SPIN_INLINE int
+__pthread_spin_destroy (__pthread_spinlock_t *__lock)
+{
+ return 0;
+}
+
+__PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock,
+ int __pshared);
+
+__PT_SPIN_INLINE int
+__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared)
+{
+ *__lock = __SPIN_LOCK_INITIALIZER;
+ return 0;
+}
+
+__PT_SPIN_INLINE int __pthread_spin_trylock (__pthread_spinlock_t *__lock);
+
+__PT_SPIN_INLINE int
+__pthread_spin_trylock (__pthread_spinlock_t *__lock)
+{
+ return __spin_try_lock (__lock) ? 0 : __EBUSY;
+}
+
+__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock);
+extern int _pthread_spin_lock (__pthread_spinlock_t *__lock);
+
+__extern_inline int
+__pthread_spin_lock (__pthread_spinlock_t *__lock)
+{
+ if (__pthread_spin_trylock (__lock))
+ return _pthread_spin_lock (__lock);
+ return 0;
+}
+
+__PT_SPIN_INLINE int __pthread_spin_unlock (__pthread_spinlock_t *__lock);
+
+__PT_SPIN_INLINE int
+__pthread_spin_unlock (__pthread_spinlock_t *__lock)
+{
+ __spin_unlock (__lock);
+ return 0;
+}
+
+#endif /* Use extern inlines or force inlines. */
+
+__END_DECLS
+
+#endif /* bits/spin-lock.h */
diff --git a/libpthread/sysdeps/mach/hurd/CVS/Entries b/libpthread/sysdeps/mach/hurd/CVS/Entries
new file mode 100644
index 00000000..a13e7635
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/CVS/Entries
@@ -0,0 +1,9 @@
+/pt-attr-setstackaddr.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-attr-setstacksize.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-docancel.c/1.3/Tue May 27 18:37:29 2008//Tzhengda-soc2008-virt-branch
+/pt-sigstate-destroy.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-sigstate-init.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-sigstate.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-sysdep.c/1.2/Wed May 4 16:04:05 2005//Tzhengda-soc2008-virt-branch
+/pt-sysdep.h/1.3/Tue Jan 18 10:08:52 2005//Tzhengda-soc2008-virt-branch
+D/i386////
diff --git a/libpthread/sysdeps/mach/hurd/CVS/Repository b/libpthread/sysdeps/mach/hurd/CVS/Repository
new file mode 100644
index 00000000..ad77c6f9
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps/mach/hurd
diff --git a/libpthread/sysdeps/mach/hurd/CVS/Root b/libpthread/sysdeps/mach/hurd/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/mach/hurd/CVS/Tag b/libpthread/sysdeps/mach/hurd/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/mach/hurd/i386/CVS/Entries b/libpthread/sysdeps/mach/hurd/i386/CVS/Entries
new file mode 100644
index 00000000..d153b1d6
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/i386/CVS/Entries
@@ -0,0 +1,3 @@
+/pt-machdep.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/pt-setup.c/1.6/Tue Jul 1 11:43:18 2008//Tzhengda-soc2008-virt-branch
+D
diff --git a/libpthread/sysdeps/mach/hurd/i386/CVS/Repository b/libpthread/sysdeps/mach/hurd/i386/CVS/Repository
new file mode 100644
index 00000000..9a741168
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/i386/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps/mach/hurd/i386
diff --git a/libpthread/sysdeps/mach/hurd/i386/CVS/Root b/libpthread/sysdeps/mach/hurd/i386/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/i386/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/mach/hurd/i386/CVS/Tag b/libpthread/sysdeps/mach/hurd/i386/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/i386/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/mach/hurd/i386/pt-machdep.c b/libpthread/sysdeps/mach/hurd/i386/pt-machdep.c
new file mode 100644
index 00000000..0f6e825e
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/i386/pt-machdep.c
@@ -0,0 +1,83 @@
+/* Machine dependent pthreads code. Hurd/i386 version.
+ Copyright (C) 2000,02 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 <mach.h>
+#include <mach/i386/thread_status.h>
+#include <mach/i386/mach_i386.h>
+#include <mach/mig_errors.h>
+#include <mach/thread_status.h>
+
+#define HURD_TLS_DESC_DECL(desc, tcb) \
+ struct descriptor desc = \
+ { /* low word: */ \
+ 0xffff /* limit 0..15 */ \
+ | (((unsigned int) (tcb)) << 16) /* base 0..15 */ \
+ , /* high word: */ \
+ ((((unsigned int) (tcb)) >> 16) & 0xff) /* base 16..23 */ \
+ | ((0x12 | 0x60 | 0x80) << 8) /* access = ACC_DATA_W|ACC_PL_U|ACC_P */ \
+ | (0xf << 16) /* limit 16..19 */ \
+ | ((4 | 8) << 20) /* granularity = SZ_32|SZ_G */ \
+ | (((unsigned int) (tcb)) & 0xff000000) /* base 24..31 */ \
+ }
+
+int
+__thread_set_pcsptp (thread_t thread,
+ int set_ip, void *ip,
+ int set_sp, void *sp,
+ int set_tp, void *tp)
+{
+ error_t err;
+ struct i386_thread_state state;
+ mach_msg_type_number_t state_count;
+
+ state_count = i386_THREAD_STATE_COUNT;
+
+ err = __thread_get_state (thread, i386_REGS_SEGS_STATE,
+ (thread_state_t) &state, &state_count);
+ if (err)
+ return err;
+
+ if (set_sp)
+ state.uesp = (unsigned int) sp;
+ if (set_ip)
+ state.eip = (unsigned int) ip;
+ if (set_tp) {
+ HURD_TLS_DESC_DECL(desc, tp);
+ int sel;
+
+ asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0));
+ if (__builtin_expect (sel, 0x48) & 4) /* LDT selector */
+ err = __i386_set_ldt (thread, sel, &desc, 1);
+ else
+ err = __i386_set_gdt (thread, &sel, desc);
+ if (err)
+ return err;
+ state.gs = sel;
+ }
+
+ err = __thread_set_state (thread, i386_REGS_SEGS_STATE,
+ (thread_state_t) &state,
+ i386_THREAD_STATE_COUNT);
+ if (err)
+ return err;
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/mach/hurd/i386/pt-setup.c b/libpthread/sysdeps/mach/hurd/i386/pt-setup.c
new file mode 100644
index 00000000..dc275e94
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/i386/pt-setup.c
@@ -0,0 +1,108 @@
+/* Setup thread stack. Hurd/i386 version.
+ Copyright (C) 2000, 2002, 2005, 2008 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 <stdint.h>
+#include <assert.h>
+#include <mach.h>
+
+#include <pt-internal.h>
+
+/* The stack layout used on the i386 is:
+
+ -----------------
+ | ARG |
+ -----------------
+ | START_ROUTINE |
+ -----------------
+ | 0 |
+ -----------------
+ | |
+ | Fast TSD |
+ | |
+ -----------------
+
+ We need to reserve __hurd_threadvar_max `unsigned long int's' of
+ (fast) thread-specific data (TSD) for the Hurd. */
+
+/* Set up the stack for THREAD, such that it appears as if
+ START_ROUTINE and ARG were passed to the new thread's entry-point.
+ Return the stack pointer for the new thread. */
+static void *
+stack_setup (struct __pthread *thread,
+ void *(*start_routine)(void *), void *arg)
+{
+ error_t err;
+ uintptr_t *bottom, *top;
+
+ /* Calculate the top of the new stack. */
+ bottom = thread->stackaddr;
+ top = (uintptr_t *) ((uintptr_t) bottom + thread->stacksize);
+
+ /* Next, make room for the TSDs. */
+ top -= __hurd_threadvar_max;
+
+ /* Save the self pointer. */
+ top[_HURD_THREADVAR_THREAD] = (void *) thread;
+
+ if (start_routine)
+ {
+ /* And then the call frame. */
+ top -= 2*sizeof(uintptr_t);
+ top = (uintptr_t) top & ~0xf;
+ top[1] = (uintptr_t) arg; /* Argument to START_ROUTINE. */
+ top[0] = (uintptr_t) start_routine;
+ *--top = 0; /* Fake return address. */
+ }
+
+ if (thread->guardsize)
+ {
+ err = __vm_protect (__mach_task_self (), (vm_address_t) bottom,
+ thread->guardsize, 0, 0);
+ assert_perror (err);
+ }
+
+ return top;
+}
+
+int
+__pthread_setup (struct __pthread *thread,
+ void (*entry_point)(void *(*)(void *), void *),
+ void *(*start_routine)(void *), void *arg)
+{
+ error_t err;
+ mach_port_t ktid;
+
+ thread->mcontext.pc = entry_point;
+ thread->mcontext.sp = stack_setup (thread, start_routine, arg);
+
+ thread->tcb->self = thread->kernel_thread;
+
+ ktid = __mach_thread_self ();
+ if (thread->kernel_thread != ktid)
+ {
+ err = __thread_set_pcsptp (thread->kernel_thread,
+ 1, thread->mcontext.pc,
+ 1, thread->mcontext.sp,
+ 1, thread->tcb);
+ assert_perror (err);
+ }
+ __mach_port_deallocate (__mach_task_self (), ktid);
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/mach/hurd/i386/pt-setup.c.orig b/libpthread/sysdeps/mach/hurd/i386/pt-setup.c.orig
new file mode 100644
index 00000000..5abbcfcd
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/i386/pt-setup.c.orig
@@ -0,0 +1,105 @@
+/* Setup thread stack. Hurd/i386 version.
+ Copyright (C) 2000, 2002, 2005, 2008 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 <stdint.h>
+#include <assert.h>
+#include <mach.h>
+
+#include <pt-internal.h>
+
+/* The stack layout used on the i386 is:
+
+ -----------------
+ | ARG |
+ -----------------
+ | START_ROUTINE |
+ -----------------
+ | 0 |
+ -----------------
+ | |
+ | Fast TSD |
+ | |
+ -----------------
+
+ We need to reserve __hurd_threadvar_max `unsigned long int's' of
+ (fast) thread-specific data (TSD) for the Hurd. */
+
+/* Set up the stack for THREAD, such that it appears as if
+ START_ROUTINE and ARG were passed to the new thread's entry-point.
+ Return the stack pointer for the new thread. */
+static void *
+stack_setup (struct __pthread *thread,
+ void *(*start_routine)(void *), void *arg)
+{
+ error_t err;
+ uintptr_t *bottom, *top;
+
+ /* Calculate the top of the new stack. */
+ bottom = thread->stackaddr;
+ top = (uintptr_t *) ((uintptr_t) bottom + thread->stacksize);
+
+ /* Next, make room for the TSDs. */
+ top -= __hurd_threadvar_max;
+
+ /* Save the self pointer. */
+ top[_HURD_THREADVAR_THREAD] = (void *) thread;
+
+ if (start_routine)
+ {
+ /* And then the call frame. */
+ top -= 2*sizeof(uintptr_t);
+ top = (uintptr_t) top & ~0xf;
+ top[1] = (uintptr_t) arg; /* Argument to START_ROUTINE. */
+ top[0] = (uintptr_t) start_routine;
+ *--top = 0; /* Fake return address. */
+ }
+
+ if (thread->guardsize)
+ {
+ err = __vm_protect (__mach_task_self (), (vm_address_t) bottom,
+ thread->guardsize, 0, 0);
+ assert_perror (err);
+ }
+
+ return top;
+}
+
+int
+__pthread_setup (struct __pthread *thread,
+ void (*entry_point)(void *(*)(void *), void *),
+ void *(*start_routine)(void *), void *arg)
+{
+ error_t err;
+ mach_port_t ktid;
+
+ thread->mcontext.pc = entry_point;
+ thread->mcontext.sp = stack_setup (thread, start_routine, arg);
+
+ ktid = __mach_thread_self ();
+ if (thread->kernel_thread != ktid)
+ {
+ err = __thread_set_pcsp (thread->kernel_thread,
+ 1, thread->mcontext.pc,
+ 1, thread->mcontext.sp);
+ assert_perror (err);
+ }
+ __mach_port_deallocate (__mach_task_self (), ktid);
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/mach/hurd/pt-attr-setstackaddr.c b/libpthread/sysdeps/mach/hurd/pt-attr-setstackaddr.c
new file mode 100644
index 00000000..1225ed5b
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-attr-setstackaddr.c
@@ -0,0 +1,35 @@
+/* pthread_attr_setstackaddr. Hurd on Mach version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+/* We use fixed sized stacks which require proper alignment. */
+#define __pthread_stacksize __pthread_default_attr.stacksize
+
+int
+pthread_attr_setstackaddr (pthread_attr_t *attr,
+ void *stackaddr)
+{
+ if ((long) stackaddr & (__pthread_stacksize - 1))
+ return EINVAL;
+
+ attr->stackaddr = stackaddr;
+ return 0;
+}
diff --git a/libpthread/sysdeps/mach/hurd/pt-attr-setstacksize.c b/libpthread/sysdeps/mach/hurd/pt-attr-setstacksize.c
new file mode 100644
index 00000000..6471c0a3
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-attr-setstacksize.c
@@ -0,0 +1,35 @@
+/* pthread_attr_setstacksize. Hurd on Mach version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <pt-internal.h>
+
+/* We use fixed sized stacks which require proper alignment. */
+#define __pthread_stacksize __pthread_default_attr.stacksize
+
+int
+pthread_attr_setstacksize (pthread_attr_t *attr,
+ size_t stacksize)
+{
+ if (stacksize != __pthread_stacksize)
+ return EINVAL;
+
+ attr->stacksize = stacksize;
+ return 0;
+}
diff --git a/libpthread/sysdeps/mach/hurd/pt-docancel.c b/libpthread/sysdeps/mach/hurd/pt-docancel.c
new file mode 100644
index 00000000..b3d31a56
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-docancel.c
@@ -0,0 +1,64 @@
+/* Cancel a thread.
+ Copyright (C) 2002, 2008 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 <pthread.h>
+
+#include <pt-internal.h>
+
+static void
+call_exit (void)
+{
+ pthread_exit (0);
+}
+
+int
+__pthread_do_cancel (struct __pthread *p)
+{
+ mach_port_t ktid;
+ int me;
+
+ assert (p->cancel_pending == 1);
+ assert (p->cancel_state == PTHREAD_CANCEL_ENABLE);
+
+ ktid = __mach_thread_self ();
+ me = p->kernel_thread == ktid;
+ __mach_port_deallocate (__mach_task_self (), ktid);
+
+ if (me)
+ call_exit ();
+ else
+ {
+ error_t err;
+
+ err = __thread_suspend (p->kernel_thread);
+ assert_perror (err);
+
+ err = __thread_abort (p->kernel_thread);
+ assert_perror (err);
+
+ err = __thread_set_pcsptp (p->kernel_thread,
+ 1, (void *) call_exit, 0, 0, 0, 0);
+ assert_perror (err);
+
+ err = __thread_resume (p->kernel_thread);
+ assert_perror (err);
+ }
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/mach/hurd/pt-sigstate-destroy.c b/libpthread/sysdeps/mach/hurd/pt-sigstate-destroy.c
new file mode 100644
index 00000000..8e56c5cf
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-sigstate-destroy.c
@@ -0,0 +1,28 @@
+/* Destroy the signal state. Hurd on Mach version.
+ Copyright (C) 2002 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 <pthread.h>
+
+#include <pt-internal.h>
+
+void
+__pthread_sigstate_destroy (struct __pthread *thread)
+{
+ /* Nothing to do. */
+}
diff --git a/libpthread/sysdeps/mach/hurd/pt-sigstate-init.c b/libpthread/sysdeps/mach/hurd/pt-sigstate-init.c
new file mode 100644
index 00000000..da5a9455
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-sigstate-init.c
@@ -0,0 +1,37 @@
+/* Initialize the signal state. Hurd on Mach version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <hurd/threadvar.h>
+
+#include <pt-internal.h>
+
+error_t
+__pthread_sigstate_init (struct __pthread *thread)
+{
+ void **location =
+ (void *) __hurd_threadvar_location_from_sp (_HURD_THREADVAR_SIGSTATE,
+ thread->stackaddr);
+
+ /* The real initialization happens internally in glibc the first
+ time that _hurd_thead_sigstate is called. */
+ *location = 0;
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/mach/hurd/pt-sigstate.c b/libpthread/sysdeps/mach/hurd/pt-sigstate.c
new file mode 100644
index 00000000..68c79c5b
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-sigstate.c
@@ -0,0 +1,69 @@
+/* Set a thread's signal state. Hurd on Mach version.
+ Copyright (C) 2002 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 <pthread.h>
+#include <assert.h>
+#include <signal.h>
+#include <hurd/signal.h>
+
+#include <pt-internal.h>
+
+error_t
+__pthread_sigstate (struct __pthread *thread, int how,
+ const sigset_t *set, sigset_t *oset,
+ int clear_pending)
+{
+ error_t err = 0;
+ struct hurd_sigstate *ss;
+
+ ss = _hurd_thread_sigstate (thread->kernel_thread);
+ assert (ss);
+
+ __pthread_spin_lock (&ss->lock);
+
+ if (oset)
+ *oset = ss->blocked;
+
+ if (set)
+ switch (how)
+ {
+ case SIG_BLOCK:
+ ss->blocked |= *set;
+ break;
+
+ case SIG_SETMASK:
+ ss->blocked = *set;
+ break;
+
+ case SIG_UNBLOCK:
+ ss->blocked &= ~*set;
+ break;
+
+ default:
+ err = EINVAL;
+ break;
+ }
+
+ if (! err && clear_pending)
+ __sigemptyset (&ss->pending);
+
+ __pthread_spin_unlock (&ss->lock);
+
+ return err;
+}
diff --git a/libpthread/sysdeps/mach/hurd/pt-sysdep.c b/libpthread/sysdeps/mach/hurd/pt-sysdep.c
new file mode 100644
index 00000000..5e070067
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-sysdep.c
@@ -0,0 +1,72 @@
+/* System dependent pthreads code. Hurd version.
+ Copyright (C) 2000, 2002, 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
+ 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 <assert.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include <mach.h>
+#include <mach/mig_support.h>
+
+#include <hurd/threadvar.h>
+
+#include <pt-internal.h>
+
+/* Forward. */
+static void *init_routine (void);
+
+/* OK, the name of this variable isn't really appropriate, but I don't
+ want to change it yet. */
+void *(*_cthread_init_routine)(void) = &init_routine;
+
+/* This function is called from the Hurd-specific startup code. It
+ should return a new stack pointer for the main thread. The caller
+ will switch to this new stack before doing anything serious. */
+static void *
+init_routine (void)
+{
+ struct __pthread *thread;
+ int err;
+
+ /* Initialize the library. */
+ __pthread_initialize ();
+
+ /* Create the pthread structure for the main thread (i.e. us). */
+ err = __pthread_create_internal (&thread, 0, 0, 0);
+ assert_perror (err);
+
+ ((void **) (__hurd_threadvar_stack_offset))[_HURD_THREADVAR_THREAD]
+ = thread;
+
+ /* Decrease the number of threads, to take into account that the
+ signal thread (which will be created by the glibc startup code
+ when we return from here) shouldn't be seen as a user thread. */
+ __pthread_total--;
+
+ /* Make MiG code thread aware. */
+ __mig_init (thread->stackaddr);
+
+ /* Make sure we can find the per-thread variables. */
+ __hurd_threadvar_stack_mask = ~(__pthread_default_attr.stacksize - 1);
+ __hurd_threadvar_stack_offset
+ = (__pthread_default_attr.stacksize
+ - __hurd_threadvar_max * sizeof (uintptr_t));
+
+ return thread->mcontext.sp;
+}
diff --git a/libpthread/sysdeps/mach/hurd/pt-sysdep.h b/libpthread/sysdeps/mach/hurd/pt-sysdep.h
new file mode 100644
index 00000000..f17d14e1
--- /dev/null
+++ b/libpthread/sysdeps/mach/hurd/pt-sysdep.h
@@ -0,0 +1,71 @@
+/* Internal defenitions for pthreads library.
+ Copyright (C) 2000, 2002 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. */
+
+#ifndef _PT_SYSDEP_H
+#define _PT_SYSDEP_H 1
+
+#include <mach.h>
+
+#include <hurd/threadvar.h>
+
+/* XXX */
+#define _POSIX_THREAD_THREADS_MAX 64
+
+/* The default stack size. */
+#define PTHREAD_STACK_DEFAULT (2 * 1024 * 1024)
+
+#define PTHREAD_SYSDEP_MEMBERS \
+ thread_t kernel_thread; \
+ mach_msg_header_t wakeupmsg;
+
+#define _HURD_THREADVAR_THREAD _HURD_THREADVAR_DYNAMIC_USER
+
+#define _pthread_self() \
+ ({ \
+ struct __pthread *thread; \
+ \
+ assert (__pthread_threads); \
+ thread = *(struct __pthread **) \
+ __hurd_threadvar_location (_HURD_THREADVAR_THREAD); \
+ \
+ assert (thread); \
+ assert (({ mach_port_t ktid = __mach_thread_self (); \
+ int ok = thread->kernel_thread == ktid; \
+ __mach_port_deallocate (__mach_task_self (), ktid);\
+ ok; })); \
+ thread; \
+ })
+
+extern inline void
+__attribute__((__always_inline__))
+__pthread_stack_dealloc (void *stackaddr, size_t stacksize)
+{
+ __vm_deallocate (__mach_task_self (), (vm_offset_t) stackaddr, stacksize);
+}
+
+/* Change thread THREAD's program counter to PC if SET_PC is true,
+ its stack pointer to SP if SET_IP is true, and its thread pointer
+ to TP if SET_TP is true. */
+extern int __thread_set_pcsptp (thread_t thread,
+ int set_pc, void *pc,
+ int set_sp, void *sp,
+ int set_tp, void *tp);
+
+
+#endif /* pt-sysdep.h */
diff --git a/libpthread/sysdeps/mach/pt-block.c b/libpthread/sysdeps/mach/pt-block.c
new file mode 100644
index 00000000..a947b27c
--- /dev/null
+++ b/libpthread/sysdeps/mach/pt-block.c
@@ -0,0 +1,39 @@
+/* Block a thread. Mach version.
+ Copyright (C) 2000 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 <assert.h>
+#include <errno.h>
+
+#include <mach.h>
+#include <mach/message.h>
+
+#include <pt-internal.h>
+
+/* Block THREAD. */
+void
+__pthread_block (struct __pthread *thread)
+{
+ mach_msg_header_t msg;
+ error_t err;
+
+ err = __mach_msg (&msg, MACH_RCV_MSG, 0, sizeof msg,
+ thread->wakeupmsg.msgh_remote_port,
+ MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
+ assert_perror (err);
+}
diff --git a/libpthread/sysdeps/mach/pt-spin.c b/libpthread/sysdeps/mach/pt-spin.c
new file mode 100644
index 00000000..d9a2a32a
--- /dev/null
+++ b/libpthread/sysdeps/mach/pt-spin.c
@@ -0,0 +1,36 @@
+/* Spin locks. Mach version.
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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 <pthread.h>
+#include <machine-lock.h>
+
+/* In glibc. */
+extern void __spin_lock_solid (__pthread_spinlock_t *lock);
+
+/* Lock the spin lock object LOCK. If the lock is held by another
+ thread spin until it becomes available. */
+int
+_pthread_spin_lock (__pthread_spinlock_t *lock)
+{
+ __spin_lock_solid (lock);
+ return 0;
+}
+
+weak_alias (_pthread_spin_lock, pthread_spin_lock);
+weak_alias (_pthread_spin_lock, __pthread_spin_lock);
diff --git a/libpthread/sysdeps/mach/pt-stack-alloc.c b/libpthread/sysdeps/mach/pt-stack-alloc.c
new file mode 100644
index 00000000..0956fc7d
--- /dev/null
+++ b/libpthread/sysdeps/mach/pt-stack-alloc.c
@@ -0,0 +1,74 @@
+/* Allocate a new stack. Mach version.
+ Copyright (C) 2000,02 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 <mach.h>
+#include <mach/machine/vm_param.h>
+
+#include <pt-internal.h>
+
+#define __pthread_stacksize __pthread_default_attr.stacksize
+
+/* The next address to use for stack allocation. */
+static vm_address_t next_stack_base = VM_MIN_ADDRESS;
+
+
+/* Allocate a new stack of size STACKSIZE. If successful, store the
+ address of the newly allocated stack in *STACKADDR and return 0.
+ Otherwise return an error code (EINVAL for an invalid stack size,
+ EAGAIN if the system lacked the necessary resources to allocate a
+ new stack). */
+int
+__pthread_stack_alloc (void **stackaddr, size_t stacksize)
+{
+ vm_offset_t base;
+ int i = 0;
+
+ if (stacksize != __pthread_stacksize)
+ return EINVAL;
+
+ get_stack:
+ i ++;
+ for (base = next_stack_base;
+ base < VM_MAX_ADDRESS
+ && __vm_allocate (__mach_task_self (), &base,
+ __pthread_stacksize, FALSE) != KERN_SUCCESS;
+ base += __pthread_stacksize)
+ ;
+
+ if (base >= VM_MAX_ADDRESS)
+ {
+ if (i == 1)
+ {
+ next_stack_base = VM_MIN_ADDRESS;
+ goto get_stack;
+ }
+ else
+ return EAGAIN;
+ }
+
+ if (base >= VM_MAX_ADDRESS)
+ return EAGAIN;
+
+ next_stack_base = base + __pthread_stacksize;
+
+ (*stackaddr) = (void *) base;
+ return 0;
+}
diff --git a/libpthread/sysdeps/mach/pt-thread-alloc.c b/libpthread/sysdeps/mach/pt-thread-alloc.c
new file mode 100644
index 00000000..1acba98a
--- /dev/null
+++ b/libpthread/sysdeps/mach/pt-thread-alloc.c
@@ -0,0 +1,101 @@
+/* Start thread. Mach version.
+ Copyright (C) 2000, 2002, 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
+ 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 <assert.h>
+#include <errno.h>
+#include <string.h>
+
+#include <mach.h>
+
+#include <pt-internal.h>
+
+/* Prepare a wakeup message. */
+static error_t
+create_wakeupmsg (struct __pthread *thread)
+{
+ kern_return_t err;
+
+ /* Build wakeup message. */
+ thread->wakeupmsg.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_COPY_SEND, 0);
+ thread->wakeupmsg.msgh_size = 0;
+
+ err = __mach_port_allocate (__mach_task_self (), MACH_PORT_RIGHT_RECEIVE,
+ &thread->wakeupmsg.msgh_remote_port);
+ if (err)
+ return EAGAIN;
+
+ thread->wakeupmsg.msgh_local_port = MACH_PORT_NULL;
+ thread->wakeupmsg.msgh_seqno = 0;
+ thread->wakeupmsg.msgh_id = 0;
+
+ err = __mach_port_insert_right (__mach_task_self (),
+ thread->wakeupmsg.msgh_remote_port,
+ thread->wakeupmsg.msgh_remote_port,
+ MACH_MSG_TYPE_MAKE_SEND);
+ if (err)
+ {
+ __mach_port_destroy (__mach_task_self (),
+ thread->wakeupmsg.msgh_remote_port);
+ return EAGAIN;
+ }
+
+ return 0;
+}
+
+/* Allocate any resouces for THREAD. The new kernel thread should not
+ be eligible to be scheduled. */
+int
+__pthread_thread_alloc (struct __pthread *thread)
+{
+ error_t err;
+
+ err = create_wakeupmsg (thread);
+ if (err)
+ return err;
+
+ /* If there are no pthreads in the system then the pthread library
+ is bootstrapping and the main thread must create initialize
+ itself. The thread itself is already running, it just has not
+ pthread context. We want to reuse what it already has (including
+ the kernel thread), however, we must determine which thread is
+ the main thread.
+
+ We cannot test if __pthread_total is one as we later decrement
+ before creating the signal thread. Currently, we check if
+ __pthread_num_threads--the number of allocated thread
+ structures--is one. __pthread_alloc has already been called in
+ __pthread_create_internal for us. This predicate could be improved,
+ however, it is sufficient for now. */
+ if (__pthread_num_threads == 1)
+ {
+ assert (__pthread_total == 0);
+ thread->kernel_thread = __mach_thread_self ();
+ /* We implicitly hold a reference drop the one that we just
+ acquired. */
+ __mach_port_deallocate (__mach_task_self (), thread->kernel_thread);
+ }
+ else
+ {
+ err = __thread_create (__mach_task_self (), &thread->kernel_thread);
+ if (err)
+ return EAGAIN;
+ }
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/mach/pt-thread-dealloc.c b/libpthread/sysdeps/mach/pt-thread-dealloc.c
new file mode 100644
index 00000000..55d8c4d5
--- /dev/null
+++ b/libpthread/sysdeps/mach/pt-thread-dealloc.c
@@ -0,0 +1,41 @@
+/* Deallocate the kernel thread resources. Mach version.
+ Copyright (C) 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
+ 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 <assert.h>
+#include <errno.h>
+#include <mach.h>
+
+#include <pt-internal.h>
+
+/* Deallocate any kernel resources associated with THREAD except don't
+ halt the thread itself. On return, the thread will be marked as
+ dead and __pthread_halt will be called. */
+void
+__pthread_thread_dealloc (struct __pthread *thread)
+{
+ /* Why no assert? Easy. When Mach kills a task, it starts by
+ invalidating the task port and then terminating the threads one
+ by one. But while it is terminating them, they are still
+ eligible to be scheduled. Imagine we have two threads, one calls
+ exit, one calls pthread_exit. The second one may run this after
+ the mask port can been destroyed thus gratuitously triggering the
+ assert. */
+ __mach_port_destroy (__mach_task_self (),
+ thread->wakeupmsg.msgh_remote_port);
+}
diff --git a/libpthread/sysdeps/mach/pt-thread-halt.c b/libpthread/sysdeps/mach/pt-thread-halt.c
new file mode 100644
index 00000000..9f860247
--- /dev/null
+++ b/libpthread/sysdeps/mach/pt-thread-halt.c
@@ -0,0 +1,43 @@
+/* Deallocate the kernel thread resources. Mach version.
+ Copyright (C) 2000, 2002, 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
+ 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 <assert.h>
+#include <errno.h>
+#include <mach.h>
+
+#include <pt-internal.h>
+
+/* Stop the kernel thread associated with THREAD. If NEED_DEALLOC is
+ true, the function must call __pthread_dealloc on THREAD.
+
+ NB: The thread executing this function may be the thread which is
+ being halted, thus the last action should be halting the thread
+ itself. */
+void
+__pthread_thread_halt (struct __pthread *thread, int need_dealloc)
+{
+ error_t err;
+ thread_t tid = thread->kernel_thread;
+
+ if (need_dealloc)
+ __pthread_dealloc (thread);
+
+ err = __thread_terminate (tid);
+ assert_perror (err);
+}
diff --git a/libpthread/sysdeps/mach/pt-thread-start.c b/libpthread/sysdeps/mach/pt-thread-start.c
new file mode 100644
index 00000000..11b017ff
--- /dev/null
+++ b/libpthread/sysdeps/mach/pt-thread-start.c
@@ -0,0 +1,49 @@
+/* Start thread. Mach version.
+ Copyright (C) 2000,02 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 <assert.h>
+#include <errno.h>
+#include <mach.h>
+
+#include <pt-internal.h>
+
+/* Start THREAD. Get the kernel thread scheduled and running. */
+int
+__pthread_thread_start (struct __pthread *thread)
+{
+ error_t err;
+
+ if (__pthread_num_threads == 1)
+ {
+ /* The main thread is already running: do nothing. */
+ assert (__pthread_total == 1);
+ assert (({ mach_port_t ktid = __mach_thread_self ();
+ int ok = thread->kernel_thread == ktid;
+ __mach_port_deallocate (__mach_task_self (),
+ thread->kernel_thread);
+ ok; }));
+ }
+ else
+ {
+ err = __thread_resume (thread->kernel_thread);
+ assert_perror (err);
+ }
+
+ return 0;
+}
diff --git a/libpthread/sysdeps/mach/pt-timedblock.c b/libpthread/sysdeps/mach/pt-timedblock.c
new file mode 100644
index 00000000..ddb8baec
--- /dev/null
+++ b/libpthread/sysdeps/mach/pt-timedblock.c
@@ -0,0 +1,68 @@
+/* Block a thread with a timeout. Mach version.
+ Copyright (C) 2000, 2002, 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
+ 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 <assert.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/time.h>
+
+#include <mach.h>
+#include <mach/message.h>
+
+#include <pt-internal.h>
+
+/* Block THREAD. */
+error_t
+__pthread_timedblock (struct __pthread *thread,
+ const struct timespec *abstime)
+{
+ error_t err;
+ mach_msg_header_t msg;
+ mach_msg_timeout_t timeout;
+ struct timeval now;
+
+ /* We have an absolute time and now we have to convert it to a
+ relative time. Arg. */
+
+ err = gettimeofday(&now, NULL);
+ assert (! err);
+
+ if (now.tv_sec > abstime->tv_sec
+ || (now.tv_sec == abstime->tv_sec
+ && now.tv_usec > ((abstime->tv_nsec + 999) / 1000)))
+ return ETIMEDOUT;
+
+ timeout = (abstime->tv_sec - now.tv_sec) * 1000;
+
+ if (((abstime->tv_nsec + 999) / 1000) >= now.tv_usec)
+ timeout -= (((abstime->tv_nsec + 999) / 1000) - now.tv_usec + 999) / 1000;
+ else
+ /* Need to do a carry. */
+ timeout -= 1000 + ((abstime->tv_nsec + 999999) / 1000000)
+ - (now.tv_usec + 999) / 1000;
+
+ err = __mach_msg (&msg, MACH_RCV_MSG | MACH_RCV_TIMEOUT, 0,
+ sizeof msg, thread->wakeupmsg.msgh_remote_port,
+ timeout, MACH_PORT_NULL);
+ if (err == EMACH_RCV_TIMED_OUT)
+ return ETIMEDOUT;
+
+ assert_perror (err);
+ return 0;
+}
diff --git a/libpthread/sysdeps/mach/pt-wakeup.c b/libpthread/sysdeps/mach/pt-wakeup.c
new file mode 100644
index 00000000..4920d102
--- /dev/null
+++ b/libpthread/sysdeps/mach/pt-wakeup.c
@@ -0,0 +1,38 @@
+/* Wakeup a thread. Mach version.
+ Copyright (C) 2000, 2002 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 <assert.h>
+#include <errno.h>
+
+#include <mach.h>
+#include <mach/message.h>
+
+#include <pt-internal.h>
+
+/* Wakeup THREAD. */
+void
+__pthread_wakeup (struct __pthread *thread)
+{
+ error_t err;
+
+ err = __mach_msg (&thread->wakeupmsg, MACH_SEND_MSG,
+ sizeof (thread->wakeupmsg), 0, MACH_PORT_NULL,
+ MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
+ assert_perror (err);
+}
diff --git a/libpthread/sysdeps/posix/CVS/Entries b/libpthread/sysdeps/posix/CVS/Entries
new file mode 100644
index 00000000..efbdeea5
--- /dev/null
+++ b/libpthread/sysdeps/posix/CVS/Entries
@@ -0,0 +1,2 @@
+/pt-spin.c/1.2/Tue Feb 8 14:42:02 2005//Tzhengda-soc2008-virt-branch
+D
diff --git a/libpthread/sysdeps/posix/CVS/Repository b/libpthread/sysdeps/posix/CVS/Repository
new file mode 100644
index 00000000..9f063683
--- /dev/null
+++ b/libpthread/sysdeps/posix/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/sysdeps/posix
diff --git a/libpthread/sysdeps/posix/CVS/Root b/libpthread/sysdeps/posix/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/sysdeps/posix/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/sysdeps/posix/CVS/Tag b/libpthread/sysdeps/posix/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/sysdeps/posix/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/sysdeps/posix/pt-spin.c b/libpthread/sysdeps/posix/pt-spin.c
new file mode 100644
index 00000000..486030de
--- /dev/null
+++ b/libpthread/sysdeps/posix/pt-spin.c
@@ -0,0 +1,54 @@
+/* Spin locks.
+ Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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 <pthread.h>
+#include <sched.h>
+
+/* The default for single processor machines; don't spin, it's
+ pointless. */
+#ifndef __PTHREAD_SPIN_COUNT
+# define __PTHREAD_SPIN_COUNT 1
+#endif
+
+/* The number of times to spin while trying to lock a spin lock object
+ before yielding the processor. */
+int __pthread_spin_count = __PTHREAD_SPIN_COUNT;
+
+
+/* Lock the spin lock object LOCK. If the lock is held by another
+ thread spin until it becomes available. */
+int
+_pthread_spin_lock (__pthread_spinlock_t *lock)
+{
+ int i;
+
+ while (1)
+ {
+ for (i = 0; i < __pthread_spin_count; i++)
+ {
+ if (__pthread_spin_trylock (lock) == 0)
+ return 0;
+ }
+
+ __sched_yield ();
+ }
+}
+
+weak_alias (_pthread_spin_lock, pthread_spin_lock);
+weak_alias (_pthread_spin_lock, __pthread_spin_lock);
diff --git a/libpthread/tests/.cvsignore b/libpthread/tests/.cvsignore
new file mode 100644
index 00000000..70845e08
--- /dev/null
+++ b/libpthread/tests/.cvsignore
@@ -0,0 +1 @@
+Makefile.in
diff --git a/libpthread/tests/CVS/Entries b/libpthread/tests/CVS/Entries
new file mode 100644
index 00000000..f974a145
--- /dev/null
+++ b/libpthread/tests/CVS/Entries
@@ -0,0 +1,19 @@
+/.cvsignore/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/Makefile/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/test-1.c/1.2/Thu May 12 20:55:36 2005//Tzhengda-soc2008-virt-branch
+/test-10.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/test-11.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/test-12.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/test-13.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/test-14.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/test-15.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/test-16.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/test-2.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/test-3.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/test-4.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/test-5.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/test-6.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/test-7.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/test-8.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+/test-9.c/1.1/Thu Oct 10 23:05:05 2002//Tzhengda-soc2008-virt-branch
+D
diff --git a/libpthread/tests/CVS/Repository b/libpthread/tests/CVS/Repository
new file mode 100644
index 00000000..3135a927
--- /dev/null
+++ b/libpthread/tests/CVS/Repository
@@ -0,0 +1 @@
+hurd/libpthread/tests
diff --git a/libpthread/tests/CVS/Root b/libpthread/tests/CVS/Root
new file mode 100644
index 00000000..a10aa66d
--- /dev/null
+++ b/libpthread/tests/CVS/Root
@@ -0,0 +1 @@
+:ext:zhengda@cvs.savannah.gnu.org:/sources/hurd
diff --git a/libpthread/tests/CVS/Tag b/libpthread/tests/CVS/Tag
new file mode 100644
index 00000000..7e454c6d
--- /dev/null
+++ b/libpthread/tests/CVS/Tag
@@ -0,0 +1 @@
+Tzhengda-soc2008-virt-branch
diff --git a/libpthread/tests/Makefile b/libpthread/tests/Makefile
new file mode 100644
index 00000000..9509c957
--- /dev/null
+++ b/libpthread/tests/Makefile
@@ -0,0 +1,29 @@
+CFLAGS=-Wall -g
+
+LDLIBS = -lpthread
+
+CHECK_SRC := test-1.c test-2.c test-3.c test-6.c test-7.c test-8.c \
+ test-9.c test-10.c test-11.c test-12.c test-13.c test-14.c \
+ test-15.c test-16.c
+
+CHECK_OBJS := $(addsuffix .o,$(basename $(notdir $(CHECK_SRC))))
+CHECK_PROGS := $(basename $(notdir $(CHECK_SRC))) \
+ $(addsuffix -static, $(basename $(CHECK_SRC)))
+
+%-static: %.o
+ $(CC) -static $(CFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS)
+
+check: $(CHECK_OBJS) $(CHECK_PROGS)
+ for i in $(CHECK_PROGS); do \
+ echo -n Running $$i...\ ; \
+ if ./$$i 2>&1 > $$i.out; \
+ then \
+ echo Success.; \
+ else \
+ echo Failure.; \
+ fi \
+ done
+
+clean:
+ rm -f $(CHECK_OBJS) $(CHECK_PROGS) \
+ $(addsuffix .out,$(basename $(notdir $(CHECK_PROGS)))) \ No newline at end of file
diff --git a/libpthread/tests/test-1.c b/libpthread/tests/test-1.c
new file mode 100644
index 00000000..318fd6e9
--- /dev/null
+++ b/libpthread/tests/test-1.c
@@ -0,0 +1,49 @@
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <unistd.h>
+#include <error.h>
+#include <errno.h>
+#include <stdio.h>
+
+#define THREADS 500
+
+void *
+foo (void *arg)
+{
+ pthread_mutex_t *mutex = arg;
+ pthread_mutex_lock (mutex);
+ pthread_mutex_unlock (mutex);
+ return mutex;
+}
+
+int
+main (int argc, char **argv)
+{
+ int i;
+ error_t err;
+ pthread_t tid[THREADS];
+ pthread_mutex_t mutex[THREADS];
+
+ for (i = 0; i < THREADS; i ++)
+ {
+ pthread_mutex_init (&mutex[i], 0);
+ pthread_mutex_lock (&mutex[i]);
+ err = pthread_create (&tid[i], 0, foo, &mutex[i]);
+ if (err)
+ error (1, err, "pthread_create");
+ sched_yield ();
+ }
+
+ for (i = THREADS - 1; i >= 0; i --)
+ {
+ void *ret;
+ pthread_mutex_unlock (&mutex[i]);
+ err = pthread_join (tid[i], &ret);
+ if (err)
+ error (1, err, "pthread_join");
+ assert (ret == &mutex[i]);
+ }
+
+ return 0;
+}
diff --git a/libpthread/tests/test-10.c b/libpthread/tests/test-10.c
new file mode 100644
index 00000000..bec05c14
--- /dev/null
+++ b/libpthread/tests/test-10.c
@@ -0,0 +1,46 @@
+/* Test error checking mutexes. */
+
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <assert.h>
+#include <error.h>
+#include <errno.h>
+
+int
+main (int argc, char **argv)
+{
+ error_t err;
+ pthread_mutexattr_t mattr;
+ pthread_mutex_t mutex;
+
+ err = pthread_mutexattr_init (&mattr);
+ if (err)
+ error (1, err, "pthread_mutexattr_init");
+
+ err = pthread_mutexattr_settype (&mattr, PTHREAD_MUTEX_ERRORCHECK);
+ if (err)
+ error (1, err, "pthread_mutexattr_settype");
+
+ err = pthread_mutex_init (&mutex, &mattr);
+ if (err)
+ error (1, err, "pthread_mutex_init");
+
+ err = pthread_mutexattr_destroy (&mattr);
+ if (err)
+ error (1, err, "pthread_mutexattr_destroy");
+
+ err = pthread_mutex_lock (&mutex);
+ assert (err == 0);
+
+ err = pthread_mutex_lock (&mutex);
+ assert (err == EDEADLK);
+
+ err = pthread_mutex_unlock (&mutex);
+ assert (err == 0);
+
+ err = pthread_mutex_unlock (&mutex);
+ assert (err == EPERM);
+
+ return 0;
+}
diff --git a/libpthread/tests/test-11.c b/libpthread/tests/test-11.c
new file mode 100644
index 00000000..de779a40
--- /dev/null
+++ b/libpthread/tests/test-11.c
@@ -0,0 +1,143 @@
+/* Test rwlocks. */
+
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <assert.h>
+#include <error.h>
+#include <errno.h>
+
+#define THREADS 1
+
+int a;
+int b;
+
+/* Get a read lock and assert that a == b. */
+void *
+test1 (void *arg)
+{
+ error_t err;
+ pthread_rwlock_t *lock = arg;
+ int i;
+
+ for (i = 0; i < 200; i ++)
+ {
+ err = pthread_rwlock_rdlock (lock);
+ assert (err == 0);
+
+ assert (a == b);
+
+ sched_yield ();
+
+ assert (a == b);
+
+ err = pthread_rwlock_unlock (lock);
+ assert (err == 0);
+ }
+
+ return 0;
+}
+
+int
+main (int argc, char **argv)
+{
+ error_t err;
+ pthread_rwlockattr_t attr;
+ pthread_rwlock_t lock;
+ int pshared;
+
+ int i;
+ pthread_t tid[THREADS];
+ void *ret;
+
+ err = pthread_rwlockattr_init (&attr);
+ if (err)
+ error (1, err, "pthread_rwlockattr_init");
+
+ err = pthread_rwlockattr_getpshared (&attr, &pshared);
+ if (err)
+ error (1, err, "pthread_rwlockattr_getpshared");
+
+ /* Assert the default state as mandated by POSIX. */
+ assert (pshared == PTHREAD_PROCESS_PRIVATE);
+
+ err = pthread_rwlockattr_setpshared (&attr, pshared);
+ if (err)
+ error (1, err, "pthread_rwlockattr_setpshared");
+
+ err = pthread_rwlock_init (&lock, &attr);
+ if (err)
+ error (1, err, "pthread_rwlock_init");
+
+ err = pthread_rwlockattr_destroy (&attr);
+ if (err)
+ error (1, err, "pthread_rwlockattr_destroy");
+
+ /* Now test the lock. */
+
+ for (i = 0; i < THREADS; i ++)
+ {
+ err = pthread_create (&tid[i], 0, test1, &lock);
+ if (err)
+ error (1, err, "pthread_create");
+ }
+
+ for (i = 0; i < 10; i ++)
+ {
+ sched_yield ();
+
+ /* Get a write lock. */
+ pthread_rwlock_wrlock (&lock);
+ /* Increment a and b giving other threads a chance to run in
+ between. */
+ sched_yield ();
+ a ++;
+ sched_yield ();
+ b ++;
+ sched_yield ();
+ /* Unlock. */
+ pthread_rwlock_unlock (&lock);
+ }
+
+ for (i = 0; i < THREADS; i ++)
+ {
+ err = pthread_join (tid[i], &ret);
+ if (err)
+ error (1, err, "pthread_join");
+ }
+
+ /* Read lock it. */
+ err = pthread_rwlock_tryrdlock (&lock);
+ assert (err == 0);
+
+ /* Try to write lock it. It should fail with EBUSY. */
+ err = pthread_rwlock_trywrlock (&lock);
+ assert (err == EBUSY);
+
+ /* Drop the read lock. */
+ err = pthread_rwlock_unlock (&lock);
+ assert (err == 0);
+
+ /* Get a write lock. */
+ err = pthread_rwlock_trywrlock (&lock);
+ assert (err == 0);
+
+ /* Fail trying to acquire another write lock. */
+ err = pthread_rwlock_trywrlock (&lock);
+ assert (err == EBUSY);
+
+ /* Try to get a read lock which should also fail. */
+ err = pthread_rwlock_tryrdlock (&lock);
+ assert (err == EBUSY);
+
+ /* Unlock it. */
+ err = pthread_rwlock_unlock (&lock);
+ assert (err == 0);
+
+
+ err = pthread_rwlock_destroy (&lock);
+ if (err)
+ error (1, err, "pthread_rwlock_destroy");
+
+ return 0;
+}
diff --git a/libpthread/tests/test-12.c b/libpthread/tests/test-12.c
new file mode 100644
index 00000000..2b784908
--- /dev/null
+++ b/libpthread/tests/test-12.c
@@ -0,0 +1,29 @@
+/* Test concurrency level. */
+
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <assert.h>
+#include <error.h>
+#include <errno.h>
+
+int
+main (int argc, char **argv)
+{
+ int i;
+ int err;
+
+ i = pthread_getconcurrency ();
+ assert (i == 0);
+
+ err = pthread_setconcurrency (-1);
+ assert (err == EINVAL);
+
+ err = pthread_setconcurrency (4);
+ assert (err == 0);
+
+ i = pthread_getconcurrency ();
+ assert (i == 4);
+
+ return 0;
+}
diff --git a/libpthread/tests/test-13.c b/libpthread/tests/test-13.c
new file mode 100644
index 00000000..13b09051
--- /dev/null
+++ b/libpthread/tests/test-13.c
@@ -0,0 +1,66 @@
+/* Test condition attributes and pthread_cond_timedwait. */
+
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <stdio.h>
+#include <assert.h>
+#include <error.h>
+#include <errno.h>
+#include <sys/time.h>
+
+int
+main (int argc, char **argv)
+{
+ error_t err;
+ int i;
+ pthread_condattr_t attr;
+ pthread_cond_t cond;
+ struct timespec ts;
+ pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+ struct timeval before, after;
+ int diff;
+
+ err = pthread_condattr_init (&attr);
+ if (err)
+ error (1, err, "pthread_condattr_init");
+
+ err = pthread_condattr_getpshared (&attr, &i);
+ if (err)
+ error (1, err, "pthread_condattr_getpshared");
+ assert (i == PTHREAD_PROCESS_PRIVATE);
+
+ err = pthread_condattr_setpshared (&attr, PTHREAD_PROCESS_PRIVATE);
+ assert (err == 0);
+
+ err = pthread_cond_init (&cond, &attr);
+ if (err)
+ error (1, err, "pthread_cond_init");
+
+ err = pthread_condattr_destroy (&attr);
+ if (err)
+ error (1, err, "pthread_condattr_destroy");
+
+ gettimeofday (&before, 0);
+ ts.tv_sec = before.tv_sec + 1;
+ ts.tv_nsec = before.tv_usec * 1000;
+
+ printf ("Starting wait @ %d\n", (int) before.tv_sec);
+
+ pthread_mutex_lock (&m);
+ err = pthread_cond_timedwait (&cond, &m, &ts);
+
+ gettimeofday (&after, 0);
+
+ printf ("End wait @ %d (err = %d)\n", (int) after.tv_sec, err);
+
+ assert (err == ETIMEDOUT);
+
+ diff = after.tv_sec * 1000000 + after.tv_usec
+ - before.tv_sec * 1000000 - before.tv_usec;
+
+ if (diff < 900000 || diff > 1100000)
+ error (1, EGRATUITOUS, "pthread_cond_timedwait waited %d us", diff);
+
+ return 0;
+}
diff --git a/libpthread/tests/test-14.c b/libpthread/tests/test-14.c
new file mode 100644
index 00000000..b1dbfa66
--- /dev/null
+++ b/libpthread/tests/test-14.c
@@ -0,0 +1,44 @@
+/* Test pthread_mutex_timedlock. */
+
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <stdio.h>
+#include <assert.h>
+#include <error.h>
+#include <errno.h>
+#include <sys/time.h>
+
+int
+main (int argc, char **argv)
+{
+ error_t err;
+ struct timespec ts;
+ pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+ struct timeval before, after;
+ int diff;
+
+ gettimeofday (&before, 0);
+ ts.tv_sec = before.tv_sec + 1;
+ ts.tv_nsec = before.tv_usec * 1000;
+
+ printf ("Starting wait @ %d\n", (int) before.tv_sec);
+
+ pthread_mutex_lock (&m);
+ /* A default mutex shall dead lock if locked twice. As such we do
+ not need spawn a second thread. */
+ err = pthread_mutex_timedlock (&m, &ts);
+ assert (err == ETIMEDOUT);
+
+ gettimeofday (&after, 0);
+
+ printf ("End wait @ %d\n", (int) after.tv_sec);
+
+ diff = after.tv_sec * 1000000 + after.tv_usec
+ - before.tv_sec * 1000000 - before.tv_usec;
+
+ if (diff < 900000 || diff > 1100000)
+ error (1, EGRATUITOUS, "pthread_mutex_timedlock waited %d us", diff);
+
+ return 0;
+}
diff --git a/libpthread/tests/test-15.c b/libpthread/tests/test-15.c
new file mode 100644
index 00000000..173f8b6b
--- /dev/null
+++ b/libpthread/tests/test-15.c
@@ -0,0 +1,87 @@
+/* Test pthread_rwlock_timedrdlock and pthread_rwlock_timedwrlock. */
+
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <stdio.h>
+#include <assert.h>
+#include <error.h>
+#include <errno.h>
+#include <sys/time.h>
+
+#define THREADS 10
+
+pthread_rwlock_t rwlock;
+
+void *
+test (void *arg)
+{
+ error_t err;
+ int foo = (int) arg;
+ struct timespec ts;
+ struct timeval before, after;
+ int diff;
+
+ gettimeofday (&before, 0);
+ ts.tv_sec = before.tv_sec + 1;
+ ts.tv_nsec = before.tv_usec * 1000;
+
+ printf ("Thread %d starting wait @ %d\n", pthread_self (),
+ (int) before.tv_sec);
+
+ if (foo % 2 == 0)
+ err = pthread_rwlock_timedrdlock (&rwlock, &ts);
+ else
+ err = pthread_rwlock_timedwrlock (&rwlock, &ts);
+
+ assert (err == ETIMEDOUT);
+
+ gettimeofday (&after, 0);
+
+ printf ("Thread %d ending wait @ %d\n", pthread_self (),
+ (int) after.tv_sec);
+
+ diff = after.tv_sec * 1000000 + after.tv_usec
+ - before.tv_sec * 1000000 - before.tv_usec;
+
+ if (diff < 900000 || diff > 1100000)
+ error (1, EGRATUITOUS, "pthread_mutex_timedlock waited %d us", diff);
+
+ return 0;
+}
+
+int
+main (int argc, char **argv)
+{
+ error_t err;
+ int i;
+ pthread_t tid[THREADS];
+
+ err = pthread_rwlock_init (&rwlock, 0);
+ if (err)
+ error (1, err, "pthread_rwlock_init");
+
+ /* Lock it so all the threads will block. */
+ err = pthread_rwlock_wrlock (&rwlock);
+ assert (err == 0);
+
+ for (i = 0; i < THREADS; i ++)
+ {
+ err = pthread_create (&tid[i], 0, test, (void *) i);
+ if (err)
+ error (1, err, "pthread_create");
+ }
+
+ for (i = 0; i < THREADS; i ++)
+ {
+ void *ret;
+
+ err = pthread_join (tid[i], &ret);
+ if (err)
+ error (1, err, "pthread_join");
+
+ assert (ret == 0);
+ }
+
+ return 0;
+}
diff --git a/libpthread/tests/test-16.c b/libpthread/tests/test-16.c
new file mode 100644
index 00000000..b6a52d01
--- /dev/null
+++ b/libpthread/tests/test-16.c
@@ -0,0 +1,71 @@
+/* Test pthread_kill.c. */
+
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <assert.h>
+#include <error.h>
+#include <errno.h>
+#include <hurd/signal.h>
+
+pthread_t testthread;
+
+int i;
+
+void *
+test (void *arg)
+{
+ error_t err;
+
+ printf ("test: %d\n", pthread_self ());
+
+ err = pthread_kill (pthread_self (), SIGINFO);
+ if (err)
+ error (1, err, "pthread_kill");
+
+ /* To avoid using condition variables in a signal handler. */
+ while (i == 0)
+ sched_yield ();
+
+ return 0;
+}
+
+static void
+handler (int sig, siginfo_t *info, void *context)
+{
+ assert (pthread_equal (pthread_self (), testthread));
+ printf ("handler: %d\n", pthread_self ());
+ i = 1;
+}
+
+int
+main (int argc, char **argv)
+{
+ error_t err;
+ struct sigaction sa;
+ void *ret;
+
+ printf ("main: %d\n", pthread_self ());
+
+ sa.sa_handler = handler;
+ sa.sa_mask = 0;
+ sa.sa_flags = 0;
+
+ err = sigaction (SIGINFO, &sa, 0);
+ if (err)
+ error (1, err, "sigaction");
+
+ err = pthread_create (&testthread, 0, test, 0);
+ if (err)
+ error (1, err, "pthread_create");
+
+ err = pthread_join (testthread, &ret);
+ if (err)
+ error (1, err, "pthread_join");
+
+ assert (ret == 0);
+
+ return 0;
+}
diff --git a/libpthread/tests/test-2.c b/libpthread/tests/test-2.c
new file mode 100644
index 00000000..701462e8
--- /dev/null
+++ b/libpthread/tests/test-2.c
@@ -0,0 +1,39 @@
+/* Test detachability. */
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <assert.h>
+#include <error.h>
+#include <errno.h>
+#include <unistd.h>
+
+void *
+thread (void *arg)
+{
+ while (1)
+ sched_yield ();
+}
+
+int
+main (int argc, char **argv)
+{
+ int err;
+ pthread_t tid;
+ void *ret;
+
+ err = pthread_create (&tid, 0, thread, 0);
+ if (err)
+ error (1, err, "pthread_create");
+
+ err = pthread_detach (tid);
+ if (err)
+ error (1, err, "pthread_detach");
+
+ err = pthread_detach (tid);
+ assert (err == EINVAL);
+
+ err = pthread_join (tid, &ret);
+ assert (err == EINVAL);
+
+ return 0;
+}
diff --git a/libpthread/tests/test-3.c b/libpthread/tests/test-3.c
new file mode 100644
index 00000000..7db2e43f
--- /dev/null
+++ b/libpthread/tests/test-3.c
@@ -0,0 +1,55 @@
+/* Test the thread attribute get and set methods. */
+
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <sched.h>
+#include <assert.h>
+#include <errno.h>
+
+int
+main (int argc, char *argv[])
+{
+ error_t err;
+ pthread_attr_t attr;
+
+ int i;
+ struct sched_param sp;
+ void *p;
+ size_t sz;
+
+ err = pthread_attr_init (&attr);
+ assert_perror (err);
+
+ err = pthread_attr_destroy (&attr);
+ assert_perror (err);
+
+ err = pthread_attr_init (&attr);
+ assert_perror (err);
+
+#define TEST1(foo, rv, v) \
+ err = pthread_attr_get##foo (&attr, rv); \
+ assert_perror (err); \
+ \
+ err = pthread_attr_set##foo (&attr, v); \
+ assert_perror (err);
+
+#define TEST(foo, rv, v) TEST1(foo, rv, v)
+
+ TEST(inheritsched, &i, i);
+ TEST(schedparam, &sp, &sp);
+ TEST(schedpolicy, &i, i);
+ TEST(scope, &i, i);
+ TEST(stackaddr, &p, p);
+ TEST(detachstate, &i, i);
+ TEST(guardsize, &sz, sz);
+ TEST(stacksize, &sz, sz);
+
+ err = pthread_attr_getstack (&attr, &p, &sz);
+ assert_perror (err);
+
+ err = pthread_attr_setstack (&attr, p, sz);
+ assert_perror (err);
+
+ return 0;
+}
diff --git a/libpthread/tests/test-4.c b/libpthread/tests/test-4.c
new file mode 100644
index 00000000..de9c8fe4
--- /dev/null
+++ b/libpthread/tests/test-4.c
@@ -0,0 +1,86 @@
+/* Test the stack guard. */
+
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <assert.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+
+size_t stacksize;
+
+void *
+thr (void *arg)
+{
+ int i;
+ char *foo;
+
+ foo = alloca (3 * stacksize / 4);
+ for (i = 0; i < sizeof foo; i ++)
+ foo[i] = -1;
+
+ return (void *) 1;
+}
+
+int
+main (int argc, char *argv[])
+{
+ error_t err;
+ pid_t child;
+
+ child = fork ();
+ switch (child)
+ {
+ case -1:
+ error (1, errno, "fork");
+ break;
+
+ case 0:
+ {
+ pthread_attr_t attr;
+ pthread_t tid;
+ void *ret;
+
+ err = pthread_attr_init (&attr);
+ assert_perror (err);
+
+ err = pthread_attr_getstacksize (&attr, &stacksize);
+ assert_perror (err);
+
+ err = pthread_attr_setguardsize (&attr, stacksize / 2);
+ if (err == ENOTSUP)
+ {
+ printf ("Stack guard attribute not supported.\n");
+ return 1;
+ }
+ assert_perror (err);
+
+ err = pthread_create (&tid, &attr, thr, 0);
+ assert_perror (err);
+
+ err = pthread_attr_destroy (&attr);
+ assert_perror (err);
+
+ err = pthread_join (tid, &ret);
+ /* Should never be successful. */
+ printf ("Thread did not segfault!?!\n");
+ assert_perror (err);
+ return 0;
+ }
+
+ default:
+ {
+ pid_t pid;
+ int status;
+
+ pid = waitpid (child, &status, 0);
+ printf ("pid = %d; child = %d; status = %d\n", pid, child, status);
+ assert (pid == child);
+ assert (status != 0);
+ }
+ }
+
+ return 0;
+}
diff --git a/libpthread/tests/test-5.c b/libpthread/tests/test-5.c
new file mode 100644
index 00000000..0f5000b2
--- /dev/null
+++ b/libpthread/tests/test-5.c
@@ -0,0 +1,75 @@
+/* Test signals. */
+
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include <error.h>
+#include <assert.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+
+void *
+thr (void *arg)
+{
+ * (int *)0 = 0;
+ return 0;
+}
+
+int foobar;
+
+int
+main (int argc, char *argv[])
+{
+ error_t err;
+ pid_t child;
+
+ struct rlimit limit;
+
+ limit.rlim_cur = 0;
+ limit.rlim_max = 0;
+
+ err = setrlimit (RLIMIT_CORE, &limit);
+ if (err)
+ error (1, err, "setrlimit");
+
+ child = fork ();
+ switch (child)
+ {
+ case -1:
+ error (1, errno, "fork");
+ break;
+
+ case 0:
+ {
+ pthread_t tid;
+ void *ret;
+
+ err = pthread_create (&tid, 0, thr, 0);
+ if (err)
+ error (1, err, "pthread_create");
+
+ err = pthread_join (tid, &ret);
+ assert_perror (err);
+
+ /* Should have never returned. Our parent expects us to fail
+ thus we succeed and indicate the error. */
+ return 0;
+ }
+
+ default:
+ {
+ pid_t pid;
+ int status;
+
+ pid = waitpid (child, &status, 0);
+ printf ("pid = %d; child = %d; status = %d\n", pid, child, status);
+ assert (pid == child);
+ assert (status != 0);
+ }
+ }
+
+ return 0;
+}
diff --git a/libpthread/tests/test-6.c b/libpthread/tests/test-6.c
new file mode 100644
index 00000000..98aa8ba7
--- /dev/null
+++ b/libpthread/tests/test-6.c
@@ -0,0 +1,95 @@
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <stdio.h>
+#include <error.h>
+#include <errno.h>
+
+#define THREADS 500
+#define WAITS 3
+
+void *
+dowait (void *arg)
+{
+ pthread_barrier_t *barrier = arg;
+ int ret;
+
+ ret = pthread_barrier_wait (barrier);
+ printf ("%d ", pthread_self ());
+ return (void *) ret;
+}
+
+int
+main (int argc, char **argv)
+{
+ pthread_barrierattr_t attr;
+ pthread_barrier_t barrier;
+
+ int i, j;
+ error_t err;
+ pthread_t tid[THREADS];
+
+ int havesyncs;
+
+ err = pthread_barrierattr_init (&attr);
+ if (err)
+ error (1, err, "pthread_barrierattr_init");
+
+ err = pthread_barrierattr_getpshared (&attr, &i);
+ if (err)
+ error (1, err, "pthread_barrierattr_getpshared");
+ assert (i == PTHREAD_PROCESS_PRIVATE || i == PTHREAD_PROCESS_SHARED);
+
+ err = pthread_barrierattr_setpshared (&attr, PTHREAD_PROCESS_PRIVATE);
+ if (err)
+ error (1, err, "pthread_barrierattr_setpshared");
+
+ err = pthread_barrier_init (&barrier, &attr, THREADS + 1);
+ if (err)
+ error (1, err, "pthread_barrier_init");
+
+ for (j = 0; j < WAITS; j ++)
+ {
+
+ for (i = 0; i < THREADS; i ++)
+ {
+ err = pthread_create (&tid[i], 0, dowait, &barrier);
+ if (err)
+ error (1, err, "pthread_create (%d)", i);
+ }
+
+ printf ("Manager will now call pthread_barrier_wait.\n");
+
+ havesyncs
+ = pthread_barrier_wait (&barrier) == PTHREAD_BARRIER_SERIAL_THREAD
+ ? 1 : 0;
+
+ for (i = THREADS - 1; i >= 0; i --)
+ {
+ void *ret;
+ err = pthread_join (tid[i], &ret);
+ if (err)
+ error (1, err, "pthread_join");
+
+ switch ((int) ret)
+ {
+ case 0:
+ break;
+
+ case PTHREAD_BARRIER_SERIAL_THREAD:
+ havesyncs ++;
+ break;
+
+ default:
+ assert (! "Unknown value returned from pthread_barrier_wait.");
+ break;
+ }
+ }
+
+ printf ("\n");
+
+ assert (havesyncs == 1);
+ }
+
+ return 0;
+}
diff --git a/libpthread/tests/test-7.c b/libpthread/tests/test-7.c
new file mode 100644
index 00000000..bd97acfa
--- /dev/null
+++ b/libpthread/tests/test-7.c
@@ -0,0 +1,66 @@
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <stdio.h>
+#include <error.h>
+#include <errno.h>
+
+#define THREADS 10
+#define KEYS 400
+
+pthread_key_t key[KEYS];
+
+void *
+thr (void *arg)
+{
+ error_t err;
+ int i;
+
+ for (i = 0; i < KEYS; i ++)
+ {
+ printf ("pthread_getspecific(%d).\n", key[i]);
+ assert (pthread_getspecific (key[i]) == NULL);
+ printf ("pthread_setspecific(%d, %d).\n", key[i], pthread_self ());
+ err = pthread_setspecific (key[i], (void *) pthread_self ());
+ printf ("pthread_setspecific(%d, %d) => %d.\n", key[i], pthread_self (), err);
+ assert_perror (err);
+ }
+
+ return 0;
+}
+
+int
+main (int argc, char **argv)
+{
+ error_t err;
+ int i;
+ pthread_t tid[THREADS];
+
+ void des (void *val)
+ {
+ assert ((pthread_t) val == pthread_self ());
+ }
+
+ for (i = 0; i < KEYS; i ++)
+ err = pthread_key_create (&key[i], des);
+
+ for (i = 0; i < THREADS; i ++)
+ {
+ err = pthread_create (&tid[i], 0, thr, 0);
+ if (err)
+ error (1, err, "pthread_create (%d)", i);
+ }
+
+ for (i = 0; i < THREADS; i ++)
+ {
+ void *ret;
+
+ err = pthread_join (tid[i], &ret);
+ if (err)
+ error (1, err, "pthread_join");
+
+ assert (ret == 0);
+ }
+
+ return 0;
+}
diff --git a/libpthread/tests/test-8.c b/libpthread/tests/test-8.c
new file mode 100644
index 00000000..85a7f8f6
--- /dev/null
+++ b/libpthread/tests/test-8.c
@@ -0,0 +1,60 @@
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <assert.h>
+#include <error.h>
+#include <errno.h>
+
+#define THREADS 10
+
+pthread_once_t inc_var_once = PTHREAD_ONCE_INIT;
+int var;
+
+void
+inc_var (void)
+{
+ var ++;
+}
+
+void *
+thr (void *arg)
+{
+ int i;
+
+ for (i = 0; i < 500; i ++)
+ pthread_once (&inc_var_once, inc_var);
+
+ return 0;
+}
+
+int
+main (int argc, char **argv)
+{
+ error_t err;
+ int i;
+ pthread_t tid[THREADS];
+
+ for (i = 0; i < THREADS; i ++)
+ {
+ err = pthread_create (&tid[i], 0, thr, 0);
+ if (err)
+ error (1, err, "pthread_create (%d)", i);
+ }
+
+ assert (thr (0) == 0);
+
+ for (i = 0; i < THREADS; i ++)
+ {
+ void *ret;
+
+ err = pthread_join (tid[i], &ret);
+ if (err)
+ error (1, err, "pthread_join");
+
+ assert (ret == 0);
+ }
+
+ assert (var == 1);
+
+ return 0;
+}
diff --git a/libpthread/tests/test-9.c b/libpthread/tests/test-9.c
new file mode 100644
index 00000000..82051570
--- /dev/null
+++ b/libpthread/tests/test-9.c
@@ -0,0 +1,88 @@
+/* Test recursive mutexes. */
+
+#define _GNU_SOURCE
+
+#include <pthread.h>
+#include <assert.h>
+#include <error.h>
+#include <errno.h>
+
+#define THREADS 10
+
+int foo;
+
+void *
+thr (void *arg)
+{
+ int i;
+
+ pthread_mutex_lock (arg);
+
+ foo = pthread_self ();
+
+ for (i = 0; i < 500; i ++)
+ pthread_mutex_lock (arg);
+ for (i = 0; i < 500; i ++)
+ pthread_mutex_unlock (arg);
+
+ assert (foo == pthread_self ());
+
+ pthread_mutex_unlock (arg);
+
+ return 0;
+}
+
+int
+main (int argc, char **argv)
+{
+ error_t err;
+ int i;
+ pthread_t tid[THREADS];
+ pthread_mutexattr_t mattr;
+ pthread_mutex_t mutex;
+
+ err = pthread_mutexattr_init (&mattr);
+ if (err)
+ error (1, err, "pthread_mutexattr_init");
+
+ err = pthread_mutexattr_settype (&mattr, PTHREAD_MUTEX_RECURSIVE);
+ if (err)
+ error (1, err, "pthread_mutexattr_settype");
+
+ err = pthread_mutex_init (&mutex, &mattr);
+ if (err)
+ error (1, err, "pthread_mutex_init");
+
+ err = pthread_mutexattr_destroy (&mattr);
+ if (err)
+ error (1, err, "pthread_mutexattr_destroy");
+
+ pthread_mutex_lock (&mutex);
+ pthread_mutex_lock (&mutex);
+ pthread_mutex_unlock (&mutex);
+ pthread_mutex_unlock (&mutex);
+
+ for (i = 0; i < THREADS; i ++)
+ {
+ err = pthread_create (&tid[i], 0, thr, &mutex);
+ if (err)
+ error (1, err, "pthread_create (%d)", i);
+ }
+
+ for (i = 0; i < THREADS; i ++)
+ {
+ void *ret;
+
+ err = pthread_join (tid[i], &ret);
+ if (err)
+ error (1, err, "pthread_join");
+
+ assert (ret == 0);
+ }
+
+ err = pthread_mutex_destroy (&mutex);
+ if (err)
+ error (1, err, "pthread_mutex_destroy");
+
+ return 0;
+}