summaryrefslogtreecommitdiff
path: root/libpthread/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'libpthread/sysdeps')
-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
218 files changed, 7557 insertions, 0 deletions
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);