summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1856
-rw-r--r--Makefile30
-rw-r--r--Makefile.am168
-rw-r--r--TODO4
-rw-r--r--headers.m445
-rw-r--r--include/libc-symbols.h4
-rw-r--r--include/pthread/pthread.h237
-rw-r--r--include/pthread/pthreadtypes.h125
-rw-r--r--include/semaphore.h4
-rw-r--r--pthread/cthreads-compat.c8
-rw-r--r--pthread/pt-alloc.c56
-rw-r--r--pthread/pt-create.c4
-rw-r--r--pthread/pt-dealloc.c33
-rw-r--r--pthread/pt-detach.c10
-rw-r--r--pthread/pt-exit.c12
-rw-r--r--pthread/pt-getattr.c49
-rw-r--r--pthread/pt-internal.h49
-rw-r--r--pthread/pt-join.c15
-rw-r--r--pthread/pt-self.c7
-rw-r--r--pthread/pt-setcancelstate.c3
-rw-r--r--pthread/pt-setcanceltype.c3
-rw-r--r--pthread/pt-yield.c26
-rw-r--r--signal/README4
-rw-r--r--signal/TODO29
-rw-r--r--signal/kill.c70
-rw-r--r--signal/pt-kill-siginfo-np.c88
-rw-r--r--signal/sig-internal.c26
-rw-r--r--signal/sig-internal.h177
-rw-r--r--signal/sigaction.c72
-rw-r--r--signal/sigaltstack.c69
-rw-r--r--signal/signal-dispatch.c117
-rw-r--r--signal/signal.h275
-rw-r--r--signal/sigpending.c38
-rw-r--r--signal/sigsuspend.c29
-rw-r--r--signal/sigtimedwait.c30
-rw-r--r--signal/sigwaiter.c91
-rw-r--r--signal/sigwaitinfo.c74
-rw-r--r--sysdeps/generic/bits/barrier-attr.h4
-rw-r--r--sysdeps/generic/bits/cancelation.h15
-rw-r--r--sysdeps/generic/bits/condition-attr.h8
-rw-r--r--sysdeps/generic/bits/condition.h4
-rw-r--r--sysdeps/generic/bits/mutex-attr.h10
-rw-r--r--sysdeps/generic/bits/mutex.h92
-rw-r--r--sysdeps/generic/bits/once.h4
-rw-r--r--sysdeps/generic/bits/pthread-np.h27
-rw-r--r--sysdeps/generic/bits/pthread.h13
-rw-r--r--sysdeps/generic/bits/pthreadtypes.h29
-rw-r--r--sysdeps/generic/bits/rwlock-attr.h4
-rw-r--r--sysdeps/generic/bits/rwlock.h31
-rw-r--r--sysdeps/generic/bits/semaphore.h4
-rw-r--r--sysdeps/generic/bits/thread-attr.h11
-rw-r--r--sysdeps/generic/killpg.c27
-rw-r--r--sysdeps/generic/pt-attr-getschedparam.c3
-rw-r--r--sysdeps/generic/pt-attr-setschedparam.c2
-rw-r--r--sysdeps/generic/pt-kill.c32
-rw-r--r--sysdeps/generic/pt-mutex-destroy.c8
-rw-r--r--sysdeps/generic/pt-mutex-init.c10
-rw-r--r--sysdeps/generic/pt-mutex-lock.c2
-rw-r--r--sysdeps/generic/pt-mutex-timedlock.c56
-rw-r--r--sysdeps/generic/pt-mutex-transfer-np.c66
-rw-r--r--sysdeps/generic/pt-mutex-trylock.c30
-rw-r--r--sysdeps/generic/pt-mutex-unlock.c42
-rw-r--r--sysdeps/generic/pt-mutexattr.c18
-rw-r--r--sysdeps/generic/pt-rwlock-destroy.c2
-rw-r--r--sysdeps/generic/pt-rwlock-init.c2
-rw-r--r--sysdeps/generic/pt-startup.c25
-rw-r--r--sysdeps/generic/raise.c41
-rw-r--r--sysdeps/generic/sem-destroy.c2
-rw-r--r--sysdeps/generic/sem-getvalue.c2
-rw-r--r--sysdeps/generic/sem-init.c2
-rw-r--r--sysdeps/generic/sem-open.c2
-rw-r--r--sysdeps/generic/sem-post.c2
-rw-r--r--sysdeps/generic/sem-timedwait.c3
-rw-r--r--sysdeps/generic/sem-trywait.c2
-rw-r--r--sysdeps/generic/sem-unlink.c2
-rw-r--r--sysdeps/generic/sem-wait.c2
-rw-r--r--sysdeps/generic/sigaddset.c35
-rw-r--r--sysdeps/generic/sigdelset.c35
-rw-r--r--sysdeps/generic/sigemptyset.c29
-rw-r--r--sysdeps/generic/sigfillset.c29
-rw-r--r--sysdeps/generic/siginterrupt.c36
-rw-r--r--sysdeps/generic/sigismember.c36
-rw-r--r--sysdeps/generic/signal.c44
-rw-r--r--sysdeps/generic/sigwait.c34
-rw-r--r--sysdeps/hurd/pt-kill.c3
-rw-r--r--sysdeps/ia32/bits/atomic.h (renamed from sysdeps/i386/bits/atomic.h)0
-rw-r--r--sysdeps/ia32/bits/memory.h (renamed from sysdeps/i386/bits/memory.h)6
-rw-r--r--sysdeps/ia32/bits/spin-lock-inline.h (renamed from sysdeps/i386/bits/spin-lock.h)25
-rw-r--r--sysdeps/ia32/bits/spin-lock.h39
-rw-r--r--sysdeps/ia32/machine-sp.h (renamed from sysdeps/i386/machine-sp.h)2
-rw-r--r--sysdeps/ia32/pt-machdep.h (renamed from sysdeps/i386/pt-machdep.h)0
-rw-r--r--sysdeps/l4/bits/pthread-np.h35
-rw-r--r--sysdeps/l4/hurd/bits/pthread-np.h31
-rw-r--r--sysdeps/l4/hurd/ia32/pt-machdep.c (renamed from sysdeps/l4/hurd/i386/pt-machdep.c)0
-rw-r--r--sysdeps/l4/hurd/ia32/pt-setup.c117
-rw-r--r--sysdeps/l4/hurd/ia32/signal-dispatch-lowlevel.c213
-rw-r--r--sysdeps/l4/hurd/powerpc/pt-machdep.c20
-rw-r--r--sysdeps/l4/hurd/powerpc/pt-setup.c (renamed from sysdeps/l4/hurd/i386/pt-setup.c)69
-rw-r--r--sysdeps/l4/hurd/pt-block.c30
-rw-r--r--sysdeps/l4/hurd/pt-kill.c3
-rw-r--r--sysdeps/l4/hurd/pt-setactivity-np.c39
-rw-r--r--sysdeps/l4/hurd/pt-sigstate-destroy.c (renamed from sysdeps/generic/bits/thread-barrier.h)18
-rw-r--r--sysdeps/l4/hurd/pt-sigstate-init.c44
-rw-r--r--sysdeps/l4/hurd/pt-sigstate.c81
-rw-r--r--sysdeps/l4/hurd/pt-startup.c30
-rw-r--r--sysdeps/l4/hurd/pt-sysdep.c39
-rw-r--r--sysdeps/l4/hurd/pt-sysdep.h35
-rw-r--r--sysdeps/l4/hurd/pt-thread-alloc.c95
-rw-r--r--sysdeps/l4/hurd/pt-thread-halt.c104
-rw-r--r--sysdeps/l4/hurd/pt-thread-start.c70
-rw-r--r--sysdeps/l4/hurd/pt-wakeup.c46
-rw-r--r--sysdeps/l4/hurd/sig-sysdep.h69
-rw-r--r--sysdeps/l4/hurd/sigprocmask.c41
-rw-r--r--sysdeps/l4/pt-block.c22
-rw-r--r--sysdeps/l4/pt-docancel.c19
-rw-r--r--sysdeps/l4/pt-pool-np.c54
-rw-r--r--sysdeps/l4/pt-spin.c63
-rw-r--r--sysdeps/l4/pt-stack-alloc.c47
-rw-r--r--sysdeps/l4/pt-start.c103
-rw-r--r--sysdeps/l4/pt-thread-alloc.c27
-rw-r--r--sysdeps/l4/pt-thread-dealloc.c32
-rw-r--r--sysdeps/l4/pt-thread-halt.c31
-rw-r--r--sysdeps/l4/pt-thread-start.c62
-rw-r--r--sysdeps/l4/pt-timedblock.c35
-rw-r--r--sysdeps/l4/pt-wakeup.c29
-rw-r--r--sysdeps/mach/bits/spin-lock-inline.h90
-rw-r--r--sysdeps/mach/bits/spin-lock.h65
-rw-r--r--sysdeps/mach/hurd/ia32/pt-machdep.c (renamed from sysdeps/mach/hurd/i386/pt-machdep.c)0
-rw-r--r--sysdeps/mach/hurd/ia32/pt-setup.c (renamed from sysdeps/mach/hurd/i386/pt-setup.c)10
-rw-r--r--sysdeps/mach/hurd/pt-docancel.c4
-rw-r--r--sysdeps/mach/hurd/pt-sysdep.h5
-rw-r--r--sysdeps/mach/pt-thread-alloc.c7
-rw-r--r--sysdeps/mach/pt-thread-halt.c10
-rw-r--r--sysdeps/mach/pt-timedblock.c6
-rw-r--r--sysdeps/posix/pt-spin.c2
-rw-r--r--sysdeps/powerpc/bits/machine-lock.h78
-rw-r--r--sysdeps/powerpc/bits/memory.h36
-rw-r--r--sysdeps/powerpc/bits/spin-lock.h108
-rw-r--r--sysdeps/powerpc/machine-sp.h31
-rw-r--r--sysdeps/powerpc/pt-machdep.h29
-rw-r--r--tests/test-1.c1
-rw-r--r--tests/test-16.c2
-rw-r--r--tests/test-6.c1
-rw-r--r--tests/test-7.c1
144 files changed, 4537 insertions, 2633 deletions
diff --git a/ChangeLog b/ChangeLog
index 22665d2..e991eac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,1854 +1,6 @@
-2007-06-13 Samuel Thibault <samuel.thibault@ens-lyon.org>
+51839d398b0f9885a17ab5c0768b8dec4dd9eb79 is the last commit imported from CVS.
+All commits after that one have valid author and committer information.
- TLS support for libpthread, Mach/Hurd (x86).
+Use this to examine the change log for earlier changes:
- * Makefile (CFLAGS): Define ENABLE_TLS.
- * pthread/pt-create.c (__pthread_create_internal) [ENABLE_TLS]: Call
- into glibc to allocate static TLS block.
- * pthread/pt-exit.c (pthread_exit) [ENABLE_TLS]: Call into glibc to
- deallocate static TLS block.
- * pthread/pt-internal.h [ENABLE_TLS] (tcbhead_t): New structure; as in
- glibc.
- (__pthread) [ENABLE_TLS]: Add TCB member.
- [ENABLE_TLS] (_dl_allocate_tls, _dl_deallocate_tls): Declare; from
- glibc.
- * sysdeps/mach/hurd/pt-sysdep.h (__thread_set_pcsp): Rename to
- __thread_set_pcsptp. Add SET_TP and TP parameters. Change all
- callers.
- * sysdeps/mach/hurd/i386/pt-machdep.c (__thread_set_pcsptp): Imlement
- TLS support.
- * sysdeps/mach/hurd/i386/pt-setup.c (__pthread_setup): Likewise.
-
-2006-03-04 Samuel Thibault <samuel.thibault@ens-lyon.org>
-
- * sysdeps/i386/machine-sp.h (thread_stack_pointer):
- Optimize esp read.
- * i386/cthreads.h (cthread_sp): Likewise.
- * include/pthread/pthread.h: Add the restrict keyword where
- appropriate for full compliance.
- * pthread/pt-internal.h: Likewise.
- * sysdeps/generic/bits/mutex.h: Likewise.
- * sysdeps/generic/bits/rwlock.h: Likewise.
- * TODO: Drop that TODO item.
-
-2006-01-20 Samuel Thibault <samuel.thibault@ens-lyon.org>
-
- Do not let other libraries (like libX11) override libpthread's
- pthread_mutex_*, pthread_rwlock_* and sem_* dynamic symbols.
- * sysdeps/generic/pt-mutex-destroy.c
- (pthread_mutex_destroy): Make the alias strong.
- * sysdeps/generic/pt-mutex-init.c
- (pthread_mutex_init): Likewise.
- * sysdeps/generic/pt-mutex-lock.c
- (_pthread_mutex_lock, pthread_mutex_lock): Likewise.
- * sysdeps/generic/pt-mutex-trylock.c
- (_pthread_mutex_trylock, pthread_mutex_trylock): Likewise.
- * sysdeps/generic/pt-mutex-unlock.c
- (_pthread_mutex_lock, pthread_mutex_unlock): Likewise.
- * sysdeps/generic/pt-rwlock-destroy.c
- (pthread_rwlock_destroy): Likewise.
- * sysdeps/generic/pt-rwlock-init.c
- (pthread_rwlock_init): Likewise.
- * sysdeps/generic/sem-destroy.c (sem_destroy): Likewise.
- * sysdeps/generic/sem-getvalue.c (sem_getvalue): Likewise.
- * sysdeps/generic/sem-init.c (sem_init): Likewise.
- * sysdeps/generic/sem-open.c (sem_open): Likewise.
- * sysdeps/generic/sem-post.c (sem_post): Likewise.
- * sysdeps/generic/sem-timedwait.c (sem_timedwait): Likewise.
- * sysdeps/generic/sem-trywait.c (sem_trywait): Likewise.
- * sysdeps/generic/sem-unlink.c (sem_unlink): Likewise.
- * sysdeps/generic/sem-wait.c (sem_wait): Likewise.
-
-2006-03-27 Thomas Schwinge <tschwinge@gnu.org>
-
- * Makefile (SRCS): Don't define two times and only list `pt-attr.c'
- once. Reported by Jeff Bailey <jbailey@gnu.org>.
-
-2005-08-28 Neal H. Walfield <neal@gnu.org>
-
- * include/semaphore.h: Use __restrict, not restrict.
-
-2005-05-31 Neal H. Walfield <neal@gnu.org>
-
- * include/pthread/pthread.h: If clockid_t is still not defined
- after including <time.h>, define it manually.
-
-2005-05-17 Neal H. Walfield <neal@gnu.org>
-
- * include/pthread/pthread.h: Define __need_clockid_t before
- including <time.h>.
-
-2005-05-12 Neal H. Walfield <neal@gnu.org>
-
- * include/pthread/pthread.h (pthread_exit): Add noreturn
- attribute.
-
- * sysdeps/generic/bits/condition.h (__PTHREAD_COND_INITIALIZER):
- Don't create a compound literal.
- * sysdeps/generic/bits/mutex.h (__PTHREAD_MUTEX_INITIALIZER):
- Don't create a compound literal.
- (pthread_mutex_init): Don't assign to *__MUTEX directly.
- Initialize an intermediate local variable and then copy the
- result.
- * sysdeps/generic/bits/rwlock.h (__PTHREAD_RWLOCK_INITIALIZER):
- Don't create a compound literal.
- (pthread_rwlock_init): Don't assign to *__RWLOCK directly.
- Initialize an intermediate local variable and then copy the
- result.
- * sysdeps/i386/bits/spin-lock.h (__SPIN_LOCK_INITIALIZER):
- Don't create a compound literal.
-
- * pthread/pt-alloc.c (initialize_pthread): Cast
- PTHREAD_MUTEX_INITIALIZER and PTHREAD_COND_INITIALIZER to create a
- compound literal.
- * tests/test-1.c (main): Use pthread_mutex_init, not
- PTHREAD_MUTEX_INIT for mutex initialization
-
- * sysdeps/generic/pt-barrier-init.c (pthread_barrier_init): Remove
- assert. Copy ATTR if non-defaults are used.
- * sysdeps/generic/pt-cond-init.c (pthread_cond_init): Include
- <string.h>. Remove assert. Copy ATTR if non-defaults are used.
- * sysdeps/generic/pt-mutex-init.c (_pthread_mutex_init): Cast
- PTHREAD_MUTEX_INITIALIZER to create a compound literal.
- * sysdeps/generic/pt-rwlock-init.c: Include <string.h>.
- (_pthread_rwlock_init): Cast __PTHREAD_RWLOCK_INITIALIZER to
- create a compound literal. Copy ATTR if non-defaults are used.
-
- * sysdeps/generic/pt-cond-timedwait.c
- (__pthread_cond_timedwait_internal): Check that ABSTIME->TV_NSEC
- is valid. Don't shadow ERR. Don't return before cleaning up.
- * sysdeps/generic/pt-mutex-timedlock.c (pthread_mutex_timedlock):
- Move after __pthread_mutex_timedlock_internal. Check that
- ABSTIME->TV_NSEC is valid.
- * sysdeps/generic/pt-rwlock-timedrdlock.c
- (pthread_rwlock_timedrdlock): Move after.
- __pthread_rwlock_timedrdlock_internal.
- (__pthread_rwlock_timedrdlock_internal): Check that
- ABSTIME->TV_NSEC is valid.
- * sysdeps/generic/pt-rwlock-timedwrlock.c
- (pthread_rwlock_timedwrlock): Move after
- __pthread_rwlock_timedwrlock_internal.
- (__pthread_rwlock_timedwrlock_internal): Check that
- ABSTIME->TV_NSEC is valid.
- * sysdeps/generic/sem-timedwait.c (__sem_timedwait_internal):
- Check that TIMEOUT->TV_NSEC is valid before enqueuing the thread.
-
- * sysdeps/generic/pt-rwlock-rdlock.c
- (__pthread_rwlock_timedrdlock_internal): Fix declaration.
-
- * sysdeps/generic/pt-mutex-trylock.c (__pthread_mutex_trylock):
- Don't return EDEADLK. POSIX does not allow it.
-
- * sysdeps/mach/pt-timedblock.c (__pthread_timedblock): Calculate
- the relative timeout without overflowing.
-
- * sysdeps/mach/hurd/i386/pt-setup.c (stack_setup): Cast THREAD.
-
-2005-05-12 Neal H. Walfield <neal@gnu.org>
-
- * Makefile (SRCS): Add sem-close.c, sem-destroy.c, sem-getvalue.c,
- sem-init.c, sem-open.c, sem-post.c, sem-timedwait.c, sem-trywait.c,
- sem-unlink.c and sem-wait.c.
- (sysdeps_headers): Add semaphore.h and bits/semaphore.h.
- * include/semaphore.h: New file.
- * sysdeps/generic/sem-close.c: New file.
- * sysdeps/generic/sem-destroy.c: New file.
- * sysdeps/generic/sem-getvalue.c: New file.
- * sysdeps/generic/sem-init.c: New file.
- * sysdeps/generic/sem-open.c: New file.
- * sysdeps/generic/sem-post.c: New file.
- * sysdeps/generic/sem-timedwait.c: New file.
- * sysdeps/generic/sem-trywait.c: New file.
- * sysdeps/generic/sem-unlink.c: New file.
- * sysdeps/generic/sem-wait.c: New file.
- * sysdeps/generic/bits/semaphore.h: New file.
-
-2005-05-04 Neal H. Walfield <neal@gnu.org>
-
- * Makefile (SRCS): Add pt-thread_dealloc.c.
- * sysdeps/mach/pt-thread-dealloc.c: New file.
- * pthread/pt-internal.h (__pthread_thread_dealloc): New
- declaration.
- (__pthread_thread_halt): Add parameter NEED_DEALLOC. Update
- callers.
- * sysdeps/mach/pt-thread-halt.c (__pthread_thread_halt): Respect
- new NEED_DEALLOC parameter. Move code which deallocates kernel
- resources from here ...
- * sysdeps/mach/pt-thread-dealloc.c (__pthread_thread_dealloc):
- ...to here.
- * pthread/pt-create.c (__pthread_create_internal): Call
- __pthread_thread_dealloc on failure.
- * pthread/pt-exit.c (pthread_exit): Call __pthread_thread_dealloc.
-
- * sysdeps/mach/pt-thread-alloc.c (create_wakeupmsg): Call
- __mach_port_destroy to deallocate the receive right.
- __mach_port_deallocate won't do it.
-
- * pthread/pt-detach.c (pthread_detach): Don't call
- __pthread_thread_halt a second time.
-
- * sysdeps/mach/hurd/pt-sysdep.c (_cthread_init_routine): Fix
- declaration.
- (init_routine): Update declaration and remove gratuitous cast.
-
-2005-05-02 Neal H. Walfield <neal@gnu.org>
-
- * pthread/pt-alloc.c (__pthread_alloc): Set the thread id to the
- table index plus one.
- * pthread/pt-internal.h (__pthread_getid): Index __pthread_threads
- using THREAD - 1, not THREAD.
- (__pthread_setid): Likewise.
- * pthread/pt-create.c (__pthread_create_internal): Likewise.
-
- * sysdeps/generic/pt-mutex-trylock.c (__pthread_mutex_trylock):
- When returning EBUSY, don't forget to first unlock MUTEX->__HELD.
-
-2005-04-20 Neal H. Walfield <neal@gnu.org>
-
- * sysdeps/generic/pt-setschedparam.c: policy's type is int, not
- int *.
- * include/pthread/pthread.h: Likewise.
- Reported by Christopher `Physicman' Bodenstein <cb@physicman.net>.
-
-2005-01-21 Michael Banck <mbanck@debian.org>
-
- * Makefile ($(libdir)/libpthread2.a): Install linker script
- from $(srcdir) instead of current directory.
- ($(libdir)/libpthread2_pic.a): Likewise.
-
-2005-02-08 Neal H. Walfield <neal@gnu.org>
-
- * sysdeps/mach/pt-spin.c (__pthread_spin_lock): Make a weak alias
- to _pthread_spin_lock.
- * sysdeps/posix/pt-spin.c (__pthread_spin_lock): Likewise.
-
-2005-01-18 Neal H. Walfield <neal@gnu.org>
-
- * sysdeps/mach/hurd/pt-sysdep.h (__pthread_stack_dealloc): Add
- __always_inline__ attribute.
- * sysdeps/l4/hurd/pt-sysdep.h (_pthread_self): Likewise.
- (__pthread_stack_dealloc): Likewise.
-
-2005-01-12 Pietro Ferrari <pietro@bastardi.net>
-
- * include/pthread/pthread.h (pthread_spin_destroy): Replace extern
- inline with extern __inline.
- (pthread_spin_init): Likewise.
- (pthread_spin_lock): Likewise.
- (pthread_spin_trylock): Likewise.
- (pthread_spin_unlock): Likewise.
- * sysdeps/mach/bits/spin-lock.h (__pthread_spin_lock): Likewise.
- * sysdeps/i386/bits/spin-lock.h (__pthread_spin_lock): Likewise.
- * sysdeps/generic/bits/mutex.h (__pthread_mutex_trylock):
- Likewise.
- (pthread_mutex_lock): Likewise.
- (pthread_mutex_trylock): Likewise.
- * sysdeps/generic/bits/pthread.h (pthread_equal): Likewise.
-
-2003-08-17 Marcus Brinkmann <marcus@gnu.org>
-
- * sysdeps/hurd/pt-key.h (PTHREAD_KEY_MEMBERS): Change type of
- THREAD_SPECIFICS to hurd_ihash_t.
- * sysdeps/hurd/pt-setspecific.c (pthread_setspecific): Call
- hurd_ihash_create instead ihash_create, and hurd_ihash_add instead
- ihash_add.
- * sysdeps/hurd/pt-getspecific.c (pthread_getspecific): Call
- hurd_ihash_find instead of ihash_find.
- * sysdeps/hurd/pt-destroy-specific.c (__pthread_destroy_specific):
- Call hurd_ihash_find instead of ihash_find, hurd_ihash_remove
- instead of ihash_remove, and hurd_ihash_free instead of
- ihash_free.
-
-2003-08-03 Marco Gerards <metgerards@student.han.nl>
-
- * Makefile (install): Do not install from $(srcdir).
-
-2002-11-26 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-create.c [HAVE_USELOCAL]: Include <locale.h>.
- (entry_point) [HAVE_USELOCALE]: Initialize the thread to the
- global locale.
-
-2002-11-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/mach/hurd/i386/pt-setup.c (__pthread_setup): Fix last
- change.
-
-2002-11-18 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/mach/pt-wakeup.c (__pthread_wakeup): Use the size of
- THREAD->wakeupmsg which may not be a mach_msg_header_t.
-
- * sysdeps/generic/pt-mutex-timedlock.c
- (__pthread_mutex_timedlock_internal): Really test for equality.
- * sysdeps/generic/pt-rwlock-timedrdlock.c
- (__pthread_rwlock_timedrdlock_internal): Likewise.
- * sysdeps/generic/pt-rwlock-timedwrlock.c
- (__pthread_rwlock_timedwrlock_internal): Likewise.
-
- * sysdeps/generic/pt-cond-timedwait.c
- (__pthread_cond_timedwait_internal): On timeout, remove our thread
- structure from the wait queue if necessary.
-
- * sysdeps/l4/pt-start.c (__pthread_start): Call L4_Myself, not
- __mach_thread_self.
-
- * sysdeps/mach/hurd/i386/pt-setup.c: Include <mach.h>.
- (__pthread_setup): Do not leak references from __mach_thread_self.
- * sysdeps/mach/hurd/pt-docancel.c (__pthread_do_cancel): Likewise.
- * sysdeps/mach/hurd/pt-sysdep.h (_pthread_self): Likewise.
- * sysdeps/mach/pt-thread-alloc.c (__pthread_thread_alloc): Likewise.
- * sysdeps/mach/pt-thread-start.c (__pthread_thread_start): Likewise.
-
- * sysdeps/mach/pt-start.c: Remove dead file.
-
-2002-11-09 Roland McGrath <roland@frob.com>
-
- * include/pthread/pthread.h: Avoid `__thread' as an identifier,
- since it might be a keyword.
-
-2002-11-02 Alfred M. Szmidt <ams@kemisten.nu>
-
- * sysdeps/generic/pt-key-delete.c, sysdeps/hurd/pt-key-delete.c
- (pthread_key_delete): Renamed from pthread_key_destroy.
- Reported by Michael Koch <konqueror@gmx.de>
-
-2002-10-12 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/hurd/pt-destroy-specific.c (__pthread_destroy_specific):
- Only call the destructor if there is one set.
-
-2002-10-10 Neal H. Walfield <neal@cs.uml.edu>
-
- * libpthread.a: It is _cthread_init_routine, not _cthread_init.
- Add -lihash.
- * libpthread_pic.a: Likewise but add -lihash_pic.
-
- * tests/Makefile (%-static): New rule.
- (CHECK_PROGS): Build static test programs.
-
-2002-10-10 Neal H. Walfield <neal@cs.uml.edu>
-
- * Makefile (install): Add $(libdir)/libpthread2.a and
- $(libdir)/libpthread2_pic.a.
- (.PHONY): Likewise.
- ($(libdir)/libpthread2.a): New rule.
- ($(libdir)/libpthread2_pic.a): Likewise.
-
- * libpthread_pic.a: New file.
- * libpthread.a: New file.
-
-2002-10-10 Neal H. Walfield <neal@cs.uml.edu>
-
- * Makefile (SRCS): Remove pt-errno.c.
- * sysdeps/mach/hurd/pt-errno.c: Removed.
- * sysdeps/l4/hurd/pt-errno.c: Removed.
-
-2002-10-10 Neal H. Walfield <neal@cs.uml.edu>
-
- * include/lock-intern.h: Removed. Use the one provided by glibc.
- * Makefile (sysdeps_headers): Remove lock-intern.h.
-
-2002-10-10 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/mach/hurd/i386/pt-setup.c (stack_setup): Save the thread
- pointer using the __hurd_threadvar routines; not a the top of the
- stack.
- * sysdeps/mach/hurd/pt-sysdep.h (_HURD_THREADVAR_THREAD): New
- marcro.
- (_pthread_self): Use __hurd_threadvar_location to access the self
- pointer.
- * sysdeps/mach/hurd/pt-sysdep.c (init_routine): Likewise. Update
- the calculation of __hurd_threadvar_stack_offset.
-
-2002-10-10 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-alloc.c (alloc_init): Removed.
- (__pthread_alloc): Allocate __pthread_threads lazily.
-
- * sysdeps/hurd/pt-getspecific.c (pthread_getspecific): Add an
- assert.
-
-2002-09-28 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/pt-cond-timedwait.c
- (__pthread_cond_timedwait_internal): Add definition.
- * sysdeps/generic/pt-rwlock-rdlock.c
- (__pthread_rwlock_timedrdlock_internal): Define this ...
- (__pthread_mutex_timedlock_internal): ... not this.
- * sysdeps/generic/pt-rwlock-wrlock.c
- (__pthread_rwlock_timedwrlock_internal): Add an extern.
-
-2002-09-28 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/mach/hurd/pt-sysdep.h (_pthread_self): Assert that
- __pthread_threads is initialized.
-
- (__pthread_self): Beautify.
-
-2002-09-28 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/mach/hurd/pt-sysdep.c (init_routine): Only call
- __pthread_initialize once.
-
-2002-09-28 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/pt-cond-init.c (pthread_cond_init): Only assert
- that ATTR->pshared is PTHREAD_PROCESS_PRIVATE if ATTR is not NULL.
- Reported by Manuel Menal <mmenal@netcourrier.com>.
-
-2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/bits/mutex.h (__PTHREAD_MUTEX_INITIALIZER):
- Initialize the LOCKS member of struct __pthread_mutex to 0, not
- NULL.
-
-2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/bits/mutex.h (struct __pthread_mutex): New
- field, cthreadcompat1: cthreads does not initialize the third
- field of a mutex and as a result, neither does glibc. Avoid
- this pit.
- (__PTHREAD_MUTEX_INITIALIZER): Initialize cthreadcompat1 to 0.
-
-2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
-
- * Makefile ($(addprefix $(includedir)/, $(sysdeps_headers))): Do
- not prepend ${srcdir}.
-
-2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-internal.h (__pthread_enqueue): New function.
- (__pthread_dequeue): New function.
- (__pthread_queue_iterate): New macro.
- (__pthread_dequeuing_iterate): New macro.
-
- * sysdeps/generic/pt-barrier-wait.c (pthread_barrier_wait): Use
- the new convenience functions.
- * sysdeps/generic/pt-cond-brdcast.c (pthread_cond_broadcast):
- Likewise.
- * sysdeps/generic/pt-cond-signal.c (cond_signal): Likewise.
- * sysdeps/generic/pt-cond-timedwait.c
- (__pthread_cond_timedwait_internal): Likewise.
- * sysdeps/generic/pt-mutex-timedlock.c
- (__pthread_mutex_timedlock_internal): Likewise.
- * sysdeps/generic/pt-mutex-unlock.c (__pthread_mutex_unlock):
- Likewise.
- * sysdeps/generic/pt-rwlock-timedrdlock.c
- (__pthread_rwlock_timedrdlock_internal): Likewise.
- * sysdeps/generic/pt-rwlock-timedwrlock.c
- (__pthread_rwlock_timedwrlock_internal): Likewise.
- * sysdeps/generic/pt-rwlock-unlock.c (pthread_rwlock_unlock):
- Likewise.
-
- * pthread/pt-alloc.c (initialize_pthread): Initialize the next and
- prevp pointers to 0.
-
-2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
-
- * tests/Makefile (CFLAGS): New variable.
-
-2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/pt-mutex-timedlock.c (pthread_mutex_timedlock):
- Call __pthread_mutex_timedlock_internal, not
- pthread_mutex_timedlock.
-
-2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-internal.h (__pthread_rwlock_unlock): Remove obsolete
- definition.
- * pthread/pt-alloc.c (__pthread_alloc): Use pthread_rwlock_wrlock
- and pthread_rwlock_unlock, not __pthread_rwlock_wrlock and
- __pthread_rwlock_unlock.
- * pthread/pt-create.c (__pthread_create_internal): Use
- pthread_rwlock_rdlock and pthread_rwlock_unlock, not
- __pthread_rwlock_rdlock and __pthread_rwlock_unlock.
- * sysdeps/generic/pt-cond-timedwait.c (pthread_cond_timedwait):
- Call __pthread_cond_timedwait_internal, not
- __pthread_cond_timedwait.
-
-2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-internal.h (__pthread_mutex_timedlock): Remove
- definition.
- (__pthread_rwlock_timedrdlock): Likewise.
- (__pthread_rwlock_timedwrlock): Likewise.
- (__pthread_cond_timedwait): Likewise.
- * include/pthread/pthread.h (pthread_mutex_timedlock): Remove
- verbage about GNU extension.
- (pthread_cond_timedwait): Likewise.
- (pthread_rwlock_timedrdlock): Likewise.
- (pthread_rwlock_timedwrlock): Likewise.
-
- * sysdeps/generic/pt-rwlock-timedrdlock.c
- (__pthread_rwlock_timedrdlock_internal): Renamed from
- __pthread_rwlock_timedrdlock.
- (pthread_rwlock_timedrdlock): New function. Remove weak alias.
- * sysdeps/generic/pt-rwlock-rdlock.c
- (__pthread_mutex_timedlock_internal): New definition.
- (pthread_rwlock_rdlock): Renamed from __pthread_rwlock_rdlock.
- Use __pthread_rwlock_timedlock_internal. Remove weak alias.
-
- * sysdeps/generic/pt-cond-timedwait.c
- (__pthread_cond_timedwait_internal): Rename from
- __pthread_cond_timedwait. Remove weak aliases.
- (pthread_cond_timedwait): New function.
- * sysdeps/generic/pt-cond-wait.c
- (__pthread_cond_timedwait_internal): New definition.
- (pthread_cond_wait): Use it.
-
- * sysdeps/generic/pt-mutex-timedlock.c
- (__pthread_mutex_timedlock_internal): Rename from
- __pthread_mutex_timedlock. Remove weak alias.
- (pthread_mutex_timedlock): New function.
- * sysdeps/generic/pt-mutex-lock.c
- (__pthread_mutex_timedlock_internal): New definition.
- (__pthread_mutex_lock): Use it.
-
- * sysdeps/generic/pt-rwlock-timedwrlock.c
- (__pthread_rwlock_timedwrlock_internal): Rename from
- __pthread_rwlock_timedwrlock.
- (pthread_rwlock_timedwrlock): New function. Remove weak alias.
- * sysdeps/generic/pt-rwlock-wrlock.c
- (__pthread_mutex_timedlock_internal): New definition.
- (pthread_rwlock_wrlock): Renamed from __pthread_rwlock_wrlock.
- Use __pthread_rwlock_timedlock_internal. Remove weak alias.
-
- * sysdeps/generic/pt-rwlock-tryrdlock.c
- (pthread_rwlock_tryrdlock): Rename from
- __pthread_rwlock_tryrdlock. Remove weak alias.
- * sysdeps/generic/pt-rwlock-trywrlock.c
- (pthread_rwlock_trywrlock): Rename from
- __pthread_rwlock_trywrlock. Remove weak alias.
-
- * sysdeps/hurd/pt-kill.c (pthread_kill): Rename from
- __pthread_kill. Remove weak alias.
- * sysdeps/generic/pt-atfork.c (pthread_atfork): Rename from
- __pthread_atfork. Remove weak alias.
-
-2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-internal.h (__pthread_create_internal): Renamed from
- __pthread_create. Updated all callers. Suggested by Roland
- McGrath.
-
-2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
-
- * Makefile: New file.
- * tests/Makefile: New file.
-
-2002-09-27 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/bits/barrier.h: Include <bits/spin-lock.h>.
- (struct __pthread_barrier): Change lock to a __pthread_spinlock_t:
- pthread_spinlock_t may not be defined in this context.
-
-2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/bits/once.h (__PTHREAD_ONCE_INIT): Be standards
- compliant: do not cast the result.
-
-2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-join.c (pthread_join): Fix typo in previous change.
-
-2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/bits/barrier.h (struct __pthread_barrier): Add
- new members attr and data.
- * sysdeps/generic/pt-barrier-init.c: Inlucde <string.h>.
- (pthread_barrier_init): Set *BARRIER to zero.
-
- * sysdeps/generic/bits/condition.h (__PTHREAD_COND_INITIALIZER):
- Initialize all fields.
-
- * sysdeps/generic/bits/mutex.h (__pthread_mutex): Rename
- cthread_compat1 to data.
- (pthread_mutex_destroy): Avoid
- inline version if __MUTEX->data is not NULL.
- (__pthread_mutex_lock): Likewise.
- (__pthread_mutex_trylock): Likewise.
-
- * sysdeps/generic/bits/rwlock.h: New member __attr.
- (__PTHREAD_RWLOCK_INITIALIZER): Initialize it to zero.
- (pthread_rwlock_destroy): Avoid inline version if __RWLOCK->__data
- is not NULL.
-
-2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-join.c (pthread_join): Protect PTHREAD->state_lock
- inconsistency due to cancelation.
-
-2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/bits/pthread.h (pthread_equal): Change from
- static inline to extern inline.
- * sysdeps/generic/pt-equal.c: New file.
- * Makefile.am (libpthread_a_SOURCES): Add pt-equal.c.
-
-2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
-
- * include/pthread/pthread.h (pthread_mutex_getprioceiling): New
- definition.
- (pthread_mutex_setprioceiling): New definition.
- (pthread_getschedparam): New definition.
- (pthread_setschedparam): New definition.
- (pthread_setschedprio): New definition.
-
- * sysdeps/generic/pt-getschedparam.c: New file.
- * sysdeps/generic/pt-mutex-getprioceiling.c: New file.
- * sysdeps/generic/pt-mutex-setprioceiling.c: New file.
- * sysdeps/generic/pt-setschedparam.c: New file.
- * sysdeps/generic/pt-setschedprio.c: New file.
- * Makefile.am (libpthread_a_SOURCES): Add pt-getschedparam.c,
- pt-mutex-getprioceiling.c, pt-mutex-setprioceiling.c,
- pt-setschedparam.c and pt-setschedprio.c.
-
-2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/Makefile.glibc: Removed.
- * pthread/pthread.patch: Removed.
-
-2002-09-26 Neal H. Walfield <neal@cs.uml.edu>
-
- * include/pthread/pthread.h (pthread_getcpuclockid): New
- definition.
- * sysdeps/generic/pt-getcpuclockid.c: New file.
- * Makefile.am (libpthread_a_SOURCES): Add pt-getcpuclockid.c.
-
-2002-09-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * include/pthread/pthread.h (pthread_kill): New definition.
- * sysdeps/hurd/pt-kill.c (__pthread_kill): New file.
- * Makefile.am (libpthread_a_SOURCES): Add pt-kill.c.
-
- * tests/Makefile.am (check_PROGRAMS): Add test-16.
- (TEST_COUNT): Bump to 16.
- (MOSTLYCLEANFILES): Add test-16.out.
- (test_16_SOURCES): New variable.
-
- * tests/test-16.c: New file.
-
-2002-09-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/pt-attr.c: Include <sched.h>.
-
-2002-09-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * tests/Makefile.am (check_PROGRAMS): Remove test-5.
- Unintentionally checked in.
-
-2002-09-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * include/pthread/pthread.h (pthread_atfork): New definition.
- * sysdeps/generic/pt-atfork.c: New file.
-
- * Makefile.am (libpthread_a_SOURCES): Add pt-atfork.c.
-
-2002-09-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-internal.h (__pthread_rwlock_rdlock): New definition.
- (__pthread_rwlock_timedrdlock): New definition.
- (__pthread_rwlock_wrlock): New definition.
- (__pthread_rwlock_timedwrlock): New definition.
- (__pthread_rwlock_unlock): New definition.
-
-2002-09-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-internal.h (__pthread_timedblock): New definition.
- * sysdeps/mach/pt-timedblock.c: New file.
-
- * include/pthread/pthread.h (pthread_mutex_timedlock): New
- definition.
- (pthread_cond_timedwait): Enable unconditionally.
- (pthread_rwlock_timedrdlock): New definition.
- (pthread_rwlock_timedwrlock): New definition.
-
- * sysdeps/generic/pt-mutex-timedlock.c: New file.
- * sysdeps/generic/pt-mutex-lock.c (__pthread_mutex_lock):
- Reimplement in terms of __pthread_mutex_timedlock.
-
- * sysdeps/generic/pt-cond-timedwait.c: New file.
- * sysdeps/generic/pt-cond-wait.c (pthread_cond_wait): Reimplement
- in terms of pthread_cond_timedwait.
-
- * sysdeps/generic/pt-rwlock-timedrdlock.c: New file.
- * sysdeps/generic/pt-rwlock-rdlock.c
- (__pthread_rwlock_rdlock): Reimplement in terms of
- __pthread_rwlock_timedrdlock.
-
- * sysdeps/generic/pt-rwlock-timedwrlock.c: New file.
- * sysdeps/generic/pt-rwlock-wrlock.c (__pthread_rwlock_wrlock):
- Reimplement in terms of __pthread_rwlock_timedwrlock.
-
- * sysdeps/generic/pt-cond-signal.c (cond_signal): Clear the
- previous pointer of the thread which we decide to wake up.
-
- * Makefile.am (libpthread_a_SOURCES): Add pt-mutex-lock.c,
- pt-mutex-trylock.c, pt-mutex-timedlock.c, pt-rwlock-timedrdlock.c,
- pt-rwlock-timedwrlock.c, pt-cond-timedwait.c and pt-timedblock.c.
-
- * tests/Makefile.am (check_PROGRAMS): Add test-13, test-14 and
- test-15.
- (TEST_COUNT): Bump to 15.
- (MOSTLYCLEANFILES): Add test-13.out, test-14.out and test-15.out.
- (test_13_SOURCES): New variable.
- (test_14_SOURCES): New variable.
- (test_15_SOURCES): New variable.
- * tests/test-13.c: New file.
- * tests/test-14.c: New file.
- * tests/test-15.c: New file.
-
-2002-09-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * include/pthread/pthread.h: Include <bits/condition-attr.h>
- (pthread_condattr_t): New type.
- (pthread_condattr_init): New definition.
- (pthread_condattr_destroy): New definition.
- (pthread_condattr_getclock): New definition.
- (pthread_condattr_setclock): New definition.
- (pthread_condattr_getpshared): New definition.
- (pthread_condattr_setpshared): New definition.
- (pthread_cond_init): New definition.
- (pthread_cond_destroy): New definition.
- * pthread/pt-internal.h (__pthread_default_condattr): New
- definition.
-
- * sysdeps/generic/pt-cond-destroy.c: New file.
- * sysdeps/generic/pt-cond-init.c: New file.
- * sysdeps/generic/pt-cond.c: New file.
- * sysdeps/generic/pt-condattr-destroy.c: New file.
- * sysdeps/generic/pt-condattr-getclock.c: New file.
- * sysdeps/generic/pt-condattr-getpshared.c: New file.
- * sysdeps/generic/pt-condattr-init.c: New file.
- * sysdeps/generic/pt-condattr-setclock.c: New file.
- * sysdeps/generic/pt-condattr-setpshared.c: New file.
- * sysdeps/generic/bits/condition-attr.h: New file.
- * Makefile.am (libpthread_a_SOURCES): Add pt-cond.c,
- pt-condattr-init.c, pt-condattr-destroy.c, pt-condattr-getclock.c,
- pt-condattr-getpshared.c, pt-condattr-setclock.c,
- pt-condattr-setpshared.c, pt-cond-destroy.c and pt-cond-init.c.
- * headers.m4 (hurd_SYSDEPS): Add bits/condition-attr.h.
-
-2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/pt-cond-wait.c (pthread_cond_wait): If canceled,
- be sure to disconnect ourself from the waiters' queue.
-
-2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/mach/hurd/pt-docancel.c (__pthread_do_cancel): Before
- overwriting the thread's state, abort any system call in progress.
-
-2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/pt-cond-wait.c (pthread_cond_wait): Rewrite
- cancelation support.
-
-2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/pt-cond-wait.c (pthread_cond_wait): Before
- returning add a cancelation point.
-
-2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
-
- * include/pthread/pthread.h (pthread_setconcurrency): New
- definition.
- (pthread_getconcurrency): New definition.
-
- * pthread/pt-internal.h (__pthread_concurrency): New definition.
-
- * sysdeps/generic/pt-getconcurrency.c: New file.
- * sysdeps/generic/pt-setconcurrency.c: New file.
-
- * Makefile.am (libpthread_a_SOURCES): Add pt-getconcurrency.c and
- pt-setconcurrency.c.
-
- * tests/Makefile.am (check_PROGRAMS): Add test-12.
- (TEST_COUNT): Bump to 12.
- (MOSTLYCLEANFILES): Add test-12.out.
- (test_12_SOURCES): New variable.
- * tests/test-12.c: New file.
-
-2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/hurd/pt-key.h (__pthread_key_lock_ready): New function.
- Initialize the __pthread_key_lock.
- * sysdeps/hurd/pt-key-create.c (__pthread_key_lock): Do not
- initialize it.
- (pthread_key_create): Do it here by calling
- __pthread_key_lock_ready.
- * sysdeps/hurd/pt-key-delete.c (pthread_key_destory): Call
- __pthread_key_lock_ready.
- * sysdeps/hurd/pt-destroy-specific.c (__pthread_destroy_specific):
- Likewise.
-
-2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
-
- * include/pthread/pthread.h: Include <bits/rwlock-attr.h>.
- (pthread_rwlockattr_t): New type.
- (pthread_rwlockattr_init): New definition.
- (pthread_rwlockattr_destroy): New definition.
- (pthread_rwlockattr_getpshared): New definition.
- (pthread_rwlockattr_setpshared): New definition.
-
- Include <bits/rwlock.h>.
- (pthread_rwlock_t): New type.
-
- (pthread_rwlock_init): New definition.
- (pthread_rwlock_destroy): New definition.
- (pthread_rwlock_rdlock): New definition.
- (pthread_rwlock_tryrdlock): New definition.
- (pthread_rwlock_wrlock): New definition.
- (pthread_rwlock_trywrlock): New definition.
- (pthread_rwlock_unlock): New definition.
-
- * pthread/pt-internal.h (pthread_rwlock_t): Remove macro.
- (__pthread_rwlock_rlock): Remove macro.
- (__pthread_rwlock_wlock): Remove macro.
- (__pthread_rwlock_unlock): Remove macro.
-
- (__pthread_default_rwlockattr): New definition.
-
- * pthread/pt-alloc.c (__pthread_alloc): Use
- __pthread_rwlock_wrlock, not __pthread_rwlock_wlock.
- * pthread/pt-create.c (__pthread_create): Use
- __pthread_rwlock_rdlock, not __pthread_rwlock_rlock.
-
- * sysdeps/generic/pt-rwlock-attr.c: New file.
- * sysdeps/generic/pt-rwlock-destroy.c: New file.
- * sysdeps/generic/pt-rwlock-init.c: New file.
- * sysdeps/generic/pt-rwlock-rdlock.c: New file.
- * sysdeps/generic/pt-rwlock-tryrdlock.c: New file.
- * sysdeps/generic/pt-rwlock-trywrlock.c: New file.
- * sysdeps/generic/pt-rwlock-unlock.c: New file.
- * sysdeps/generic/pt-rwlock-wrlock.c: New file.
- * sysdeps/generic/pt-rwlockattr-destroy.c: New file.
- * sysdeps/generic/pt-rwlockattr-getpshared.c: New file.
- * sysdeps/generic/pt-rwlockattr-init.c: New file.
- * sysdeps/generic/pt-rwlockattr-setpshared.c: New file.
- * sysdeps/generic/bits/rwlock-attr.h: New file.
- * sysdeps/generic/bits/rwlock.h: New file.
-
- * headers.m4 [hurd_SYSDEPS]: Add bits/rwlock.h and
- bits/rwlock-attr.h.
-
- * Makefile.am (libpthread_a_SOURCES): Add pt-rwlock-attr.c,
- pt-rwlockattr-init.c, pt-rwlockattr-destroy.c,
- pt-rwlockattr-getpshared.c, pt-rwlockattr-setpshared.c,
- pt-rwlock-init.c, pt-rwlock-destroy.c, pt-rwlock-rdlock.c,
- pt-rwlock-tryrdlock.c, pt-rwlock-trywrlock.c, pt-rwlock-wrlock.c
- and pt-rwlock-unlock.c.
-
- * tests/Makefile.am (check_PROGRAMS): Add test-11.
- (TEST_COUNT): Bump to 11.
- (MOSTLYCLEANFILES): Add test-11.out.
- (test_11_SOURCES): New variable.
- * tests/test-11.c: New file.
-
-2002-09-24 Neal H. Walfield <neal@cs.uml.edu>
-
- * Makefile.am (SYSDEPS) [L4]: Removed crt0.c.
-
- * crt0.c: Moved to ../libc/crt0.c.
-
-2002-09-23 Neal H. Walfield <neal@cs.uml.edu>
-
- * Makefile.am (libpthread_a_SOURCES): Add pt-mutexattr.c,
- pt-mutexattr-destroy.c, pt-mutexattr-init.c,
- pt-mutexattr-getprioceiling.c, pt-mutexattr-getprotocol.c,
- pt-mutexattr-getpshared.c, pt-mutexattr-gettype.c,
- pt-mutexattr-setprioceiling.c, pt-mutexattr-setprotocol.c,
- pt-mutexattr-setpshared.c, pt-mutexattr-settype.c,
- pt-mutex-init.c, pt-mutex-destroy.c and pt-mutex-trylock.c.
-
- * headers.m4 [hurd_SYSDEPS]: Add bits/mutex-attr.h.
-
- * include/pthread/pthread.h: Include <bits/mutex-attr.h>.
- (__pthread_mutex_protocol): New enumeration.
- (__pthread_mutex_type): New enumeration.
- (pthread_mutexattr_t): New type.
- (pthread_mutexattr_init): New definition.
- (pthread_mutexattr_destroy): New definition.
- (pthread_mutexattr_getprioceiling): New definition.
- (pthread_mutexattr_setprioceiling): New definition.
- (pthread_mutexattr_getprotocol): New definition.
- (pthread_mutexattr_setprotocol): New definition.
- (pthread_mutexattr_getpshared): New definition.
- (pthread_mutexattr_setpshared): New definition.
- (pthread_mutexattr_gettype): New definition.
- (pthread_mutexattr_settype): New definition.
-
- * pthread/pt-internal.h (__pthread_default_mutexattr): New
- definition.
-
- * sysdeps/generic/bits/mutex.h: Include <bits/mutex-attr.h>.
- (struct __pthread_mutex): Add member OWNER and member LOCKS to
- support error checking and recursive mutexes. Renamed __attr to
- attr, updated users.
- (pthread_mutexattr_t): Removed.
- (__PTHREAD_MUTEX_INITIALIZER): Add initializers for new members.
- (pthread_mutex_init): If ATTR, call _pthread_mutex_init.
- (pthread_mutex_destroy): If __MUTEX has an attribute, call
- _pthread_mutex_destroy.
- * sysdeps/generic/pt-mutex-lock.c (__pthread_mutex_lock): Grok
- mutex attribute.
- * sysdeps/generic/pt-mutex-unlock.c (__pthread_mutex_unlock):
- Likewise.
- Add a weak alias to _pthread_mutex_unlock.
-
- * sysdeps/generic/pt-mutex-destroy.c: New file.
- * sysdeps/generic/pt-mutex-init.c: New file.
- * sysdeps/generic/pt-mutex-trylock.c: New file.
- * sysdeps/generic/pt-mutexattr-destroy.c: New file.
- * sysdeps/generic/pt-mutexattr-getprioceiling.c: New file.
- * sysdeps/generic/pt-mutexattr-getprotocol.c: New file.
- * sysdeps/generic/pt-mutexattr-getpshared.c: New file.
- * sysdeps/generic/pt-mutexattr-gettype.c: New file.
- * sysdeps/generic/pt-mutexattr-init.c: New file.
- * sysdeps/generic/pt-mutexattr-setprioceiling.c: New file.
- * sysdeps/generic/pt-mutexattr-setprotocol.c: New file.
- * sysdeps/generic/pt-mutexattr-setpshared.c: New file.
- * sysdeps/generic/pt-mutexattr-settype.c: New file.
- * sysdeps/generic/pt-mutexattr.c: New file.
- * sysdeps/generic/bits/mutex-attr.h: New file.
-
- * tests/Makefile.am (AM_LDFLAGS): Add `-u__pthread_mutex_trylock
- -u__pthread_mutex_unlock -u__pthread_mutex_unlock'.
- (check_PROGRAMS): Add test-9 and test-10.
- (TEST_COUNT): Bump to 10.
- (MOSTLYCLEANFILES): Add test-9.out and test-10.out.
- (test_9_SOURCES): New variable.
- (test_10_SOURCES): Likewise.
- * tests/test-9.c: New file.
- * tests/test-10.c: New file.
-
-2002-09-23 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-exit.c (pthread_exit): Call pthread_setcancelstate
- correctly: NULL is not a legal value for the oldstate parameter.
-
-2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-exit.c: Remove dead code.
- (pthread_exit): When running the cancelation handlers, disable
- cancelation.
-
-2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
-
- * tests/test-5.c (main): Fork a child. Do not dump a core.
- (thr): Renamed from foo.
-
-2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-initialize.c (__pthread_init): Fully prototype it.
-
-2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
-
- * Makefile.am (libpthread_a_SOURCES): Add pt-sigmask.c,
- pt-stack-alloc.c, pt-thread-alloc.c, pt-thread-dealloc.c,
- pt-thread-start.c, pt-sigstate-init.c, pt-sigstate-destroy.c
- pt-sigstate.c.
- Remove pt-stack.c and pt-start.c.
-
- * pthread/pt-create.c (__pthread_create): Instead of calling
- __pthread_start, first call __pthread_thread_alloc, then setup the
- signal state and finally start the thread by calling
- __pthread_thread_start.
-
- * pthread/pt-exit.c (pthread_exit): Destroy any signal state by
- calling __pthread_sigstate_destroy.
-
- * pthread/pt-sigmask.c: New file.
-
- * pthread/pt-internal.c (__pthread_thread_halt): New definition to
- replace __pthread_halt macro. Update all callers.
- * sysdeps/mach/hurd/pt-sysdep.h (__pthread_halt): Renamed to
- __pthread_thread_halt and moved from here ...
- * sysdeps/mach/pt-thread-halt.c: ... to here.
- * sysdeps/l4/hurd/pt-sysdep.h (__pthread_halt): Renamed to
- __pthread_thread_halt and moved from here ...
- * sysdeps/l4/pt-thread-halt.c: ... to here.
-
- * pthread/pt-internal.h (__pthread_start): Split into
- __pthread_thread_alloc and __pthread_thread_start. Update all
- callers.
- (__pthread_thread_alloc): New definition.
- (__pthread_thread_start): Likewise.
- * sysdeps/l4/pt-start.c: Split file into ...
- * sysdeps/l4/pt-thread-alloc.c: ... this ...
- * sysdeps/l4/pt-thread-start.c: ... and this.
- * sysdeps/mach/pt-start.c: Split file into ...
- * sysdeps/mach/pt-thread-alloc.c: ... this ...
- * sysdeps/mach/pt-thread-start.c: ... and this.
-
- * sysdeps/l4/pt-stack.c: Moved from here ...
- * sysdeps/l4/pt-stack-alloc.c: ... to here.
- * sysdeps/mach/pt-stack.c: Moved from here ...
- * sysdeps/mach/pt-stack-alloc.c: ... to here.
-
- * pt-internal.h: Include <signal.h>.
- (__pthread_sigstate_init): New definition.
- (__pthread_sigstate_destroy): Likewise.
- (__pthread_sigstate): Likewise.
- * sysdeps/mach/hurd/pt-sigstate-destroy.c: New file.
- * sysdeps/mach/hurd/pt-sigstate-init.c: New file.
- * sysdeps/mach/hurd/pt-sigstate.c: New file.
-
- * sysdeps/mach/hurd/i386/pt-setup.c (__pthread_setup): Setup the
- initial thread state but only if THREAD is not the main thread.
-
-2002-09-17 Neal H. Walfield <neal@cs.uml.edu>
-
- Get signals working.
-
- * sysdeps/mach/hurd/pt-destroy-signal-state.c: Likewise.
- * sysdeps/mach/hurd/pt-init-signal-state.c: Likewise.
- * sysdeps/mach/hurd/pt-sigstate.c: Likewise.
-
-
- * pthread/pt-internal.h: Include <signal.h>.
- (__pthread_init_signal_state): New definition.
- (__pthread_destroy_signal_state): Likewise.
- (__pthread_sigstate): Likewise.
-
- * pthread/pt-create.c (pthread_create): Call
- __pthread_init_signal_state (and __pthread_destroy_signal_state on
- a failure). Also set the new thread's sigmask and pending signal
- state appropriately.
-
- * pthread/pt-exit.c (pthread_exit): Call
- __pthread_destroy_signal_state as appropriate.
-
-2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-alloc.c (__pthread_alloc): Factor out initialization
- code into ...
- (initialize_pthread): ... this new function.
-
- (__pthread_alloc): If reusing a thread structure fails, clean up
- the mess correctly.
-
-2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-alloc.c (__pthread_alloc): Revert last change.
-
-2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-alloc.c (__pthread_alloc): Remove assert.
-
-2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-initialize.c (__pthread_main): Removed. The added
- convenience does not help initialization and severely complicates
- the library if the the main thread calls pthread_exit.
- (__pthread_init): Remove parameter, thread.
- (__pthread_initialize): Updated to reflect new semantics.
- * pthread/pt-alloc.c (alloc_init): Update to new semantics. Do
- not try to initialize the main thread.
-
- * pthread/pt-create.c (__pthread_total): The main thread is now
- created explicitly, initialize to zero.
-
- * pthread/pt-internal.h (__pthread_num_threads): Add definition.
- (__pthread_main): Removed.
-
- * pthread/pt-internal.h (__pthread_create): New definition.
- * pthread/pt-create.c (pthread_create): Move functionality from
- here ...
- (__pthread_create): ... to here.
- (pthread_create): Use __pthread_create.
-
- * sysdeps/mach/hurd/pt-sysdep.c (init_routine): Use
- __pthread_create directly rather than rewriting the functionality
- here.
- * sysdeps/l4/hurd/pt-sysdep.c (init_routine): Likewise.
-
- * sysdeps/mach/pt-start.c (__pthread_start): Do not detect the
- main thread using __pthread_main. If main thread, set the kernel
- thread id.
- * sysdeps/l4/pt-start.c (__pthread_start): Likewise.
-
-2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/l4/hurd/pt-save-self.c (__pthread_save_self): Move
- functionality from here ...
- * sysdeps/l4/hurd/i386/pt-setup.c (__pthread_setup): ... to here
- where it belongs.
-
- * sysdeps/l4/hurd/pt-sysdep.c (init_routine): Do not save pthread
- self pointer here, it will be done automatically in
- __pthread_setup.
-
- __pthread_save_self is now obsolete.
-
- * pthread/pt-internal.h (__pthread_save_self): Remove definition.
- * sysdeps/mach/hurd/pt-save-self.c: Removed file.
- * sysdeps/l4/hurd/pt-save-self.c: Removed file.
- * Makefile.am (libpthread_a_SOURCES): Remove pt-save-self.c.
-
-2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-create.c (pthread_create): Do not call
- __pthread_save_self. This is completely bogus.
-
- * pthread/pt-internal.h: Permit _pthread_self to be a macro.
-
- * sysdeps/mach/hurd/pt-sysdep.h (__pthread_self): Renamed from
- _pthread_self.
- (_pthread_self): New marcro. Do some sanity checks.
-
-2002-09-21 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/mach/hurd/pt-sysdep.c (init_routine): We cannot use
- __hurd_threadvar_location with the initial stack. This is
- completely bogus; removed. Neither can we use the TSD on the new
- stack: once the initial thread returns to the libc initialization
- code, libc overwrites it. Thus, we shift the TSD by a pointer and
- use the first word of the stack to store the self pointer.
- * sysdeps/mach/hurd/pt-sysdep.h (_HURD_THREADVAR_THREAD): Removed.
- (_pthread_self): Update to reflect new semantics.
- * sysdeps/mach/hurd/pt-save-self.c (__pthread_save_self):
- Likewise.
- * sysdeps/mach/hurd/i386/pt-setup.c (stack_setup): Likewise.
-
-2002-09-17 Neal H. Walfield <neal@cs.uml.edu>
-
- * Makefile.am (AM_CPPFLAGS): Add -D_IO_MTSAFE_IO.
- (SYSDEPS) [MACH]: Add lockfile.c.
-
- * lockfile.c: Include <cthread.h>.
-
- * tests/Makefile.am (AM_LDFLAGS): Add -u_cthreads_flockfile to
- force the inclusion of lockfile.c.
-
-2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
-
- * tests/test-7.c: Include <stdio.h>.
-
-2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/cthreads-compat.c (__mutex_lock_solid): New function.
- (__mutex_unlock_solid): Likewise.
-
- * sysdeps/mach/pt-spin.c: New file.
- * sysdeps/mach/bits: New directory.
- * sysdeps/mach/bits/spin-lock.h: New file.
-
- * sysdeps/generic/bits/mutex.h: Add comments.
-
- * sysdeps/posix/pt-spin.c (_pthread_spin_lock): Renamed from
- __pthread_spin_lock. Update weak aliases to point to _pthread_spin
- lock in lieu of __pthread_spin_lock.
-
-2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
-
- * Makefile.am (AM_CPPFLAGS): Order more appropriately.
- (VPATH): Likewise.
-
-2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/bits/spin-lock.h: Move from here ...
- * sysdeps/i386/bits/spin-lock.h: ... to here.
-
-2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/cthreads-compat.c (__libc_getspecific): New function.
-
-2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/cthreads-compat.c (cthread_keycreate): New function.
- (cthread_getspecific): Likewise.
- (cthread_setspecific): Likewise.
-
-2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/bits/pthread.h (pthread_equal): Add comments.
-
-2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
-
- * tests/test-6.c: Include <stdio.h>.
- (main): Remove superfluous sleep.
-
-2002-09-16 Neal H. Walfield <neal@cs.uml.edu>
-
- * Makefile.am (libpthread_a_SOURCES): Add pt-once.c.
- * headers.m4 [hurd_SYSDEPS]: Add bits/once.h.
-
- * sysdeps/generic/pt-once.c: New file.
- * sysdeps/generic/bits/once.h: New file.
- * sysdeps/i386/bits/memory.h: New file.
-
- * include/pthread/pthread.h: Include <bits/once.h>.
- (PTHREAD_ONCE_INIT): New macro.
- (pthread_once): New definition.
-
- * tests/Makefile.am (AM_CFLAGS): Set to -Wall.
- (check_PROGRAMS): Add test-8.
- (TEST_COUNT): Bump to 8.
- (MOSTLYCLEANFILES): Add test-8.out.
- (test_8_SOURCES): New variable.
-
- * tests/test-8.c (main): New file.
-
-2002-09-15 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/mach/pt-stack.c (__pthread_stack_alloc): If we reach the
- end of the virtual address space, do not just fail but wrap
- around.
-
-2002-09-15 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/pt-destroy-specific.c: New file.
- * sysdeps/generic/pt-getspecific.c: Likewise.
- * sysdeps/generic/pt-init-specific.c: Likewise.
- * sysdeps/generic/pt-key-create.c: Likewise.
- * sysdeps/generic/pt-key-delete.c: Likewise.
- * sysdeps/generic/pt-key.h: Likewise.
- * sysdeps/generic/pt-setspecific.c: Likewise.
- * sysdeps/generic/bits/thread-specific.h: Likewise.
-
- * sysdeps/hurd: New directory for files that only depend on a Hurd
- personality (and not the underlying microkernel).
-
- * sysdeps/hurd/pt-destroy-specific.c: New file.
- * sysdeps/hurd/pt-getspecific.c: Likewise.
- * sysdeps/hurd/pt-init-specific.c: Likewise.
- * sysdeps/hurd/pt-key-create.c: Likewise.
- * sysdeps/hurd/pt-key-delete.c: Likewise.
- * sysdeps/hurd/pt-key.h: Likewise.
- * sysdeps/hurd/pt-setspecific.c: Likewise.
-
- * Makefile.am (AM_CPPFLAGS): Add -I$(srcdir)/sysdeps/hurd.
- (VPATH): Add $(srcdir)/sysdeps/hurd.
- (libpthread_a_SOURCES): Add pt-key.h, pt-destroy-specific.c,
- pt-init-specific.c, pt-key-create.c, pt-key-delete.c,
- pt-getspecific.c and pt-setspecific.c.
-
- * headers.m4 (hurd_SYSDEPS): Add thread_specific.h.
-
- * include/pthread/pthread.h: Include <bits/thread-specific>.
- (pthread_key_t): New definition.
- (pthread_key_create): Likewise.
- (pthread_key_delete): Likewise.
- (pthread_getspecific): Likewise.
- (pthread_setspecific): Likewise.
-
- * pthread/pt-internal.h: Include <pt-key.h>
- [! PTHREAD_KEY_MEMBERS]: Define it to be empty.
- (struct __pthread): Include the value of PTHREAD_KEY_MEMBERS.
-
- (__pthread_init_specific): New definition.
- (__pthread_destroy_specific): Likewise.
-
- * pthread/pt-alloc.c (__pthread_alloc): Call
- __pthread_init_specific.
- * pthread/pt-exit.c (pthread_exit): Call
- __pthread_destroy_specific.
-
- * tests/Makefile.am (LDADD): Add -lihash.
- (check_PROGRAMS): Add test-7.
- (MOSTLYCLEANFILES): Add test-7.out.
- (TEST_COUNT): Bump to 7.
- (test_7_SOURCES): New variable.
- * tests/test-7.c: New file.
-
-2002-09-15 Neal H. Walfield <neal@cs.uml.edu>
-
- * tests/test-6.c: Improve test; iterate WAIT times over
- pthread_barrier_wait rather than just once.
-
-2002-09-14 Neal H. Walfield <neal@cs.uml.edu>
-
- Add support for barrier attributes and barriers.
-
- * sysdeps/generic/pt-barrier-destroy.c: New file.
- * sysdeps/generic/pt-barrier-init.c: Likewise.
- * sysdeps/generic/pt-barrier-wait.c: Likewise.
- * sysdeps/generic/pt-barrier.c: Likewise.
- * sysdeps/generic/pt-barrierattr-destroy.c: Likewise.
- * sysdeps/generic/pt-barrierattr-getpshared.c: Likewise.
- * sysdeps/generic/pt-barrierattr-init.c: Likewise.
- * sysdeps/generic/pt-barrierattr-setpshared.c: Likewise.
- * sysdeps/generic/bits/barrier-attr.h: Likewise.
- * sysdeps/generic/bits/barrier.h: Likewise.
- * sysdeps/generic/bits/thread-barrier.h: Likewise.
-
- * Makefile.am (libpthread_a_SOURCES): Added pt-barrier-destroy.c,
- pt-barrier-init.c, pt-barrier-wait.c, pt-barrier.c,
- pt-barrierattr-destroy.c, pt-barrierattr-init.c,
- pt-barrierattr-getpshared.c and pt-barrierattr-setpshared.c.
-
- * headers.m4 (hurd_SYSDEPS): Added bits/barrier-attr.h and
- bits/barrier.h.
-
- * include/pthread/pthread.h: Include <bits/barrier-attr.h> and
- <bits/barrier.h>.
-
- (__pthread_process_shared): New enumeration.
- (PTHREAD_PROCESS_PRIVATE): New macro.
- (PTHREAD_PROCESS_SHARED): Likewise.
- (pthread_barrierattr_t): New typedef.
-
- (pthread_barrierattr_init): New definition.
- (pthread_barrierattr_destroy): Likewise.
- (pthread_barrierattr_getpshared): Likewise.
- (pthread_barrierattr_setpshared): Likewise.
-
- (pthread_barrier_t): New typedef.
- (PTHREAD_BARRIER_SERIAL_THREAD): New macro.
- (pthread_barrier_init): New declaration.
- (pthread_barrier_destroy): Likewise.
- (pthread_barrier_wait): Likewise.
-
- * pthread/pt-internal.h (__pthread_default_barrierattr): New
- definition.
-
- * tests/test-6.c: New file.
- * tests/Makefile.am (check_PROGRAMS): Add test-6.
- (MOSTLYCLEANFILES): Add test-6.out.
- (test_6_SOURCES): New variable.
- (TEST_COUNT): Update.
-
-2002-09-12 Neal H. Walfield <neal@cs.uml.edu>
-
- * tests/Makefile.am
- (check_PROGRAMS): Add test test-3 and test-5.
- (MOSTLYCLEANFILES): Add test-3.out, test-4.out and test-5.out.
- (TEST_COUNT): Change to 5.
- (test_3_SOURCES): New variable.
- (test_5_SOURCES): New variable.
- (check): Fix typo.
-
- * tests/test-3.c: New file.
- * tests/test-4.c: New file.
- * tests/test-5.c: New file.
-
-2002-09-12 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/mach/hurd/pt-attr-setstackaddr.c: New file.
- * sysdeps/mach/hurd/pt-attr-setstacksize.c: New file.
- * sysdeps/mach/hurd/i386/pt-setup.c: New file.
-
- * sysdeps/mach/hurd/i386/pt-setup.c (stack_setup): Setup the stack
- guard if necessary.
-
-2002-09-12 Neal H. Walfield <neal@cs.uml.edu>
-
- Generic attributes.
-
- * sysdeps/generic/pt-attr-destroy.c: New file.
- * sysdeps/generic/pt-attr-getdetachstate.c: New file.
- * sysdeps/generic/pt-attr-getguardsize.c: New file.
- * sysdeps/generic/pt-attr-getinheritsched.c: New file.
- * sysdeps/generic/pt-attr-getschedparam.c: New file.
- * sysdeps/generic/pt-attr-getschedpolicy.c: New file.
- * sysdeps/generic/pt-attr-getscope.c: New file.
- * sysdeps/generic/pt-attr-getstack.c: New file.
- * sysdeps/generic/pt-attr-getstackaddr.c: New file.
- * sysdeps/generic/pt-attr-getstacksize.c: New file.
- * sysdeps/generic/pt-attr-init.c: New file.
- * sysdeps/generic/pt-attr-setdetachstate.c: New file.
- * sysdeps/generic/pt-attr-setguardsize.c: New file.
- * sysdeps/generic/pt-attr-setinheritsched.c: New file.
- * sysdeps/generic/pt-attr-setschedparam.c: New file.
- * sysdeps/generic/pt-attr-setschedpolicy.c: New file.
- * sysdeps/generic/pt-attr-setscope.c: New file.
- * sysdeps/generic/pt-attr-setstack.c: New file.
- * sysdeps/generic/pt-attr-setstackaddr.c: New file.
- * sysdeps/generic/pt-attr-setstacksize.c: New file.
- * sysdeps/generic/pt-attr.c: New file.
-
- * sysdeps/generic/bits/thread-attr.h: New file.
-
- * Makefile.am (libpthread_a_SOURCES): Add pt-attr.c,
- pt-attr-destroy.c, pt-attr-getdetachstate.c,
- pt-attr-getguardsize.c, pt-attr-getinheritsched.c,
- pt-attr-getschedparam.c, pt-attr-getschedpolicy.c,
- pt-attr-getscope.c, pt-attr-getstack.c, pt-attr-getstackaddr.c,
- pt-attr-getstacksize.c, pt-attr-init.c, pt-attr-setdetachstate.c,
- pt-attr-setguardsize.c, pt-attr-setinheritsched.c,
- pt-attr-setschedparam.c, pt-attr-setschedpolicy.c,
- pt-attr-setscope.c, pt-attr-setstack.c, pt-attr-setstackaddr.c,
- pt-attr-setstacksize.c and pt-attr.c.
-
- * headers.m4: Add bits/thread-attr.h.
-
- * include/pthread/pthread.h: Inlucde <bits/thread-attr.h>.
- (__pthread_inheritsched): New enumeration.
- (__pthread_contentionscop): Likewise.
- (__pthread_detachstate): Beautify.
-
- (pthread_attr_t): Update declaration.
-
- (pthread_attr_init): New definition.
- (pthread_attr_destroy): Likewise.
- (pthread_attr_getinheritsched): Likewise.
- (pthread_attr_setinheritsched): Likewise.
- (pthread_attr_getschedparam): Likewise.
- (pthread_attr_setschedparam): Likewise.
- (pthread_attr_getschedpolicy): Likewise.
- (pthread_attr_setschedpolicy): Likewise.
- (pthread_attr_getscope): Likewise.
- (pthread_attr_setscope): Likewise.
- (pthread_attr_getstackaddr): Likewise.
- (pthread_attr_setstackaddr): Likewise.
- (pthread_attr_getstack): Likewise.
- (pthread_attr_setstack): Likewise.
- (pthread_attr_getdetachstate): Likewise.
- (pthread_attr_setdetachstate): Likewise.
- (pthread_attr_getguardsize): Likewise.
- (pthread_attr_setguardsize): Likewise.
- (pthread_attr_getstacksize): Likewise.
- (pthread_attr_setstacksize): Likewise.
-
- * pthread/pt-internal.h (struct __pthread): New member, guardsize.
- (__pthread_default_attr): Make constant.
- (struct __pthread_attr): Moved definition from here ...
- * sysdeps/generic/bits/thread-attr.h: ... to here.
- (struct __pthread_attr): Add new members: guardsize, inheritsched,
- contentionscope and schedpolicy.
-
- * pthread/pt-attr.c: Moved from here ...
- * sysdeps/generic/pt-attr.c: ... to here.
- (__pthread_default_attr): Initialize new members guardsize,
- inheritsched, contentionscope and schedpolicy.
-
- * pthread/pt-create.c (pthread_create): Make SETUP constant.
- Sync with pthread_attr_t type change.
- Set PTHREAD->guardsize appropriately.
-
-2002-09-12 Neal H. Walfield <neal@cs.uml.edu>
-
- * tests/Makefile.am (AM_CPPFLAGS): Learn to spel.
-
-2002-09-12 Neal H. Walfield <neal@cs.uml.edu>
-
- * tests/test-2.c: Implement it.
-
-2002-09-11 Neal H. Walfield <neal@cs.uml.edu>
-
- * Makefile.am (SUBDIRS): New variable.
-
- * tests/Makefile.am: New file.
- * tests/test-1.c: file.
- * tests/test-2.c: file.
-
-2002-09-11 Neal H. Walfield <neal@cs.uml.edu>
-
- * include/libc-symbols.h: Do not define SHARED.
- * not-in-libc.h (__mach_port_allocate): New macro.
-
- * pthread/pt-alloc.c (__pthread_alloc): Add an assert.
-
- * sysdeps/generic/pt-mutex-unlock.c (__pthread_mutex_unlock):
- Simplify logic: WAKEUP is known not to be NULL after it is tested.
-
- * sysdeps/mach/pt-start.c (create_wakeupmsg): Do not allocate a
- reply port; use a normal port.
- If __mach_port_insert_right fails, deallocate
- THREAD->wakeupmsg.msgh_remote_port.
-
-2002-09-11 Neal H. Walfield <neal@cs.uml.edu>
-
- * Makefile.am (libpthread_a_SOURCES): Add cthreads-compat.c.
-
-2002-08-26 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/mach/hurd/pt-errno.c: New file.
-
-2002-08-26 Neal H. Walfield <neal@cs.uml.edu>
-
- * include/pthread/pthread.h (pthread_mutexattr_t): Moved from here
- ..
- * sysdeps/generic/bits/mutex.h: ... to here.
-
-2002-08-26 Neal H. Walfield <neal@cs.uml.edu>
-
- * Makefile.am (SYSDEPS) [MACH]: Do not built lockfile.c.
- (include_HEADERS): List headers to be installed. Leave commented
- until it works with VPATH.
-
-2002-08-26 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/l4/pt-stack.c (allocate_page): Fix typo.
-
-2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/l4/pt-stack.c (allocate_page): Request the correct
- permissions for the request memory.
-
-2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/Makefile: Moved from here ...
- * pthread/Makefile.glibc: ... to here to avoid confusing automake.
-
-2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
-
- * Makefile.am (AM_CPPFLAGS): Fix the include paths.
- Implicitly include include/libc-symbols.h.
- (SYSDEPS) [L4]: Add crt0.c.
- (libpthread_a_SOURCES): Remove crt0.c.
-
- (VPATH): New variable.
- (libpthread_a_SOURCES): Depend on the VPATH; do not use absolute
- paths.
-
-2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/pt-cond-wait.c: Doc fix thanks to Marcus
- Brinkmann for pointing this out.
- * sysdeps/generic/pt-mutex-lock.c: Likewise.
-
-2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/mach/hurd/pt-sysdep.h (__thread_set_pcsp): Prototype new
- function.
- * sysdeps/mach/hurd/i386/pt-machdep.c (__thread_set_pcsp):
- Implement it.
- * sysdeps/mach/pt-start.c (__pthread_start): Use it.
-
-2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/l4/pt-stack.c: Remove comment about next_stack_base.
- This is baggage carried over from the Mach version.
- (allocate_page): Use L4_FpageLog2 properly.
-
-2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-internal.h (struct __pthread_attr): Add schedparam
- field.
- * pthread/pt-attr.c (__pthread_default_attr): Initialize
- schedparam field.
-
-2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-internal.h (__pthread_do_cancel): Add prototype.
-
-2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-alloc.c (alloc_init): Make static and use RUN_HOOK.
- * pthread/pt-initialize.c (__pthread_initialize): Remove the hack
- and use RUN_HOOK.
-
-2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-create.c: Include <signal.h>.
-
-2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/mach/hurd/pt-docancel.c: New file.
- * sysdeps/mach/hurd/pt-save-self.c: New file.
-
-2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
-
- * include/pthread/pthread.h: Include <sched.h> and <time.h>.
- (pthread_mutexattr_t): Add prototype.
- (pthread_mutex_init): Likewise.
- (pthread_mutex_destroy): Likewise.
-
- * sysdeps/generic/bits/mutex.h (pthread_mutex_init): New function.
- (pthread_mutex_destroy): New function.
-
- * sysdeps/generic/bits/pthread.h (pthread_equal): New function.
-
-2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-setcancelstate.c (pthread_setcancelstate): Add
- explicit break to elide gcc warning.
- * pthread/pt-setcanceltype.c (pthread_setcanceltype): Likewise.
-
-2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
-
- * include/libc-symbols.h: Do not define _LIBC as we are not
- actually compiling glibc.
- (HAVE_ASM_WEAKEXT_DIRECTIVE): Do not define it.
- (HAVE_ASM_SET_DIRECTIVE): Define it.
- (HAVE_BUILTIN_EXPECT): Likewise.
- (HAVE_GNU_LD): Likewise.
- (HAVE_ELF): Likewise.
- (HAVE_SECTION_QUOTES): Likewise.
- (HAVE_VISIBILITY_ATTRIBUTE): Likewise.
- (SHARED): Likewise.
-
- * not-in-libc.h: New file.
- * Makefile.am (AM_CPPFLAGS): Include not-in-libc.h implicitly.
-
- * lockfile.c: New file.
- * Makefile.am (SYSDEPS) [MACH]: Add lockfile.c.
-
-2002-08-22 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/mach/hurd/bits/pthread.h: Removed. Used the generic
- version.
-
-2002-08-21 Neal H. Walfield <neal@cs.uml.edu>
-
- * headers.m4: Fix typo.
-
-2002-08-21 Neal H. Walfield <neal@cs.uml.edu>
-
- * include: Moved from libc/include except for include/sched.h and
- include/time.h.
- * pthread: Moved from libc/pthread.
- * sysdeps: Moved from libc/sysdeps except for
- sysdeps/i386/bits/atomic.h and sysdeps/hurd/hurd/threadvar.h.
- * crt0.c: Moved from libc/crt0.c.
-
- * sysdeps/generic/bits: Moved from include/bits except
- include/bits/wordsize.h.
- * include/pthread: Moved from include/pthread.
- * include/lock-intern.h: Moved from include/lock-intern.h.
- * include/pthread.h: Moved from include/pthread.h.
-
- * headers.m4: New file.
-
-2002-08-19 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/l4/pt-start.c [WORKING_EXREGS]: Ideal implementation.
-
-2002-08-05 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pthread.h (PTHREAD_SPINLOCK_INITIALIZER): New
- declaration.
-
-2002-08-03 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/l4/hurd/pt-sysdep.h (PTHREAD_SYSDEP_MEMBERS): Add
- my_errno.
- * sysdeps/l4/hurd/pt-errno.c: New file.
- * Makefile.am (libc_a_SOURCES): Added sysdeps/l4/hurd/pt-errno.c.
-
-2002-07-29 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-internal.h (__pthread_save_self): New declaration.
- Dual of _pthread_self ().
- * sysdeps/l4/pt-save-self.c: New file.
- * Makefile.am (libc_a_SOURCES): Added
- sysdeps/l4/hurd/pt-save-self.c.
-
- * pthread/pt-create.c (pthread_create): Save the new thread's
- control block explicitly using __pthread_save_self.
- * sysdeps/l4/hurd/pt-sysdep.c (init_routine): Replace Hurd's
- threadvar code with __pthread_save_self.
- * sysdeps/l4/hurd/pt-sysdep.h (_pthread_self): Likewise.
- (_HURD_THREADVAR_THREAD): Removed macro.
- * sysdeps/l4/hurd/i386/pt-setup.c (stack_setup): Remove Hurd's
- threadvar code. Mechanism is now in _pthread_save_self.
-
-2002-07-29 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-internal.h (struct __pthread): Add fields
- cancel_state, cancel_type, cancel_pending and
- cancelation_handlers to support cancelation.
- * pthread/pt-alloc.c (__pthread_alloc): Initialize
- NEW->cancel_state, NEW->cancel_type, NEW->cancel_pending and
- NEW->cancelation_handlers.
- * pthread/pt-exit.c (pthread_exit): Run registered cleanup
- handlers. If thread was canceled, set the status to
- PTHREAD_CANCELED.
- * pthread/pt-cleanup.c: New file.
- * pthread/pt-setcancelstate.c: New file.
- * pthread/pt-setcanceltype.c: New file.
- * pthread/pt-testcancel.c: New file.
- * sysdeps/l4/pt-docancel.c: New file.
-
- * Makefile.am (libc_a_SOURCES): Add pthread/pt-cleanup.c,
- pthread/pt-setcancelstate.c, pthread/pt-setcanceltype.c,
- pthread/pt-testcancel.c and sysdeps/l4/pt-docancel.c.
-
-2002-07-29 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pthread.h (pthread_cleanup_push): Moved from here ...
- * bits/cancelation.h: ... to here.
- * pthread/pthread.h (pthread_cleanup_pop): Moved from here ...
- * bits/cancelation.h: ... to here.
-
- * pthread/pthread.h (pthread_cleanup_push): New definition.
- * pthread/pthread.h (pthread_cleanup_pop): New definition.
-
- * bits/cancelation.h: Include <assert.h>.
- * pthread/pthread.h: Do not include <assert.h>.
-
-2002-07-29 Neal H. Walfield <neal@cs.uml.edu>
-
- * bits/condition.h (__PTHREAD_COND_INITIALIZER): Cast result.
- * bits/mutex.h (__PTHREAD_MUTEX_INITIALIZER): Likewise.
- * bits/spin-lock.h (__SPIN_LOCK_INITIALIZER): Likewise.
-
-2002-07-29 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pthread.h: Include <bits/cancelation.h> and <assert.h>.
- (PTHREAD_CANCEL_DISABLE): New macro.
- (PTHREAD_CANCEL_ENABLE): New macro.
- (PTHREAD_CANCEL_DEFERRED): New macro.
- (PTHREAD_CANCEL_ASYNCHRONOUS): New macro.
- (PTHREAD_CANCELED): New macro.
- (pthread_setcancelstate): New definition.
- (pthread_setcanceltype): New definition.
- (pthread_cancel): New definition.
- (pthread_testcancel): New definition.
- (pthread_cleanup_push): New macro.
- (pthread_cleanup_pop): New macro.
- * bit/condition.h: New file.
-
-2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/l4/pt-block.c (__pthread_block): Receive from any local
- thread, not any thread.
-
-2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * crt0.c (exit): Print the exit value for debugging purposes.
-
-2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-alloc.c (__pthread_alloc): Improve comments. When
- allocating a new pthread, really initialize it.
- * pthread/pt-create.c (pthread_create): Reuse the old stacks when
- possible. If allocating the thread structure fails, do not try to
- free anything. Clear the thread id on failure. Beautify and add
- comments.
-
- * pthread/pt-dealloc.c (__pthread_dealloc): Rewritten to be the
- dual of __pthread_alloc rather than an all-in-one.
- * pthread/pt-detach.c (pthread_detach): Factor out code that is in
- __pthread_dealloc. Unlock PTHREAD->state_lock before calling
- __pthread_dealloc.
- * pthread/pt-exit.c (pthread_exit): Likewise.
- * pthread/pt-join.c (pthread_join): Likewise.
-
-2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-internal.h: Beautify and fix comments.
- (__pthread_setid): Get a write lock, not a read lock.
-
-2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pt-alloc.c (__pthread_alloc): (alloc_init): Make it an
- external, not static as RUN_HOOKS does not work yet.
- * pthread/pt-initialize.c (__pthread_initialize): Call alloc_init
- directly as RUN_HOOK does not yet work.
-
-2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/l4/hurd/pt-sysdep.c (init_routine): Be sure that
- __hurd_threadvar_stack_mask and __hurd_threadvar_stack_offset are
- set before calling __pthread_setup.
- * sysdeps/l4/hurd/i386/pt-setup.c (stack_setup): Elide hack and
- use __hurd_threadvar_location_from-sp.
-
-2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/generic/pt-cond-wait.c (pthread_cond_wait): Add
- comment about a race condition.
- * sysdeps/generic/pt-mutex-lock.c (__pthread_mutex_lock):
- Likewise.
-
-2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/l4/pt-start.c (send_startup_ipc): Use task_server (which
- is now also the thread_server). Do smarter casting.
- * sysdeps/l4/hurd/pt-sysdep.h (__pthread_halt): Likewise.
-
-2002-07-25 Neal H. Walfield <neal@cs.uml.edu>
-
- * sysdeps/l4/pt-wakeup.c: Fix comment.
-
-2002-07-24 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/Makefile: New file. Imported from Mark's pthread
- package with local modifications.
- * pthread/Versions: Likewise.
- * pthread/cthreads-compat.c: Likewise.
- * pthread/pt-alloc.c: Likewise.
- * pthread/pt-attr.c: Likewise.
- * pthread/pt-create.c: Likewise.
- * pthread/pt-dealloc.c: Likewise.
- * pthread/pt-detach.c: Likewise.
- * pthread/pt-exit.c: Likewise.
- * pthread/pt-initialize.c: Likewise.
- * pthread/pt-internal.h: Likewise.
- * pthread/pt-join.c: Likewise.
- * pthread/pt-self.c: Likewise.
- * pthread/pt-spin-inlines.c: Likewise.
- * pthread/pthread.patch: Likewise.
- * sysdeps/generic/pt-cond-brdcast.c: Likewise.
- * sysdeps/generic/pt-cond-signal.c: Likewise.
- * sysdeps/generic/pt-cond-wait.c: Likewise.
- * sysdeps/generic/pt-mutex-lock.c: Likewise.
- * sysdeps/generic/pt-mutex-unlock.c: Likewise.
- * sysdeps/hurd/hurd/threadvar.h: Likewise.
- * sysdeps/i386/machine-sp.h: Likewise.
- * sysdeps/i386/pt-machdep.h: Likewise.
- * sysdeps/i386/bits/atomic.h: Likewise.
- * sysdeps/l4/pt-block.c: Likewise.
- * sysdeps/l4/pt-stack.c: Likewise.
- * sysdeps/l4/pt-start.c: Likewise.
- * sysdeps/l4/pt-wakeup.c: Likewise.
- * sysdeps/l4/hurd/pt-sysdep.c: Likewise.
- * sysdeps/l4/hurd/pt-sysdep.h: Likewise.
- * sysdeps/l4/hurd/i386/pt-machdep.c: Likewise.
- * sysdeps/l4/hurd/i386/pt-setup.c: Likewise.
- * sysdeps/mach/pt-block.c: Likewise.
- * sysdeps/mach/pt-stack.c: Likewise.
- * sysdeps/mach/pt-start.c: Likewise.
- * sysdeps/mach/pt-wakeup.c: Likewise.
- * sysdeps/mach/hurd/pt-sysdep.c: Likewise.
- * sysdeps/mach/hurd/pt-sysdep.h: Likewise.
- * sysdeps/mach/hurd/bits/pthread.h: Likewise.
- * sysdeps/mach/hurd/i386/pt-machdep.c: Likewise.
- * sysdeps/mach/hurd/i386/pt-setup.c: Likewise.
- * sysdeps/posix/pt-spin.c: Likewise.
-
- * include/libc-symbols.h: Imported from glibc with local
- modifications for pthread port.
- * include/set-hooks.h: Likewise.
-
- * include/sched.h: Glue code for pthread port until a real
- implementation is available.
- * include/time.h: Likewise.
-
- * Makefile.am (libc_a_SOURCES): Added most of the above c files.
- (CFLAGS): Build up the include paths the way that glibc does.
-
- * TODO: New file.
-
- * crt0.c: Rewritten to include support for initializing pthreads
- and dealing with the new stack layout.
-
-2002-07-24 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pthread.h: Define pthread_spinlock_t.
- (pthread_spin_destroy): Use it, not __pthread_spinlock_t.
- (pthread_spin_init): Likewise.
- (pthread_spin_lock): Likewise.
- (pthread_spin_trylock): Likewise.
- (pthread_spin_unlock): Likewise.
-
- * features.h (__USE_XOPEN2K): Define it.
-
-2002-07-24 Neal H. Walfield <neal@cs.uml.edu>
-
- * pthread/pthread.h: New file imported from Mark's pthead package.
-
-2002-07-24 Neal H. Walfield <neal@cs.uml.edu>
-
- * bits/condition.h: New file imported from Mark's pthead package.
- * bits/mutex.h: Likewise.
- * bits/pthread.h: Likewise.
- * bits/spin-lock.h: Likewise.
-
-2002-07-23 Jeff Bailey <jbailey@outpost.dnsalias.org>
-
- * .cvsignore: New File
-
-2002-07-21 Neal H. Walfield <neal@cs.uml.edu>
-
- * crt0.c (_start): Put in .START section, not in the text.
-
-2002-07-17 Neal H. Walfield <neal@cs.uml.edu>
-
- * Makefile.am (AM_CFLAGS): Library is no longer called libcrt0 but
- libc. Adjust accordingly.
+ $ git show 51839d398b0f9885a17ab5c0768b8dec4dd9eb79:ChangeLog
diff --git a/Makefile b/Makefile
index ca63b97..a1801f5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
#
-# Copyright (C) 1994,95,96,97,2000,02, 2004, 2005, 2006, 2007
-# Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995, 1996, 1997, 2000, 2002, 2004, 2005, 2006, 2007,
+# 2008, 2011 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -45,6 +45,7 @@ SRCS := pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \
\
pt-alloc.c \
pt-create.c \
+ pt-getattr.c \
pt-equal.c \
pt-dealloc.c \
pt-detach.c \
@@ -70,6 +71,7 @@ SRCS := pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \
pt-mutex-init.c pt-mutex-destroy.c \
pt-mutex-lock.c pt-mutex-trylock.c pt-mutex-timedlock.c \
pt-mutex-unlock.c \
+ pt-mutex-transfer-np.c \
pt-mutex-getprioceiling.c pt-mutex-setprioceiling.c \
\
pt-rwlock-attr.c \
@@ -98,6 +100,7 @@ SRCS := pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \
pt-thread-dealloc.c \
pt-thread-start.c \
pt-thread-halt.c \
+ pt-startup.c \
\
pt-getconcurrency.c pt-setconcurrency.c \
\
@@ -119,6 +122,7 @@ SRCS := pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \
pt-getcpuclockid.c \
\
pt-getschedparam.c pt-setschedparam.c pt-setschedprio.c \
+ pt-yield.c \
\
sem-close.c sem-destroy.c sem-getvalue.c sem-init.c sem-open.c \
sem-post.c sem-timedwait.c sem-trywait.c sem-unlink.c \
@@ -136,13 +140,16 @@ libname = libpthread
sysdeps_headers = \
pthread.h \
pthread/pthread.h \
+ pthread/pthreadtypes.h \
semaphore.h \
\
bits/pthread.h \
+ bits/pthread-np.h \
bits/mutex.h \
bits/condition.h \
bits/condition-attr.h \
bits/spin-lock.h \
+ bits/spin-lock-inline.h \
bits/cancelation.h \
bits/thread-attr.h \
bits/barrier-attr.h \
@@ -154,12 +161,12 @@ sysdeps_headers = \
bits/rwlock-attr.h \
bits/semaphore.h
-SYSDEP_PATH = $(srcdir)/sysdeps/$(MICROKERNEL)/hurd/i386 \
- $(srcdir)/sysdeps/$(MICROKERNEL)/i386 \
+SYSDEP_PATH = $(srcdir)/sysdeps/$(MICROKERNEL)/hurd/ia32 \
+ $(srcdir)/sysdeps/$(MICROKERNEL)/ia32 \
+ $(srcdir)/sysdeps/ia32 \
$(srcdir)/sysdeps/$(MICROKERNEL)/hurd \
$(srcdir)/sysdeps/$(MICROKERNEL) \
$(srcdir)/sysdeps/hurd \
- $(srcdir)/sysdeps/i386 \
$(srcdir)/sysdeps/generic \
$(srcdir)/sysdeps/posix \
$(srcdir)/pthread \
@@ -169,16 +176,17 @@ VPATH += $(SYSDEP_PATH)
HURDLIBS = ihash
-CFLAGS := -D_IO_MTSAFE_IO \
+installhdrs :=
+installhdrsubdir := .
+
+include ../Makeconf
+
+CPPFLAGS += \
-DENABLE_TLS \
- $(addprefix -I, $(SYSDEP_PATH)) \
+ $(addprefix -I, $(SYSDEP_PATH)) \
-imacros $(srcdir)/include/libc-symbols.h \
-imacros $(srcdir)/not-in-libc.h
-installhdrs :=
-installhdrsubdir = .
-
-include ../Makeconf
install: install-headers $(libdir)/libpthread2.a $(libdir)/libpthread2_pic.a
install-headers: $(addprefix $(includedir)/, $(sysdeps_headers))
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..e1c062c
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,168 @@
+# Makefile.am - Makefile template for libpthread.
+# Copyright (C) 2003, 2008 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Hurd.
+#
+# The GNU Hurd is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# The GNU Hurd is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+if ARCH_IA32
+ arch=ia32
+endif
+if ARCH_POWERPC
+ arch=powerpc
+endif
+
+# The source files are scattered over several directories. Add
+# all these directories to the vpath.
+SYSDEP_PATH = $(srcdir)/sysdeps/l4/hurd/${arch} \
+ $(srcdir)/sysdeps/l4/${arch} \
+ $(srcdir)/sysdeps/${arch} \
+ $(srcdir)/sysdeps/l4/hurd \
+ $(srcdir)/sysdeps/l4 \
+ $(srcdir)/sysdeps/hurd \
+ $(srcdir)/sysdeps/generic \
+ $(srcdir)/sysdeps/posix \
+ $(srcdir)/pthread \
+ $(srcdir)/signal \
+ $(srcdir)/include
+vpath %.c $(SYSDEP_PATH)
+
+AM_CPPFLAGS = $(USER_CPPFLAGS) -I$(srcdir)/pthread \
+ $(addprefix -I, $(SYSDEP_PATH)) -imacros $(srcdir)/include/libc-symbols.h
+AM_CFLAGS = $(USER_CFLAGS)
+
+# Sources.
+SYSDEPS := lockfile.c
+
+if ! ENABLE_TESTS
+noinst_LIBRARIES = libpthread.a
+endif
+
+libpthread_a_SOURCES = pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \
+ pt-attr-getguardsize.c pt-attr-getinheritsched.c \
+ pt-attr-getschedparam.c pt-attr-getschedpolicy.c pt-attr-getscope.c \
+ pt-attr-getstack.c pt-attr-getstackaddr.c pt-attr-getstacksize.c \
+ pt-attr-init.c pt-attr-setdetachstate.c pt-attr-setguardsize.c \
+ pt-attr-setinheritsched.c pt-attr-setschedparam.c \
+ pt-attr-setschedpolicy.c pt-attr-setscope.c pt-attr-setstack.c \
+ pt-attr-setstackaddr.c pt-attr-setstacksize.c pt-attr.c \
+ pt-barrier-destroy.c pt-barrier-init.c pt-barrier-wait.c \
+ pt-barrier.c pt-barrierattr-destroy.c pt-barrierattr-init.c \
+ pt-barrierattr-getpshared.c pt-barrierattr-setpshared.c \
+ pt-destroy-specific.c pt-init-specific.c \
+ pt-key-create.c pt-key-delete.c \
+ pt-getspecific.c pt-setspecific.c \
+ pt-once.c \
+ pt-alloc.c \
+ pt-create.c \
+ pt-getattr.c \
+ pt-pool-np.c \
+ pt-equal.c \
+ pt-dealloc.c \
+ pt-detach.c \
+ pt-exit.c \
+ pt-initialize.c \
+ pt-join.c \
+ pt-self.c \
+ pt-sigmask.c \
+ pt-spin-inlines.c \
+ pt-cleanup.c \
+ pt-setcancelstate.c \
+ pt-setcanceltype.c \
+ pt-testcancel.c \
+ pt-cancel.c \
+ pt-mutexattr.c \
+ pt-mutexattr-destroy.c pt-mutexattr-init.c \
+ pt-mutexattr-getprioceiling.c pt-mutexattr-getprotocol.c \
+ pt-mutexattr-getpshared.c pt-mutexattr-gettype.c \
+ pt-mutexattr-setprioceiling.c pt-mutexattr-setprotocol.c \
+ pt-mutexattr-setpshared.c pt-mutexattr-settype.c \
+ pt-mutex-init.c pt-mutex-destroy.c \
+ pt-mutex-lock.c pt-mutex-trylock.c pt-mutex-timedlock.c \
+ pt-mutex-unlock.c \
+ pt-mutex-transfer-np.c \
+ pt-mutex-getprioceiling.c pt-mutex-setprioceiling.c \
+ pt-rwlock-attr.c \
+ pt-rwlockattr-init.c pt-rwlockattr-destroy.c \
+ pt-rwlockattr-getpshared.c pt-rwlockattr-setpshared.c \
+ pt-rwlock-init.c pt-rwlock-destroy.c \
+ pt-rwlock-rdlock.c pt-rwlock-tryrdlock.c \
+ pt-rwlock-trywrlock.c pt-rwlock-wrlock.c \
+ pt-rwlock-timedrdlock.c pt-rwlock-timedwrlock.c \
+ pt-rwlock-unlock.c \
+ pt-cond.c \
+ pt-condattr-init.c pt-condattr-destroy.c \
+ pt-condattr-getclock.c pt-condattr-getpshared.c \
+ pt-condattr-setclock.c pt-condattr-setpshared.c \
+ pt-cond-destroy.c pt-cond-init.c \
+ pt-cond-brdcast.c \
+ pt-cond-signal.c \
+ pt-cond-wait.c \
+ pt-cond-timedwait.c \
+ pt-stack-alloc.c \
+ pt-thread-alloc.c \
+ pt-thread-dealloc.c \
+ pt-thread-start.c \
+ pt-thread-halt.c \
+ pt-startup.c \
+ pt-getconcurrency.c pt-setconcurrency.c \
+ pt-block.c \
+ pt-timedblock.c \
+ pt-wakeup.c \
+ pt-docancel.c \
+ pt-sysdep.c \
+ pt-setup.c \
+ pt-machdep.c \
+ pt-spin.c \
+ pt-sigstate-init.c \
+ pt-sigstate-destroy.c \
+ pt-sigstate.c \
+ pt-atfork.c \
+ pt-kill.c \
+ pt-getcpuclockid.c \
+ pt-getschedparam.c pt-setschedparam.c pt-setschedprio.c \
+ pt-yield.c \
+ sem-close.c sem-init.c sem-timedwait.c sem-wait.c \
+ sem-destroy.c sem-open.c sem-trywait.c sem-getvalue.c \
+ sem-post.c sem-unlink.c \
+ \
+ pt-setactivity-np.c \
+ \
+ kill.c \
+ killpg.c \
+ pt-kill-siginfo-np.c \
+ raise.c \
+ sigaction.c \
+ sigaddset.c \
+ sigaltstack.c \
+ sigdelset.c \
+ sigemptyset.c \
+ sigfillset.c \
+ sig-internal.c \
+ sig-internal.h \
+ siginterrupt.c \
+ sigismember.c \
+ signal.c \
+ signal-dispatch.c \
+ signal.h \
+ sigpending.c \
+ sigprocmask.c \
+ sigsuspend.c \
+ sigtimedwait.c \
+ sigwait.c \
+ sigwaiter.c \
+ sigwaitinfo.c \
+ signal-dispatch-lowlevel.c \
+ sigprocmask.c
diff --git a/TODO b/TODO
index c9ca81d..d7e54da 100644
--- a/TODO
+++ b/TODO
@@ -13,10 +13,6 @@
platforms.
* Implementation details
-** Feature test macros
- This is most likely wrong. We need a standards expert to really
- look over this or someone who can outline what I need to do.
-
** pthread_atfork
This cannot be implemented without either changing glibc to export
some hooks (c.f. libc/sysdeps/mach/hurd/fork.c) or by providing a
diff --git a/headers.m4 b/headers.m4
new file mode 100644
index 0000000..5a58b9b
--- /dev/null
+++ b/headers.m4
@@ -0,0 +1,45 @@
+# headers.m4 - Autoconf snippets to install links for header files.
+# Copyright 2003, 2008 Free Software Foundation, Inc.
+# Written by Marcus Brinkmann <marcus@gnu.org>.
+#
+# This file is free software; as a special exception the author gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+#
+# This file is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+AC_CONFIG_LINKS([
+ sysroot/include/pthread.h:libpthread/include/pthread.h
+ sysroot/include/pthread/pthread.h:libpthread/include/pthread/pthread.h
+ sysroot/include/pthread/pthreadtypes.h:libpthread/include/pthread/pthreadtypes.h
+ sysroot/include/bits/memory.h:libpthread/sysdeps/${arch}/bits/memory.h
+ sysroot/include/bits/spin-lock.h:libpthread/sysdeps/${arch}/bits/spin-lock.h
+ sysroot/include/bits/spin-lock-inline.h:libpthread/sysdeps/${arch}/bits/spin-lock-inline.h
+ sysroot/include/bits/pthreadtypes.h:libpthread/sysdeps/generic/bits/pthreadtypes.h
+ sysroot/include/bits/barrier-attr.h:libpthread/sysdeps/generic/bits/barrier-attr.h
+ sysroot/include/bits/barrier.h:libpthread/sysdeps/generic/bits/barrier.h
+ sysroot/include/bits/cancelation.h:libpthread/sysdeps/generic/bits/cancelation.h
+ sysroot/include/bits/condition-attr.h:libpthread/sysdeps/generic/bits/condition-attr.h
+ sysroot/include/bits/condition.h:libpthread/sysdeps/generic/bits/condition.h
+ sysroot/include/bits/mutex-attr.h:libpthread/sysdeps/generic/bits/mutex-attr.h
+ sysroot/include/bits/mutex.h:libpthread/sysdeps/generic/bits/mutex.h
+ sysroot/include/bits/once.h:libpthread/sysdeps/generic/bits/once.h
+ sysroot/include/bits/pthread.h:libpthread/sysdeps/generic/bits/pthread.h
+ sysroot/include/bits/rwlock-attr.h:libpthread/sysdeps/generic/bits/rwlock-attr.h
+ sysroot/include/bits/rwlock.h:libpthread/sysdeps/generic/bits/rwlock.h
+ sysroot/include/bits/thread-attr.h:libpthread/sysdeps/generic/bits/thread-attr.h
+ sysroot/include/bits/thread-barrier.h:libpthread/sysdeps/generic/bits/thread-barrier.h
+ sysroot/include/bits/thread-specific.h:libpthread/sysdeps/generic/bits/thread-specific.h
+ sysroot/include/bits/pthread-np.h:libpthread/sysdeps/l4/hurd/bits/pthread-np.h
+ sysroot/include/semaphore.h:libpthread/include/semaphore.h
+ sysroot/include/bits/semaphore.h:libpthread/sysdeps/generic/bits/semaphore.h
+ sysroot/include/signal.h:libpthread/signal/signal.h
+])
+
+AC_CONFIG_COMMANDS_POST([
+ mkdir -p sysroot/lib libpthread &&
+ ln -sf ../../libpthread/libpthread.a sysroot/lib/ &&
+ touch libpthread/libpthread.a
+])
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index efbd0c5..54dd6e2 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -1,6 +1,7 @@
/* Support macros for making weak and strong aliases for symbols,
and for using symbol sets and linker warnings with GNU ld.
- Copyright (C) 1995-1998,2000,2001,2002 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2008
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -60,6 +61,7 @@
#define HAVE_ELF
#define HAVE_SECTION_QUOTES
#define HAVE_VISIBILITY_ATTRIBUTE
+#define HAVE_ASM_PREVIOUS_DIRECTIVE
// #define SHARED
/* The symbols in all the user (non-_) macros are C symbols.
diff --git a/include/pthread/pthread.h b/include/pthread/pthread.h
index 21a9b51..4dbcb0c 100644
--- a/include/pthread/pthread.h
+++ b/include/pthread/pthread.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2002, 2005, 2006, 2007, 2008, 2009, 2010
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,67 +26,57 @@
#include <features.h>
+#include <sys/cdefs.h>
+#ifndef __extern_inline
+/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
+ inline semantics, unless -fgnu89-inline is used. */
+# if !defined __cplusplus || __GNUC_PREREQ (4,3)
+# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
+# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
+# if __GNUC_PREREQ (4,3)
+# define __extern_always_inline \
+ extern __always_inline __attribute__ ((__gnu_inline__, __artificial__))
+# else
+# define __extern_always_inline \
+ extern __always_inline __attribute__ ((__gnu_inline__))
+# endif
+# else
+# define __extern_inline extern __inline
+# define __extern_always_inline extern __always_inline
+# endif
+# endif
+#endif
+
#include <sched.h>
-#define __need_clockid_t
#include <time.h>
-/* If we are in a mode where clockid_t is not automatically defined
- and another header has already included <time.h> then defining
- __need_clockid_t was not enough. */
-#ifndef __clockid_t_defined
-# define __clockid_t_defined 1
-# include <bits/types.h>
-/* Clock ID used in clock and timer functions. */
-typedef __clockid_t clockid_t;
-#endif
-
__BEGIN_DECLS
+#include <pthread/pthreadtypes.h>
+
#include <bits/pthread.h>
/* Possible values for the process shared attribute. */
-enum __pthread_process_shared
- {
- PTHREAD_PROCESS_PRIVATE = 0,
-#define PTHREAD_PROCESS_PRIVATE 0
- PTHREAD_PROCESS_SHARED
-#define PTHREAD_PROCESS_SHARED 1
- };
+#define PTHREAD_PROCESS_PRIVATE __PTHREAD_PROCESS_PRIVATE
+#define PTHREAD_PROCESS_SHARED __PTHREAD_PROCESS_SHARED
/* Thread attributes. */
/* Possible values for the inheritsched attribute. */
-enum __pthread_inheritsched
- {
- PTHREAD_EXPLICIT_SCHED = 0,
-#define PTHREAD_EXPLICIT_SCHED 0
- PTHREAD_INHERIT_SCHED
-#define PTHREAD_INHERIT_SCHED 1
- };
+#define PTHREAD_EXPLICIT_SCHED __PTHREAD_EXPLICIT_SCHED
+#define PTHREAD_INHERIT_SCHED __PTHREAD_INHERIT_SCHED
/* Possible values for the `contentionscope' attribute. */
-enum __pthread_contentionscope
- {
- PTHREAD_SCOPE_SYSTEM = 0,
-#define PTHREAD_SCOPE_SYSTEM 0
- PTHREAD_SCOPE_PROCESS,
-#define PTHREAD_SCOPE_PROCESS 1
- };
+#define PTHREAD_SCOPE_SYSTEM __PTHREAD_SCOPE_SYSTEM
+#define PTHREAD_SCOPE_PROCESS __PTHREAD_SCOPE_PROCESS
/* Possible values for the `detachstate' attribute. */
-enum __pthread_detachstate
- {
- PTHREAD_CREATE_JOINABLE = 0,
-#define PTHREAD_CREATE_JOINABLE 0
- PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
- };
+#define PTHREAD_CREATE_JOINABLE __PTHREAD_CREATE_JOINABLE
+#define PTHREAD_CREATE_DETACHED __PTHREAD_CREATE_DETACHED
#include <bits/thread-attr.h>
-typedef struct __pthread_attr pthread_attr_t;
-
/* Initialize the thread attribute object in *ATTR to the default
values. */
extern int pthread_attr_init (pthread_attr_t *attr);
@@ -144,6 +135,7 @@ extern int pthread_attr_setstackaddr (pthread_attr_t *attr,
void *stackaddr);
+#ifdef __USE_XOPEN2K
/* Return the value of the stackaddr and stacksize attributes in *ATTR
in *STACKADDR and *STACKSIZE respectively. */
extern int pthread_attr_getstack (const pthread_attr_t *__restrict attr,
@@ -155,6 +147,7 @@ extern int pthread_attr_getstack (const pthread_attr_t *__restrict attr,
extern int pthread_attr_setstack (pthread_attr_t *attr,
void *stackaddr,
size_t stacksize);
+#endif
/* Return the value of the detachstate attribute in *ATTR in
@@ -186,6 +179,13 @@ extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict attr,
/* Set the value of the stacksize attribute in *ATTR to STACKSIZE. */
extern int pthread_attr_setstacksize (pthread_attr_t *attr,
size_t stacksize);
+
+#ifdef __USE_GNU
+/* Initialize thread attribute *ATTR with attributes corresponding to the
+ already running thread THREAD. It shall be called on an uninitialized ATTR
+ and destroyed with pthread_attr_destroy when no longer needed. */
+extern int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr);
+#endif
/* Create a thread with attributes given by ATTR, executing
@@ -211,37 +211,48 @@ extern int pthread_detach (pthread_t __threadp);
if they are not. */
extern int pthread_equal (pthread_t __t1, pthread_t __t2);
+# ifdef __USE_EXTERN_INLINES
+
+__extern_inline int
+pthread_equal (pthread_t __t1, pthread_t __t2)
+{
+ return __pthread_equal (__t1, __t2);
+}
+
+# endif /* Use extern inlines. */
+
+
/* Return the thread ID of the calling thread. */
extern pthread_t pthread_self (void);
/* Mutex attributes. */
-enum __pthread_mutex_protocol
- {
- PTHREAD_PRIO_NONE = 0,
-#define PTHREAD_PRIO_NONE 0
- PTHREAD_PRIO_INHERIT,
-#define PTHREAD_PRIO_INHERIT 1
- PTHREAD_PRIO_PROTECT
-#define PTHREAD_PRIO_PROTECT 2
- };
-
-enum __pthread_mutex_type
- {
- PTHREAD_MUTEX_NORMAL = 0,
-#define PTHREAD_MUTEX_NORMAL 0
-#define PTHREAD_MUTEX_DEFAULT 0
- PTHREAD_MUTEX_ERRORCHECK,
-#define PTHREAD_MUTEX_ERRORCHECK 1
- PTHREAD_MUTEX_RECURSIVE,
-#define PTHREAD_MUTEX_RECURSIVE 2
- };
+#define PTHREAD_PRIO_NONE_NP __PTHREAD_PRIO_NONE
+#define PTHREAD_PRIO_INHERIT_NP __PTHREAD_PRIO_INHERIT
+#define PTHREAD_PRIO_PROTECT_NP __PTHREAD_PRIO_PROTECT
+#ifdef __USE_UNIX98
+#define PTHREAD_PRIO_NONE PTHREAD_PRIO_NONE_NP
+#define PTHREAD_PRIO_INHERIT PTHREAD_PRIO_INHERIT_NP
+#define PTHREAD_PRIO_PROTECT PTHREAD_PRIO_PROTECT_NP
+#endif
+
+#define PTHREAD_MUTEX_TIMED_NP __PTHREAD_MUTEX_TIMED
+#define PTHREAD_MUTEX_ERRORCHECK_NP __PTHREAD_MUTEX_ERRORCHECK
+#define PTHREAD_MUTEX_RECURSIVE_NP __PTHREAD_MUTEX_RECURSIVE
+#ifdef __USE_UNIX98
+#define PTHREAD_MUTEX_NORMAL PTHREAD_MUTEX_TIMED_NP
+#define PTHREAD_MUTEX_ERRORCHECK PTHREAD_MUTEX_ERRORCHECK_NP
+#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP
+#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL
+#endif
+#ifdef __USE_GNU
+/* For compatibility. */
+#define PTHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_TIMED_NP
+#endif
#include <bits/mutex-attr.h>
-typedef struct __pthread_mutexattr pthread_mutexattr_t;
-
/* Initialize the mutex attribute object in *ATTR to the default
values. */
extern int pthread_mutexattr_init(pthread_mutexattr_t *attr);
@@ -250,6 +261,7 @@ extern int pthread_mutexattr_init(pthread_mutexattr_t *attr);
extern int pthread_mutexattr_destroy(pthread_mutexattr_t *attr);
+#ifdef __USE_UNIX98
/* Return the value of the prioceiling attribute in *ATTR in
*PRIOCEILING. */
extern int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *__restrict attr,
@@ -269,6 +281,7 @@ extern int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *__restrict a
/* Set the value of the protocol attribute in *ATTR to PROTOCOL. */
extern int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr,
int protocol);
+#endif
/* Return the value of the process shared attribute in *ATTR in
@@ -282,6 +295,7 @@ extern int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr,
int pshared);
+#ifdef __USE_UNIX98
/* Return the value of the type attribute in *ATTR in *TYPE. */
extern int pthread_mutexattr_gettype(const pthread_mutexattr_t *__restrict attr,
int *__restrict type);
@@ -289,15 +303,22 @@ extern int pthread_mutexattr_gettype(const pthread_mutexattr_t *__restrict attr,
/* Set the value of the type attribute in *ATTR to TYPE. */
extern int pthread_mutexattr_settype(pthread_mutexattr_t *attr,
int type);
+#endif
/* Mutexes. */
#include <bits/mutex.h>
-typedef struct __pthread_mutex pthread_mutex_t;
-
#define PTHREAD_MUTEX_INITIALIZER __PTHREAD_MUTEX_INITIALIZER
+/* Static initializer for recursive mutexes. */
+
+#ifdef __USE_GNU
+# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
+ __PTHREAD_ERRORCHECK_MUTEX_INITIALIZER
+# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
+ __PTHREAD_RECURSIVE_MUTEX_INITIALIZER
+#endif
/* Create a mutex with attributes given by ATTR and store it in
*__MUTEX. */
@@ -313,14 +334,22 @@ extern int pthread_mutex_lock (pthread_mutex_t *__mutex);
/* Try to lock MUTEX. */
extern int pthread_mutex_trylock (pthread_mutex_t *__mutex);
+#ifdef __USE_XOPEN2K
/* Try to lock MUTEX, block until *ABSTIME if it is already held. */
extern int pthread_mutex_timedlock (struct __pthread_mutex *__restrict mutex,
const struct timespec *__restrict abstime);
+#endif
/* Unlock MUTEX. */
extern int pthread_mutex_unlock (pthread_mutex_t *__mutex);
+/* Transfer ownership of the mutex MUTEX to the thread TID. The
+ caller must own the lock. */
+extern int __pthread_mutex_transfer_np (struct __pthread_mutex *mutex,
+ pthread_t tid);
+
+#ifdef __USE_UNIX98
/* Return the priority ceiling of mutex *MUTEX in *PRIOCEILING. */
extern int pthread_mutex_getprioceiling (const pthread_mutex_t *__restrict mutex,
int *__restrict prioceiling);
@@ -330,6 +359,7 @@ extern int pthread_mutex_getprioceiling (const pthread_mutex_t *__restrict mutex
release the mutex. */
extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict mutex,
int prio, int *__restrict oldprio);
+#endif
@@ -337,8 +367,6 @@ extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict mutex,
#include <bits/condition-attr.h>
-typedef struct __pthread_condattr pthread_condattr_t;
-
/* Initialize the condition attribute in *ATTR to the default
values. */
extern int pthread_condattr_init (pthread_condattr_t *attr);
@@ -347,13 +375,15 @@ extern int pthread_condattr_init (pthread_condattr_t *attr);
extern int pthread_condattr_destroy (pthread_condattr_t *attr);
+#ifdef __USE_XOPEN2K
/* Return the value of the clock attribute in *ATTR in *CLOCK_ID. */
extern int pthread_condattr_getclock (const pthread_condattr_t *__restrict attr,
- clockid_t *__restrict clock_id);
+ __clockid_t *__restrict clock_id);
/* Set the value of the clock attribute in *ATTR to CLOCK_ID. */
extern int pthread_condattr_setclock (pthread_condattr_t *attr,
- clockid_t clock_id);
+ __clockid_t clock_id);
+#endif
/* Return the value of the process shared attribute in *ATTR in
@@ -371,8 +401,6 @@ extern int pthread_condattr_setpshared (pthread_condattr_t *attr,
#include <bits/condition.h>
-typedef struct __pthread_cond pthread_cond_t;
-
#define PTHREAD_COND_INITIALIZER __PTHREAD_COND_INITIALIZER
extern int pthread_cond_init (pthread_cond_t *__restrict cond,
@@ -408,9 +436,7 @@ extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
# include <bits/spin-lock.h>
-typedef __pthread_spinlock_t pthread_spinlock_t;
-
-#define PTHREAD_SPINLOCK_INITIALIZER __SPIN_LOCK_INITIALIZER
+#define PTHREAD_SPINLOCK_INITIALIZER __PTHREAD_SPIN_LOCK_INITIALIZER
/* Destroy the spin lock object LOCK. */
extern int pthread_spin_destroy (pthread_spinlock_t *__lock);
@@ -432,31 +458,33 @@ extern int pthread_spin_unlock (pthread_spinlock_t *__lock);
# ifdef __USE_EXTERN_INLINES
-extern __inline int
+# include <bits/spin-lock-inline.h>
+
+__extern_inline int
pthread_spin_destroy (pthread_spinlock_t *__lock)
{
return __pthread_spin_destroy (__lock);
}
-extern __inline int
+__extern_inline int
pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
{
return __pthread_spin_init (__lock, __pshared);
}
-extern __inline int
+__extern_inline int
pthread_spin_lock (pthread_spinlock_t *__lock)
{
return __pthread_spin_lock (__lock);
}
-extern __inline int
+__extern_inline int
pthread_spin_trylock (pthread_spinlock_t *__lock)
{
return __pthread_spin_trylock (__lock);
}
-extern __inline int
+__extern_inline int
pthread_spin_unlock (pthread_spinlock_t *__lock)
{
return __pthread_spin_unlock (__lock);
@@ -469,9 +497,9 @@ pthread_spin_unlock (pthread_spinlock_t *__lock)
/* rwlock attributes. */
-#include <bits/rwlock-attr.h>
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
-typedef struct __pthread_rwlockattr pthread_rwlockattr_t;
+#include <bits/rwlock-attr.h>
/* Initialize rwlock attribute object in *ATTR to the default
values. */
@@ -496,8 +524,7 @@ extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *attr,
#include <bits/rwlock.h>
-typedef struct __pthread_rwlock pthread_rwlock_t;
-
+#define PTHREAD_RWLOCK_INITIALIZER __PTHREAD_RWLOCK_INITIALIZER
/* Create a rwlock object with attributes given by ATTR and strore the
result in *RWLOCK. */
extern int pthread_rwlock_init (pthread_rwlock_t *__restrict rwlock,
@@ -512,10 +539,12 @@ extern int pthread_rwlock_rdlock (pthread_rwlock_t *rwlock);
/* Acquire the rwlock *RWLOCK for reading. */
extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock);
+# ifdef __USE_XOPEN2K
/* Acquire the rwlock *RWLOCK for reading blocking until *ABSTIME if
it is already held. */
extern int pthread_rwlock_timedrdlock (struct __pthread_rwlock *__restrict rwlock,
const struct timespec *__restrict abstime);
+# endif
/* Acquire the rwlock *RWLOCK for writing. */
extern int pthread_rwlock_wrlock (pthread_rwlock_t *rwlock);
@@ -523,13 +552,18 @@ extern int pthread_rwlock_wrlock (pthread_rwlock_t *rwlock);
/* Try to acquire the rwlock *RWLOCK for writing. */
extern int pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock);
+# ifdef __USE_XOPEN2K
/* Acquire the rwlock *RWLOCK for writing blocking until *ABSTIME if
it is already held. */
extern int pthread_rwlock_timedwrlock (struct __pthread_rwlock *__restrict rwlock,
const struct timespec *__restrict abstime);
+# endif
/* Release the lock held by the current thread on *RWLOCK. */
extern int pthread_rwlock_unlock (pthread_rwlock_t *rwlock);
+
+#endif /* __USE_UNIX98 || __USE_XOPEN2K */
+
/* Cancelation. */
@@ -542,6 +576,9 @@ extern void pthread_cleanup_pop (int execute);
#include <bits/cancelation.h>
+#define pthread_cleanup_push(rt, rtarg) __pthread_cleanup_push(rt, rtarg)
+#define pthread_cleanup_pop(execute) __pthread_cleanup_pop(execute)
+
#define PTHREAD_CANCEL_DISABLE 0
#define PTHREAD_CANCEL_ENABLE 1
@@ -569,9 +606,9 @@ extern void pthread_testcancel (void);
/* Barriers attributes. */
-#include <bits/barrier-attr.h>
+#ifdef __USE_XOPEN2K
-typedef struct __pthread_barrierattr pthread_barrierattr_t;
+#include <bits/barrier-attr.h>
/* Initialize barrier attribute object in *ATTR to the default
values. */
@@ -596,8 +633,6 @@ extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *attr,
#include <bits/barrier.h>
-typedef struct __pthread_barrier pthread_barrier_t;
-
/* Returned by pthread_barrier_wait to exactly one thread each time a
barrier is passed. */
#define PTHREAD_BARRIER_SERIAL_THREAD -1
@@ -612,14 +647,15 @@ extern int pthread_barrier_destroy (pthread_barrier_t *barrier);
/* Wait on barrier BARRIER. */
extern int pthread_barrier_wait (pthread_barrier_t *barrier);
+
+#endif /* __USE_XOPEN2K */
+
/* Thread specific data. */
#include <bits/thread-specific.h>
-typedef __pthread_key pthread_key_t;
-
/* Create a thread specific data key in KEY visible to all threads.
On thread destruction, DESTRUCTOR shall be called with the thread
specific data associate with KEY if it is not NULL. */
@@ -641,8 +677,6 @@ extern int pthread_setspecific (pthread_key_t key, const void *value);
#include <bits/once.h>
-typedef struct __pthread_once pthread_once_t;
-
#define PTHREAD_ONCE_INIT __PTHREAD_ONCE_INIT
/* Call INIT_ROUTINE if this function has never been called with
@@ -653,11 +687,13 @@ extern int pthread_once (pthread_once_t *once_control,
/* Concurrency. */
+#ifdef __USE_UNIX98
/* Set the desired concurrency level to NEW_LEVEL. */
extern int pthread_setconcurrency (int new_level);
/* Get the current concurrency level. */
extern int pthread_getconcurrency (void);
+#endif
/* Forking. */
@@ -681,8 +717,10 @@ extern int pthread_kill (pthread_t thread, int signo);
/* Time. */
+#ifdef __USE_XOPEN2K
/* Return the thread cpu clock. */
-extern int pthread_getcpuclockid (pthread_t thread, clockid_t *clock);
+extern int pthread_getcpuclockid (pthread_t thread, __clockid_t *clock);
+#endif
/* Scheduling. */
@@ -698,6 +736,19 @@ extern int pthread_setschedparam (pthread_t thread, int policy,
/* Set thread THREAD's scheduling priority. */
extern int pthread_setschedprio (pthread_t thread, int prio);
+#ifdef __USE_GNU
+/* Yield the processor to another thread or process.
+ This function is similar to the POSIX `sched_yield' function but
+ might be differently implemented in the case of a m-on-n thread
+ implementation. */
+extern int pthread_yield (void);
+#endif
+
+
+/* Kernel-specific interfaces. */
+
+#include <bits/pthread-np.h>
+
__END_DECLS
diff --git a/include/pthread/pthreadtypes.h b/include/pthread/pthreadtypes.h
new file mode 100644
index 0000000..33bd009
--- /dev/null
+++ b/include/pthread/pthreadtypes.h
@@ -0,0 +1,125 @@
+/* Copyright (C) 2000, 2002, 2005, 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/*
+ * POSIX Threads Extension: ??? <pthreadtypes.h>
+ */
+
+#ifndef _PTHREADTYPES_H
+#define _PTHREADTYPES_H 1
+
+#include <features.h>
+
+#include <bits/types.h>
+
+__BEGIN_DECLS
+
+#include <bits/pthread.h>
+typedef __pthread_t pthread_t;
+
+/* Possible values for the process shared attribute. */
+enum __pthread_process_shared
+ {
+ __PTHREAD_PROCESS_PRIVATE = 0,
+ __PTHREAD_PROCESS_SHARED
+ };
+
+/* Possible values for the inheritsched attribute. */
+enum __pthread_inheritsched
+ {
+ __PTHREAD_EXPLICIT_SCHED = 0,
+ __PTHREAD_INHERIT_SCHED
+ };
+
+/* Possible values for the `contentionscope' attribute. */
+enum __pthread_contentionscope
+ {
+ __PTHREAD_SCOPE_SYSTEM = 0,
+ __PTHREAD_SCOPE_PROCESS
+ };
+
+/* Possible values for the `detachstate' attribute. */
+enum __pthread_detachstate
+ {
+ __PTHREAD_CREATE_JOINABLE = 0,
+ __PTHREAD_CREATE_DETACHED
+ };
+
+#include <bits/thread-attr.h>
+typedef struct __pthread_attr pthread_attr_t;
+
+enum __pthread_mutex_protocol
+ {
+ __PTHREAD_PRIO_NONE= 0,
+ __PTHREAD_PRIO_INHERIT,
+ __PTHREAD_PRIO_PROTECT
+ };
+
+enum __pthread_mutex_type
+ {
+ __PTHREAD_MUTEX_TIMED,
+ __PTHREAD_MUTEX_ERRORCHECK,
+ __PTHREAD_MUTEX_RECURSIVE
+ };
+
+#include <bits/mutex-attr.h>
+typedef struct __pthread_mutexattr pthread_mutexattr_t;
+
+#include <bits/mutex.h>
+typedef struct __pthread_mutex pthread_mutex_t;
+
+#include <bits/condition-attr.h>
+typedef struct __pthread_condattr pthread_condattr_t;
+
+#include <bits/condition.h>
+typedef struct __pthread_cond pthread_cond_t;
+
+#ifdef __USE_XOPEN2K
+# include <bits/spin-lock.h>
+typedef __pthread_spinlock_t pthread_spinlock_t;
+#endif /* XPG6. */
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+
+#include <bits/rwlock-attr.h>
+typedef struct __pthread_rwlockattr pthread_rwlockattr_t;
+
+#include <bits/rwlock.h>
+typedef struct __pthread_rwlock pthread_rwlock_t;
+
+#endif /* __USE_UNIX98 || __USE_XOPEN2K */
+
+#ifdef __USE_XOPEN2K
+
+#include <bits/barrier-attr.h>
+typedef struct __pthread_barrierattr pthread_barrierattr_t;
+
+#include <bits/barrier.h>
+typedef struct __pthread_barrier pthread_barrier_t;
+
+#endif /* __USE_XOPEN2K */
+
+#include <bits/thread-specific.h>
+typedef __pthread_key pthread_key_t;
+
+#include <bits/once.h>
+typedef struct __pthread_once pthread_once_t;
+
+__END_DECLS
+
+#endif /* pthreadtypes.h */
diff --git a/include/semaphore.h b/include/semaphore.h
index 8acb768..657e796 100644
--- a/include/semaphore.h
+++ b/include/semaphore.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -45,10 +45,12 @@ extern int sem_wait (sem_t *sem);
without blocking. */
extern int sem_trywait (sem_t *sem);
+#ifdef __USE_XOPEN2K
/* Perform a down operation on semaphore *SEM but don't wait longer
than TIMEOUT. */
extern int sem_timedwait (sem_t *__restrict sem,
const struct timespec *__restrict timeout);
+#endif
/* Perform an up operation on semaphore *SEM. */
extern int sem_post (sem_t *sem);
diff --git a/pthread/cthreads-compat.c b/pthread/cthreads-compat.c
index ccea03c..e0536ef 100644
--- a/pthread/cthreads-compat.c
+++ b/pthread/cthreads-compat.c
@@ -1,5 +1,5 @@
/* Compatibility routines for cthreads.
- Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+ 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
@@ -20,7 +20,11 @@
#include <assert.h>
#include <pthread.h>
-#include <cthreads.h>
+typedef void *cthread_t;
+typedef void *(*cthread_fn_t) (void *arg);
+typedef int cthread_key_t;
+
+#define CTHREAD_KEY_INVALID (cthread_key_t) -1
void
cthread_detach (cthread_t thread)
diff --git a/pthread/pt-alloc.c b/pthread/pt-alloc.c
index 30dcede..6af2da9 100644
--- a/pthread/pt-alloc.c
+++ b/pthread/pt-alloc.c
@@ -1,5 +1,5 @@
/* Allocate a new thread structure.
- Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2005, 2007, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,8 +25,6 @@
#include <pt-internal.h>
-#include <bits/atomic.h>
-
/* This braindamage is necessary because the standard says that some
of the threads functions "shall fail" if "No thread could be found
corresponding to that specified by the given thread ID." */
@@ -44,9 +42,9 @@ int __pthread_num_threads;
/* A lock for the table, and the other variables above. */
pthread_rwlock_t __pthread_threads_lock;
-
/* List of thread structures corresponding to free thread IDs. */
-__atomicptr_t __pthread_free_threads;
+struct __pthread *__pthread_free_threads;
+pthread_mutex_t __pthread_free_threads_lock;
static inline error_t
initialize_pthread (struct __pthread *new, int recycling)
@@ -94,33 +92,35 @@ __pthread_alloc (struct __pthread **pthread)
int max_threads;
int new_max_threads;
- /* Try to re-use a thread structure before creating a new one. */
- while ((new = (struct __pthread *)__pthread_free_threads))
+ pthread_mutex_lock (&__pthread_free_threads_lock);
+ for (new = __pthread_free_threads; new; new = new->next)
{
- if (__atomicptr_compare_and_swap (&__pthread_free_threads,
- new, new->next))
+ /* There is no need to take NEW->STATE_LOCK: if NEW is on this
+ list, then it is protected by __PTHREAD_FREE_THREADS_LOCK
+ except in __pthread_dealloc where after it is added to the
+ list (with the lock held), it drops the lock and then sets
+ NEW->STATE and immediately stops using NEW. */
+ if (new->state == PTHREAD_TERMINATED)
{
- /* Yes, we managed to get one. The thread number in the
- thread structure still refers to the correct slot. */
- err = initialize_pthread (new, 1);
- if (err)
- /* An error occured, however, we cannot just free NEW as
- there may be resources attached to it. We must return
- it to the free list. */
- while (1)
- {
- new->next = (struct __pthread *)__pthread_free_threads;
- if (__atomicptr_compare_and_swap (&__pthread_free_threads,
- new->next, new))
- break;
- }
-
- if (! err)
- *pthread = new;
-
- return err;
+ __pthread_dequeue (new);
+ break;
}
}
+ pthread_mutex_unlock (&__pthread_free_threads_lock);
+
+ if (new)
+ {
+ /* The thread may still be running. Make sure it is stopped.
+ If this is the case, then the thread is either at the end of
+ __pthread_dealloc or in __pthread_thread_halt. In both
+ cases, we are interrupt it. */
+ __pthread_thread_halt (new);
+
+ err = initialize_pthread (new, 1);
+ if (! err)
+ *pthread = new;
+ return err;
+ }
/* Allocate a new thread structure. */
new = malloc (sizeof (struct __pthread));
diff --git a/pthread/pt-create.c b/pthread/pt-create.c
index 0d66d6c..346c697 100644
--- a/pthread/pt-create.c
+++ b/pthread/pt-create.c
@@ -45,6 +45,8 @@ entry_point (void *(*start_routine)(void *), void *arg)
uselocale (LC_GLOBAL_LOCALE);
#endif
+ __pthread_startup ();
+
pthread_exit (start_routine (arg));
}
@@ -204,7 +206,7 @@ __pthread_create_internal (struct __pthread **thread,
failed_thread_tls_alloc:
#endif /* ENABLE_TLS */
__pthread_thread_dealloc (pthread);
- __pthread_thread_halt (pthread, 0);
+ __pthread_thread_halt (pthread);
failed_thread_alloc:
__pthread_stack_dealloc (pthread->stackaddr, pthread->stacksize);
pthread->stack = 0;
diff --git a/pthread/pt-dealloc.c b/pthread/pt-dealloc.c
index 1fc7a7b..92fe1fd 100644
--- a/pthread/pt-dealloc.c
+++ b/pthread/pt-dealloc.c
@@ -1,5 +1,5 @@
/* Deallocate a thread structure.
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 2000, 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
@@ -23,13 +23,12 @@
#include <pt-internal.h>
-#include <bits/atomic.h>
-
/* List of thread structures corresponding to free thread IDs. */
-extern __atomicptr_t __pthread_free_threads;
+extern struct __pthread *__pthread_free_threads;
+extern pthread_mutex_t __pthread_free_threads_lock;
+
-/* Deallocate the thread structure for PTHREAD and the resources
- associated with it. */
+/* Deallocate the thread structure for PTHREAD. */
void
__pthread_dealloc (struct __pthread *pthread)
{
@@ -44,20 +43,22 @@ __pthread_dealloc (struct __pthread *pthread)
pthread_join is completely bogus, but unfortunately allowed
by the standards. */
__pthread_mutex_lock (&pthread->state_lock);
- pthread->state = PTHREAD_TERMINATED;
if (pthread->state != PTHREAD_EXITED)
pthread_cond_broadcast (&pthread->state_cond);
__pthread_mutex_unlock (&pthread->state_lock);
/* We do not actually deallocate the thread structure, but add it to
a list of re-usable thread structures. */
- while (1)
- {
- pthread->next = (struct __pthread *)__pthread_free_threads;
- if (__atomicptr_compare_and_swap (&__pthread_free_threads,
- pthread->next, pthread))
- return;
- }
-
- /* NOTREACHED */
+ pthread_mutex_lock (&__pthread_free_threads_lock);
+ __pthread_enqueue (&__pthread_free_threads, pthread);
+ pthread_mutex_unlock (&__pthread_free_threads_lock);
+
+ /* Setting PTHREAD->STATE to PTHREAD_TERMINATED makes this TCB
+ available for reuse. After that point, we can no longer assume
+ that PTHREAD is valid.
+
+ Note that it is safe to not lock this update to PTHREAD->STATE:
+ the only way that it can now be accessed is in __pthread_alloc,
+ which reads this variable. */
+ pthread->state = PTHREAD_TERMINATED;
}
diff --git a/pthread/pt-detach.c b/pthread/pt-detach.c
index 42a8408..1e42c45 100644
--- a/pthread/pt-detach.c
+++ b/pthread/pt-detach.c
@@ -58,10 +58,20 @@ pthread_detach (pthread_t thread)
__pthread_mutex_unlock (&pthread->state_lock);
+ /* Make sure the thread is not running before we remove its
+ stack. (The only possibility is that it is in a call to
+ __pthread_thread_halt itself, but that is enough to cause a
+ sigsegv.) */
+ __pthread_thread_halt (pthread);
+
+ /* Destroy the stack, the kernel resources and the control
+ block. */
assert (pthread->stack);
__pthread_stack_dealloc (pthread->stackaddr, pthread->stacksize);
pthread->stack = 0;
+ __pthread_thread_dealloc (pthread);
+
__pthread_dealloc (pthread);
break;
diff --git a/pthread/pt-exit.c b/pthread/pt-exit.c
index 941526a..c01efda 100644
--- a/pthread/pt-exit.c
+++ b/pthread/pt-exit.c
@@ -1,5 +1,5 @@
/* Thread termination.
- Copyright (C) 2000, 2002, 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2005, 2007, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -28,14 +28,13 @@
/* Terminate the current thread and make STATUS available to any
- thread that might join us. */
+ thread that might join it. */
void
pthread_exit (void *status)
{
struct __pthread *self = _pthread_self ();
struct __pthread_cancelation_handler **handlers;
int oldstate;
- int need_dealloc;
/* Run any cancelation handlers. According to POSIX, the
cancellation cleanup handlers should be called with cancellation
@@ -74,7 +73,6 @@ pthread_exit (void *status)
if (self->tcb)
_dl_deallocate_tls (self->tcb, 1);
#endif /* ENABLE_TLS */
- __pthread_thread_dealloc (self);
switch (self->state)
{
@@ -90,7 +88,8 @@ pthread_exit (void *status)
deallocate our own stack. However, it will eventually be
reused when this thread structure is recycled. */
__pthread_mutex_unlock (&self->state_lock);
- need_dealloc = 1;
+
+ __pthread_dealloc (self);
break;
@@ -107,7 +106,6 @@ pthread_exit (void *status)
waiting to join us. */
pthread_cond_broadcast (&self->state_cond);
__pthread_mutex_unlock (&self->state_lock);
- need_dealloc = 0;
break;
}
@@ -117,7 +115,7 @@ pthread_exit (void *status)
This means that before freeing any resources, such a thread
should make sure that this thread is really halted. */
- __pthread_thread_halt (self, need_dealloc);
+ __pthread_thread_halt (self);
/* NOTREACHED */
abort ();
diff --git a/pthread/pt-getattr.c b/pthread/pt-getattr.c
new file mode 100644
index 0000000..24599c6
--- /dev/null
+++ b/pthread/pt-getattr.c
@@ -0,0 +1,49 @@
+/* Thread attributes retrieval.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+
+#include <pt-internal.h>
+
+/* Initialize thread attribute *ATTR with attributes corresponding to the
+ already running thread THREAD. It shall be called on an uninitialized ATTR
+ and destroyed with pthread_attr_destroy when no longer needed. */
+int
+pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
+{
+ struct __pthread *pthread;
+
+ pthread = __pthread_getid(thread);
+ if (pthread == NULL)
+ return ESRCH;
+
+ /* Some attributes (schedparam, inheritsched, contentionscope and schedpolicy)
+ are not supported yet, so fill them with our default values. */
+ *attr = __pthread_default_attr;
+
+ attr->stackaddr = pthread->stackaddr;
+ attr->stacksize = pthread->stacksize;
+ attr->guardsize = pthread->guardsize;
+ attr->detachstate = (pthread->state == PTHREAD_DETACHED
+ ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE);
+
+ return 0;
+}
diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h
index 159f1cb..3f69d2d 100644
--- a/pthread/pt-internal.h
+++ b/pthread/pt-internal.h
@@ -1,5 +1,5 @@
/* Internal defenitions for pthreads library.
- Copyright (C) 2000, 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -36,9 +36,13 @@
/* Thread state. */
enum pthread_state
{
+ /* The thread is running and joinable. */
PTHREAD_JOINABLE = 0,
+ /* The thread is running and detached. */
PTHREAD_DETACHED,
+ /* A joinable thread exited and its return code is available. */
PTHREAD_EXITED,
+ /* The thread structure is unallocated and available for reuse. */
PTHREAD_TERMINATED
};
@@ -128,15 +132,22 @@ __pthread_dequeue (struct __pthread *thread)
}
/* Iterate over QUEUE storing each element in ELEMENT. */
-#define __pthread_queue_iterate(queue, element) \
- for (element = queue; element; element = element->next)
+#define __pthread_queue_iterate(queue, element) \
+ for (struct __pthread *__pdi_next = (queue); \
+ ((element) = __pdi_next) \
+ && ((__pdi_next = __pdi_next->next), \
+ 1); \
+ )
/* Iterate over QUEUE dequeuing each element, storing it in
ELEMENT. */
-#define __pthread_dequeuing_iterate(queue, element) \
- for (element = queue; \
- element && ((element->prevp = 0), 1); \
- element = element->next)
+#define __pthread_dequeuing_iterate(queue, element) \
+ for (struct __pthread *__pdi_next = (queue); \
+ ((element) = __pdi_next) \
+ && ((__pdi_next = __pdi_next->next), \
+ ((element)->prevp = 0), \
+ 1); \
+ )
/* The total number of threads currently active. */
extern __atomic_t __pthread_total;
@@ -214,23 +225,27 @@ extern int __pthread_setup (struct __pthread *__restrict thread,
resources) for THREAD; it must not be placed on the run queue. */
extern int __pthread_thread_alloc (struct __pthread *thread);
-/* Deallocate any kernel resources associated with THREAD except don't
- halt the thread itself. On return, the thread will be marked as
- dead and __pthread_halt will be called. */
+/* Deallocate any kernel resources associated with THREAD. The thread
+ must not be running (that is, if __pthread_thread_start was called,
+ __pthread_thread_halt must first be called). This function will
+ never be called by a thread on itself. In the case that a thread
+ exits, its thread structure will be cached and cleaned up
+ later. */
extern void __pthread_thread_dealloc (struct __pthread *thread);
/* Start THREAD making it eligible to run. */
extern int __pthread_thread_start (struct __pthread *thread);
-/* Stop the kernel thread associated with THREAD. If NEED_DEALLOC is
- true, the function must call __pthread_dealloc on THREAD.
+/* Stop the kernel thread associated with THREAD. This function may
+ be called by two threads in parallel. In particular, by the thread
+ itself and another thread trying to join it. This function must be
+ implemented such that this is safe. */
+extern void __pthread_thread_halt (struct __pthread *thread);
- NB: The thread executing this function may be the thread which is
- being halted, thus the last action should be halting the thread
- itself. */
-extern void __pthread_thread_halt (struct __pthread *thread,
- int need_dealloc);
+/* Called by a thread just before it calls the provided start
+ routine. */
+extern void __pthread_startup (void);
/* Block THREAD. */
extern void __pthread_block (struct __pthread *thread);
diff --git a/pthread/pt-join.c b/pthread/pt-join.c
index 698b6c9..153058b 100644
--- a/pthread/pt-join.c
+++ b/pthread/pt-join.c
@@ -37,7 +37,8 @@ pthread_join (pthread_t thread, void **status)
return ESRCH;
__pthread_mutex_lock (&pthread->state_lock);
- pthread_cleanup_push (__pthread_mutex_unlock, &pthread->state_lock);
+ pthread_cleanup_push ((void (*)(void *)) __pthread_mutex_unlock,
+ &pthread->state_lock);
while (pthread->state == PTHREAD_JOINABLE)
pthread_cond_wait (&pthread->state_cond, &pthread->state_lock);
@@ -53,12 +54,20 @@ pthread_join (pthread_t thread, void **status)
if (status)
*status = pthread->status;
- /* Make sure nobody can reference it anymore, and mark it as
- terminated. */
+ /* Make sure the thread is not running before we remove its
+ stack. (The only possibility is that it is in a call to
+ __pthread_thread_halt itself, but that is enough to cause a
+ sigsegv.) */
+ __pthread_thread_halt (pthread);
+
+ /* Destroy the stack, the kernel resources and the control
+ block. */
assert (pthread->stack);
__pthread_stack_dealloc (pthread->stackaddr, pthread->stacksize);
pthread->stack = 0;
+ __pthread_thread_dealloc (pthread);
+
__pthread_dealloc (pthread);
break;
diff --git a/pthread/pt-self.c b/pthread/pt-self.c
index e14fe1e..4976864 100644
--- a/pthread/pt-self.c
+++ b/pthread/pt-self.c
@@ -1,5 +1,5 @@
/* Get calling thread's ID.
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 2000, 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
@@ -25,5 +25,8 @@
pthread_t
pthread_self (void)
{
- return _pthread_self()->thread;
+ struct __pthread *self = _pthread_self ();
+ assert (self);
+
+ return self->thread;
}
diff --git a/pthread/pt-setcancelstate.c b/pthread/pt-setcancelstate.c
index ded5892..e2d8183 100644
--- a/pthread/pt-setcancelstate.c
+++ b/pthread/pt-setcancelstate.c
@@ -35,7 +35,8 @@ pthread_setcancelstate (int state, int *oldstate)
break;
}
- *oldstate = p->cancel_state;
+ if (oldstate)
+ *oldstate = p->cancel_state;
p->cancel_state = state;
return 0;
diff --git a/pthread/pt-setcanceltype.c b/pthread/pt-setcanceltype.c
index 9511c99..3ce4259 100644
--- a/pthread/pt-setcanceltype.c
+++ b/pthread/pt-setcanceltype.c
@@ -35,7 +35,8 @@ pthread_setcanceltype (int type, int *oldtype)
break;
}
- *oldtype = p->cancel_type;
+ if (oldtype)
+ *oldtype = p->cancel_type;
p->cancel_type = type;
return 0;
diff --git a/pthread/pt-yield.c b/pthread/pt-yield.c
new file mode 100644
index 0000000..27848bb
--- /dev/null
+++ b/pthread/pt-yield.c
@@ -0,0 +1,26 @@
+/* Yield the processor to another thread or process.
+ Copyright (C) 2010 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see 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>
+
+int pthread_yield(void)
+{
+ return sched_yield ();
+}
diff --git a/signal/README b/signal/README
new file mode 100644
index 0000000..5487e2e
--- /dev/null
+++ b/signal/README
@@ -0,0 +1,4 @@
+This directory provides a signal implementation, which is appropriate
+for operating systems where signals are managed at user-level. It is
+up to the run-time to catch the signals and forward them to the
+implementation via, e.g., the pthread_kill_info_np call.
diff --git a/signal/TODO b/signal/TODO
new file mode 100644
index 0000000..1148abb
--- /dev/null
+++ b/signal/TODO
@@ -0,0 +1,29 @@
+Unimplemented Functionality
+---------------------------
+
+We don't support interruptible functions. That is, if a signal is
+delivered when a thread is in e.g. the write system call, then the
+write function should be interrupted and return EINTR when the signal
+handler is finished. To realize this behavior, we could have a thread
+local interruptible flag and a setjmp buffer. A function that is
+interruptible would fill the jump buffer and set the interruptible
+flag. If a signal comes in and the interruptible flag is set, rather
+than resuming the thread, we longjmp to the buffer.
+
+If a signal action has set the SA_SIGINFO, the third argument must be
+a pointer to a ucontext describing the thread's interrupted state;
+this implementation passes NULL. This isn't as bad as it sounds as
+the the ucontext family of functions are marked obsolete in SUSv3 with
+the advisory that any use of them should be replaced by the use of
+pthread functionality (cf. makecontext rationale).
+
+stop and continue signals are not implemented (as we need to stop all
+threads, this requires being in bed with libpthread).
+
+Implementation is not yet cancellation-safe.
+
+There are not even stubs for sighold, sigingore, sigpause, sigrelse,
+however, according to posix: "Use of any of these functions is
+unspecified in a multi-threaded process."
+
+Implement sigtimedwait, sigqueue. \ No newline at end of file
diff --git a/signal/kill.c b/signal/kill.c
new file mode 100644
index 0000000..27c9c32
--- /dev/null
+++ b/signal/kill.c
@@ -0,0 +1,70 @@
+/* kill.c - Generic kill implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+kill (pid_t pid, int signo)
+{
+ if (pid != getpid ())
+ {
+ errno = EOPNOTSUPP;
+ return -1;
+ }
+
+ /* "Signals generated for the process shall be delivered to exactly
+ one of those threads within the process which is in a call to a
+ sigwait() function selecting that signal or has not blocked
+ delivery of the signal. If there are no threads in a call to a
+ sigwait() function selecting that signal, and if all threads
+ within the process block delivery of the signal, the signal shall
+ remaing pending on the process" (2.4.1). */
+
+ /* First, see if there is a waiter, which is interested in this
+ signal. */
+ pthread_mutex_lock (&sig_lock);
+
+ struct sigwaiter *waiter;
+ for (waiter = sigwaiters; waiter; waiter = waiter->next)
+ if ((waiter->signals & sigmask (signo)))
+ /* Got a winner. */
+ {
+ sigdelset (&process_pending, signo);
+
+ pthread_mutex_lock (&waiter->ss->lock);
+ sigdelset (&waiter->ss->pending, signo);
+
+ memset (&waiter->info, 0, sizeof (waiter->info));
+ waiter->info.si_signo = signo;
+
+ sigwaiter_unblock (waiter);
+
+ return 0;
+ }
+
+ pthread_mutex_unlock (&sig_lock);
+
+ /* XXX: We just generate the signal for the current thread. If the
+ current thread has blocked the signal, the correct thing to do is
+ to iterate over all the other threads and find on that hasn't
+ blocked it. */
+ return pthread_kill (pthread_self (), signo);
+}
+
diff --git a/signal/pt-kill-siginfo-np.c b/signal/pt-kill-siginfo-np.c
new file mode 100644
index 0000000..9bdf6cc
--- /dev/null
+++ b/signal/pt-kill-siginfo-np.c
@@ -0,0 +1,88 @@
+/* pthread-kill-siginfo-np.c - Generic pthread_kill_siginfo_np implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "pt-internal.h"
+#include "sig-internal.h"
+
+int
+pthread_kill_siginfo_np (pthread_t tid, siginfo_t si)
+{
+ int sig = si.si_signo;
+
+ if (sig < 0 || sig >= NSIG)
+ return EINVAL;
+
+ if (sig == 0)
+ return 0;
+
+ struct signal_state *ss = &__pthread_getid (tid)->ss;
+
+ pthread_mutex_lock (&sig_lock);
+ pthread_mutex_lock (&ss->lock);
+
+ if (ss->sigwaiter && (ss->sigwaiter->signals & sigmask (si.si_signo)))
+ /* The thread is in a call to sigwait. */
+ {
+ ss->sigwaiter->info = si;
+ sigwaiter_unblock (ss->sigwaiter);
+ return 0;
+ }
+
+ pthread_mutex_unlock (&sig_lock);
+
+ if (ss->actions[sig - 1].sa_handler == (void *) SIG_IGN
+ || (ss->actions[sig - 1].sa_handler == (void *) SIG_DFL
+ && default_action (sig) == sig_ignore))
+ /* It is unclear (to me) what is supposed to happen when a signal
+ is generated for a thread, which is blocking that signal and
+ ignoring it. POSIX does say that when the action associated
+ with a pending, blocked signal is set to SIG_IGN, the pending
+ signal is to be cleared. Thus, it makes sense that any signal
+ set to ignore is discarded at generation. */
+ {
+ pthread_mutex_unlock (&ss->lock);
+ return 0;
+ }
+
+
+ if ((sigmask (sig) & ss->blocked))
+ /* The signal is blocked. Mark it pending. */
+ {
+ ss->pending |= sigmask (sig);
+ pthread_mutex_unlock (&ss->lock);
+ return 0;
+ }
+
+ if (pthread_self () == tid
+ && (! (ss->actions[si.si_signo - 1].sa_flags & SA_ONSTACK)
+ || (ss->stack.ss_flags & SS_DISABLE)
+ || (ss->stack.ss_flags & SS_ONSTACK)))
+ /* We are sending a signal to ourself and we don't use an
+ alternate stack. */
+ signal_dispatch (ss, &si);
+ else
+ signal_dispatch_lowlevel (ss, tid, si);
+
+ /* Don't unlock ss: signal_dispatch and signal_dispatch_lowlevel
+ assume ownership of the lock. */
+
+ return 0;
+}
+
diff --git a/signal/sig-internal.c b/signal/sig-internal.c
new file mode 100644
index 0000000..f73f38b
--- /dev/null
+++ b/signal/sig-internal.c
@@ -0,0 +1,26 @@
+/* sig-internal.c - Signal state functions.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+pthread_mutex_t sig_lock = PTHREAD_MUTEX_INITIALIZER;
+
+sigset_t process_pending;
+siginfo_t process_pending_info[NSIG];
diff --git a/signal/sig-internal.h b/signal/sig-internal.h
new file mode 100644
index 0000000..6c86c79
--- /dev/null
+++ b/signal/sig-internal.h
@@ -0,0 +1,177 @@
+/* sig-internal.h - Internal signal handling interface.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SIG_INTERNAL_H
+#define SIG_INTERNAL_H
+
+#include <signal.h>
+
+#include <sig-sysdep.h>
+
+#define sigmask(sig) (1ULL << (sig - 1))
+#define STOPSIGS (sigmask (SIGTTIN) | sigmask (SIGTTOU) | \
+ sigmask (SIGSTOP) | sigmask (SIGTSTP))
+
+/* General lock. Protects PROCESS_PENDING, PROCESS_PENDING_INFO,
+ SIGWAITERS. */
+extern pthread_mutex_t sig_lock;
+
+/* "Signals generated for the process shall be delivered to exactly
+ one of those threads within the process which is in a call to a
+ sigwait() function selecting that signal or has not blocked
+ delivery of the signal. If there are no threads in a call to a
+ sigwait() function selecting that signal, and if all threads within
+ the process block delivery of the signal, the signal shall remaing
+ pending on the process" (2.4.1).
+
+ This variable is protected by SIG_LOCK. */
+extern sigset_t process_pending;
+extern siginfo_t process_pending_info[NSIG];
+
+struct sigwaiter;
+
+/* The per-thread signal state. */
+struct signal_state
+{
+ /* Protects the following fields. STACK.SA_FLAGS may be accessed
+ using atomic operations. */
+ pthread_mutex_t lock;
+
+ /* Pending signals. */
+ sigset_t pending;
+
+ /* Blocked signals (i.e., the signal mask). */
+ sigset_t blocked;
+
+ stack_t stack;
+ struct sigaction actions[NSIG];
+ siginfo_t info[NSIG];
+
+ /* If the thread is blocked in a call to sigwait. */
+ struct sigwaiter *sigwaiter;
+};
+
+#define PTHREAD_SIGNAL_MEMBERS struct signal_state ss;
+
+/* Arranges for thread TID to call signal_dispatch. Must not be
+ called if TID is the caller and an alternate stack is not required.
+ In this case, the caller should call signal_dispatch directly. */
+extern void signal_dispatch_lowlevel (struct signal_state *ss,
+ pthread_t tid, siginfo_t si);
+
+/* This is the signal handler entry point. A thread is forced into
+ this state when it receives a signal. We need to save the thread's
+ state and then invoke the high-level signal dispatcher. SS->LOCK
+ is locked by the caller. */
+extern void signal_dispatch (struct signal_state *ss, siginfo_t *si);
+
+#ifndef SIGNAL_DISPATCH_ENTRY
+#define SIGNAL_DISPATCH_ENTRY
+#endif
+
+#ifndef SIGNAL_DISPATCH_EXIT
+#define SIGNAL_DISPATCH_EXIT
+#endif
+
+/* When a thread calls sigwait and a requested signal is not pending,
+ it allocates the following structure, fills it in, adds it to
+ sigwaiters and sleeps. */
+struct sigwaiter
+{
+ struct sigwaiter *next;
+ struct sigwaiter *prev;
+
+ /* Thread's signal state. */
+ struct signal_state *ss;
+
+ /* Signals this thread is waiting for. */
+ sigset_t signals;
+
+ /* The selected signal is returned here. The waiter also
+ futex_waits on this info.si_signo. */
+ siginfo_t info;
+};
+
+/* This variable is protected by SIG_LOCK. */
+extern struct sigwaiter *sigwaiters;
+
+/* Block the caller waiting for a signal in set SET. SIG_LOCK and
+ SS->LOCK must be held and will be unlocked by this function before
+ blocking. */
+extern siginfo_t sigwaiter_block (struct signal_state *ss,
+ const sigset_t *restrict set);
+
+/* Unblock the waiter WAITER. SIG_LOCK and WAITER->SS->LOCK must be
+ held. Both will be dropped on return. */
+extern void sigwaiter_unblock (struct sigwaiter *waiter);
+
+enum sig_action { sig_core, sig_terminate, sig_ignore, sig_cont, sig_stop };
+
+static inline enum sig_action
+default_action (int signo)
+{
+ switch (signo)
+ {
+ case SIGABRT:
+ case SIGBUS:
+ case SIGFPE:
+ case SIGILL:
+ case SIGQUIT:
+ case SIGSEGV:
+ case SIGSTKFLT:
+ case SIGSYS:
+ case SIGTRAP:
+ case SIGXCPU:
+ case SIGXFSZ:
+ return sig_core;
+
+ case SIGALRM:
+ case SIGHUP:
+ case SIGINT:
+ case SIGIO: /* Perhaps ignore? */
+ case SIGKILL:
+ case SIGPIPE:
+ case SIGPROF:
+ case SIGTERM:
+ case SIGUSR1:
+ case SIGUSR2:
+ case SIGVTALRM:
+ return sig_terminate;
+
+ case SIGCHLD:
+ case SIGPWR:
+ case SIGURG:
+ case SIGWINCH:
+ return sig_ignore;
+
+ case SIGCONT:
+ return sig_cont;
+
+ case SIGSTOP:
+ case SIGTSTP:
+ case SIGTTIN:
+ case SIGTTOU:
+ return sig_stop;
+ }
+
+ panic ("Unknown signal number: %d", signo);
+}
+
+#endif
diff --git a/signal/sigaction.c b/signal/sigaction.c
new file mode 100644
index 0000000..0126c99
--- /dev/null
+++ b/signal/sigaction.c
@@ -0,0 +1,72 @@
+/* sigaction.c - Generic sigaction implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+#include "pt-internal.h"
+
+int
+sigaction (int sig, const struct sigaction *restrict sa,
+ struct sigaction *restrict osa)
+{
+ if (sig <= 0 || sig >= NSIG)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ struct signal_state *ss = &_pthread_self ()->ss;
+
+ pthread_mutex_lock (&ss->lock);
+
+ if (osa)
+ *osa = ss->actions[sig - 1];
+
+ if (sa)
+ {
+ ss->actions[sig - 1] = *sa;
+
+ /* "The SIGKILL and SIGSTOP signals shall not be added to the
+ signal mask using this mechanism; this restriction shall be
+ enforced by the system without causing an error to be
+ indicated" (sigaction). */
+ sigdelset (&ss->blocked, SIGKILL);
+ sigdelset (&ss->blocked, SIGSTOP);
+
+ /* A "signal shall remain pending on the process until it is
+ unblocked, it is accepted when ..., or the action associated
+ with it is set to ignore the signal" (2.4.1).
+
+ "Setting a signal action to SIG_DFL for a signal that is
+ pending, and whose default action is to ignore the signal,
+ ..., shall cause the pending signal to be discarded, whether
+ or not it is blocked" (2.4.3). */
+ if (sa->sa_handler == SIG_IGN
+ || (sa->sa_handler == SIG_DFL && default_action (sig) == sig_ignore))
+ {
+ sigdelset (&ss->pending, sig);
+ sigdelset (&process_pending, sig);
+ }
+ }
+
+ pthread_mutex_unlock (&ss->lock);
+
+ return 0;
+}
+
diff --git a/signal/sigaltstack.c b/signal/sigaltstack.c
new file mode 100644
index 0000000..8334811
--- /dev/null
+++ b/signal/sigaltstack.c
@@ -0,0 +1,69 @@
+/* sigaltstack.c - Generic sigaltstack implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+#include "pt-internal.h"
+
+int
+sigaltstack (const stack_t *restrict stack, stack_t *restrict old)
+{
+ int err = 0;
+ struct signal_state *ss = &_pthread_self ()->ss;
+
+ pthread_mutex_lock (&ss->lock);
+
+ if (old)
+ *old = ss->stack;
+
+ if (stack)
+ {
+ if (stack->ss_size < MINSIGSTKSZ)
+ {
+ err = ENOMEM;
+ goto out;
+ }
+
+ if ((stack->ss_flags & ~(SS_DISABLE)))
+ /* Flags contains a value other than SS_DISABLE. */
+ {
+ err = EINVAL;
+ goto out;
+ }
+
+ if ((ss->stack.ss_flags & SS_ONSTACK))
+ /* Stack in use. */
+ {
+ err = EPERM;
+ goto out;
+ }
+
+ ss->stack = *stack;
+ }
+
+ out:
+ pthread_mutex_unlock (&ss->lock);
+
+ if (err)
+ {
+ errno = err;
+ return -1;
+ }
+ return 0;
+}
diff --git a/signal/signal-dispatch.c b/signal/signal-dispatch.c
new file mode 100644
index 0000000..40440b7
--- /dev/null
+++ b/signal/signal-dispatch.c
@@ -0,0 +1,117 @@
+/* signal-dispatch.c - Signal dispatcher.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+/* This is the signal handler entry point. A thread is forced into
+ this state when it receives a signal. We need to save the thread's
+ state and then invoke the high-level signal dispatcher. SS->LOCK
+ is locked by the caller. */
+void
+signal_dispatch (struct signal_state *ss, siginfo_t *si)
+{
+ SIGNAL_DISPATCH_ENTRY;
+
+ int signo = si->si_signo;
+
+ assert (signo > 0 && signo < NSIG);
+ assert (pthread_mutex_trylock (&ss->lock) == EBUSY);
+
+ do
+ {
+ if ((sigmask (signo) & STOPSIGS))
+ /* Stop signals clear a pending SIGCONT even if they
+ are handled or ignored (but not if preempted). */
+ {
+ sigdelset (&ss->pending, SIGCONT);
+ sigdelset (&process_pending, SIGCONT);
+ }
+ else if ((signo == SIGCONT))
+ /* Even if handled or ignored (but not preempted), SIGCONT
+ clears stop signals and resumes the process. */
+ {
+ ss->pending &= ~STOPSIGS;
+ process_pending &= ~STOPSIGS;
+ }
+
+ void (*handler)(int, siginfo_t *, void *)
+ = ss->actions[signo - 1].sa_sigaction;
+
+ /* Reset to SIG_DFL if requested. SIGILL and SIGTRAP cannot
+ be automatically reset when delivered; the system silently
+ enforces this restriction (sigaction). */
+ if (ss->actions[signo - 1].sa_flags & SA_RESETHAND
+ && signo != SIGILL && signo != SIGTRAP)
+ ss->actions[signo - 1].sa_handler = SIG_DFL;
+
+ sigset_t orig_blocked = ss->blocked;
+ /* Block requested signals while running the handler. */
+ ss->blocked |= ss->actions[signo - 1].sa_mask;
+
+ /* Block SIGNO unless we're asked not to. */
+ if (! (ss->actions[signo - 1].sa_flags & (SA_RESETHAND | SA_NODEFER)))
+ sigaddset (&ss->blocked, signo);
+
+ sigdelset (&ss->pending, signo);
+ pthread_mutex_unlock (&ss->lock);
+
+ pthread_mutex_lock (&sig_lock);
+ sigdelset (&process_pending, signo);
+ pthread_mutex_unlock (&sig_lock);
+
+ if (handler == (void *) SIG_DFL)
+ {
+ enum sig_action action = default_action (signo);
+
+ if (action == sig_terminate || action == sig_core)
+ _exit (128 + signo);
+
+ if (action == sig_stop)
+ /* XXX: Implement me. */
+ panic ("Stopping process unimplemented.");
+
+ if (action == sig_cont)
+ /* XXX: Implement me. */;
+ panic ("Continuing process unimplemented.");
+ }
+ else if (handler == (void *) SIG_IGN)
+ ;
+ else
+ handler (signo, si, NULL);
+
+ pthread_mutex_lock (&ss->lock);
+
+ /* "When a thread's signal mask is changed in a signal-catching
+ function that is installed by sigaction(), the restoration of
+ the signal mask on return from the signal-catching function
+ overrides that change (see sigaction())" (sigprocmask). */
+ ss->blocked = orig_blocked;
+
+ sigset_t pending = ~ss->blocked & ss->pending;
+ if (! pending)
+ pending = ~ss->blocked & process_pending;
+ signo = l4_lsb64 (pending);
+ }
+ while (signo);
+
+ pthread_mutex_unlock (&ss->lock);
+
+ SIGNAL_DISPATCH_EXIT;
+}
diff --git a/signal/signal.h b/signal/signal.h
new file mode 100644
index 0000000..a33d995
--- /dev/null
+++ b/signal/signal.h
@@ -0,0 +1,275 @@
+/* signal.h - Signal handling interface.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SIGNAL_H
+#define _SIGNAL_H 1
+
+#include <stdint.h>
+#include <sys/types.h>
+
+typedef volatile int sig_atomic_t;
+
+typedef uint64_t sigset_t;
+
+int sigaddset (sigset_t *, int);
+int sigdelset (sigset_t *, int);
+int sigemptyset (sigset_t *);
+int sigfillset (sigset_t *);
+int sigismember (const sigset_t *, int);
+
+/* These values are consistent with Linux. */
+#define SIGRTMIN 34
+#define SIGRTMAX 64
+
+enum
+ {
+ SIGHUP = 1,
+#define SIGHUP SIGHUP
+ SIGINT,
+#define SIGINT SIGINT
+ SIGQUIT,
+#define SIGQUIT SIGQUIT
+ SIGILL,
+#define SIGILL SIGILL
+ SIGTRAP,
+#define SIGTRAP SIGTRAP
+ SIGABRT,
+#define SIGABRT SIGABRT
+ SIGBUS,
+#define SIGBUS SIGBUS
+ SIGFPE,
+#define SIGFPE SIGFPE
+ SIGKILL,
+#define SIGKILL SIGKILL
+ SIGUSR1,
+#define SIGUSR1 SIGUSR1
+ SIGSEGV,
+#define SIGSEGV SIGSEGV
+ SIGUSR2,
+#define SIGUSR2 SIGUSR2
+ SIGPIPE,
+#define SIGPIPE SIGPIPE
+ SIGALRM,
+#define SIGALRM SIGALRM
+ SIGTERM,
+#define SIGTERM SIGTERM
+ SIGSTKFLT,
+#define SIGSTKFLT SIGSTKFLT
+ SIGCHLD,
+#define SIGCHLD SIGCHLD
+ SIGCONT,
+#define SIGCONT SIGCONT
+ SIGSTOP,
+#define SIGSTOP SIGSTOP
+ SIGTSTP,
+#define SIGTSTP SIGTSTP
+ SIGTTIN,
+#define SIGTTIN SIGTTIN
+ SIGTTOU,
+#define SIGTTOU SIGTTOU
+ SIGURG,
+#define SIGURG SIGURG
+ SIGXCPU,
+#define SIGXCPU SIGXCPU
+ SIGXFSZ,
+#define SIGXFSZ SIGXFSZ
+ SIGVTALRM,
+#define SIGVTALRM SIGVTALRM
+ SIGPROF,
+#define SIGPROF SIGPROF
+ SIGWINCH,
+#define SIGWINCH SIGWINCH
+ SIGIO,
+#define SIGIO SIGIO
+ SIGPWR,
+#define SIGPWR SIGPWR
+ SIGSYS,
+#define SIGSYS SIGSYS
+ NSIG
+ };
+
+/* The resulting set is the union of the current set and the signal
+ set pointed to by the argument set. */
+#define SIG_BLOCK 1
+/* The resulting set is the intersection of the current set and the
+ complement of the signal set pointed to by the argument set. */
+#define SIG_UNBLOCK 2
+/* The resulting set is the signal set pointed to by the argument
+ set. */
+#define SIG_SETMASK 3
+
+int pthread_sigmask (int how, const sigset_t *mask, sigset_t *old);
+int sigprocmask (int how, const sigset_t *restrict mask,
+ sigset_t *restrict old);
+
+/* Return set of pending signals. */
+int sigpending(sigset_t *set);
+
+union sigval
+{
+ int sival_int;
+ void *sival_ptr;
+};
+
+#define SIG_DFL ((void (*)(int)) (0))
+#define SIG_ERR ((void (*)(int)) (-1))
+#define SIG_IGN ((void (*)(int)) (1))
+
+/* Causes signal delivery to occur on an alternate stack. */
+#define SA_ONSTACK (1 << 0)
+/* Do not generate SIGCHLD when children stop or stopped children
+ continue. */
+#define SA_NOCLDSTOP (1 << 1)
+/* Causes signal dispositions to be set to SIG_DFL on entry to signal
+ handlers. */
+#define SA_RESETHAND (1 << 2)
+/* Causes certain functions to become restartable. */
+#define SA_RESTART (1 << 3)
+/* Causes extra information to be passed to signal handlers at the
+ time of receipt of a signal. */
+#define SA_SIGINFO (1 << 4)
+/* Causes implementations not to create zombie processes on child
+ death. */
+#define SA_NOCLDWAIT (1 << 5)
+/* Causes signal not to be automatically blocked on entry to
+ signal handler. */
+#define SA_NODEFER (1 << 6)
+
+typedef struct
+{
+ int si_signo;
+ int si_code;
+ int si_errno;
+ pid_t si_pid;
+ uid_t si_uid;
+ void *si_addr;
+ int si_status;
+ long si_band;
+ union sigval si_value;
+} siginfo_t;
+
+struct sigaction
+{
+ union
+ {
+ /* Pointer to a signal-catching function or one of the macros
+ SIG_IGN or SIG_DFL. */
+ void (*sa_handler)(int);
+
+ /* Pointer to a signal-catching function. */
+ void (*sa_sigaction)(int, siginfo_t *, void *);
+ };
+
+ /* Set of signals to be blocked during execution of the signal
+ handling function. */
+ sigset_t sa_mask;
+
+ /* Special flags. */
+ int sa_flags;
+};
+
+int sigaction (int signo, const struct sigaction *restrict newaction,
+ struct sigaction *restrict oldaction);
+
+void (*signal (int signo, void (*handler)(int)))(int);
+void (*bsd_signal (int signo, void (*handler)(int)))(int);
+
+/* Process is executing on an alternate signal stack. */
+#define SS_ONSTACK (1 << 0)
+/* Alternate signal stack is disabled. */
+#define SS_DISABLE (1 << 1)
+
+/* Minimum stack size for a signal handler. */
+#define MINSIGSTKSZ PAGESIZE
+/* Default size in bytes for the alternate signal stack. */
+#define SIGSTKSZ (16 * PAGESIZE)
+
+typedef struct
+{
+ void *ss_sp;
+ size_t ss_size;
+ int ss_flags;
+} stack_t;
+
+int sigaltstack(const stack_t *restrict stack, stack_t *restrict old);
+
+#include <pthread.h>
+
+/* Send SIGNO to the process PID. */
+int kill(pid_t pid, int signo);
+
+/* Send SIGNO to the process group PG. */
+int killpg(pid_t pg, int signo);
+
+/* Send SIGNO to thread TID. */
+int pthread_kill(pthread_t tid, int signo);
+
+/* Send a signal to thread TID using SIGINFO. */
+int pthread_kill_siginfo_np (pthread_t tid, siginfo_t siginfo);
+
+/* Send SIGNO to the calling thread. */
+int raise(int signo);
+
+typedef struct sigevent
+{
+ /* Notification type. */
+ int sigev_notify;
+
+ /* Signal number. */
+ int sigev_signo;
+
+ /* Signal value. */
+ union sigval sigev_value;
+
+ /* Notification function. */
+ void (*sigev_notify_function) (union sigval);
+
+ /* Notification attributes. */
+ pthread_attr_t *sigev_notify_attributes;
+} sigevent_t;
+
+enum
+ {
+ SIGEV_NONE = 0,
+#define SIGEV_NONE SIGEV_NONE
+ SIGEV_SIGNAL,
+#define SIGEV_SIGNAL SIGEV_SIGNAL
+ SIGEV_THREAD
+#define SIGEV_THREAD SIGEV_THREAD
+ };
+
+#define SIG_HOLD
+
+int sighold (int);
+int sigignore (int);
+int siginterrupt (int, int);
+int sigpause (int);
+int sigqueue (pid_t, int, const union sigval);
+int sigrelse (int);
+void (*sigset (int, void (*)(int)))(int);
+int sigsuspend (const sigset_t *);
+
+/* Wait for a signal. */
+int sigwait (const sigset_t *restrict set, int *restrict signo);
+int sigwaitinfo (const sigset_t *restrict set, siginfo_t *restrict info);
+int sigtimedwait (const sigset_t *restrict set, siginfo_t *restrict info,
+ const struct timespec *restrict timespec);
+
+#endif
diff --git a/signal/sigpending.c b/signal/sigpending.c
new file mode 100644
index 0000000..609b55d
--- /dev/null
+++ b/signal/sigpending.c
@@ -0,0 +1,38 @@
+/* sigpending.c - Generic sigpending implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sig-internal.h>
+#include <pt-internal.h>
+
+int
+sigpending (sigset_t *set)
+{
+ struct signal_state *ss = &_pthread_self ()->ss;
+
+ pthread_mutex_lock (&ss->lock);
+
+ /* There is no need to lock SIG_LOCK for process_pending since we
+ just read it, which is atomic. */
+ *set = (ss->pending | process_pending) & ss->blocked;
+
+ pthread_mutex_unlock (&ss->lock);
+
+ return 0;
+}
diff --git a/signal/sigsuspend.c b/signal/sigsuspend.c
new file mode 100644
index 0000000..73cf12a
--- /dev/null
+++ b/signal/sigsuspend.c
@@ -0,0 +1,29 @@
+/* sigsuspend.c - Generic sigsuspend implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+sigsuspend (const sigset_t *set)
+{
+ /* XXX: Implement me. */
+ errno = EOPNOTSUPP;
+ return -1;
+}
diff --git a/signal/sigtimedwait.c b/signal/sigtimedwait.c
new file mode 100644
index 0000000..52cd017
--- /dev/null
+++ b/signal/sigtimedwait.c
@@ -0,0 +1,30 @@
+/* sigtimedwait.c - Generic sigtimedwait implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+sigtimedwait (const sigset_t *restrict set, siginfo_t *restrict info,
+ const struct timespec *restrict timeout)
+{
+ errno = EOPNOTSUPP;
+ return -1;
+}
+
diff --git a/signal/sigwaiter.c b/signal/sigwaiter.c
new file mode 100644
index 0000000..8d041ac
--- /dev/null
+++ b/signal/sigwaiter.c
@@ -0,0 +1,91 @@
+/* sigwaiter.c - Signal handling functions.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+#include <hurd/futex.h>
+
+struct sigwaiter *sigwaiters;
+
+siginfo_t
+sigwaiter_block (struct signal_state *ss, const sigset_t *restrict set)
+{
+ assert (pthread_mutex_trylock (&sig_lock) == EBUSY);
+ assert (pthread_mutex_trylock (&ss->lock) == EBUSY);
+
+ assert (! ss->sigwaiter);
+
+ struct sigwaiter waiter;
+
+ waiter.next = sigwaiters;
+ if (waiter.next)
+ {
+ assert (! waiter.next->prev);
+ waiter.next->prev = &waiter;
+ }
+ waiter.prev = 0;
+ sigwaiters = &waiter;
+
+ waiter.ss = ss;
+ waiter.info.si_signo = 0;
+ waiter.signals = *set;
+
+ ss->sigwaiter = &waiter;
+
+ pthread_mutex_unlock (&ss->lock);
+ pthread_mutex_unlock (&sig_lock);
+
+ futex_wait (&waiter.info.si_signo, 0);
+
+#ifndef NDEBUG
+ pthread_mutex_lock (&ss->lock);
+ ss->sigwaiter = 0;
+ pthread_mutex_unlock (&ss->lock);
+#endif
+
+ assert (waiter.info.si_signo);
+ return waiter.info;
+}
+
+void
+sigwaiter_unblock (struct sigwaiter *waiter)
+{
+ assert (pthread_mutex_trylock (&sig_lock) == EBUSY);
+ assert (pthread_mutex_trylock (&waiter->ss->lock) == EBUSY);
+
+ struct sigwaiter *prev = waiter->prev;
+ struct sigwaiter *next = waiter->next;
+
+ if (next)
+ next->prev = prev;
+
+ if (prev)
+ prev->next = next;
+ else
+ sigwaiters = next;
+
+ sigdelset (&process_pending, waiter->info.si_signo);
+ sigdelset (&waiter->ss->pending, waiter->info.si_signo);
+
+ pthread_mutex_unlock (&waiter->ss->lock);
+ pthread_mutex_unlock (&sig_lock);
+
+ futex_wake (&waiter->info.si_signo, 1);
+}
diff --git a/signal/sigwaitinfo.c b/signal/sigwaitinfo.c
new file mode 100644
index 0000000..1b47079
--- /dev/null
+++ b/signal/sigwaitinfo.c
@@ -0,0 +1,74 @@
+/* sigwaitinfo.c - Generic sigwaitinfo implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sig-internal.h>
+#include <pt-internal.h>
+
+int
+sigwaitinfo (const sigset_t *restrict set, siginfo_t *restrict info)
+{
+ pthread_mutex_lock (&sig_lock);
+
+ struct signal_state *ss = &_pthread_self ()->ss;
+
+ pthread_mutex_lock (&ss->lock);
+
+ if ((process_pending & *set) || (ss->pending & *set))
+ /* There is at least one signal pending. */
+ {
+ bool local = true;
+ sigset_t extant = process_pending & *set;
+ if (! extant)
+ {
+ local = false;
+ extant = ss->pending & *set;
+ }
+
+ assert (extant);
+
+ int signo = l4_msb64 (extant);
+
+ if (info)
+ {
+ if (local)
+ *info = ss->info[signo - 1];
+ else
+ *info = process_pending_info[signo - 1];
+ info->si_signo = signo;
+ }
+
+ sigdelset (&process_pending, signo);
+ sigdelset (&ss->pending, signo);
+
+ pthread_mutex_unlock (&ss->lock);
+ pthread_mutex_unlock (&sig_lock);
+ return 0;
+ }
+
+ siginfo_t i = sigwaiter_block (ss, set);
+ assert (i.si_signo);
+ assert ((sigmask (i.si_signo) & *set));
+
+ if (info)
+ *info = i;
+
+ return 0;
+}
+
diff --git a/sysdeps/generic/bits/barrier-attr.h b/sysdeps/generic/bits/barrier-attr.h
index 86f3cb0..a9900b7 100644
--- a/sysdeps/generic/bits/barrier-attr.h
+++ b/sysdeps/generic/bits/barrier-attr.h
@@ -1,5 +1,5 @@
/* Thread barrier attribute type. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ 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
@@ -20,6 +20,8 @@
#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
diff --git a/sysdeps/generic/bits/cancelation.h b/sysdeps/generic/bits/cancelation.h
index bb6b58a..46486f5 100644
--- a/sysdeps/generic/bits/cancelation.h
+++ b/sysdeps/generic/bits/cancelation.h
@@ -1,5 +1,5 @@
/* Cancelation. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ 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
@@ -20,8 +20,6 @@
#ifndef _BITS_CANCELATION_H
#define _BITS_CANCELATION_H 1
-#include <assert.h>
-
struct __pthread_cancelation_handler
{
void (*handler)(void *);
@@ -32,22 +30,21 @@ struct __pthread_cancelation_handler
/* 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) \
+#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 \
+ (rt), \
+ (rtarg), \
+ *__handlers \
}; \
*__handlers = &__handler;
-#define pthread_cleanup_pop(execute) \
+#define __pthread_cleanup_pop(execute) \
if (execute) \
__handler.handler (__handler.arg); \
- assert (*__handlers == &__handler); \
*__handlers = __handler.next; \
}
diff --git a/sysdeps/generic/bits/condition-attr.h b/sysdeps/generic/bits/condition-attr.h
index 2d48dfb..4cd4e8c 100644
--- a/sysdeps/generic/bits/condition-attr.h
+++ b/sysdeps/generic/bits/condition-attr.h
@@ -1,5 +1,5 @@
/* Condition attribute type. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ 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
@@ -20,13 +20,15 @@
#ifndef _BITS_CONDITION_ATTR_H
#define _BITS_CONDITION_ATTR_H 1
-#include <time.h>
+#include <bits/types.h>
+
+enum __pthread_process_shared;
/* User visible part of a condition attribute variable. */
struct __pthread_condattr
{
enum __pthread_process_shared pshared;
- clockid_t clock;
+ __clockid_t clock;
};
#endif /* bits/condition.h */
diff --git a/sysdeps/generic/bits/condition.h b/sysdeps/generic/bits/condition.h
index f3b09be..bf13ada 100644
--- a/sysdeps/generic/bits/condition.h
+++ b/sysdeps/generic/bits/condition.h
@@ -1,5 +1,5 @@
/* Condition type. Generic version.
- Copyright (C) 2000, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2005, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -34,6 +34,6 @@ struct __pthread_cond
/* Initializer for a condition variable. */
#define __PTHREAD_COND_INITIALIZER \
- { __SPIN_LOCK_INITIALIZER, NULL, NULL, NULL, NULL }
+ { __PTHREAD_SPIN_LOCK_INITIALIZER, NULL, NULL, NULL, NULL }
#endif /* bits/condition.h */
diff --git a/sysdeps/generic/bits/mutex-attr.h b/sysdeps/generic/bits/mutex-attr.h
index 883b074..8514ebe 100644
--- a/sysdeps/generic/bits/mutex-attr.h
+++ b/sysdeps/generic/bits/mutex-attr.h
@@ -1,5 +1,5 @@
/* Mutex attribute type. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ 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
@@ -20,6 +20,10 @@
#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
@@ -30,4 +34,8 @@ struct __pthread_mutexattr
enum __pthread_mutex_type mutex_type;
};
+/* Attributes for a recursive mutex. */
+extern const struct __pthread_mutexattr __pthread_errorcheck_mutexattr;
+extern const struct __pthread_mutexattr __pthread_recursive_mutexattr;
+
#endif /* bits/mutex-attr.h */
diff --git a/sysdeps/generic/bits/mutex.h b/sysdeps/generic/bits/mutex.h
index feb6d07..c734c39 100644
--- a/sysdeps/generic/bits/mutex.h
+++ b/sysdeps/generic/bits/mutex.h
@@ -1,5 +1,8 @@
/* Mutex type. Generic version.
- Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
+
+ Copyright (C) 2000, 2002, 2005, 2006, 2007, 2008, 2009
+ Free Software Foundation, Inc.
+
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -52,88 +55,21 @@ struct __pthread_mutex
/* 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 }
+ { __PTHREAD_SPIN_LOCK_INITIALIZER, __PTHREAD_SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0, 0 }
-# endif
-#endif /* Not __pthread_mutex_defined. */
+# define __PTHREAD_ERRORCHECK_MUTEXATTR ((struct __pthread_mutexattr *) ((unsigned long) __PTHREAD_MUTEX_ERRORCHECK + 1))
-#ifdef _BITS_MUTEX_H
+# define __PTHREAD_ERRORCHECK_MUTEX_INITIALIZER \
+ { __PTHREAD_SPIN_LOCK_INITIALIZER, __PTHREAD_SPIN_LOCK_INITIALIZER, 0, 0, \
+ __PTHREAD_ERRORCHECK_MUTEXATTR, 0, 0, 0 }
-#include <errno.h>
-#include <stddef.h>
+# define __PTHREAD_RECURSIVE_MUTEXATTR ((struct __pthread_mutexattr *) ((unsigned long) __PTHREAD_MUTEX_RECURSIVE + 1))
-#ifdef __USE_EXTERN_INLINES
+# define __PTHREAD_RECURSIVE_MUTEX_INITIALIZER \
+ { __PTHREAD_SPIN_LOCK_INITIALIZER, __PTHREAD_SPIN_LOCK_INITIALIZER, 0, 0, \
+ __PTHREAD_RECURSIVE_MUTEXATTR, 0, 0, 0 }
-# ifndef _EXTERN_INLINE
-# define _EXTERN_INLINE extern __inline
# endif
-
-_EXTERN_INLINE int
-pthread_mutex_init (struct __pthread_mutex *__restrict __mutex,
- const pthread_mutexattr_t *__restrict attr)
-{
- struct __pthread_mutex initialized_mutex = __PTHREAD_MUTEX_INITIALIZER;
-
- extern int _pthread_mutex_init (struct __pthread_mutex *,
- const pthread_mutexattr_t *);
-
- if (attr)
- return _pthread_mutex_init (__mutex, attr);
-
- *__mutex = initialized_mutex;
- return 0;
-}
-
-_EXTERN_INLINE int
-pthread_mutex_destroy (struct __pthread_mutex *__mutex)
-{
- extern int _pthread_mutex_destroy (struct __pthread_mutex *);
-
- if (__mutex->attr || __mutex->data)
- return _pthread_mutex_destroy (__mutex);
-
- return 0;
-}
-
-_EXTERN_INLINE int
-__pthread_mutex_lock (struct __pthread_mutex *__mutex)
-{
- extern int _pthread_mutex_lock (struct __pthread_mutex *);
-
- if (__mutex->attr == NULL
- && __mutex->data == NULL
- && __pthread_spin_trylock (&__mutex->__held) == 0)
- return 0;
-
- return _pthread_mutex_lock (__mutex);
-}
-
-extern __inline int
-__pthread_mutex_trylock (struct __pthread_mutex *__mutex)
-{
- extern int _pthread_mutex_trylock (struct __pthread_mutex *);
-
- if (__mutex->attr == NULL
- && __mutex->data == NULL)
- return __pthread_spin_trylock (&__mutex->__held);
-
- return _pthread_mutex_trylock (__mutex);
-}
-
-extern __inline int
-pthread_mutex_lock (struct __pthread_mutex *__mutex)
-{
- return __pthread_mutex_lock (__mutex);
-}
-
-extern __inline int
-pthread_mutex_trylock (struct __pthread_mutex *__mutex)
-{
- return __pthread_mutex_trylock (__mutex);
-}
-
-#endif /* Use extern inlines. */
-
-#endif
+#endif /* Not __pthread_mutex_defined. */
#endif /* bits/mutex.h */
diff --git a/sysdeps/generic/bits/once.h b/sysdeps/generic/bits/once.h
index 7f572fa..f4985d6 100644
--- a/sysdeps/generic/bits/once.h
+++ b/sysdeps/generic/bits/once.h
@@ -1,5 +1,5 @@
/* Dynamic package initialization data structures. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -29,6 +29,6 @@ struct __pthread_once
};
#define __PTHREAD_ONCE_INIT \
- { 0, __SPIN_LOCK_INITIALIZER }
+ { 0, __PTHREAD_SPIN_LOCK_INITIALIZER }
#endif /* bits/once.h */
diff --git a/sysdeps/generic/bits/pthread-np.h b/sysdeps/generic/bits/pthread-np.h
new file mode 100644
index 0000000..d5ddbb0
--- /dev/null
+++ b/sysdeps/generic/bits/pthread-np.h
@@ -0,0 +1,27 @@
+/* Non-portable functions. Generic version.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/*
+ * Never include this file directly; use <pthread.h> or <cthreads.h> instead.
+ */
+
+#ifndef _BITS_PTHREAD_NP_H
+#define _BITS_PTHREAD_NP_H 1
+
+#endif /* bits/pthread-np.h */
diff --git a/sysdeps/generic/bits/pthread.h b/sysdeps/generic/bits/pthread.h
index 3f9df13..80e6b09 100644
--- a/sysdeps/generic/bits/pthread.h
+++ b/sysdeps/generic/bits/pthread.h
@@ -1,5 +1,5 @@
/* Pthread data structures. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ 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
@@ -20,14 +20,19 @@
#ifndef _BITS_PTHREAD_H
#define _BITS_PTHREAD_H 1
-typedef int pthread_t;
+typedef int __pthread_t;
/* Return true if __T1 and __T2 both name the same thread. Otherwise,
false. */
-extern __inline int
-pthread_equal (pthread_t __t1, pthread_t __t2)
+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/sysdeps/generic/bits/pthreadtypes.h b/sysdeps/generic/bits/pthreadtypes.h
new file mode 100644
index 0000000..e5cbfd2
--- /dev/null
+++ b/sysdeps/generic/bits/pthreadtypes.h
@@ -0,0 +1,29 @@
+/*
+ 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. */
+
+#if !defined _BITS_TYPES_H && !defined _PTHREAD_H
+# error "Never include <bits/pthreadtypes.h> directly; use <sys/types.h> instead."
+#endif
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#include <pthread.h>
+
+#endif /* bits/pthreadtypes.h */
diff --git a/sysdeps/generic/bits/rwlock-attr.h b/sysdeps/generic/bits/rwlock-attr.h
index 44765bd..dba99f1 100644
--- a/sysdeps/generic/bits/rwlock-attr.h
+++ b/sysdeps/generic/bits/rwlock-attr.h
@@ -1,5 +1,5 @@
/* Thread rwlock attribute type. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ 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
@@ -20,6 +20,8 @@
#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
diff --git a/sysdeps/generic/bits/rwlock.h b/sysdeps/generic/bits/rwlock.h
index fc429b4..af6b1c8 100644
--- a/sysdeps/generic/bits/rwlock.h
+++ b/sysdeps/generic/bits/rwlock.h
@@ -1,5 +1,5 @@
/* rwlock type. Generic version.
- Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -40,34 +40,7 @@ struct __pthread_rwlock
/* Initializer for a rwlock. */
#define __PTHREAD_RWLOCK_INITIALIZER \
- { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0 }
+ { __PTHREAD_SPIN_LOCK_INITIALIZER, __PTHREAD_SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0 }
-_EXTERN_INLINE int
-pthread_rwlock_init (struct __pthread_rwlock *__restrict __rwlock,
- const struct __pthread_rwlockattr *__restrict __attr)
-{
- struct __pthread_rwlock initialized_rwlock = __PTHREAD_RWLOCK_INITIALIZER;
- extern int _pthread_rwlock_init (struct __pthread_rwlock *,
- const struct __pthread_rwlockattr *);
-
- if (__attr)
- return _pthread_rwlock_init (__rwlock, __attr);
-
- *__rwlock = initialized_rwlock;
- return 0;
-}
-
-_EXTERN_INLINE int
-pthread_rwlock_destroy (struct __pthread_rwlock *__rwlock)
-{
- extern int _pthread_rwlock_destroy (struct __pthread_rwlock *);
-
- if (__rwlock->__attr
- || __rwlock->__data)
- return _pthread_rwlock_destroy (__rwlock);
-
- return 0;
-}
-
#endif /* bits/rwlock.h */
diff --git a/sysdeps/generic/bits/semaphore.h b/sysdeps/generic/bits/semaphore.h
index b53f47e..5e987c1 100644
--- a/sysdeps/generic/bits/semaphore.h
+++ b/sysdeps/generic/bits/semaphore.h
@@ -1,5 +1,5 @@
/* Semaphore type. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -38,6 +38,6 @@ struct __semaphore
/* Initializer for a semaphore. */
#define __SEMAPHORE_INITIALIZER(pshared, value) \
- { __SPIN_LOCK_INITIALIZER, NULL, (pshared), (value), NULL }
+ { __PTHREAD_SPIN_LOCK_INITIALIZER, NULL, (pshared), (value), NULL }
#endif /* bits/mutex.h */
diff --git a/sysdeps/generic/bits/thread-attr.h b/sysdeps/generic/bits/thread-attr.h
index 3163022..f2e55f2 100644
--- a/sysdeps/generic/bits/thread-attr.h
+++ b/sysdeps/generic/bits/thread-attr.h
@@ -1,5 +1,5 @@
/* Thread attribute type. Generic version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ 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
@@ -20,13 +20,18 @@
#ifndef _BITS_THREAD_ATTR_H
#define _BITS_THREAD_ATTR_H 1
-#include <sched.h>
+#define __need_schedparam
+#include <bits/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;
+ struct __sched_param schedparam;
void *stackaddr;
size_t stacksize;
size_t guardsize;
diff --git a/sysdeps/generic/killpg.c b/sysdeps/generic/killpg.c
new file mode 100644
index 0000000..7f7ed87
--- /dev/null
+++ b/sysdeps/generic/killpg.c
@@ -0,0 +1,27 @@
+/* killpg.c - Generic killpg implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+killpg (pid_t pid, int sig)
+{
+ return kill (-pid, sig);
+}
diff --git a/sysdeps/generic/pt-attr-getschedparam.c b/sysdeps/generic/pt-attr-getschedparam.c
index 25afebd..190cf9d 100644
--- a/sysdeps/generic/pt-attr-getschedparam.c
+++ b/sysdeps/generic/pt-attr-getschedparam.c
@@ -19,6 +19,7 @@
#include <pthread.h>
#include <sched.h>
+#include <string.h>
#include <pt-internal.h>
@@ -26,6 +27,6 @@ int
pthread_attr_getschedparam (const pthread_attr_t *attr,
struct sched_param *param)
{
- *param = attr->schedparam;
+ memcpy (param, &attr->schedparam, sizeof *param);
return 0;
}
diff --git a/sysdeps/generic/pt-attr-setschedparam.c b/sysdeps/generic/pt-attr-setschedparam.c
index 18a575e..5459f10 100644
--- a/sysdeps/generic/pt-attr-setschedparam.c
+++ b/sysdeps/generic/pt-attr-setschedparam.c
@@ -30,7 +30,7 @@ pthread_attr_setschedparam (pthread_attr_t *attr,
if (memcmp (param, &__pthread_default_attr.schedparam,
sizeof *param) == 0)
{
- attr->schedparam = *param;
+ memcpy (&attr->schedparam, param, sizeof *param);
return 0;
}
diff --git a/sysdeps/generic/pt-kill.c b/sysdeps/generic/pt-kill.c
new file mode 100644
index 0000000..0dfac34
--- /dev/null
+++ b/sysdeps/generic/pt-kill.c
@@ -0,0 +1,32 @@
+/* pthread-kill.c - Generic pthread-kill implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+pthread_kill (pthread_t tid, int signo)
+{
+ siginfo_t si;
+ memset (&si, 0, sizeof (si));
+ si.si_signo = signo;
+
+ return pthread_kill_siginfo_np (tid, si);
+}
+
diff --git a/sysdeps/generic/pt-mutex-destroy.c b/sysdeps/generic/pt-mutex-destroy.c
index 72faefe..3bbc73f 100644
--- a/sysdeps/generic/pt-mutex-destroy.c
+++ b/sysdeps/generic/pt-mutex-destroy.c
@@ -1,5 +1,5 @@
/* Destroy a mutex. Generic version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ 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
@@ -26,7 +26,11 @@
int
_pthread_mutex_destroy (pthread_mutex_t *mutex)
{
- if (mutex->attr)
+ if (mutex->attr == __PTHREAD_ERRORCHECK_MUTEXATTR
+ || mutex->attr == __PTHREAD_RECURSIVE_MUTEXATTR)
+ /* Static attributes. */
+ ;
+ else
free (mutex->attr);
return 0;
diff --git a/sysdeps/generic/pt-mutex-init.c b/sysdeps/generic/pt-mutex-init.c
index da1781b..2f96028 100644
--- a/sysdeps/generic/pt-mutex-init.c
+++ b/sysdeps/generic/pt-mutex-init.c
@@ -1,5 +1,5 @@
/* Initialize a mutex. Generic version.
- Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2000, 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
@@ -32,12 +32,14 @@ _pthread_mutex_init (pthread_mutex_t *mutex,
if (! attr
|| memcmp (attr, &__pthread_default_mutexattr, sizeof (*attr) == 0))
- /* Use the default attributes. */
+ /* The default attributes. */
return 0;
- /* Non-default attributes. */
+ if (! mutex->attr
+ || mutex->attr == __PTHREAD_ERRORCHECK_MUTEXATTR
+ || mutex->attr == __PTHREAD_RECURSIVE_MUTEXATTR)
+ mutex->attr = malloc (sizeof *attr);
- mutex->attr = malloc (sizeof *attr);
if (! mutex->attr)
return ENOMEM;
diff --git a/sysdeps/generic/pt-mutex-lock.c b/sysdeps/generic/pt-mutex-lock.c
index 60fc55a..528e593 100644
--- a/sysdeps/generic/pt-mutex-lock.c
+++ b/sysdeps/generic/pt-mutex-lock.c
@@ -1,5 +1,5 @@
/* Lock a mutex. Generic version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ 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
diff --git a/sysdeps/generic/pt-mutex-timedlock.c b/sysdeps/generic/pt-mutex-timedlock.c
index 5e222bd..883e50a 100644
--- a/sysdeps/generic/pt-mutex-timedlock.c
+++ b/sysdeps/generic/pt-mutex-timedlock.c
@@ -1,5 +1,5 @@
/* Lock a mutex with a timeout. Generic version.
- Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
+ 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
@@ -31,13 +31,33 @@ __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex,
const struct timespec *abstime)
{
struct __pthread *self;
+ const struct __pthread_mutexattr *attr = mutex->attr;
+
+ if (attr == __PTHREAD_ERRORCHECK_MUTEXATTR)
+ attr = &__pthread_errorcheck_mutexattr;
+ if (attr == __PTHREAD_RECURSIVE_MUTEXATTR)
+ attr = &__pthread_recursive_mutexattr;
__pthread_spin_lock (&mutex->__lock);
if (__pthread_spin_trylock (&mutex->__held) == 0)
/* Successfully acquired the lock. */
{
- if (mutex->attr)
- switch (mutex->attr->mutex_type)
+#ifdef ALWAYS_TRACK_MUTEX_OWNER
+#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
+#endif
+
+ if (attr)
+ switch (attr->mutex_type)
{
case PTHREAD_MUTEX_NORMAL:
break;
@@ -59,14 +79,18 @@ __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex,
/* The lock is busy. */
self = _pthread_self ();
+ assert (self);
- if (mutex->attr)
+ if (! attr || attr->mutex_type == PTHREAD_MUTEX_NORMAL)
+ {
+#if defined(ALWAYS_TRACK_MUTEX_OWNER)
+ assert (mutex->owner != self);
+#endif
+ }
+ else
{
- switch (mutex->attr->mutex_type)
+ switch (attr->mutex_type)
{
- case PTHREAD_MUTEX_NORMAL:
- break;
-
case PTHREAD_MUTEX_ERRORCHECK:
if (mutex->owner == self)
{
@@ -89,6 +113,11 @@ __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex,
}
}
+#if !defined(ALWAYS_TRACK_MUTEX_OWNER)
+ if (attr && attr->mutex_type != PTHREAD_MUTEX_NORMAL)
+#endif
+ assert (mutex->owner);
+
if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000))
return EINVAL;
@@ -123,8 +152,15 @@ __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex,
else
__pthread_block (self);
- if (mutex->attr)
- switch (mutex->attr->mutex_type)
+#if !defined(ALWAYS_TRACK_MUTEX_OWNER)
+ if (attr && attr->mutex_type != PTHREAD_MUTEX_NORMAL)
+#endif
+ {
+ assert (mutex->owner == self);
+ }
+
+ if (attr)
+ switch (attr->mutex_type)
{
case PTHREAD_MUTEX_NORMAL:
break;
diff --git a/sysdeps/generic/pt-mutex-transfer-np.c b/sysdeps/generic/pt-mutex-transfer-np.c
new file mode 100644
index 0000000..967f1c7
--- /dev/null
+++ b/sysdeps/generic/pt-mutex-transfer-np.c
@@ -0,0 +1,66 @@
+/* Transfer ownership of a mutex. Generic version.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <pthread.h>
+#include <assert.h>
+
+#include <pt-internal.h>
+
+int
+__pthread_mutex_transfer_np (struct __pthread_mutex *mutex, pthread_t tid)
+{
+ assert (mutex->owner == _pthread_self ());
+
+ struct __pthread *thread = __pthread_getid (tid);
+ const struct __pthread_mutexattr *attr = mutex->attr;
+
+ if (! thread)
+ return ESRCH;
+
+ if (thread == _pthread_self ())
+ return 0;
+
+ if (attr == __PTHREAD_ERRORCHECK_MUTEXATTR)
+ attr = &__pthread_errorcheck_mutexattr;
+ if (attr == __PTHREAD_RECURSIVE_MUTEXATTR)
+ attr = &__pthread_recursive_mutexattr;
+
+ if (attr && attr->mutex_type == PTHREAD_MUTEX_ERRORCHECK)
+ {
+
+ if (mutex->owner != _pthread_self ())
+ return EPERM;
+
+ mutex->owner = thread;
+ }
+
+#ifndef NDEBUG
+# if !defined(ALWAYS_TRACK_MUTEX_OWNER)
+ if (attr && attr->mutex_type != PTHREAD_MUTEX_NORMAL)
+# endif
+ {
+ mutex->owner = thread;
+ }
+#endif
+
+ return 0;
+}
+
+strong_alias (__pthread_mutex_transfer_np, pthread_mutex_transfer_np)
diff --git a/sysdeps/generic/pt-mutex-trylock.c b/sysdeps/generic/pt-mutex-trylock.c
index d56f6e1..7a54cc9 100644
--- a/sysdeps/generic/pt-mutex-trylock.c
+++ b/sysdeps/generic/pt-mutex-trylock.c
@@ -1,5 +1,5 @@
/* Try to Lock a mutex. Generic version.
- Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 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
@@ -29,13 +29,33 @@ __pthread_mutex_trylock (struct __pthread_mutex *mutex)
{
int err;
struct __pthread *self;
+ const struct __pthread_mutexattr *attr = mutex->attr;
+
+ if (attr == __PTHREAD_ERRORCHECK_MUTEXATTR)
+ attr = &__pthread_errorcheck_mutexattr;
+ if (attr == __PTHREAD_RECURSIVE_MUTEXATTR)
+ attr = &__pthread_recursive_mutexattr;
__pthread_spin_lock (&mutex->__lock);
if (__pthread_spin_trylock (&mutex->__held) == 0)
/* Acquired the lock. */
{
- if (mutex->attr)
- switch (mutex->attr->mutex_type)
+#if defined(ALWAYS_TRACK_MUTEX_OWNER)
+#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
+#endif
+
+ if (attr)
+ switch (attr->mutex_type)
{
case PTHREAD_MUTEX_NORMAL:
break;
@@ -56,10 +76,10 @@ __pthread_mutex_trylock (struct __pthread_mutex *mutex)
err = EBUSY;
- if (mutex->attr)
+ if (attr)
{
self = _pthread_self ();
- switch (mutex->attr->mutex_type)
+ switch (attr->mutex_type)
{
case PTHREAD_MUTEX_NORMAL:
break;
diff --git a/sysdeps/generic/pt-mutex-unlock.c b/sysdeps/generic/pt-mutex-unlock.c
index 2f719d3..09d70f8 100644
--- a/sysdeps/generic/pt-mutex-unlock.c
+++ b/sysdeps/generic/pt-mutex-unlock.c
@@ -1,5 +1,5 @@
/* Unlock a mutex. Generic version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ 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
@@ -28,15 +28,31 @@ int
__pthread_mutex_unlock (pthread_mutex_t *mutex)
{
struct __pthread *wakeup;
-
+ const struct __pthread_mutexattr *attr = mutex->attr;
+
+ if (attr == __PTHREAD_ERRORCHECK_MUTEXATTR)
+ attr = &__pthread_errorcheck_mutexattr;
+ if (attr == __PTHREAD_RECURSIVE_MUTEXATTR)
+ attr = &__pthread_recursive_mutexattr;
+
__pthread_spin_lock (&mutex->__lock);
- if (mutex->attr)
- switch (mutex->attr->mutex_type)
+ if (! attr || attr->mutex_type == PTHREAD_MUTEX_NORMAL)
+ {
+#if defined(ALWAYS_TRACK_MUTEX_OWNER)
+# ifndef NDEBUG
+ if (_pthread_self ())
+ {
+ assert (mutex->owner);
+ assert (mutex->owner == _pthread_self ());
+ mutex->owner = NULL;
+ }
+# endif
+#endif
+ }
+ else
+ switch (attr->mutex_type)
{
- case PTHREAD_MUTEX_NORMAL:
- break;
-
case PTHREAD_MUTEX_ERRORCHECK:
case PTHREAD_MUTEX_RECURSIVE:
if (mutex->owner != _pthread_self ())
@@ -45,7 +61,7 @@ __pthread_mutex_unlock (pthread_mutex_t *mutex)
return EPERM;
}
- if (mutex->attr->mutex_type == PTHREAD_MUTEX_RECURSIVE)
+ if (attr->mutex_type == PTHREAD_MUTEX_RECURSIVE)
if (--mutex->locks > 0)
{
__pthread_spin_unlock (&mutex->__lock);
@@ -59,6 +75,7 @@ __pthread_mutex_unlock (pthread_mutex_t *mutex)
LOSE;
}
+
if (mutex->__queue == NULL)
{
__pthread_spin_unlock (&mutex->__held);
@@ -69,6 +86,15 @@ __pthread_mutex_unlock (pthread_mutex_t *mutex)
wakeup = mutex->__queue;
__pthread_dequeue (wakeup);
+#ifndef NDEBUG
+# if !defined (ALWAYS_TRACK_MUTEX_OWNER)
+ if (attr && attr->mutex_type != PTHREAD_MUTEX_NORMAL)
+# endif
+ {
+ mutex->owner = wakeup;
+ }
+#endif
+
/* We do not unlock MUTEX->held: we are transferring the ownership
to the thread that we are waking up. */
diff --git a/sysdeps/generic/pt-mutexattr.c b/sysdeps/generic/pt-mutexattr.c
index 647db24..5ebde6e 100644
--- a/sysdeps/generic/pt-mutexattr.c
+++ b/sysdeps/generic/pt-mutexattr.c
@@ -1,5 +1,5 @@
/* Default mutex attributes. Generic version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ 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
@@ -27,3 +27,19 @@ const struct __pthread_mutexattr __pthread_default_mutexattr =
pshared: PTHREAD_PROCESS_PRIVATE,
mutex_type: PTHREAD_MUTEX_DEFAULT
};
+
+const struct __pthread_mutexattr __pthread_errorcheck_mutexattr =
+{
+ prioceiling: 0,
+ protocol: PTHREAD_PRIO_NONE,
+ pshared: PTHREAD_PROCESS_PRIVATE,
+ mutex_type: PTHREAD_MUTEX_ERRORCHECK
+};
+
+const struct __pthread_mutexattr __pthread_recursive_mutexattr =
+{
+ prioceiling: 0,
+ protocol: PTHREAD_PRIO_NONE,
+ pshared: PTHREAD_PROCESS_PRIVATE,
+ mutex_type: PTHREAD_MUTEX_RECURSIVE
+};
diff --git a/sysdeps/generic/pt-rwlock-destroy.c b/sysdeps/generic/pt-rwlock-destroy.c
index 034d930..045eebd 100644
--- a/sysdeps/generic/pt-rwlock-destroy.c
+++ b/sysdeps/generic/pt-rwlock-destroy.c
@@ -1,5 +1,5 @@
/* Destroy a rwlock. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/generic/pt-rwlock-init.c b/sysdeps/generic/pt-rwlock-init.c
index 8aa495e..c9ff9b2 100644
--- a/sysdeps/generic/pt-rwlock-init.c
+++ b/sysdeps/generic/pt-rwlock-init.c
@@ -1,5 +1,5 @@
/* Initialize a rwlock. Generic version.
- Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ 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
diff --git a/sysdeps/generic/pt-startup.c b/sysdeps/generic/pt-startup.c
new file mode 100644
index 0000000..c21a181
--- /dev/null
+++ b/sysdeps/generic/pt-startup.c
@@ -0,0 +1,25 @@
+/* Thread initialization. Generic version.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <pt-internal.h>
+
+void
+__pthread_startup (void)
+{
+}
diff --git a/sysdeps/generic/raise.c b/sysdeps/generic/raise.c
new file mode 100644
index 0000000..410f557
--- /dev/null
+++ b/sysdeps/generic/raise.c
@@ -0,0 +1,41 @@
+/* raise.c - Generic raise implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+raise (int signo)
+{
+ /* According to POSIX, if we implement threads (and we do), then
+ "the effect of the raise() function shall be equivalent to
+ calling: pthread_kill(pthread_self(), sig);" */
+
+debug (0, "");
+ int err = pthread_kill (pthread_self (), signo);
+debug (0, "");
+ if (err)
+ {
+ errno = err;
+ return -1;
+ }
+
+ return 0;
+}
+
diff --git a/sysdeps/generic/sem-destroy.c b/sysdeps/generic/sem-destroy.c
index 985f4ad..6486599 100644
--- a/sysdeps/generic/sem-destroy.c
+++ b/sysdeps/generic/sem-destroy.c
@@ -1,5 +1,5 @@
/* Destroy a semaphore. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ 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
diff --git a/sysdeps/generic/sem-getvalue.c b/sysdeps/generic/sem-getvalue.c
index 8e418e3..7762089 100644
--- a/sysdeps/generic/sem-getvalue.c
+++ b/sysdeps/generic/sem-getvalue.c
@@ -1,5 +1,5 @@
/* Get the value of a semaphore. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ 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
diff --git a/sysdeps/generic/sem-init.c b/sysdeps/generic/sem-init.c
index 6c6d79e..d2414f5 100644
--- a/sysdeps/generic/sem-init.c
+++ b/sysdeps/generic/sem-init.c
@@ -1,5 +1,5 @@
/* Initialize a semaphore. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ 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
diff --git a/sysdeps/generic/sem-open.c b/sysdeps/generic/sem-open.c
index 9eb13aa..bae87ed 100644
--- a/sysdeps/generic/sem-open.c
+++ b/sysdeps/generic/sem-open.c
@@ -1,5 +1,5 @@
/* Open a named semaphore. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ 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
diff --git a/sysdeps/generic/sem-post.c b/sysdeps/generic/sem-post.c
index 0e20ea7..6d438bf 100644
--- a/sysdeps/generic/sem-post.c
+++ b/sysdeps/generic/sem-post.c
@@ -1,5 +1,5 @@
/* Post a semaphore. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ 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
diff --git a/sysdeps/generic/sem-timedwait.c b/sysdeps/generic/sem-timedwait.c
index d01bfdb..e34539a 100644
--- a/sysdeps/generic/sem-timedwait.c
+++ b/sysdeps/generic/sem-timedwait.c
@@ -1,5 +1,5 @@
/* Wait on a semaphore with a timeout. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 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
@@ -18,7 +18,6 @@
Boston, MA 02111-1307, USA. */
#include <semaphore.h>
-#include <error.h>
#include <errno.h>
#include <assert.h>
diff --git a/sysdeps/generic/sem-trywait.c b/sysdeps/generic/sem-trywait.c
index 199f317..437e282 100644
--- a/sysdeps/generic/sem-trywait.c
+++ b/sysdeps/generic/sem-trywait.c
@@ -1,5 +1,5 @@
/* Lock a semaphore if it does not require blocking. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ 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
diff --git a/sysdeps/generic/sem-unlink.c b/sysdeps/generic/sem-unlink.c
index 519f4f7..570ed61 100644
--- a/sysdeps/generic/sem-unlink.c
+++ b/sysdeps/generic/sem-unlink.c
@@ -1,5 +1,5 @@
/* Unlink a named semaphore. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ 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
diff --git a/sysdeps/generic/sem-wait.c b/sysdeps/generic/sem-wait.c
index 50752f3..8347480 100644
--- a/sysdeps/generic/sem-wait.c
+++ b/sysdeps/generic/sem-wait.c
@@ -1,5 +1,5 @@
/* Wait on a semaphore. Generic version.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ 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
diff --git a/sysdeps/generic/sigaddset.c b/sysdeps/generic/sigaddset.c
new file mode 100644
index 0000000..14edb71
--- /dev/null
+++ b/sysdeps/generic/sigaddset.c
@@ -0,0 +1,35 @@
+/* sigaddset.c - Generic sigaddset implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+sigaddset (sigset_t *sigset, int signo)
+{
+ if (signo <= 0 || signo >= NSIG)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ *sigset |= sigmask (signo);
+ return 0;
+}
+
diff --git a/sysdeps/generic/sigdelset.c b/sysdeps/generic/sigdelset.c
new file mode 100644
index 0000000..5456467
--- /dev/null
+++ b/sysdeps/generic/sigdelset.c
@@ -0,0 +1,35 @@
+/* sigdelset.c - Generic sigdelset implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+sigdelset (sigset_t *sigset, int signo)
+{
+ if (signo <= 0 || signo >= NSIG)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ *sigset &= ~sigmask (signo);
+ return 0;
+}
+
diff --git a/sysdeps/generic/sigemptyset.c b/sysdeps/generic/sigemptyset.c
new file mode 100644
index 0000000..690c15b
--- /dev/null
+++ b/sysdeps/generic/sigemptyset.c
@@ -0,0 +1,29 @@
+/* sigemptyset.c - Generic sigemptyset implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <signal.h>
+
+int
+sigemptyset (sigset_t *sigset)
+{
+ *sigset = 0;
+ return 0;
+}
+
diff --git a/sysdeps/generic/sigfillset.c b/sysdeps/generic/sigfillset.c
new file mode 100644
index 0000000..f0ac078
--- /dev/null
+++ b/sysdeps/generic/sigfillset.c
@@ -0,0 +1,29 @@
+/* sigfillset.c - Generic sigfillset implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <signal.h>
+
+int
+sigfillset (sigset_t *sigset)
+{
+ *sigset = (1ULL << (NSIG - 1)) - 1;
+ return 0;
+}
+
diff --git a/sysdeps/generic/siginterrupt.c b/sysdeps/generic/siginterrupt.c
new file mode 100644
index 0000000..0899efb
--- /dev/null
+++ b/sysdeps/generic/siginterrupt.c
@@ -0,0 +1,36 @@
+/* siginterrupt.c - Generic siginterrupt implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+siginterrupt (int sig, int flag)
+{
+ int ret;
+ struct sigaction act;
+
+ sigaction (sig, NULL, &act);
+ if (flag)
+ act.sa_flags &= ~SA_RESTART;
+ else
+ act.sa_flags |= SA_RESTART;
+ ret = sigaction(sig, &act, NULL);
+ return ret;
+}
diff --git a/sysdeps/generic/sigismember.c b/sysdeps/generic/sigismember.c
new file mode 100644
index 0000000..b3d65c9
--- /dev/null
+++ b/sysdeps/generic/sigismember.c
@@ -0,0 +1,36 @@
+/* sigismember.c - Generic sigismember implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+sigismember (const sigset_t *sigset, int signo)
+{
+ if (signo <= 0 || signo >= NSIG)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (*sigset & sigmask (signo))
+ return 1;
+ else
+ return 0;
+}
diff --git a/sysdeps/generic/signal.c b/sysdeps/generic/signal.c
new file mode 100644
index 0000000..7555d0a
--- /dev/null
+++ b/sysdeps/generic/signal.c
@@ -0,0 +1,44 @@
+/* signal.c - Generic signal implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+void (*signal (int sig, void (*handler)(int)))(int)
+{
+ struct sigaction sa;
+
+ sa.sa_handler = handler;
+ sa.sa_flags = SA_RESTART;
+
+ if (sigemptyset (&sa.sa_mask) < 0
+ || sigaddset (&sa.sa_mask, sig) < 0)
+ return SIG_ERR;
+
+ struct sigaction osa;
+ if (sigaction (sig, &sa, &osa) < 0)
+ return SIG_ERR;
+
+ return osa.sa_handler;
+}
+
+void (*bsd_signal (int sig, void (*func)(int)))(int)
+{
+ return signal (sig, func);
+}
diff --git a/sysdeps/generic/sigwait.c b/sysdeps/generic/sigwait.c
new file mode 100644
index 0000000..7d10bf8
--- /dev/null
+++ b/sysdeps/generic/sigwait.c
@@ -0,0 +1,34 @@
+/* sigwait.c - Generic sigwait implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "sig-internal.h"
+
+int
+sigwait (const sigset_t *restrict set, int *restrict signo)
+{
+ siginfo_t info;
+
+ if (sigwaitinfo (set, &info) < 0)
+ return -1;
+
+ *signo = info.si_signo;
+ return 0;
+}
+
diff --git a/sysdeps/hurd/pt-kill.c b/sysdeps/hurd/pt-kill.c
index f970e06..d204e3f 100644
--- a/sysdeps/hurd/pt-kill.c
+++ b/sysdeps/hurd/pt-kill.c
@@ -39,6 +39,9 @@ pthread_kill (pthread_t thread, int sig)
ss = _hurd_thread_sigstate (pthread->kernel_thread);
assert (ss);
+ if (!sig)
+ return 0;
+
detail.exc = 0;
detail.code = sig;
detail.error = 0;
diff --git a/sysdeps/i386/bits/atomic.h b/sysdeps/ia32/bits/atomic.h
index 0dfc1f6..0dfc1f6 100644
--- a/sysdeps/i386/bits/atomic.h
+++ b/sysdeps/ia32/bits/atomic.h
diff --git a/sysdeps/i386/bits/memory.h b/sysdeps/ia32/bits/memory.h
index 201305b..932c408 100644
--- a/sysdeps/i386/bits/memory.h
+++ b/sysdeps/ia32/bits/memory.h
@@ -1,5 +1,5 @@
/* Memory barrier operations. i386 version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ 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
@@ -21,14 +21,14 @@
#define _BITS_MEMORY_H 1
/* Prevent read and write reordering across this function. */
-inline void
+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));
+ __asm__ __volatile ("lock; incl %0" : "=m" (i) : "m" (i) : "memory");
}
/* Prevent read reordering across this function. */
diff --git a/sysdeps/i386/bits/spin-lock.h b/sysdeps/ia32/bits/spin-lock-inline.h
index e86bc13..e5ed3de 100644
--- a/sysdeps/i386/bits/spin-lock.h
+++ b/sysdeps/ia32/bits/spin-lock-inline.h
@@ -1,5 +1,5 @@
/* Machine-specific definitions for spin locks. i386 version.
- Copyright (C) 2000, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,19 +21,14 @@
* Never include this file directly; use <pthread.h> or <cthreads.h> instead.
*/
-#ifndef _BITS_SPIN_LOCK_H
-#define _BITS_SPIN_LOCK_H 1
+#ifndef _BITS_SPIN_LOCK_INLINE_H
+#define _BITS_SPIN_LOCK_INLINE_H 1
#include <features.h>
+#include <bits/spin-lock.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
@@ -42,7 +37,7 @@ typedef __volatile int __pthread_spinlock_t;
# endif
# ifndef __PT_SPIN_INLINE
-# define __PT_SPIN_INLINE extern __inline
+# define __PT_SPIN_INLINE __extern_inline
# endif
__PT_SPIN_INLINE int __pthread_spin_destroy (__pthread_spinlock_t *__lock);
@@ -59,7 +54,7 @@ __PT_SPIN_INLINE int __pthread_spin_init (__pthread_spinlock_t *__lock,
__PT_SPIN_INLINE int
__pthread_spin_init (__pthread_spinlock_t *__lock, int __pshared)
{
- *__lock = __SPIN_LOCK_INITIALIZER;
+ *__lock = __PTHREAD_SPIN_LOCK_INITIALIZER;
return 0;
}
@@ -70,14 +65,14 @@ __pthread_spin_trylock (__pthread_spinlock_t *__lock)
{
int __locked;
__asm__ __volatile ("xchgl %0, %1"
- : "=&r" (__locked), "=m" (*__lock) : "0" (1));
+ : "=&r" (__locked), "=m" (*__lock) : "0" (1) : "memory");
return __locked ? __EBUSY : 0;
}
-extern __inline int __pthread_spin_lock (__pthread_spinlock_t *__lock);
+__extern_inline int __pthread_spin_lock (__pthread_spinlock_t *__lock);
extern int _pthread_spin_lock (__pthread_spinlock_t *__lock);
-extern __inline int
+__extern_inline int
__pthread_spin_lock (__pthread_spinlock_t *__lock)
{
if (__pthread_spin_trylock (__lock))
@@ -92,7 +87,7 @@ __pthread_spin_unlock (__pthread_spinlock_t *__lock)
{
int __unlocked;
__asm__ __volatile ("xchgl %0, %1"
- : "=&r" (__unlocked), "=m" (*__lock) : "0" (0));
+ : "=&r" (__unlocked), "=m" (*__lock) : "0" (0) : "memory");
return 0;
}
diff --git a/sysdeps/ia32/bits/spin-lock.h b/sysdeps/ia32/bits/spin-lock.h
new file mode 100644
index 0000000..5ae81e1
--- /dev/null
+++ b/sysdeps/ia32/bits/spin-lock.h
@@ -0,0 +1,39 @@
+/* Machine-specific definitions for spin locks. i386 version.
+ Copyright (C) 2000, 2005, 2008, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; 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 __PTHREAD_SPIN_LOCK_INITIALIZER ((__pthread_spinlock_t) 0)
+
+__END_DECLS
+
+#endif /* bits/spin-lock.h */
diff --git a/sysdeps/i386/machine-sp.h b/sysdeps/ia32/machine-sp.h
index 945a36b..cef6ab7 100644
--- a/sysdeps/i386/machine-sp.h
+++ b/sysdeps/ia32/machine-sp.h
@@ -1,5 +1,5 @@
/* Machine-specific function to return the stack pointer. i386 version.
- Copyright (C) 1994,97,2001 Free Software Foundation, Inc.
+ 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
diff --git a/sysdeps/i386/pt-machdep.h b/sysdeps/ia32/pt-machdep.h
index 6d45636..6d45636 100644
--- a/sysdeps/i386/pt-machdep.h
+++ b/sysdeps/ia32/pt-machdep.h
diff --git a/sysdeps/l4/bits/pthread-np.h b/sysdeps/l4/bits/pthread-np.h
new file mode 100644
index 0000000..6a02bdc
--- /dev/null
+++ b/sysdeps/l4/bits/pthread-np.h
@@ -0,0 +1,35 @@
+/* Non-portable functions. L4 version.
+ Copyright (C) 2003, 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. */
+
+/*
+ * Never include this file directly; use <pthread.h> or <cthreads.h> instead.
+ */
+
+#ifndef _BITS_PTHREAD_NP_H
+#define _BITS_PTHREAD_NP_H 1
+
+#include <l4.h>
+
+/* Add the thread TID to the internal kernel thread pool. */
+extern int pthread_pool_add_np (l4_thread_id_t tid);
+
+/* Get the first thread from the pool. */
+extern l4_thread_id_t pthread_pool_get_np (void);
+
+#endif /* bits/pthread-np.h */
diff --git a/sysdeps/l4/hurd/bits/pthread-np.h b/sysdeps/l4/hurd/bits/pthread-np.h
new file mode 100644
index 0000000..a90793d
--- /dev/null
+++ b/sysdeps/l4/hurd/bits/pthread-np.h
@@ -0,0 +1,31 @@
+/* Non-portable functions. Viengoos version.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/*
+ * Never include this file directly; use <pthread.h> or <cthreads.h> instead.
+ */
+
+#ifndef _BITS_PTHREAD_NP_H
+#define _BITS_PTHREAD_NP_H 1
+
+#include <hurd/addr.h>
+
+int pthread_setactivity_np (addr_t activity);
+
+#endif /* bits/pthread-np.h */
diff --git a/sysdeps/l4/hurd/i386/pt-machdep.c b/sysdeps/l4/hurd/ia32/pt-machdep.c
index dbf5cd7..dbf5cd7 100644
--- a/sysdeps/l4/hurd/i386/pt-machdep.c
+++ b/sysdeps/l4/hurd/ia32/pt-machdep.c
diff --git a/sysdeps/l4/hurd/ia32/pt-setup.c b/sysdeps/l4/hurd/ia32/pt-setup.c
new file mode 100644
index 0000000..579905c
--- /dev/null
+++ b/sysdeps/l4/hurd/ia32/pt-setup.c
@@ -0,0 +1,117 @@
+/* Setup thread stack. Viengoos/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.h>
+
+#include <pt-internal.h>
+#include <hurd/thread.h>
+#include <hurd/exceptions.h>
+
+/* The stack layout used on the i386 is:
+
+ -----------------
+ | ARG |
+ -----------------
+ | START_ROUTINE |
+ -----------------
+ | Return address |
+ ----------------- <- %ebp
+ | Frame pointer |
+ -----------------
+
+ We do the following: setup the stack to return to the entry routine.
+
+
+*/
+
+/* The stack contains:
+
+ arg
+ start_routine
+ 0 <- fake return address
+ C entry_point
+*/
+extern uintptr_t _pthread_entry_point;
+__asm__ ("\n\
+ .globl _pthread_entry_point, __pthread_entry_point\n\
+_pthread_entry_point:\n\
+__pthread_entry_point:\n\
+ pushl $0\n\
+ popf\n\
+\n\
+ xor %ebp, %ebp\n\
+ ret\n");
+
+/* 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,
+ void (*entry_point)(void *(*)(void *), void *))
+{
+ uintptr_t *top;
+
+ /* Calculate top of the new stack. */
+ top = (uintptr_t *) ((uintptr_t) thread->stackaddr + thread->stacksize);
+
+ /* Align on 0x10 for MMX operations. */
+ top = (uintptr_t) top & ~0xf;
+
+ if (start_routine)
+ {
+ /* Set up call frame. */
+ *--top = (uintptr_t) arg; /* Argument to START_ROUTINE. */
+ *--top = (uintptr_t) start_routine;
+ *--top = 0; /* Fake return address. */
+ *--top = (uintptr_t) entry_point;
+ }
+
+ return top;
+}
+
+int
+__pthread_setup (struct __pthread *thread,
+ void (*entry_point)(void *(*)(void *), void *),
+ void *(*start_routine)(void *), void *arg)
+{
+ thread->mcontext.pc = (void *) &_pthread_entry_point;
+ thread->mcontext.sp = (void *) stack_setup (thread, start_routine, arg,
+ entry_point);
+
+ if (__pthread_num_threads == 1)
+ return 0;
+
+ assert (! ADDR_IS_VOID (thread->exception_area[0]));
+
+ struct exception_page *exception_page = thread->exception_area_va;
+
+ /* SP is set to the end of the exception area minus one word, which
+ is the location of the exception page. */
+ exception_page->exception_handler_sp
+ = (uintptr_t) thread->exception_area_va + EXCEPTION_AREA_SIZE;
+ exception_page->exception_handler_sp -= sizeof (void *);
+ * (void **) exception_page->exception_handler_sp = thread->exception_area_va;
+
+ exception_page->exception_handler_ip = (uintptr_t) &exception_handler_entry;
+ exception_page->exception_handler_end = (uintptr_t) &exception_handler_end;
+
+ return 0;
+}
diff --git a/sysdeps/l4/hurd/ia32/signal-dispatch-lowlevel.c b/sysdeps/l4/hurd/ia32/signal-dispatch-lowlevel.c
new file mode 100644
index 0000000..37ef821
--- /dev/null
+++ b/sysdeps/l4/hurd/ia32/signal-dispatch-lowlevel.c
@@ -0,0 +1,213 @@
+/* signal-dispatch-lowlevel.c - ia32 specific signal handling functions.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <pt-internal.h>
+#include <sig-internal.h>
+
+#include <hurd/thread.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <atomic.h>
+
+extern char _signal_dispatch_entry;
+/* - 0(%esp) a pointer to the thread's struct signal_state.
+ - 4(%esp) a pointer to a siginfo_t.
+ - 8(%esp) is a pointer to the ss_flags field (or NULL).
+ - 12(%esp)+4 is the value of the sp when the thread was interrupted (intr_sp)
+ - 0(intr_sp) is the value of the ip when the thread was interrupted.
+ - 16(%esp) - 16 byte register save area
+*/
+__asm__ ("\n\
+ .globl _signal_dispatch_entry\n\
+_signal_dispatch_entry:\n\
+ /* Save caller saved registers (16 bytes). */\n\
+ mov %eax, 16(%esp)\n\
+ mov %ecx, 16+4(%esp)\n\
+ mov %edx, 16+8(%esp)\n\
+ pushf\n\
+ popl %eax\n\
+ mov %eax, 16+12(%esp)\n\
+\n\
+ /* Reset EFLAGS. */\n\
+ cld\n\
+ call signal_dispatch\n\
+\n\
+ /* Get the original stack and begin restoration. */\n\
+ mov 12(%esp), %edx\n\
+\n\
+ /* Move the saved registers to the user stack. */\n\
+ sub $16, %edx\n\
+ /* eax. */\n\
+ mov 16+0(%esp), %ecx\n\
+ mov %ecx, 0(%edx)\n\
+ /* ecx. */\n\
+ mov 16+4(%esp), %ecx\n\
+ mov %ecx, 4(%edx)\n\
+ /* edx. */\n\
+ mov 16+8(%esp), %ecx\n\
+ mov %ecx, 8(%edx)\n\
+ /* eflags. */\n\
+ mov 16+12(%esp), %ecx\n\
+ mov %ecx, 12(%edx)\n\
+\n\
+ /* Get the pointer to the sigaltstack flags. */\n\
+ mov 8(%esp), %ecx\n\
+\n\
+ /* Restore the user stack. */\n\
+ mov %edx, %esp\n\
+\n\
+ /* Clear the SA_ONSTACK flag. */\n\
+ and %ecx, %ecx\n\
+ jz after_clear\n\
+ lock; and $~1, 0(%ecx)\n\
+after_clear:\n\
+\n\
+ /* Restore eflags, the scratch regs and the original sp and ip. */\n\
+ popl %eax\n\
+ popl %ecx\n\
+ popl %edx\n\
+ popf\n\
+ ret\n");
+
+extern char _signal_dispatch_entry_self;
+/* - 0(%esp) is the return address (we ignore it)
+ - 4(%esp) is the sp to load
+
+ Since we are returning to signal_dispatch_lowlevel's caller, we
+ also need to restore its frame pointer. */
+__asm__ ("\n\
+ .globl _signal_dispatch_entry_self\n\
+_signal_dispatch_entry_self:\n\
+ mov 0(%ebp), %ebp\n\
+ mov 4(%esp), %esp\n\
+ jmp _signal_dispatch_entry\n");
+
+void
+signal_dispatch_lowlevel (struct signal_state *ss, pthread_t tid,
+ siginfo_t si)
+{
+ assert (pthread_mutex_trylock (&ss->lock) == EBUSY);
+
+ struct __pthread *thread = __pthread_getid (tid);
+
+ bool self = tid == pthread_self ();
+
+ uintptr_t intr_sp;
+
+ if (self)
+ {
+ /* The return address is just before the first argument. */
+ intr_sp = (uintptr_t) &ss - 4;
+ assert (* (void **) intr_sp == __builtin_return_address (0));
+ }
+ else
+ {
+ struct hurd_thread_exregs_in in;
+ memset (&in, 0, sizeof (in));
+ struct hurd_thread_exregs_out out;
+
+ error_t err;
+ err = rm_thread_exregs (ADDR_VOID, thread->object,
+ HURD_EXREGS_STOP | HURD_EXREGS_ABORT_IPC
+ | HURD_EXREGS_GET_REGS,
+ in, &out);
+ if (err)
+ panic ("Failed to modify thread " ADDR_FMT,
+ ADDR_PRINTF (thread->object));
+
+ intr_sp = out.sp;
+
+ /* Push the ip on the user stack. */
+ intr_sp -= 4;
+ * (uintptr_t *) intr_sp = out.ip;
+ }
+
+ bool altstack = false;
+ uintptr_t sp;
+ if (! (ss->actions[si.si_signo - 1].sa_flags & SA_ONSTACK)
+ || (ss->stack.ss_flags & SS_DISABLE)
+ || (ss->stack.ss_flags & SS_ONSTACK))
+ {
+ assert (! self);
+ sp = intr_sp;
+ }
+ else
+ {
+ /* The stack grows down. */
+ sp = (uintptr_t) ss->stack.ss_sp + ss->stack.ss_size;
+
+ /* We know intimately that SS_ONSTACK is the least significant
+ bit. */
+ assert (SS_ONSTACK == 1);
+ atomic_bit_set (&ss->stack.ss_flags, 0);
+
+ altstack = true;
+ }
+
+ /* Set up the call frame for a call to signal_dispatch_entry. */
+
+ /* Allocate a siginfo structure on the stack. */
+ sp = sp - sizeof (siginfo_t);
+ siginfo_t *sip = (void *) sp;
+ /* Copy the user supplied values. */
+ *sip = si;
+
+ /* Add space for the 4 caller saved registers. */
+ sp -= 4 * sizeof (uintptr_t);
+
+ /* Save the interrupted sp. */
+ sp -= 4;
+ * (uintptr_t *) sp = intr_sp;
+
+ /* Address of the ss_flags. */
+ sp -= 4;
+ if (altstack)
+ * (uintptr_t *) sp = (uintptr_t) &ss->stack.ss_flags;
+ else
+ * (uintptr_t *) sp = 0;
+
+ /* Push the parameters to signal_dispatch. */
+
+ /* signal info structure. */
+ sp -= 4;
+ * (uintptr_t *) sp = (uintptr_t) sip;
+
+ /* The ss. */
+ sp -= 4;
+ * (uintptr_t *) sp = (uintptr_t) ss;
+
+ pthread_mutex_transfer_np (&ss->lock, tid);
+
+ if (self)
+ ((void (*) (uintptr_t)) &_signal_dispatch_entry_self) ((uintptr_t) sp);
+ else
+ {
+ struct hurd_thread_exregs_in in;
+ struct hurd_thread_exregs_out out;
+
+ in.sp = sp;
+ in.ip = (uintptr_t) &_signal_dispatch_entry;
+
+ rm_thread_exregs (ADDR_VOID, thread->object,
+ HURD_EXREGS_SET_SP_IP
+ | HURD_EXREGS_START | HURD_EXREGS_ABORT_IPC,
+ in, &out);
+ }
+}
diff --git a/sysdeps/l4/hurd/powerpc/pt-machdep.c b/sysdeps/l4/hurd/powerpc/pt-machdep.c
new file mode 100644
index 0000000..754d203
--- /dev/null
+++ b/sysdeps/l4/hurd/powerpc/pt-machdep.c
@@ -0,0 +1,20 @@
+/* Machine dependent pthreads code. Hurd/PowerPC version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; 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/sysdeps/l4/hurd/i386/pt-setup.c b/sysdeps/l4/hurd/powerpc/pt-setup.c
index fe77d53..d3cf4ec 100644
--- a/sysdeps/l4/hurd/i386/pt-setup.c
+++ b/sysdeps/l4/hurd/powerpc/pt-setup.c
@@ -1,5 +1,5 @@
-/* Setup thread stack. Hurd/i386 version.
- Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+/* Setup thread stack. Hurd/PowerPC version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -17,19 +17,33 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <l4/l4.h>
+#include <l4.h>
#include <pt-internal.h>
-/* The stack layout used on the i386 is:
+/* Arguments is passed in registers on the PowerPC. But the
+ exchange registers syscall only allows us to set the PC and the
+ stack pointer so we put the entry point and start function on
+ the stack. */
+struct start_info
+{
+ void (*entry_point) (void *(*)(void *), void *);
+ void *(*start_routine) (void *);
+ void *arg;
+};
+
+void first_entry_1 (void);
- -----------------
- | ARG |
- -----------------
- | START_ROUTINE |
- -----------------
- | 0 |
- ----------------- */
+/* Stage 1 entry function. The start_info structure is inlined on the
+ stack. Put values into registers and call entry function. */
+asm (" ;\
+first_entry_1: ;\
+ lwz 0, 0(1) ;\
+ lwz 3, 4(1) ;\
+ lwz 4, 8(1) ;\
+ mtctr 0 ;\
+ bctrl ;\
+");
/* 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.
@@ -37,21 +51,27 @@
opportunity to install THREAD in our utcb. */
static void *
stack_setup (struct __pthread *thread,
+ void (*entry_point)(void *(*)(void *), void *),
void *(*start_routine)(void *), void *arg)
{
- L4_Word_t *top;
+ l4_word_t *top;
/* Calculate top of the new stack. */
- top = (L4_Word_t *) ((L4_Word_t) thread->stackaddr + thread->stacksize);
+ top = (l4_word_t *) ((l4_word_t) thread->stackaddr + thread->stacksize);
+
+ /* Initial stack frame. */
+ top[-4] = 0;
+ top = top - 4;
if (start_routine)
{
- /* Set up call frame. */
- *--top = (L4_Word_t) arg; /* Argument to START_ROUTINE. */
- *--top = (L4_Word_t) start_routine;
- *--top = 0; /* Fake return address. */
- }
+ struct start_info *info = ((struct start_info *) top) - 1;
+ info->entry_point = entry_point;
+ info->start_routine = start_routine;
+ info->arg = arg;
+ return (void *) info;
+ }
return top;
}
@@ -60,13 +80,14 @@ __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);
+ thread->mcontext.pc = first_entry_1;
+ thread->mcontext.sp = stack_setup (thread, entry_point,
+ start_routine, arg);
- if (L4_SameThreads (thread->threadid, L4_Myself ()))
- L4_Set_MyUserDefinedHandle (thread);
+ if (l4_same_threads (thread->threadid, l4_myself ()))
+ l4_set_user_defined_handle ((l4_word_t) thread);
else
- L4_Set_UserDefinedHandle (thread->threadid, thread);
-
+ l4_set_user_defined_handle_of (thread->threadid,
+ (l4_word_t) thread);
return 0;
}
diff --git a/sysdeps/l4/hurd/pt-block.c b/sysdeps/l4/hurd/pt-block.c
new file mode 100644
index 0000000..2315b1c
--- /dev/null
+++ b/sysdeps/l4/hurd/pt-block.c
@@ -0,0 +1,30 @@
+/* Block a thread. Viengoos version.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <pt-internal.h>
+
+#include <hurd/stddef.h>
+#include <hurd/futex.h>
+
+/* Block THREAD. */
+void
+__pthread_block (struct __pthread *thread)
+{
+ futex_wait (&thread->threadid, thread->threadid);
+}
diff --git a/sysdeps/l4/hurd/pt-kill.c b/sysdeps/l4/hurd/pt-kill.c
new file mode 100644
index 0000000..c72e82f
--- /dev/null
+++ b/sysdeps/l4/hurd/pt-kill.c
@@ -0,0 +1,3 @@
+/* The generic version is good enough for us, however, the generic
+ Hurd on Mach version supplies a specialized version */
+#include "../generic/pt-kill.c"
diff --git a/sysdeps/l4/hurd/pt-setactivity-np.c b/sysdeps/l4/hurd/pt-setactivity-np.c
new file mode 100644
index 0000000..f2f0723
--- /dev/null
+++ b/sysdeps/l4/hurd/pt-setactivity-np.c
@@ -0,0 +1,39 @@
+/* Set a thread's activity activity. Viengoos version.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <pt-internal.h>
+
+#include <hurd/addr.h>
+#include <hurd/thread.h>
+
+int
+pthread_setactivity_np (addr_t activity)
+{
+ struct __pthread *self = _pthread_self ();
+
+ struct hurd_thread_exregs_in in;
+ in.activity = activity;
+
+ struct hurd_thread_exregs_out out;
+ int err = rm_thread_exregs (ADDR_VOID, self->object,
+ HURD_EXREGS_SET_ACTIVITY,
+ in, &out);
+
+ return err;
+}
diff --git a/sysdeps/generic/bits/thread-barrier.h b/sysdeps/l4/hurd/pt-sigstate-destroy.c
index 23d51ae..997a036 100644
--- a/sysdeps/generic/bits/thread-barrier.h
+++ b/sysdeps/l4/hurd/pt-sigstate-destroy.c
@@ -1,4 +1,4 @@
-/* Thread barrier attribute type. Generic version.
+/* Destroy the signal state. Hurd on L4 version.
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -17,14 +17,12 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#ifndef _BITS_THREAD_BARRIER_H
-#define _BITS_THREAD_BARRIER_H 1
+#include <pthread.h>
-/* This structure describes the attributes of a POSIX thread barrier.
- Note that not all of them are supported on all systems. */
-struct __pthread_attr
-{
- enum __
-};
+#include <pt-internal.h>
-#endif /* bits/thread-barrier.h */
+void
+__pthread_sigstate_destroy (struct __pthread *thread)
+{
+ /* Nothing to do. */
+}
diff --git a/sysdeps/l4/hurd/pt-sigstate-init.c b/sysdeps/l4/hurd/pt-sigstate-init.c
new file mode 100644
index 0000000..4c40fdb
--- /dev/null
+++ b/sysdeps/l4/hurd/pt-sigstate-init.c
@@ -0,0 +1,44 @@
+/* Initialize the signal state. Hurd on L4 version.
+ Copyright (C) 2003, 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>
+#include <sig-internal.h>
+
+error_t
+__pthread_sigstate_init (struct __pthread *thread)
+{
+ struct signal_state *ss = &thread->ss;
+
+ memset (ss, 0, sizeof (*ss));
+
+ ss->stack.ss_flags = SS_DISABLE;
+
+ int signo;
+ for (signo = 1; signo < NSIG; ++signo)
+ {
+ sigemptyset (&ss->actions[signo - 1].sa_mask);
+ ss->actions[signo - 1].sa_flags = SA_RESTART;
+ ss->actions[signo - 1].sa_handler = SIG_DFL;
+ ss->lock = (pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER;
+ }
+
+ return 0;
+}
diff --git a/sysdeps/l4/hurd/pt-sigstate.c b/sysdeps/l4/hurd/pt-sigstate.c
new file mode 100644
index 0000000..66dd08c
--- /dev/null
+++ b/sysdeps/l4/hurd/pt-sigstate.c
@@ -0,0 +1,81 @@
+/* Set a thread's signal state. Hurd on L4 version.
+ Copyright (C) 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 <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)
+{
+ struct signal_state *ss = &thread->ss;
+ pthread_mutex_lock (&ss->lock);
+
+ if (oset)
+ *oset = ss->blocked;
+
+ if (set)
+ {
+ /* Mask out SIGKILL and SIGSTOP. */
+ sigset_t s = *set;
+ sigdelset (&s, SIGKILL);
+ sigdelset (&s, SIGSTOP);
+
+ switch (how)
+ {
+ case SIG_BLOCK:
+ ss->blocked |= s;
+ break;
+ case SIG_UNBLOCK:
+ ss->blocked &= ~s;
+ break;
+ case SIG_SETMASK:
+ ss->blocked = s;
+ break;
+ default:
+ errno = EINVAL;
+ pthread_mutex_unlock (&ss->lock);
+ return -1;
+ }
+ }
+
+ if (clear_pending)
+ sigemptyset (&ss->pending);
+
+ /* A "signal shall remain pending until it is unblocked" (2.4.1).
+
+ "If there are any pending unblocked signals after the call to
+ sigprocmask(), at least one of those signals shall be delivered
+ before the call to sigprocmask() returns."
+ (pthread_sigmask). */
+ sigset_t extant = ~ss->blocked & ss->pending;
+ if (! extant)
+ extant = ~ss->blocked & process_pending;
+
+ pthread_mutex_unlock (&ss->lock);
+
+ if (extant)
+ raise (l4_lsb64 (extant));
+
+ return 0;
+}
diff --git a/sysdeps/l4/hurd/pt-startup.c b/sysdeps/l4/hurd/pt-startup.c
new file mode 100644
index 0000000..b6461de
--- /dev/null
+++ b/sysdeps/l4/hurd/pt-startup.c
@@ -0,0 +1,30 @@
+/* Thread initialization. Hurd/L4 version.
+ Copyright (C) 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. */
+
+#include <l4.h>
+#include <pt-internal.h>
+
+#include <hurd/exceptions.h>
+
+void
+__pthread_startup (void)
+{
+ struct __pthread *pthread = _pthread_self ();
+ pthread->threadid = l4_myself ();
+}
diff --git a/sysdeps/l4/hurd/pt-sysdep.c b/sysdeps/l4/hurd/pt-sysdep.c
index 265592c..c23364c 100644
--- a/sysdeps/l4/hurd/pt-sysdep.c
+++ b/sysdeps/l4/hurd/pt-sysdep.c
@@ -1,5 +1,5 @@
/* System dependent pthreads code. Hurd version.
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 2000, 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
@@ -23,36 +23,39 @@
#include <pt-internal.h>
+int
+sched_yield (void)
+{
+ l4_yield ();
+ return 0;
+}
+
/* Forward. */
-static void *init_routine (void);
+static void init_routine (void (*) (void *), void *)
+ __attribute__ ((noreturn));
/* 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;
+void (*_pthread_init_routine)(void (*) (void *), 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)
+static void
+init_routine (void (*entry) (void *), void *arg)
{
- struct __pthread *thread;
- int err;
-
/* Initialize the library. */
__pthread_initialize ();
+ struct __pthread *thread;
+ int err;
+
/* Create the pthread structure for the main thread (i.e. us). */
- err = __pthread_create_internal (&thread, 0, 0, 0);
+ err = __pthread_create_internal (&thread, 0,
+ (void *(*)(void *)) entry, arg);
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;
+ /* Switch stacks. */
+ l4_start_sp_ip (l4_myself (), thread->mcontext.sp,
+ thread->mcontext.pc);
}
diff --git a/sysdeps/l4/hurd/pt-sysdep.h b/sysdeps/l4/hurd/pt-sysdep.h
index 8717533..08bcd14 100644
--- a/sysdeps/l4/hurd/pt-sysdep.h
+++ b/sysdeps/l4/hurd/pt-sysdep.h
@@ -1,5 +1,5 @@
-/* Internal defenitions for pthreads library.
- Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+/* Internal definitions for pthreads library.
+ Copyright (C) 2000, 2002, 2005, 2007, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,33 +20,42 @@
#ifndef _PT_SYSDEP_H
#define _PT_SYSDEP_H 1
-#include <l4/l4.h>
-#include <task_client.h>
-#include <machine/vmparam.h>
+#include <l4.h>
+#include <hurd/storage.h>
+#include <sys/mman.h>
/* XXX */
#define _POSIX_THREAD_THREADS_MAX 64
-/* The default stack size. */
-#define PTHREAD_STACK_DEFAULT (PAGE_SIZE)
+/* The default stack size: 2MB. */
+#define PTHREAD_STACK_DEFAULT (2 * 1024 * 1024)
+
+#include <hurd/exceptions.h>
+
+#define EXCEPTION_AREA_SIZE EXCEPTION_STACK_SIZE
+#define EXCEPTION_AREA_SIZE_LOG2 EXCEPTION_STACK_SIZE_LOG2
+/* The exception page is the first object. */
+#define EXCEPTION_PAGE 0
#define PTHREAD_SYSDEP_MEMBERS \
- L4_ThreadId_t threadid; \
- L4_Word_t my_errno;
+ addr_t object; \
+ l4_thread_id_t threadid; \
+ addr_t exception_area[EXCEPTION_AREA_SIZE / PAGESIZE]; \
+ void *exception_area_va; \
+ l4_word_t my_errno;
extern inline struct __pthread *
__attribute__((__always_inline__))
_pthread_self (void)
{
- return (struct __pthread *) L4_MyUserDefinedHandle ();
+ return (struct __pthread *) l4_user_defined_handle ();
}
extern inline void
-__pthread_stack_dealloc (void *stackaddr, size_t stacksize)
__attribute__((__always_inline__))
+__pthread_stack_dealloc (void *stackaddr, size_t stacksize)
{
- /* XXX: can only implement this once we have a working memory manager. */
- return;
+ munmap (stackaddr, stacksize);
}
#endif /* pt-sysdep.h */
diff --git a/sysdeps/l4/hurd/pt-thread-alloc.c b/sysdeps/l4/hurd/pt-thread-alloc.c
new file mode 100644
index 0000000..ada7b3b
--- /dev/null
+++ b/sysdeps/l4/hurd/pt-thread-alloc.c
@@ -0,0 +1,95 @@
+/* Allocate kernel thread. Viengoos version.
+ Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
+#include <hurd/startup.h>
+#include <hurd/storage.h>
+#include <hurd/as.h>
+#include <hurd/addr.h>
+
+#include <pt-internal.h>
+
+extern struct hurd_startup_data *__hurd_startup_data;
+
+extern addr_t meta_data_activity;
+
+int
+__pthread_thread_alloc (struct __pthread *thread)
+{
+ /* The main thread is already running of course. */
+ if (__pthread_num_threads == 1)
+ {
+ thread->object = __hurd_startup_data->thread;
+ thread->threadid = l4_myself ();
+ return 0;
+ }
+ else
+ {
+ addr_t exception_area = as_alloc (EXCEPTION_AREA_SIZE_LOG2, 1, true);
+
+ thread->exception_area_va
+ = ADDR_TO_PTR (addr_extend (exception_area,
+ 0, EXCEPTION_AREA_SIZE_LOG2));
+
+ int i;
+ for (i = 0; i < EXCEPTION_AREA_SIZE / PAGESIZE; i ++)
+ {
+ addr_t slot = addr_chop (PTR_TO_ADDR (thread->exception_area_va
+ + i * PAGESIZE),
+ PAGESIZE_LOG2);
+ as_ensure (slot);
+
+ struct storage storage = storage_alloc (ADDR_VOID, cap_page,
+ STORAGE_LONG_LIVED,
+ OBJECT_POLICY_DEFAULT,
+ slot);
+ if (ADDR_IS_VOID (storage.addr))
+ {
+ int j;
+ for (j = 0; j < i; j ++)
+ storage_free (thread->exception_area[j], false);
+ as_free (exception_area, false);
+ return EAGAIN;
+ }
+
+ thread->exception_area[i] = storage.addr;
+ }
+
+ struct storage storage;
+ storage = storage_alloc (meta_data_activity, cap_thread,
+ /* Threads are rarely shortly lived. */
+ STORAGE_MEDIUM_LIVED, OBJECT_POLICY_DEFAULT,
+ ADDR_VOID);
+ if (ADDR_IS_VOID (storage.addr))
+ {
+ int j;
+ for (j = 0; j < EXCEPTION_AREA_SIZE / PAGESIZE; j ++)
+ storage_free (thread->exception_area[j], false);
+ as_free (exception_area, false);
+ return EAGAIN;
+ }
+
+ thread->object = storage.addr;
+ }
+
+ return 0;
+}
diff --git a/sysdeps/l4/hurd/pt-thread-halt.c b/sysdeps/l4/hurd/pt-thread-halt.c
new file mode 100644
index 0000000..98fefaa
--- /dev/null
+++ b/sysdeps/l4/hurd/pt-thread-halt.c
@@ -0,0 +1,104 @@
+/* Deallocate the kernel thread resources. Viengoos version.
+ Copyright (C) 2007, 2008 Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see 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 <pt-internal.h>
+
+#include <hurd/exceptions.h>
+#include <hurd/mutex.h>
+#include <hurd/as.h>
+#include <hurd/addr.h>
+
+/* If we try to deallocate our self, we will end up causing a
+ deadlock. Thus, when a thread tries to free itself, we add it
+ here. The next thread to free a thread will free it. */
+ss_mutex_t saved_object_lock;
+static addr_t saved_object;
+
+void
+__pthread_thread_halt (struct __pthread *thread, int need_dealloc)
+{
+ /* We may deallocate THREAD. First save any data we need. */
+
+ addr_t exception_area[EXCEPTION_AREA_SIZE / PAGESIZE];
+ memcpy (exception_area, thread->exception_area,
+ sizeof (thread->exception_area));
+ memset (thread->exception_area, 0, sizeof (thread->exception_area));
+
+ void *va = thread->exception_area_va;
+
+ addr_t object = thread->object;
+ l4_thread_id_t tid = thread->threadid;
+
+ if (need_dealloc)
+ __pthread_dealloc (thread);
+
+ /* The THREAD data structure is no longer valid. */
+ thread = NULL;
+
+ /* Deallocate any saved object. */
+ ss_mutex_lock (&saved_object_lock);
+ if (! ADDR_IS_VOID (saved_object))
+ {
+ storage_free (saved_object, false);
+ saved_object = ADDR_VOID;
+ }
+ ss_mutex_unlock (&saved_object_lock);
+
+ /* Free the exception area. */
+
+ /* Clean up the exception page. */
+ exception_page_cleanup
+ (ADDR_TO_PTR (addr_extend (exception_area[EXCEPTION_PAGE],
+ 0, PAGESIZE_LOG2)));
+
+ /* Free the storage. */
+ int i;
+ for (i = 0; i < EXCEPTION_AREA_SIZE / PAGESIZE; i ++)
+ {
+ assert (! ADDR_IS_VOID (exception_area[i]));
+ storage_free (exception_area[i], false);
+ }
+
+ /* And the address space. */
+ as_free (addr_chop (PTR_TO_ADDR (va), EXCEPTION_AREA_SIZE_LOG2), false);
+
+ if (tid == l4_myself ())
+ /* If we try to storage_free (storage.addr), we will freeze in the
+ middle. That's no good. We set SAVED_OBJECT to our thread
+ object and the next thread in will free us. */
+ {
+ ss_mutex_lock (&saved_object_lock);
+ saved_object = object;
+ ss_mutex_unlock (&saved_object_lock);
+ }
+ else
+ storage_free (object, false);
+
+ if (tid == l4_myself ())
+ {
+ l4_send_timeout (l4_myself (), L4_NEVER);
+ panic ("Failed to stop thread %x.%x!",
+ l4_thread_no (l4_myself ()), l4_version (l4_myself ()));
+ }
+ else
+ thread_stop (object);
+}
diff --git a/sysdeps/l4/hurd/pt-thread-start.c b/sysdeps/l4/hurd/pt-thread-start.c
new file mode 100644
index 0000000..9db399c
--- /dev/null
+++ b/sysdeps/l4/hurd/pt-thread-start.c
@@ -0,0 +1,70 @@
+/* Start thread. L4 version.
+ Copyright (C) 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. */
+
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+#include <hurd/thread.h>
+#include <hurd/exceptions.h>
+
+#include <pt-internal.h>
+
+int
+__pthread_thread_start (struct __pthread *thread)
+{
+ error_t err;
+
+ if (__pthread_num_threads == 1)
+ /* The main thread is already running of course. */
+ {
+ assert (__pthread_total == 1);
+ assert (l4_is_thread_equal (l4_myself (), thread->threadid));
+ l4_set_user_defined_handle ((l4_word_t) thread);
+ }
+ else
+ {
+ struct hurd_thread_exregs_in in;
+ struct hurd_thread_exregs_out out;
+
+ in.aspace = ADDR (0, 0);
+ in.aspace_cap_properties = CAP_PROPERTIES_VOID;
+ in.aspace_cap_properties_flags = CAP_COPY_COPY_SOURCE_GUARD;
+
+ in.activity = ADDR_VOID;
+
+ in.exception_page = addr_chop (PTR_TO_ADDR (thread->exception_area_va),
+ PAGESIZE_LOG2);
+
+ in.sp = (l4_word_t) thread->mcontext.sp;
+ in.ip = (l4_word_t) thread->mcontext.pc;
+
+ in.user_handle = (l4_word_t) thread;
+ err = rm_thread_exregs (ADDR_VOID, thread->object,
+ HURD_EXREGS_SET_ASPACE
+ | HURD_EXREGS_SET_ACTIVITY
+ | HURD_EXREGS_SET_EXCEPTION_PAGE
+ | HURD_EXREGS_SET_SP_IP
+ | HURD_EXREGS_SET_USER_HANDLE
+ | HURD_EXREGS_START
+ | HURD_EXREGS_ABORT_IPC,
+ in, &out);
+ assert (err == 0);
+ }
+ return 0;
+}
diff --git a/sysdeps/l4/hurd/pt-wakeup.c b/sysdeps/l4/hurd/pt-wakeup.c
new file mode 100644
index 0000000..e568a6f
--- /dev/null
+++ b/sysdeps/l4/hurd/pt-wakeup.c
@@ -0,0 +1,46 @@
+/* Wakeup a thread. Viengoos version.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <pt-internal.h>
+
+#include <hurd/stddef.h>
+#include <hurd/futex.h>
+#include <stdint.h>
+
+/* Wakeup THREAD. */
+void
+__pthread_wakeup (struct __pthread *thread)
+{
+ /* We need to loop here as the blocked thread may not yet be
+ blocked! Here's what happens when a thread blocks: it registers
+ itself as blocked, drops the relevant lock and then actually
+ blocks (via __pthread_block). This means that after dropping the
+ lock and before blocking, it may be interrupted and another
+ thread may try to wake it. */
+ long ret;
+ do
+ {
+ ret = futex_wake (&thread->threadid, INT_MAX);
+ assertx (ret <= 1, "tid: %x, ret: %d", thread->threadid, ret);
+
+ if (ret == 0)
+ l4_thread_switch (thread->threadid);
+ }
+ while (ret == 0);
+}
diff --git a/sysdeps/l4/hurd/sig-sysdep.h b/sysdeps/l4/hurd/sig-sysdep.h
new file mode 100644
index 0000000..33e1385
--- /dev/null
+++ b/sysdeps/l4/hurd/sig-sysdep.h
@@ -0,0 +1,69 @@
+/* sig-sysdep.h - Hurd system specific header file.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <l4.h>
+#include <string.h>
+
+struct utcb
+{
+ l4_word_t saved_sender;
+ l4_word_t saved_receiver;
+ l4_word_t saved_timeout;
+ l4_word_t saved_error_code;
+ l4_word_t saved_flags;
+ l4_word_t saved_br0;
+ l4_msg_t saved_message;
+};
+
+static inline void
+utcb_state_save (struct utcb *buffer)
+{
+ l4_word_t *utcb = _L4_utcb ();
+
+ buffer->saved_sender = utcb[_L4_UTCB_SENDER];
+ buffer->saved_receiver = utcb[_L4_UTCB_RECEIVER];
+ buffer->saved_timeout = utcb[_L4_UTCB_TIMEOUT];
+ buffer->saved_error_code = utcb[_L4_UTCB_ERROR_CODE];
+ buffer->saved_flags = utcb[_L4_UTCB_FLAGS];
+ buffer->saved_br0 = utcb[_L4_UTCB_BR0];
+ memcpy (&buffer->saved_message,
+ utcb, L4_NUM_MRS * sizeof (l4_word_t));
+}
+
+static inline void
+utcb_state_restore (struct utcb *buffer)
+{
+ l4_word_t *utcb = _L4_utcb ();
+
+ utcb[_L4_UTCB_SENDER] = buffer->saved_sender;
+ utcb[_L4_UTCB_RECEIVER] = buffer->saved_receiver;
+ utcb[_L4_UTCB_TIMEOUT] = buffer->saved_timeout;
+ utcb[_L4_UTCB_ERROR_CODE] = buffer->saved_error_code;
+ utcb[_L4_UTCB_FLAGS] = buffer->saved_flags;
+ utcb[_L4_UTCB_BR0] = buffer->saved_br0;
+ memcpy (utcb, &buffer->saved_message,
+ L4_NUM_MRS * sizeof (l4_word_t));
+}
+
+#define SIGNAL_DISPATCH_ENTRY \
+ struct utcb buffer; utcb_state_save (&buffer);
+
+#define SIGNAL_DISPATCH_EXIT \
+ utcb_state_restore (&buffer);
diff --git a/sysdeps/l4/hurd/sigprocmask.c b/sysdeps/l4/hurd/sigprocmask.c
new file mode 100644
index 0000000..a38b379
--- /dev/null
+++ b/sysdeps/l4/hurd/sigprocmask.c
@@ -0,0 +1,41 @@
+/* sigprocmask.c - Generic sigprocmask implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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 3 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that 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 this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <pt-internal.h>
+#include <sig-internal.h>
+
+int
+sigprocmask (int how, const sigset_t *restrict set, sigset_t *restrict old)
+{
+ struct __pthread *thread = _pthread_self ();
+ if (! thread)
+ /* Library is initializing. */
+ {
+ assert (__pthread_num_threads == 1);
+
+ /* We should get the default mask from the startup data structure. */
+ if (old)
+ *old = 0;
+
+ return 0;
+ }
+
+ return pthread_sigmask (how, set, old);
+}
diff --git a/sysdeps/l4/pt-block.c b/sysdeps/l4/pt-block.c
index 050c694..69e1d35 100644
--- a/sysdeps/l4/pt-block.c
+++ b/sysdeps/l4/pt-block.c
@@ -17,13 +17,31 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <l4/l4.h>
+#include <l4.h>
#include <pt-internal.h>
+#include <hurd/stddef.h>
+
/* Block THREAD. */
void
__pthread_block (struct __pthread *thread)
{
- L4_Receive (L4_anylocalthread);
+ debug (5, "%x.%x/%x blocking",
+ l4_thread_no (thread->threadid), l4_version (thread->threadid),
+ thread->threadid);
+
+ l4_accept (L4_UNTYPED_WORDS_ACCEPTOR);
+ l4_msg_tag_t tag = l4_receive (l4_anythread);
+ if (l4_ipc_failed (tag))
+ {
+ debug (1, "%x.%x failed to block: %d, offset: %x",
+ l4_thread_no (l4_myself ()), l4_version (l4_myself ()),
+ (l4_error_code () >> 1) & 0x7,
+ l4_error_code () >> 4);
+ assert (! l4_ipc_failed (tag));
+ }
+ else
+ debug (5, "%x.%x unblocked",
+ l4_thread_no (thread->threadid), l4_version (thread->threadid));
}
diff --git a/sysdeps/l4/pt-docancel.c b/sysdeps/l4/pt-docancel.c
index 9a3bb26..a3965d0 100644
--- a/sysdeps/l4/pt-docancel.c
+++ b/sysdeps/l4/pt-docancel.c
@@ -1,5 +1,5 @@
/* Cancel a thread.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 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
@@ -30,22 +30,13 @@ call_exit (void)
int
__pthread_do_cancel (struct __pthread *p)
{
- assert (p->cancel_pending = 1);
+ assert (p->cancel_pending == 1);
assert (p->cancel_state == PTHREAD_CANCEL_ENABLE);
- if (L4_SameThreads (L4_Myself (), p->threadid))
+ if (l4_is_thread_equal (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);
- }
-
+ l4_start_sp_ip (p->threadid, (l4_word_t) p->mcontext.sp,
+ (l4_word_t) call_exit);
return 0;
}
diff --git a/sysdeps/l4/pt-pool-np.c b/sysdeps/l4/pt-pool-np.c
new file mode 100644
index 0000000..e83022b
--- /dev/null
+++ b/sysdeps/l4/pt-pool-np.c
@@ -0,0 +1,54 @@
+/* Thread pool for L4 threads.
+ Copyright (C) 2004, 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. */
+
+#include <pt-internal.h>
+#include <l4/thread.h>
+
+static pthread_mutex_t pool_lock = PTHREAD_MUTEX_INITIALIZER;
+
+_L4_thread_id_t pool_list = l4_nilthread;
+
+/* Add the thread TID to the pthread kernel thread pool. */
+int
+pthread_pool_add_np (l4_thread_id_t tid)
+{
+ __pthread_mutex_lock (&pool_lock);
+ /* FIXME: Do error checking. */
+ l4_set_user_defined_handle_of (tid, pool_list);
+ pool_list = tid;
+ __pthread_mutex_unlock (&pool_lock);
+
+ return 0;
+}
+
+
+/* Get the first thread from the pool. */
+l4_thread_id_t
+pthread_pool_get_np (void)
+{
+ _L4_thread_id_t tid;
+
+ __pthread_mutex_lock (&pool_lock);
+ /* FIXME: Do error checking. */
+ tid = pool_list;
+ if (tid != l4_nilthread)
+ pool_list = l4_user_defined_handle_of (tid);
+ __pthread_mutex_unlock (&pool_lock);
+ return tid;
+}
diff --git a/sysdeps/l4/pt-spin.c b/sysdeps/l4/pt-spin.c
new file mode 100644
index 0000000..b6978b0
--- /dev/null
+++ b/sysdeps/l4/pt-spin.c
@@ -0,0 +1,63 @@
+/* Spin locks. L4 version.
+ 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 <l4.h>
+
+#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)
+{
+ l4_time_t timeout;
+ int i;
+
+ /* Start with a small timeout of 2 microseconds, then back off
+ exponentially. */
+ timeout = l4_time_period (2);
+
+ while (1)
+ {
+ for (i = 0; i < __pthread_spin_count; i++)
+ {
+ if (__pthread_spin_trylock (lock) == 0)
+ return 0;
+ }
+ l4_sleep (timeout);
+
+ timeout = l4_time_mul2 (timeout);
+ if (timeout == L4_NEVER)
+ timeout = L4_TIME_PERIOD_MAX;
+ }
+}
+
+weak_alias (_pthread_spin_lock, pthread_spin_lock);
diff --git a/sysdeps/l4/pt-stack-alloc.c b/sysdeps/l4/pt-stack-alloc.c
index e28d531..b7ec12b 100644
--- a/sysdeps/l4/pt-stack-alloc.c
+++ b/sysdeps/l4/pt-stack-alloc.c
@@ -1,5 +1,5 @@
/* Allocate a new stack. L4 Hurd version.
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 2000, 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
@@ -17,41 +17,14 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <l4/l4.h>
+#include <l4.h>
#include <errno.h>
#include <pt-internal.h>
-#define __pthread_stacksize __pthread_default_attr.stacksize
+#include <sys/mman.h>
-#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
+/* 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
@@ -59,12 +32,12 @@ allocate_page (void)
int
__pthread_stack_alloc (void **stackaddr, size_t stacksize)
{
- if (stacksize != __pthread_stacksize)
- return EINVAL;
-
- *stackaddr = allocate_page ();
- if (! *stackaddr)
+ void *buffer = mmap (0, stacksize, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (buffer == MAP_FAILED)
return EAGAIN;
-
+
+ *stackaddr = buffer;
+
return 0;
}
diff --git a/sysdeps/l4/pt-start.c b/sysdeps/l4/pt-start.c
deleted file mode 100644
index fb4e27b..0000000
--- a/sysdeps/l4/pt-start.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* 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/sysdeps/l4/pt-thread-alloc.c b/sysdeps/l4/pt-thread-alloc.c
index a9d5e21..ec69afb 100644
--- a/sysdeps/l4/pt-thread-alloc.c
+++ b/sysdeps/l4/pt-thread-alloc.c
@@ -1,5 +1,5 @@
-/* Start thread. L4 version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+/* Allocate kernel thread. L4 version.
+ Copyright (C) 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -23,30 +23,21 @@
#include <pt-internal.h>
-/* Start THREAD. Get the kernel thread scheduled and running. */
int
-__pthread_thread_start (struct __pthread *thread)
+__pthread_thread_alloc (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 ();
- }
+ 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;
- }
+ thread->threadid = pthread_pool_get_np ();
+ if (thread->threadid != l4_nilthread)
+ return 0;
+ return EAGAIN;
+ }
return 0;
}
diff --git a/sysdeps/l4/pt-thread-dealloc.c b/sysdeps/l4/pt-thread-dealloc.c
new file mode 100644
index 0000000..c09e486
--- /dev/null
+++ b/sysdeps/l4/pt-thread-dealloc.c
@@ -0,0 +1,32 @@
+/* Deallocate the kernel thread resources. L4 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 <l4.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)
+{
+}
diff --git a/sysdeps/l4/pt-thread-halt.c b/sysdeps/l4/pt-thread-halt.c
index 04d622f..aa2bf43 100644
--- a/sysdeps/l4/pt-thread-halt.c
+++ b/sysdeps/l4/pt-thread-halt.c
@@ -1,5 +1,5 @@
-/* Deallocate the kernel thread resources. Mach version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+/* Deallocate the kernel thread resources. L4version.
+ Copyright (C) 2000, 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
@@ -19,20 +19,27 @@
#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)
+__pthread_thread_halt (struct __pthread *thread, int need_dealloc)
{
- 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;
+ l4_thread_id_t tid = thread->threadid;
+
+ if (need_dealloc)
+ __pthread_dealloc (thread);
+
+ /* There is potential race here: once if TID is the current thread,
+ then once we add TID to the pool, someone can reallocate it
+ before we call stop. However, to start the thread, the caller
+ atomically starts and sets the sp and ip, thus, if the stop has
+ not yet executed at that point, it won't. */
+
+ if (tid != l4_myself ())
+ l4_stop (tid);
+ pthread_pool_add_np (tid);
+ if (tid == l4_myself ())
+ l4_stop (tid);
}
diff --git a/sysdeps/l4/pt-thread-start.c b/sysdeps/l4/pt-thread-start.c
index c428d29..144c58b 100644
--- a/sysdeps/l4/pt-thread-start.c
+++ b/sysdeps/l4/pt-thread-start.c
@@ -1,5 +1,5 @@
/* Start thread. L4 version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -23,70 +23,18 @@
#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)
+ /* The main thread is already running of course. */
{
assert (__pthread_total == 1);
- assert (thread->thread_id == L4_Myself ());
+ assert (l4_is_thread_equal (l4_myself (), thread->threadid));
}
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);
-
- }
-
+ l4_start_sp_ip (thread->threadid, (l4_word_t) thread->mcontext.sp,
+ (l4_word_t) thread->mcontext.pc);
return 0;
}
diff --git a/sysdeps/l4/pt-timedblock.c b/sysdeps/l4/pt-timedblock.c
new file mode 100644
index 0000000..ce7972b
--- /dev/null
+++ b/sysdeps/l4/pt-timedblock.c
@@ -0,0 +1,35 @@
+/* Block a thread with a timeout. L4 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 <time.h>
+#include <sys/time.h>
+
+#include <pt-internal.h>
+
+/* Block THREAD. */
+error_t
+__pthread_timedblock (struct __pthread *thread,
+ const struct timespec *abstime)
+{
+#warning Need gettimeofday to implement properly.
+ __pthread_block (thread);
+ return 0;
+}
diff --git a/sysdeps/l4/pt-wakeup.c b/sysdeps/l4/pt-wakeup.c
index 7b00e4f..de37846 100644
--- a/sysdeps/l4/pt-wakeup.c
+++ b/sysdeps/l4/pt-wakeup.c
@@ -17,13 +17,38 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <l4/l4.h>
+#include <l4.h>
#include <pt-internal.h>
+#include <hurd/stddef.h>
+
/* Wakeup THREAD. */
void
__pthread_wakeup (struct __pthread *thread)
{
- L4_Send (thread->threadid);
+ debug (5, "%x.%x/%x waking %x.%x/%x",
+ l4_thread_no (l4_myself ()), l4_version (l4_myself ()), l4_myself (),
+ l4_thread_no (thread->threadid), l4_version (thread->threadid),
+ thread->threadid);
+
+ /* Signal the waiter. */
+ l4_msg_t msg;
+ l4_msg_clear (msg);
+ l4_msg_set_untyped_words (msg, 0);
+ l4_msg_load (msg);
+
+ l4_msg_tag_t tag = l4_send (thread->threadid);
+ if (l4_ipc_failed (tag))
+ {
+ int err = l4_error_code ();
+ debug (1, "%x.%x failed to wake %x.%x: %s (%d)",
+ l4_thread_no (l4_myself ()), l4_version (l4_myself ()),
+ l4_thread_no (thread->threadid), l4_version (thread->threadid),
+ l4_strerror (err), err);
+ }
+ else
+ debug (5, "%x.%x woke %x.%x",
+ l4_thread_no (l4_myself ()), l4_version (l4_myself ()),
+ l4_thread_no (thread->threadid), l4_version (thread->threadid));
}
diff --git a/sysdeps/mach/bits/spin-lock-inline.h b/sysdeps/mach/bits/spin-lock-inline.h
new file mode 100644
index 0000000..f9f7c29
--- /dev/null
+++ b/sysdeps/mach/bits/spin-lock-inline.h
@@ -0,0 +1,90 @@
+/* Definitions of user-visible names for spin locks.
+ Copyright (C) 1994, 1997, 2002, 2008, 2009 Free Software Foundation, Inc.
+ This file is part of the 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_INLINE_H
+#define _BITS_SPIN_LOCK_INLINE_H 1
+
+#include <features.h>
+#include <bits/spin-lock.h>
+#include <machine-lock.h> /* This does all the work. */
+
+__BEGIN_DECLS
+
+#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 = __PTHREAD_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/sysdeps/mach/bits/spin-lock.h b/sysdeps/mach/bits/spin-lock.h
index e137c24..537dac9 100644
--- a/sysdeps/mach/bits/spin-lock.h
+++ b/sysdeps/mach/bits/spin-lock.h
@@ -1,5 +1,5 @@
/* Definitions of user-visible names for spin locks.
- Copyright (C) 1994, 1997, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1994, 1997, 2002, 2008, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -29,69 +29,10 @@ __BEGIN_DECLS
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>.
+#ifndef __PTHREAD_SPIN_LOCK_INITIALIZER
+#error __PTHREAD_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/sysdeps/mach/hurd/i386/pt-machdep.c b/sysdeps/mach/hurd/ia32/pt-machdep.c
index f3c8cf5..f3c8cf5 100644
--- a/sysdeps/mach/hurd/i386/pt-machdep.c
+++ b/sysdeps/mach/hurd/ia32/pt-machdep.c
diff --git a/sysdeps/mach/hurd/i386/pt-setup.c b/sysdeps/mach/hurd/ia32/pt-setup.c
index 020f677..5420dc8 100644
--- a/sysdeps/mach/hurd/i386/pt-setup.c
+++ b/sysdeps/mach/hurd/ia32/pt-setup.c
@@ -1,5 +1,5 @@
/* Setup thread stack. Hurd/i386 version.
- Copyright (C) 2000, 2002, 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2005, 2007, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -58,13 +58,15 @@ stack_setup (struct __pthread *thread,
top -= __hurd_threadvar_max;
/* Save the self pointer. */
- top[_HURD_THREADVAR_THREAD] = (void *) thread;
+ top[_HURD_THREADVAR_THREAD] = (uintptr_t) thread;
if (start_routine)
{
/* And then the call frame. */
- *--top = (uintptr_t) arg; /* Argument to START_ROUTINE. */
- *--top = (uintptr_t) start_routine;
+ top -= 2;
+ top = (uintptr_t *) ((uintptr_t) top & ~0xf);
+ top[1] = (uintptr_t) arg; /* Argument to START_ROUTINE. */
+ top[0] = (uintptr_t) start_routine;
*--top = 0; /* Fake return address. */
}
diff --git a/sysdeps/mach/hurd/pt-docancel.c b/sysdeps/mach/hurd/pt-docancel.c
index 84f04c0..105c6fd 100644
--- a/sysdeps/mach/hurd/pt-docancel.c
+++ b/sysdeps/mach/hurd/pt-docancel.c
@@ -1,5 +1,5 @@
/* Cancel a thread.
- Copyright (C) 2002, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2007, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -33,7 +33,7 @@ __pthread_do_cancel (struct __pthread *p)
mach_port_t ktid;
int me;
- assert (p->cancel_pending = 1);
+ assert (p->cancel_pending == 1);
assert (p->cancel_state == PTHREAD_CANCEL_ENABLE);
ktid = __mach_thread_self ();
diff --git a/sysdeps/mach/hurd/pt-sysdep.h b/sysdeps/mach/hurd/pt-sysdep.h
index f652b68..13e235d 100644
--- a/sysdeps/mach/hurd/pt-sysdep.h
+++ b/sysdeps/mach/hurd/pt-sysdep.h
@@ -1,5 +1,5 @@
/* Internal defenitions for pthreads library.
- Copyright (C) 2000, 2002, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2007, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -32,7 +32,8 @@
#define PTHREAD_SYSDEP_MEMBERS \
thread_t kernel_thread; \
- mach_msg_header_t wakeupmsg;
+ mach_msg_header_t wakeupmsg; \
+ int have_kernel_resources;
#define _HURD_THREADVAR_THREAD _HURD_THREADVAR_DYNAMIC_USER
diff --git a/sysdeps/mach/pt-thread-alloc.c b/sysdeps/mach/pt-thread-alloc.c
index 1acba98..3d7c046 100644
--- a/sysdeps/mach/pt-thread-alloc.c
+++ b/sysdeps/mach/pt-thread-alloc.c
@@ -1,5 +1,5 @@
/* Start thread. Mach version.
- Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
+ 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
@@ -63,6 +63,9 @@ create_wakeupmsg (struct __pthread *thread)
int
__pthread_thread_alloc (struct __pthread *thread)
{
+ if (thread->have_kernel_resources)
+ return 0;
+
error_t err;
err = create_wakeupmsg (thread);
@@ -97,5 +100,7 @@ __pthread_thread_alloc (struct __pthread *thread)
return EAGAIN;
}
+ thread->have_kernel_resources = 1;
+
return 0;
}
diff --git a/sysdeps/mach/pt-thread-halt.c b/sysdeps/mach/pt-thread-halt.c
index 9f86024..973cde1 100644
--- a/sysdeps/mach/pt-thread-halt.c
+++ b/sysdeps/mach/pt-thread-halt.c
@@ -30,14 +30,8 @@
being halted, thus the last action should be halting the thread
itself. */
void
-__pthread_thread_halt (struct __pthread *thread, int need_dealloc)
+__pthread_thread_halt (struct __pthread *thread)
{
- error_t err;
- thread_t tid = thread->kernel_thread;
-
- if (need_dealloc)
- __pthread_dealloc (thread);
-
- err = __thread_terminate (tid);
+ error_t err = __thread_terminate (thread->kernel_thread);
assert_perror (err);
}
diff --git a/sysdeps/mach/pt-timedblock.c b/sysdeps/mach/pt-timedblock.c
index ddb8bae..6f54726 100644
--- a/sysdeps/mach/pt-timedblock.c
+++ b/sysdeps/mach/pt-timedblock.c
@@ -51,11 +51,11 @@ __pthread_timedblock (struct __pthread *thread,
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;
+ 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;
+ timeout -= (now.tv_usec + 999) / 1000 -
+ ((abstime->tv_nsec + 999999) / 1000000);
err = __mach_msg (&msg, MACH_RCV_MSG | MACH_RCV_TIMEOUT, 0,
sizeof msg, thread->wakeupmsg.msgh_remote_port,
diff --git a/sysdeps/posix/pt-spin.c b/sysdeps/posix/pt-spin.c
index 486030d..cb809c6 100644
--- a/sysdeps/posix/pt-spin.c
+++ b/sysdeps/posix/pt-spin.c
@@ -1,5 +1,5 @@
/* Spin locks.
- Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/powerpc/bits/machine-lock.h b/sysdeps/powerpc/bits/machine-lock.h
new file mode 100644
index 0000000..cba6b0a
--- /dev/null
+++ b/sysdeps/powerpc/bits/machine-lock.h
@@ -0,0 +1,78 @@
+/* Machine-specific definition for spin locks. PowerPC version.
+ Copyright (C) 1994,97,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 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_LOCK_H
+#define _MACHINE_LOCK_H
+
+/* The type of a spin lock variable. */
+
+typedef __volatile long int __spin_lock_t;
+
+/* Value to initialize `__spin_lock_t' variables to. */
+
+#define __SPIN_LOCK_INITIALIZER 0L
+
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE extern __inline
+#endif
+
+/* Unlock LOCK. */
+
+_EXTERN_INLINE void
+__spin_unlock (__spin_lock_t *__lock)
+{
+ long int __locked;
+ __asm__ __volatile__ ("\
+0: lwarx %0,0,%1\n\
+ stwcx. %2,0,%1\n\
+ bne- 0b\n\
+" : "=&r" (__locked) : "r" (__lock), "r" (0) : "cr0");
+}
+
+/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */
+
+_EXTERN_INLINE int
+__spin_try_lock (register __spin_lock_t *__lock)
+{
+ long int __rtn;
+ __asm__ __volatile__ ("\
+0: lwarx %0,0,%1\n\
+ stwcx. %2,0,%1\n\
+ bne- 0b\n\
+" : "=&r" (__rtn) : "r" (__lock), "r" (1) : "cr0");
+ return !__rtn;
+}
+
+/* Return nonzero if LOCK is locked. */
+
+_EXTERN_INLINE int
+__spin_lock_locked (__spin_lock_t *__lock)
+{
+ long int __rtn;
+ __asm__ __volatile__ ("\
+0: lwarx %0,0,%1\n\
+ stwcx. %0,0,%1\n\
+ bne- 0b\n\
+" : "=&r" (__rtn) : "r" (__lock) : "cr0");
+ return __rtn;
+}
+
+
+#endif /* machine-lock.h */
diff --git a/sysdeps/powerpc/bits/memory.h b/sysdeps/powerpc/bits/memory.h
new file mode 100644
index 0000000..96624c3
--- /dev/null
+++ b/sysdeps/powerpc/bits/memory.h
@@ -0,0 +1,36 @@
+/* Memory barrier operations. PowerPC version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; 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. */
+inline void
+__memory_barrier (void)
+{
+ asm ("sync" ::: "memory");
+}
+
+/* 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/sysdeps/powerpc/bits/spin-lock.h b/sysdeps/powerpc/bits/spin-lock.h
new file mode 100644
index 0000000..1dc2571
--- /dev/null
+++ b/sysdeps/powerpc/bits/spin-lock.h
@@ -0,0 +1,108 @@
+/* Machine-specific definitions for spin locks. PowerPC version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; 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 ((__pthread_spinlock_t) 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)
+{
+ long int __rtn;
+ __asm__ __volatile__ ("\
+0: lwarx %0,0,%1\n\
+ stwcx. %2,0,%1\n\
+ bne- 0b\n\
+" : "=&r" (__rtn) : "r" (__lock), "r" (1) : "cr0");
+ return __rtn ? __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)
+{
+ long int __locked;
+ __asm__ __volatile__ ("\
+0: lwarx %0,0,%1\n\
+ stwcx. %2,0,%1\n\
+ bne- 0b\n\
+" : "=&r" (__locked) : "r" (__lock), "r" (0) : "cr0");
+}
+
+#endif /* Use extern inlines or force inlines. */
+
+__END_DECLS
+
+#endif /* bits/spin-lock.h */
diff --git a/sysdeps/powerpc/machine-sp.h b/sysdeps/powerpc/machine-sp.h
new file mode 100644
index 0000000..aa787c5
--- /dev/null
+++ b/sysdeps/powerpc/machine-sp.h
@@ -0,0 +1,31 @@
+/* Machine-specific function to return the stack pointer. i386 version.
+ Copyright (C) 1994,97,2001 Free Software Foundation, Inc.
+ This file is part of the 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() ({ \
+ void *__sp__; \
+ __asm__ ("mr %0, 1" : "=r" (__sp__)); \
+ __sp__; \
+})
+
+#endif /* machine-sp.h */
diff --git a/sysdeps/powerpc/pt-machdep.h b/sysdeps/powerpc/pt-machdep.h
new file mode 100644
index 0000000..6d45636
--- /dev/null
+++ b/sysdeps/powerpc/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/tests/test-1.c b/tests/test-1.c
index 318fd6e..6ec1afb 100644
--- a/tests/test-1.c
+++ b/tests/test-1.c
@@ -1,6 +1,7 @@
#define _GNU_SOURCE
#include <pthread.h>
+#include <assert.h>
#include <unistd.h>
#include <error.h>
#include <errno.h>
diff --git a/tests/test-16.c b/tests/test-16.c
index b6a52d0..3660f5f 100644
--- a/tests/test-16.c
+++ b/tests/test-16.c
@@ -33,7 +33,7 @@ test (void *arg)
}
static void
-handler (int sig, siginfo_t *info, void *context)
+handler (int sig)
{
assert (pthread_equal (pthread_self (), testthread));
printf ("handler: %d\n", pthread_self ());
diff --git a/tests/test-6.c b/tests/test-6.c
index 98aa8ba..edf2919 100644
--- a/tests/test-6.c
+++ b/tests/test-6.c
@@ -3,6 +3,7 @@
#include <pthread.h>
#include <stdio.h>
#include <error.h>
+#include <assert.h>
#include <errno.h>
#define THREADS 500
diff --git a/tests/test-7.c b/tests/test-7.c
index bd97acf..8159be3 100644
--- a/tests/test-7.c
+++ b/tests/test-7.c
@@ -1,6 +1,7 @@
#define _GNU_SOURCE
#include <pthread.h>
+#include <assert.h>
#include <stdio.h>
#include <error.h>
#include <errno.h>