From db7bf9590dc08a72de9a9c46db7937188156fa2e Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 27 Nov 2011 18:39:25 +0100 Subject: Fix __mutex_unlock_solid safety libc releases the spinlock before calling __mutex_unlock_solid, so we have to try to reacquire it before possibly giving it to some blocked thread. * pthread/cthreads-compat.c (__mutex_unlock_solid): Call __pthread_spin_trylock before calling __pthread_mutex_unlock. --- pthread/cthreads-compat.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'pthread') diff --git a/pthread/cthreads-compat.c b/pthread/cthreads-compat.c index e0536ef..cbe8170 100644 --- a/pthread/cthreads-compat.c +++ b/pthread/cthreads-compat.c @@ -100,5 +100,8 @@ __mutex_lock_solid (void *lock) void __mutex_unlock_solid (void *lock) { + if (__pthread_spin_trylock (lock) != 0) + /* Somebody already got the lock, that one will manage waking up others */ + return; __pthread_mutex_unlock (lock); } -- cgit v1.2.3 From 51feb14bff6b4aa70e2f13a54e26a6b270de3e4d Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 21 Apr 2012 22:07:49 +0000 Subject: Rename pthread functions to be used for forwarding Libc will need to be able to call them, so they need to have a different name. * pthread/pt-exit.c (pthread_exit): Rename with __ prefix and add strong alias. * pthread/pt-self.c (pthread_self): Likewise. * pthread/pt-setcancelstate.c (pthread_setcancelstate): Likewise * pthread/pt-setcanceltype.c (pthread_setcanceltype): Likewise * sysdeps/generic/pt-attr-destroy.c (pthread_attr_destroy): Likewise * sysdeps/generic/pt-attr-getdetachstate.c (pthread_attr_getdetachstate): Likewise * sysdeps/generic/pt-attr-getinheritsched.c (pthread_attr_getinheritsched): Likewise * sysdeps/generic/pt-attr-getschedparam.c (pthread_attr_getschedparam): Likewise * sysdeps/generic/pt-attr-getschedpolicy.c (pthread_attr_getschedpolicy): Likewise * sysdeps/generic/pt-attr-getscope.c (pthread_attr_getscope): Likewise * sysdeps/generic/pt-attr-init.c (pthread_attr_init): Likewise * sysdeps/generic/pt-attr-setdetachstate.c (pthread_attr_setdetachstate): Likewise * sysdeps/generic/pt-attr-setinheritsched.c (pthread_attr_setinheritsched): Likewise * sysdeps/generic/pt-attr-setschedparam.c (pthread_attr_setschedparam): Likewise * sysdeps/generic/pt-attr-setschedpolicy.c (pthread_attr_setschedpolicy): Likewise * sysdeps/generic/pt-attr-setscope.c (pthread_attr_setscope): Likewise * sysdeps/generic/pt-cond-brdcast.c (pthread_cond_broadcast): Likewise * sysdeps/generic/pt-cond-destroy.c (pthread_cond_destroy): Likewise * sysdeps/generic/pt-cond-init.c (pthread_cond_init): Likewise * sysdeps/generic/pt-cond-signal.c (pthread_cond_signal): Likewise * sysdeps/generic/pt-cond-timedwait.c (pthread_cond_timedwait): Likewise * sysdeps/generic/pt-cond-wait.c (pthread_cond_wait): Likewise * sysdeps/generic/pt-condattr-destroy.c (pthread_condattr_destroy): Likewise * sysdeps/generic/pt-condattr-init.c (pthread_condattr_init): Likewise * sysdeps/generic/pt-equal.c (pthread_equal): Likewise * sysdeps/generic/pt-getschedparam.c (pthread_getschedparam): Likewise * sysdeps/generic/pt-setschedparam.c (pthread_setschedparam): Likewise --- pthread/pt-exit.c | 4 +++- pthread/pt-self.c | 4 +++- pthread/pt-setcancelstate.c | 4 +++- pthread/pt-setcanceltype.c | 4 +++- sysdeps/generic/pt-attr-destroy.c | 3 ++- sysdeps/generic/pt-attr-getdetachstate.c | 4 +++- sysdeps/generic/pt-attr-getinheritsched.c | 4 +++- sysdeps/generic/pt-attr-getschedparam.c | 4 +++- sysdeps/generic/pt-attr-getschedpolicy.c | 4 +++- sysdeps/generic/pt-attr-getscope.c | 4 +++- sysdeps/generic/pt-attr-init.c | 3 ++- sysdeps/generic/pt-attr-setdetachstate.c | 4 +++- sysdeps/generic/pt-attr-setinheritsched.c | 4 +++- sysdeps/generic/pt-attr-setschedparam.c | 4 +++- sysdeps/generic/pt-attr-setschedpolicy.c | 4 +++- sysdeps/generic/pt-attr-setscope.c | 4 +++- sysdeps/generic/pt-cond-brdcast.c | 4 +++- sysdeps/generic/pt-cond-destroy.c | 4 +++- sysdeps/generic/pt-cond-init.c | 4 +++- sysdeps/generic/pt-cond-signal.c | 4 +++- sysdeps/generic/pt-cond-timedwait.c | 4 +++- sysdeps/generic/pt-cond-wait.c | 4 +++- sysdeps/generic/pt-condattr-destroy.c | 4 +++- sysdeps/generic/pt-condattr-init.c | 4 +++- sysdeps/generic/pt-equal.c | 4 +++- sysdeps/generic/pt-getschedparam.c | 4 +++- sysdeps/generic/pt-setschedparam.c | 4 +++- 27 files changed, 79 insertions(+), 27 deletions(-) (limited to 'pthread') diff --git a/pthread/pt-exit.c b/pthread/pt-exit.c index c01efda..53a0427 100644 --- a/pthread/pt-exit.c +++ b/pthread/pt-exit.c @@ -30,7 +30,7 @@ /* Terminate the current thread and make STATUS available to any thread that might join it. */ void -pthread_exit (void *status) +__pthread_exit (void *status) { struct __pthread *self = _pthread_self (); struct __pthread_cancelation_handler **handlers; @@ -120,3 +120,5 @@ pthread_exit (void *status) /* NOTREACHED */ abort (); } + +strong_alias (__pthread_exit, pthread_exit); diff --git a/pthread/pt-self.c b/pthread/pt-self.c index 4976864..deb57c0 100644 --- a/pthread/pt-self.c +++ b/pthread/pt-self.c @@ -23,10 +23,12 @@ /* Return the thread ID of the calling thread. */ pthread_t -pthread_self (void) +__pthread_self (void) { struct __pthread *self = _pthread_self (); assert (self); return self->thread; } + +strong_alias (__pthread_self, pthread_self); diff --git a/pthread/pt-setcancelstate.c b/pthread/pt-setcancelstate.c index e2d8183..38550ee 100644 --- a/pthread/pt-setcancelstate.c +++ b/pthread/pt-setcancelstate.c @@ -22,7 +22,7 @@ #include int -pthread_setcancelstate (int state, int *oldstate) +__pthread_setcancelstate (int state, int *oldstate) { struct __pthread *p = _pthread_self (); @@ -41,3 +41,5 @@ pthread_setcancelstate (int state, int *oldstate) return 0; } + +strong_alias (__pthread_setcancelstate, pthread_setcancelstate); diff --git a/pthread/pt-setcanceltype.c b/pthread/pt-setcanceltype.c index 3ce4259..7226a3a 100644 --- a/pthread/pt-setcanceltype.c +++ b/pthread/pt-setcanceltype.c @@ -22,7 +22,7 @@ #include int -pthread_setcanceltype (int type, int *oldtype) +__pthread_setcanceltype (int type, int *oldtype) { struct __pthread *p = _pthread_self (); @@ -41,3 +41,5 @@ pthread_setcanceltype (int type, int *oldtype) return 0; } + +strong_alias (__pthread_setcanceltype, pthread_setcanceltype); diff --git a/sysdeps/generic/pt-attr-destroy.c b/sysdeps/generic/pt-attr-destroy.c index c4b9aa5..b9bd374 100644 --- a/sysdeps/generic/pt-attr-destroy.c +++ b/sysdeps/generic/pt-attr-destroy.c @@ -21,7 +21,8 @@ #include int -pthread_attr_destroy (pthread_attr_t *attr) +__pthread_attr_destroy (pthread_attr_t *attr) { return 0; } +strong_alias (__pthread_attr_destroy, pthread_attr_destroy); diff --git a/sysdeps/generic/pt-attr-getdetachstate.c b/sysdeps/generic/pt-attr-getdetachstate.c index be406f1..b50f913 100644 --- a/sysdeps/generic/pt-attr-getdetachstate.c +++ b/sysdeps/generic/pt-attr-getdetachstate.c @@ -21,9 +21,11 @@ #include int -pthread_attr_getdetachstate (const pthread_attr_t *attr, +__pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate) { *detachstate = attr->detachstate; return 0; } + +strong_alias (__pthread_attr_getdetachstate, pthread_attr_getdetachstate); diff --git a/sysdeps/generic/pt-attr-getinheritsched.c b/sysdeps/generic/pt-attr-getinheritsched.c index cca4e3d..7f1f601 100644 --- a/sysdeps/generic/pt-attr-getinheritsched.c +++ b/sysdeps/generic/pt-attr-getinheritsched.c @@ -21,9 +21,11 @@ #include int -pthread_attr_getinheritsched (const pthread_attr_t *attr, +__pthread_attr_getinheritsched (const pthread_attr_t *attr, int *inheritsched) { *inheritsched = attr->inheritsched; return 0; } + +strong_alias (__pthread_attr_getinheritsched, pthread_attr_getinheritsched); diff --git a/sysdeps/generic/pt-attr-getschedparam.c b/sysdeps/generic/pt-attr-getschedparam.c index 190cf9d..4519b69 100644 --- a/sysdeps/generic/pt-attr-getschedparam.c +++ b/sysdeps/generic/pt-attr-getschedparam.c @@ -24,9 +24,11 @@ #include int -pthread_attr_getschedparam (const pthread_attr_t *attr, +__pthread_attr_getschedparam (const pthread_attr_t *attr, struct sched_param *param) { memcpy (param, &attr->schedparam, sizeof *param); return 0; } + +strong_alias (__pthread_attr_getschedparam, pthread_attr_getschedparam); diff --git a/sysdeps/generic/pt-attr-getschedpolicy.c b/sysdeps/generic/pt-attr-getschedpolicy.c index 4349a23..0980bdd 100644 --- a/sysdeps/generic/pt-attr-getschedpolicy.c +++ b/sysdeps/generic/pt-attr-getschedpolicy.c @@ -21,9 +21,11 @@ #include int -pthread_attr_getschedpolicy (const pthread_attr_t *attr, +__pthread_attr_getschedpolicy (const pthread_attr_t *attr, int *policy) { *policy = attr->schedpolicy; return 0; } + +strong_alias (__pthread_attr_getschedpolicy, pthread_attr_getschedpolicy); diff --git a/sysdeps/generic/pt-attr-getscope.c b/sysdeps/generic/pt-attr-getscope.c index 97198fa..46eb604 100644 --- a/sysdeps/generic/pt-attr-getscope.c +++ b/sysdeps/generic/pt-attr-getscope.c @@ -21,9 +21,11 @@ #include int -pthread_attr_getscope (const pthread_attr_t *attr, +__pthread_attr_getscope (const pthread_attr_t *attr, int *contentionscope) { *contentionscope = attr->contentionscope; return 0; } + +strong_alias (__pthread_attr_getscope, pthread_attr_getscope); diff --git a/sysdeps/generic/pt-attr-init.c b/sysdeps/generic/pt-attr-init.c index 6a930e3..f9eb361 100644 --- a/sysdeps/generic/pt-attr-init.c +++ b/sysdeps/generic/pt-attr-init.c @@ -21,8 +21,9 @@ #include int -pthread_attr_init (pthread_attr_t *attr) +__pthread_attr_init (pthread_attr_t *attr) { *attr = __pthread_default_attr; return 0; } +strong_alias (__pthread_attr_init, pthread_attr_init); diff --git a/sysdeps/generic/pt-attr-setdetachstate.c b/sysdeps/generic/pt-attr-setdetachstate.c index 688ba5d..abd6bbb 100644 --- a/sysdeps/generic/pt-attr-setdetachstate.c +++ b/sysdeps/generic/pt-attr-setdetachstate.c @@ -21,7 +21,7 @@ #include int -pthread_attr_setdetachstate (pthread_attr_t *attr, +__pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate) { switch (detachstate) @@ -36,3 +36,5 @@ pthread_attr_setdetachstate (pthread_attr_t *attr, return 0; } + +strong_alias (__pthread_attr_setdetachstate, pthread_attr_setdetachstate); diff --git a/sysdeps/generic/pt-attr-setinheritsched.c b/sysdeps/generic/pt-attr-setinheritsched.c index e9012c5..9fdbd4e 100644 --- a/sysdeps/generic/pt-attr-setinheritsched.c +++ b/sysdeps/generic/pt-attr-setinheritsched.c @@ -21,7 +21,7 @@ #include int -pthread_attr_setinheritsched (pthread_attr_t *attr, +__pthread_attr_setinheritsched (pthread_attr_t *attr, int inheritsched) { switch (inheritsched) @@ -36,3 +36,5 @@ pthread_attr_setinheritsched (pthread_attr_t *attr, return 0; } + +strong_alias (__pthread_attr_setinheritsched, pthread_attr_setinheritsched); diff --git a/sysdeps/generic/pt-attr-setschedparam.c b/sysdeps/generic/pt-attr-setschedparam.c index 5459f10..2fd1d3a 100644 --- a/sysdeps/generic/pt-attr-setschedparam.c +++ b/sysdeps/generic/pt-attr-setschedparam.c @@ -24,7 +24,7 @@ #include int -pthread_attr_setschedparam (pthread_attr_t *attr, +__pthread_attr_setschedparam (pthread_attr_t *attr, const struct sched_param *param) { if (memcmp (param, &__pthread_default_attr.schedparam, @@ -36,3 +36,5 @@ pthread_attr_setschedparam (pthread_attr_t *attr, return ENOTSUP; } + +strong_alias (__pthread_attr_setschedparam, pthread_attr_setschedparam); diff --git a/sysdeps/generic/pt-attr-setschedpolicy.c b/sysdeps/generic/pt-attr-setschedpolicy.c index e481d04..04e93c9 100644 --- a/sysdeps/generic/pt-attr-setschedpolicy.c +++ b/sysdeps/generic/pt-attr-setschedpolicy.c @@ -21,7 +21,7 @@ #include int -pthread_attr_setschedpolicy (pthread_attr_t *attr, +__pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy) { switch (policy) @@ -40,3 +40,5 @@ pthread_attr_setschedpolicy (pthread_attr_t *attr, return 0; } + +strong_alias (__pthread_attr_setschedpolicy, pthread_attr_setschedpolicy); diff --git a/sysdeps/generic/pt-attr-setscope.c b/sysdeps/generic/pt-attr-setscope.c index c74a4f6..d86d7b5 100644 --- a/sysdeps/generic/pt-attr-setscope.c +++ b/sysdeps/generic/pt-attr-setscope.c @@ -21,7 +21,7 @@ #include int -pthread_attr_setscope (pthread_attr_t *attr, +__pthread_attr_setscope (pthread_attr_t *attr, int contentionscope) { if (contentionscope == __pthread_default_attr.contentionscope) @@ -39,3 +39,5 @@ pthread_attr_setscope (pthread_attr_t *attr, return EINVAL; } } + +strong_alias (__pthread_attr_setscope, pthread_attr_setscope); diff --git a/sysdeps/generic/pt-cond-brdcast.c b/sysdeps/generic/pt-cond-brdcast.c index 3f55e33..999cc2d 100644 --- a/sysdeps/generic/pt-cond-brdcast.c +++ b/sysdeps/generic/pt-cond-brdcast.c @@ -23,7 +23,7 @@ /* Unblock all threads that are blocked on condition variable COND. */ int -pthread_cond_broadcast (pthread_cond_t *cond) +__pthread_cond_broadcast (pthread_cond_t *cond) { struct __pthread *wakeup; @@ -40,3 +40,5 @@ pthread_cond_broadcast (pthread_cond_t *cond) return 0; } + +strong_alias (__pthread_cond_broadcast, pthread_cond_broadcast); diff --git a/sysdeps/generic/pt-cond-destroy.c b/sysdeps/generic/pt-cond-destroy.c index eba4778..d72ea75 100644 --- a/sysdeps/generic/pt-cond-destroy.c +++ b/sysdeps/generic/pt-cond-destroy.c @@ -21,7 +21,9 @@ #include int -pthread_cond_destroy (pthread_cond_t *cond) +__pthread_cond_destroy (pthread_cond_t *cond) { return 0; } + +strong_alias (__pthread_cond_destroy, pthread_cond_destroy); diff --git a/sysdeps/generic/pt-cond-init.c b/sysdeps/generic/pt-cond-init.c index b9e9fb7..350f2eb 100644 --- a/sysdeps/generic/pt-cond-init.c +++ b/sysdeps/generic/pt-cond-init.c @@ -24,7 +24,7 @@ #include int -pthread_cond_init (pthread_cond_t *cond, +__pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr) { *cond = (pthread_cond_t) __PTHREAD_COND_INITIALIZER; @@ -43,3 +43,5 @@ pthread_cond_init (pthread_cond_t *cond, *cond->__attr = *attr; return 0; } + +strong_alias (__pthread_cond_init, pthread_cond_init); diff --git a/sysdeps/generic/pt-cond-signal.c b/sysdeps/generic/pt-cond-signal.c index c5e1bc1..d7c91e6 100644 --- a/sysdeps/generic/pt-cond-signal.c +++ b/sysdeps/generic/pt-cond-signal.c @@ -46,9 +46,11 @@ cond_signal (struct __pthread_cond *cond, int *unblocked) /* Unblock at least one of the threads that are blocked on condition variable COND. */ int -pthread_cond_signal (pthread_cond_t *cond) +__pthread_cond_signal (pthread_cond_t *cond) { int unblocked = 0; return cond_signal (cond, &unblocked); } + +strong_alias (__pthread_cond_signal, pthread_cond_signal); diff --git a/sysdeps/generic/pt-cond-timedwait.c b/sysdeps/generic/pt-cond-timedwait.c index c10bdb3..483f277 100644 --- a/sysdeps/generic/pt-cond-timedwait.c +++ b/sysdeps/generic/pt-cond-timedwait.c @@ -26,13 +26,15 @@ extern int __pthread_cond_timedwait_internal (pthread_cond_t *cond, const struct timespec *abstime); int -pthread_cond_timedwait (pthread_cond_t *cond, +__pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime) { return __pthread_cond_timedwait_internal (cond, mutex, abstime); } +strong_alias (__pthread_cond_timedwait, pthread_cond_timedwait); + /* Block on condition variable COND until ABSTIME. As a GNU extension, if ABSTIME is NULL, then wait forever. MUTEX should be held by the calling thread. On return, MUTEX will be held by the diff --git a/sysdeps/generic/pt-cond-wait.c b/sysdeps/generic/pt-cond-wait.c index a03476d..38a2ae6 100644 --- a/sysdeps/generic/pt-cond-wait.c +++ b/sysdeps/generic/pt-cond-wait.c @@ -31,7 +31,9 @@ extern int __pthread_cond_timedwait_internal (pthread_cond_t *cond, calling thread. On return, MUTEX will be held by the calling thread. */ int -pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) +__pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) { return __pthread_cond_timedwait_internal (cond, mutex, 0); } + +strong_alias (__pthread_cond_wait, pthread_cond_wait); diff --git a/sysdeps/generic/pt-condattr-destroy.c b/sysdeps/generic/pt-condattr-destroy.c index c8fd71b..9fd55b1 100644 --- a/sysdeps/generic/pt-condattr-destroy.c +++ b/sysdeps/generic/pt-condattr-destroy.c @@ -21,7 +21,9 @@ #include int -pthread_condattr_destroy (pthread_condattr_t *cond) +__pthread_condattr_destroy (pthread_condattr_t *cond) { return 0; } + +strong_alias (__pthread_condattr_destroy, pthread_condattr_destroy); diff --git a/sysdeps/generic/pt-condattr-init.c b/sysdeps/generic/pt-condattr-init.c index cf9e198..8570fd1 100644 --- a/sysdeps/generic/pt-condattr-init.c +++ b/sysdeps/generic/pt-condattr-init.c @@ -21,8 +21,10 @@ #include int -pthread_condattr_init (pthread_condattr_t *attr) +__pthread_condattr_init (pthread_condattr_t *attr) { *attr = __pthread_default_condattr; return 0; } + +strong_alias (__pthread_condattr_init, pthread_condattr_init); diff --git a/sysdeps/generic/pt-equal.c b/sysdeps/generic/pt-equal.c index 8fbc519..72fc7e6 100644 --- a/sysdeps/generic/pt-equal.c +++ b/sysdeps/generic/pt-equal.c @@ -23,7 +23,9 @@ /* Return true if __T1 and __T2 both name the same thread. Otherwise, false. */ int -pthread_equal (pthread_t __t1, pthread_t __t2) +__pthread_equal (pthread_t __t1, pthread_t __t2) { return __t1 == __t2; } + +strong_alias (__pthread_equal, pthread_equal); diff --git a/sysdeps/generic/pt-getschedparam.c b/sysdeps/generic/pt-getschedparam.c index c128d02..6ec45fe 100644 --- a/sysdeps/generic/pt-getschedparam.c +++ b/sysdeps/generic/pt-getschedparam.c @@ -21,8 +21,10 @@ #include int -pthread_getschedparam (pthread_t thread, int *policy, +__pthread_getschedparam (pthread_t thread, int *policy, struct sched_param *param) { return ENOSYS; } + +strong_alias (__pthread_getschedparam, pthread_getschedparam); diff --git a/sysdeps/generic/pt-setschedparam.c b/sysdeps/generic/pt-setschedparam.c index a70b079..14aeb0c 100644 --- a/sysdeps/generic/pt-setschedparam.c +++ b/sysdeps/generic/pt-setschedparam.c @@ -21,8 +21,10 @@ #include int -pthread_setschedparam (pthread_t thread, int policy, +__pthread_setschedparam (pthread_t thread, int policy, const struct sched_param *param) { return ENOSYS; } + +strong_alias (__pthread_setschedparam, pthread_setschedparam); -- cgit v1.2.3 From 608a12659f15d57abf42a972c1e56c6a24cfe244 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 21 Apr 2012 22:14:22 +0000 Subject: Rename bits/atomic.h to bits/pt-atomic.h This avoids a conflict with glibc-provided bits/atomic.h * sysdeps/ia32/bits/atomic.h: Rename to... * sysdeps/ia32/bits/pt-atomic.h: ... this. * pthread/pt-create.c: Include instead of * pthread/pt-exit.c: Likewise. * pthread/pt-internal.h: Likewise. --- pthread/pt-create.c | 2 +- pthread/pt-exit.c | 2 +- pthread/pt-internal.h | 2 +- sysdeps/ia32/bits/atomic.h | 66 ------------------------------------------- sysdeps/ia32/bits/pt-atomic.h | 66 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 69 deletions(-) delete mode 100644 sysdeps/ia32/bits/atomic.h create mode 100644 sysdeps/ia32/bits/pt-atomic.h (limited to 'pthread') diff --git a/pthread/pt-create.c b/pthread/pt-create.c index 346c697..ca6b66c 100644 --- a/pthread/pt-create.c +++ b/pthread/pt-create.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include diff --git a/pthread/pt-exit.c b/pthread/pt-exit.c index 53a0427..c47b604 100644 --- a/pthread/pt-exit.c +++ b/pthread/pt-exit.c @@ -24,7 +24,7 @@ #include -#include +#include /* Terminate the current thread and make STATUS available to any diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index 3f69d2d..94bc9a7 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include diff --git a/sysdeps/ia32/bits/atomic.h b/sysdeps/ia32/bits/atomic.h deleted file mode 100644 index 0dfc1f6..0000000 --- a/sysdeps/ia32/bits/atomic.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Atomic operations. i386 version. - Copyright (C) 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef _BITS_ATOMIC_H -#define _BITS_ATOMIC_H 1 - -typedef __volatile int __atomic_t; - -static inline void -__atomic_inc (__atomic_t *__var) -{ - __asm__ __volatile ("lock; incl %0" : "=m" (*__var) : "m" (*__var)); -} - -static inline void -__atomic_dec (__atomic_t *__var) -{ - __asm__ __volatile ("lock; decl %0" : "=m" (*__var) : "m" (*__var)); -} - -static inline int -__atomic_dec_and_test (__atomic_t *__var) -{ - unsigned char __ret; - - __asm__ __volatile ("lock; decl %0; sete %1" - : "=m" (*__var), "=qm" (__ret) : "m" (*__var)); - return __ret != 0; -} - -/* We assume that an __atomicptr_t is only used for pointers to - word-aligned objects, and use the lowest bit for a simple lock. */ -typedef __volatile int * __atomicptr_t; - -/* Actually we don't implement that yet, and assume that we run on - something that has the i486 instruction set. */ -static inline int -__atomicptr_compare_and_swap (__atomicptr_t *__ptr, void *__oldval, - void * __newval) -{ - char __ret; - int __dummy; - - __asm__ __volatile ("lock; cmpxchgl %3, %1; sete %0" - : "=q" (__ret), "=m" (*__ptr), "=a" (__dummy) - : "r" (__newval), "m" (*__ptr), "a" (__oldval)); - return __ret; -} - -#endif diff --git a/sysdeps/ia32/bits/pt-atomic.h b/sysdeps/ia32/bits/pt-atomic.h new file mode 100644 index 0000000..0dfc1f6 --- /dev/null +++ b/sysdeps/ia32/bits/pt-atomic.h @@ -0,0 +1,66 @@ +/* Atomic operations. i386 version. + Copyright (C) 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _BITS_ATOMIC_H +#define _BITS_ATOMIC_H 1 + +typedef __volatile int __atomic_t; + +static inline void +__atomic_inc (__atomic_t *__var) +{ + __asm__ __volatile ("lock; incl %0" : "=m" (*__var) : "m" (*__var)); +} + +static inline void +__atomic_dec (__atomic_t *__var) +{ + __asm__ __volatile ("lock; decl %0" : "=m" (*__var) : "m" (*__var)); +} + +static inline int +__atomic_dec_and_test (__atomic_t *__var) +{ + unsigned char __ret; + + __asm__ __volatile ("lock; decl %0; sete %1" + : "=m" (*__var), "=qm" (__ret) : "m" (*__var)); + return __ret != 0; +} + +/* We assume that an __atomicptr_t is only used for pointers to + word-aligned objects, and use the lowest bit for a simple lock. */ +typedef __volatile int * __atomicptr_t; + +/* Actually we don't implement that yet, and assume that we run on + something that has the i486 instruction set. */ +static inline int +__atomicptr_compare_and_swap (__atomicptr_t *__ptr, void *__oldval, + void * __newval) +{ + char __ret; + int __dummy; + + __asm__ __volatile ("lock; cmpxchgl %3, %1; sete %0" + : "=q" (__ret), "=m" (*__ptr), "=a" (__dummy) + : "r" (__newval), "m" (*__ptr), "a" (__oldval)); + return __ret; +} + +#endif -- cgit v1.2.3 From d21d530170abcaec33ba272b11cb6615eb2804de Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 21 Apr 2012 22:54:16 +0000 Subject: Do not redefine tcbhead_t in glibc * pthread/pt-internal.h (tcbhead_t): Define struct only if IS_IN_libpthread is not defined. --- pthread/pt-internal.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pthread') diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index 94bc9a7..6186c86 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -54,6 +54,7 @@ enum pthread_state # define PTHREAD_SYSDEP_MEMBERS #endif +#ifndef IS_IN_libpthread #ifdef ENABLE_TLS /* Type of the TCB. */ typedef struct @@ -63,6 +64,7 @@ typedef struct thread_t self; /* This thread's control port. */ } tcbhead_t; #endif /* ENABLE_TLS */ +#endif /* IS_IN_libpthread */ /* This structure describes a POSIX thread. */ struct __pthread -- cgit v1.2.3 From c310aa40efd3b2d954354e0550b1bbb6a8e7e349 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 21 Apr 2012 23:15:55 +0000 Subject: Add glibc build support * Makeconfig, Versions, configure.in, forward.c, libc_pthread_init.c, pthread/pthread-functions.h, shlib-versions, sysdeps/i386/Implies, sysdeps/mach/hurd/Implies, sysdeps/mach/hurd/i386/Implies: New files. * Makefile: Add glibc rules, enabled when IN_GLIBC is defined to yes, when $(..) is defined. * pthread/pt-initialize.c [IS_IN_libpthread] (pthread_functions): New variable. [IS_IN_libpthread] (__pthread_initialize): Call __libc_pthread_init. --- Makeconfig | 10 ++ Makefile | 299 +++++++++++++++++++++++++---------------- Versions | 132 ++++++++++++++++++ configure.in | 4 + forward.c | 127 +++++++++++++++++ libc_pthread_init.c | 34 +++++ pthread/pt-initialize.c | 50 +++++++ pthread/pthread-functions.h | 116 ++++++++++++++++ shlib-versions | 1 + sysdeps/i386/Implies | 1 + sysdeps/mach/hurd/Implies | 1 + sysdeps/mach/hurd/i386/Implies | 1 + 12 files changed, 662 insertions(+), 114 deletions(-) create mode 100644 Makeconfig create mode 100644 Versions create mode 100644 configure.in create mode 100644 forward.c create mode 100644 libc_pthread_init.c create mode 100644 pthread/pthread-functions.h create mode 100644 shlib-versions create mode 100644 sysdeps/i386/Implies create mode 100644 sysdeps/mach/hurd/Implies create mode 100644 sysdeps/mach/hurd/i386/Implies (limited to 'pthread') diff --git a/Makeconfig b/Makeconfig new file mode 100644 index 0000000..e7e567c --- /dev/null +++ b/Makeconfig @@ -0,0 +1,10 @@ +# Makeconfig fragment for Hurd libpthread add-on. +# This gets included at the end of the main glibc Makeconfig. + +have-thread-library = yes + +shared-thread-library = $(common-objpfx)libpthread/libpthread.so +static-thread-library = $(common-objpfx)libpthread/libpthread.a +bounded-thread-library = $(static-thread-library) + +rpath-dirs += libpthread diff --git a/Makefile b/Makefile index a1801f5..b291177 100644 --- a/Makefile +++ b/Makefile @@ -16,128 +16,147 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +ifeq ($(..),) +# non-glibc build +IN_GLIBC = no +else +# glibc build +IN_GLIBC = yes +endif + +ifeq ($(IN_GLIBC),no) dir := libpthread makemode := library +else +subdir := libpthread + +pthread-version := 0.3 + +srcdir = . +endif MICROKERNEL := mach -SYSDEPS := lockfile.c - -LCLHDRS := - -SRCS := pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \ - pt-attr-getguardsize.c pt-attr-getinheritsched.c \ - pt-attr-getschedparam.c pt-attr-getschedpolicy.c pt-attr-getscope.c \ - pt-attr-getstack.c pt-attr-getstackaddr.c pt-attr-getstacksize.c \ - pt-attr-init.c pt-attr-setdetachstate.c pt-attr-setguardsize.c \ - pt-attr-setinheritsched.c pt-attr-setschedparam.c \ - pt-attr-setschedpolicy.c pt-attr-setscope.c pt-attr-setstack.c \ - pt-attr-setstackaddr.c pt-attr-setstacksize.c \ - \ - pt-barrier-destroy.c pt-barrier-init.c pt-barrier-wait.c \ - pt-barrier.c pt-barrierattr-destroy.c pt-barrierattr-init.c \ - pt-barrierattr-getpshared.c pt-barrierattr-setpshared.c \ - \ - pt-destroy-specific.c pt-init-specific.c \ - pt-key-create.c pt-key-delete.c \ - pt-getspecific.c pt-setspecific.c \ - \ - pt-once.c \ - \ - pt-alloc.c \ - pt-create.c \ - pt-getattr.c \ - pt-equal.c \ - pt-dealloc.c \ - pt-detach.c \ - pt-exit.c \ - pt-initialize.c \ - pt-join.c \ - pt-self.c \ - pt-sigmask.c \ - pt-spin-inlines.c \ - pt-cleanup.c \ - pt-setcancelstate.c \ - pt-setcanceltype.c \ - pt-testcancel.c \ - pt-cancel.c \ - \ - pt-mutexattr.c \ - pt-mutexattr-destroy.c pt-mutexattr-init.c \ - pt-mutexattr-getprioceiling.c pt-mutexattr-getprotocol.c \ - pt-mutexattr-getpshared.c pt-mutexattr-gettype.c \ - pt-mutexattr-setprioceiling.c pt-mutexattr-setprotocol.c \ - pt-mutexattr-setpshared.c pt-mutexattr-settype.c \ - \ - pt-mutex-init.c pt-mutex-destroy.c \ - pt-mutex-lock.c pt-mutex-trylock.c pt-mutex-timedlock.c \ - pt-mutex-unlock.c \ - pt-mutex-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-destroy.c sem-getvalue.c sem-init.c sem-open.c \ - sem-post.c sem-timedwait.c sem-trywait.c sem-unlink.c \ - sem-wait.c \ - \ - cthreads-compat.c \ +SYSDEPS := lockfile + +LCLHDRS := + +libpthread-routines := pt-attr pt-attr-destroy pt-attr-getdetachstate \ + pt-attr-getguardsize pt-attr-getinheritsched \ + pt-attr-getschedparam pt-attr-getschedpolicy pt-attr-getscope \ + pt-attr-getstack pt-attr-getstackaddr pt-attr-getstacksize \ + pt-attr-init pt-attr-setdetachstate pt-attr-setguardsize \ + pt-attr-setinheritsched pt-attr-setschedparam \ + pt-attr-setschedpolicy pt-attr-setscope pt-attr-setstack \ + pt-attr-setstackaddr pt-attr-setstacksize \ + \ + pt-barrier-destroy pt-barrier-init pt-barrier-wait \ + pt-barrier pt-barrierattr-destroy pt-barrierattr-init \ + pt-barrierattr-getpshared pt-barrierattr-setpshared \ + \ + pt-destroy-specific pt-init-specific \ + pt-key-create pt-key-delete \ + pt-getspecific pt-setspecific \ + \ + pt-once \ + \ + pt-alloc \ + pt-create \ + pt-getattr \ + pt-equal \ + pt-dealloc \ + pt-detach \ + pt-exit \ + pt-initialize \ + pt-join \ + pt-self \ + pt-sigmask \ + pt-spin-inlines \ + pt-cleanup \ + pt-setcancelstate \ + pt-setcanceltype \ + pt-testcancel \ + pt-cancel \ + \ + pt-mutexattr \ + pt-mutexattr-destroy pt-mutexattr-init \ + pt-mutexattr-getprioceiling pt-mutexattr-getprotocol \ + pt-mutexattr-getpshared pt-mutexattr-gettype \ + pt-mutexattr-setprioceiling pt-mutexattr-setprotocol \ + pt-mutexattr-setpshared pt-mutexattr-settype \ + \ + pt-mutex-init pt-mutex-destroy \ + pt-mutex-lock pt-mutex-trylock pt-mutex-timedlock \ + pt-mutex-unlock \ + pt-mutex-transfer-np \ + pt-mutex-getprioceiling pt-mutex-setprioceiling \ + \ + pt-rwlock-attr \ + pt-rwlockattr-init pt-rwlockattr-destroy \ + pt-rwlockattr-getpshared pt-rwlockattr-setpshared \ + \ + pt-rwlock-init pt-rwlock-destroy \ + pt-rwlock-rdlock pt-rwlock-tryrdlock \ + pt-rwlock-trywrlock pt-rwlock-wrlock \ + pt-rwlock-timedrdlock pt-rwlock-timedwrlock \ + pt-rwlock-unlock \ + \ + pt-cond \ + pt-condattr-init pt-condattr-destroy \ + pt-condattr-getclock pt-condattr-getpshared \ + pt-condattr-setclock pt-condattr-setpshared \ + \ + pt-cond-destroy pt-cond-init \ + pt-cond-brdcast \ + pt-cond-signal \ + pt-cond-wait \ + pt-cond-timedwait \ + \ + pt-stack-alloc \ + pt-thread-alloc \ + pt-thread-dealloc \ + pt-thread-start \ + pt-thread-halt \ + pt-startup \ + \ + pt-getconcurrency pt-setconcurrency \ + \ + pt-block \ + pt-timedblock \ + pt-wakeup \ + pt-docancel \ + pt-sysdep \ + pt-setup \ + pt-machdep \ + pt-spin \ + \ + pt-sigstate-init \ + pt-sigstate-destroy \ + pt-sigstate \ + \ + pt-atfork \ + pt-kill \ + pt-getcpuclockid \ + \ + pt-getschedparam pt-setschedparam pt-setschedprio \ + pt-yield \ + \ + sem-close sem-destroy sem-getvalue sem-init sem-open \ + sem-post sem-timedwait sem-trywait sem-unlink \ + sem-wait \ + \ + cthreads-compat \ $(SYSDEPS) +ifeq ($(IN_GLIBC),no) +SRCS := $(addsuffix .c,$(libpthread-routines)) OBJS = $(addsuffix .o,$(basename $(notdir $(SRCS)))) OTHERTAGS = libname = libpthread +endif -sysdeps_headers = \ +headers := \ pthread.h \ pthread/pthread.h \ pthread/pthreadtypes.h \ @@ -161,6 +180,21 @@ sysdeps_headers = \ bits/rwlock-attr.h \ bits/semaphore.h +ifeq ($(IN_GLIBC),yes) +distribute := + +routines := forward libc_pthread_init +shared-only-routines = forward + +vpath %.c + +extra-libs := libpthread +extra-libs-others := $(extra-libs) +install-lib-ldscripts := libpthread.so + +include ../Makeconfig +endif + SYSDEP_PATH = $(srcdir)/sysdeps/$(MICROKERNEL)/hurd/ia32 \ $(srcdir)/sysdeps/$(MICROKERNEL)/ia32 \ $(srcdir)/sysdeps/ia32 \ @@ -174,22 +208,41 @@ SYSDEP_PATH = $(srcdir)/sysdeps/$(MICROKERNEL)/hurd/ia32 \ VPATH += $(SYSDEP_PATH) +ifeq ($(IN_GLIBC),no) HURDLIBS = ihash +else +LDLIBS-pthread.so = -lihash +endif +ifeq ($(IN_GLIBC),no) installhdrs := installhdrsubdir := . include ../Makeconf +endif CPPFLAGS += \ -DENABLE_TLS \ $(addprefix -I, $(SYSDEP_PATH)) \ - -imacros $(srcdir)/include/libc-symbols.h \ -imacros $(srcdir)/not-in-libc.h +ifeq ($(IN_GLIBC),no) +CPPFLAGS += \ + -imacros $(srcdir)/include/libc-symbols.h +else +CPPFLAGS += \ + -imacros libc-symbols.h +endif + +ifeq ($(IN_GLIBC),yes) +CFLAGS-lockfile.c = -D_IO_MTSAFE_IO +all: # Make this the default target; it will be defined in Rules. +endif + +ifeq ($(IN_GLIBC),no) install: install-headers $(libdir)/libpthread2.a $(libdir)/libpthread2_pic.a -install-headers: $(addprefix $(includedir)/, $(sysdeps_headers)) +install-headers: $(addprefix $(includedir)/, $(headers)) # XXX: If $(libdir)/libpthread2.a is installed and # $(libdir)/libpthread is not, we can have some issues. @@ -206,10 +259,27 @@ $(libdir)/libpthread2.a: $(libdir)/libpthread.a $(libdir)/libpthread2_pic.a: $(libdir)/libpthread_pic.a mv $< $@ $(INSTALL_DATA) $(srcdir)/libpthread_pic.a $< +endif + +ifeq ($(IN_GLIBC),yes) +libc-link.so = $(common-objpfx)libc.so + +include ../Rules + +# Depend on libc.so so a DT_NEEDED is generated in the shared objects. +# This ensures they will load libc.so for needed symbols if loaded by +# a statically-linked program that hasn't already loaded it. +# Depend on ld.so too to get proper versions of ld.so symbols. +$(objpfx)libpthread.so: $(libc-link.so) $(common-objpfx)libc_nonshared.a \ + $(if $(filter yes,$(elf)), $(elfobjdir)/ld.so) \ + $(common-objpfx)/mach/libmachuser.so \ + $(common-objpfx)/hurd/libhurduser.so +endif -.PHONY: $(addprefix $(includedir)/, $(sysdeps_headers)) +ifeq ($(IN_GLIBC),no) +.PHONY: $(addprefix $(includedir)/, $(headers)) -$(addprefix $(includedir)/, $(sysdeps_headers)): +$(addprefix $(includedir)/, $(headers)): @set -e; \ t="$@"; \ t=$${t#$(includedir)/}; \ @@ -247,3 +317,4 @@ maintainer.; \ # $(libname).so.$(hurd-version): $(srcdir)/$(libname).map # # endif +endif diff --git a/Versions b/Versions new file mode 100644 index 0000000..77eb870 --- /dev/null +++ b/Versions @@ -0,0 +1,132 @@ +libc { + GLIBC_2.13 { + pthread_attr_destroy; pthread_attr_getdetachstate; + pthread_attr_getinheritsched; pthread_attr_getschedparam; + pthread_attr_getschedpolicy; pthread_attr_getscope; pthread_attr_init; + pthread_attr_setdetachstate; pthread_attr_setinheritsched; + pthread_attr_setschedparam; pthread_attr_setschedpolicy; + pthread_attr_setscope; + pthread_condattr_destroy; pthread_condattr_init; + pthread_cond_broadcast; pthread_cond_destroy; + pthread_cond_init; pthread_cond_signal; pthread_cond_wait; + pthread_cond_timedwait; + pthread_equal; + pthread_exit; pthread_getschedparam; pthread_setschedparam; + pthread_mutex_destroy; pthread_mutex_init; + pthread_mutex_lock; pthread_mutex_trylock; pthread_mutex_unlock; + pthread_self; pthread_setcancelstate; pthread_setcanceltype; + __pthread_get_cleanup_stack; + GLIBC_PRIVATE { + __libc_pthread_init; + } +} + +libpthread { + GLIBC_2.12 { + __pthread_errorcheck_mutexattr; __pthread_recursive_mutexattr; + + _IO_flockfile; _IO_ftrylockfile; _IO_funlockfile; + + __pthread_get_cleanup_stack; + + __pthread_mutex_transfer_np; + + _pthread_mutex_destroy; _pthread_mutex_init; + _pthread_mutex_lock; _pthread_mutex_trylock; _pthread_mutex_unlock; + _pthread_rwlock_destroy; _pthread_rwlock_init; + + _cthread_init_routine; + + cthread_detach; + cthread_fork; + cthread_keycreate; + cthread_getspecific; + __libc_getspecific; + cthread_setspecific; + __mutex_lock_solid; + __mutex_unlock_solid; + _cthreads_flockfile; + _cthreads_ftrylockfile; + _cthreads_funlockfile; + + flockfile; ftrylockfile; funlockfile; + + pthread_atfork; + + pthread_attr_destroy; pthread_attr_getdetachstate; + pthread_attr_getguardsize; pthread_attr_getinheritsched; + pthread_attr_getschedparam; pthread_attr_getschedpolicy; + pthread_attr_getscope; pthread_attr_getstack; pthread_attr_getstackaddr; + pthread_attr_getstacksize; pthread_attr_init; pthread_attr_setdetachstate; + pthread_attr_setguardsize; pthread_attr_setinheritsched; + pthread_attr_setschedparam; pthread_attr_setschedpolicy; + pthread_attr_setscope; pthread_attr_setstack; pthread_attr_setstackaddr; + pthread_attr_setstacksize; + + pthread_barrier_destroy; pthread_barrier_init; pthread_barrier_wait; + pthread_barrierattr_destroy; pthread_barrierattr_getpshared; + pthread_barrierattr_init; pthread_barrierattr_setpshared; + + pthread_cancel; + + pthread_cond_broadcast; pthread_cond_destroy; pthread_cond_init; + pthread_cond_signal; pthread_cond_timedwait; pthread_cond_wait; + + pthread_condattr_destroy; pthread_condattr_getclock; + pthread_condattr_getpshared; pthread_condattr_init; + pthread_condattr_setclock; pthread_condattr_setpshared; + + pthread_create; pthread_detach; pthread_equal; pthread_exit; + + pthread_getattr_np; + + pthread_getconcurrency; pthread_getcpuclockid; + pthread_getschedparam; pthread_getspecific; + + pthread_join; + + pthread_key_create; pthread_key_delete; + + pthread_kill; + + pthread_mutex_destroy; pthread_mutex_getprioceiling; + pthread_mutex_init; pthread_mutex_lock; pthread_mutex_setprioceiling; + pthread_mutex_timedlock; pthread_mutex_transfer_np; + pthread_mutex_trylock; pthread_mutex_unlock; + + pthread_mutexattr_destroy; pthread_mutexattr_getprioceiling; + pthread_mutexattr_getprotocol; pthread_mutexattr_getpshared; + pthread_mutexattr_gettype; pthread_mutexattr_init; + pthread_mutexattr_setprioceiling; pthread_mutexattr_setprotocol; + pthread_mutexattr_setpshared; pthread_mutexattr_settype; + + pthread_once; + + pthread_rwlock_destroy; pthread_rwlock_init; pthread_rwlock_rdlock; + pthread_rwlock_timedrdlock; pthread_rwlock_timedwrlock; + pthread_rwlock_tryrdlock; pthread_rwlock_trywrlock; + pthread_rwlock_unlock; pthread_rwlock_wrlock; + + pthread_rwlockattr_destroy; pthread_rwlockattr_getpshared; + pthread_rwlockattr_init; pthread_rwlockattr_setpshared; + + pthread_self; + + pthread_setcancelstate; pthread_setcanceltype; + pthread_setconcurrency; pthread_setschedparam; + pthread_setschedprio; pthread_setspecific; + + pthread_sigmask; + pthread_testcancel; + pthread_yield; + + sem_close; sem_destroy; sem_getvalue; sem_init; sem_open; sem_post; + sem_timedwait; sem_trywait; sem_unlink; sem_wait; + + pthread_spin_destroy; pthread_spin_init; pthread_spin_lock; + pthread_spin_trylock; pthread_spin_unlock; + __pthread_spin_destroy; __pthread_spin_init; + __pthread_spin_lock; __pthread_spin_trylock; __pthread_spin_unlock; + _pthread_spin_lock; + } +} diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..4e140b1 --- /dev/null +++ b/configure.in @@ -0,0 +1,4 @@ +GLIBC_PROVIDES + +libc_add_on_canonical=libpthread +libc_add_on_subdirs=. diff --git a/forward.c b/forward.c new file mode 100644 index 0000000..c07d7c0 --- /dev/null +++ b/forward.c @@ -0,0 +1,127 @@ +/* Copyright (C) 2002, 2003, 2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2002. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include + +/* Pointers to the libc functions. */ +struct pthread_functions __libc_pthread_functions attribute_hidden; + + +# define FORWARD2(name, rettype, decl, params, defaction) \ +rettype \ +name decl \ +{ \ + if (__libc_pthread_functions.ptr_##name == NULL) \ + defaction; \ + \ + return __libc_pthread_functions.ptr_##name params; \ +} + +# define FORWARD(name, decl, params, defretval) \ + FORWARD2 (name, int, decl, params, return defretval) + +FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0) + +FORWARD (pthread_attr_init, (pthread_attr_t *attr), (attr), 0) + +FORWARD (pthread_attr_getdetachstate, + (const pthread_attr_t *attr, int *detachstate), (attr, detachstate), + 0) +FORWARD (pthread_attr_setdetachstate, (pthread_attr_t *attr, int detachstate), + (attr, detachstate), 0) + +FORWARD (pthread_attr_getinheritsched, + (const pthread_attr_t *attr, int *inherit), (attr, inherit), 0) +FORWARD (pthread_attr_setinheritsched, (pthread_attr_t *attr, int inherit), + (attr, inherit), 0) + +FORWARD (pthread_attr_getschedparam, + (const pthread_attr_t *attr, struct sched_param *param), + (attr, param), 0) +FORWARD (pthread_attr_setschedparam, + (pthread_attr_t *attr, const struct sched_param *param), + (attr, param), 0) + +FORWARD (pthread_attr_getschedpolicy, + (const pthread_attr_t *attr, int *policy), (attr, policy), 0) +FORWARD (pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy), + (attr, policy), 0) + +FORWARD (pthread_attr_getscope, + (const pthread_attr_t *attr, int *scope), (attr, scope), 0) +FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope), + (attr, scope), 0) + + +FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0) +FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0) + + +FORWARD (pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0) +FORWARD (pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0) +FORWARD (pthread_cond_init, + (pthread_cond_t *cond, const pthread_condattr_t *cond_attr), + (cond, cond_attr), 0) +FORWARD (pthread_cond_signal, (pthread_cond_t *cond), (cond), 0) +FORWARD (pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex), + (cond, mutex), 0) +FORWARD (pthread_cond_timedwait, + (pthread_cond_t *cond, pthread_mutex_t *mutex, + const struct timespec *abstime), (cond, mutex, abstime), 0) + +FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2), + (thread1, thread2), 1) + + +/* Use an alias to avoid warning, as pthread_exit is declared noreturn. */ +FORWARD2 (pthread_exit, void, (void *retval), (retval), exit (EXIT_SUCCESS)) + + +FORWARD (pthread_getschedparam, + (pthread_t target_thread, int *policy, struct sched_param *param), + (target_thread, policy, param), 0) +FORWARD (pthread_setschedparam, + (pthread_t target_thread, int policy, + const struct sched_param *param), (target_thread, policy, param), 0) + + +FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0) + +FORWARD (pthread_mutex_init, + (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr), + (mutex, mutexattr), 0) + +FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0) + +FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0) + + +FORWARD2 (pthread_self, pthread_t, (void), (), return 0) + + +FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate), + 0) + +FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0) + +struct __pthread_cancelation_handler *dummy_list; +FORWARD2 (__pthread_get_cleanup_stack, struct __pthread_cancelation_handler **, (void), (), return &dummy_list); diff --git a/libc_pthread_init.c b/libc_pthread_init.c new file mode 100644 index 0000000..e6c8b9f --- /dev/null +++ b/libc_pthread_init.c @@ -0,0 +1,34 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2002. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +void +__libc_pthread_init (functions) + const struct pthread_functions *functions; +{ +#ifdef SHARED + /* We copy the content of the variable pointed to by the FUNCTIONS + parameter to one in libc.so since this means access to the array + can be done with one memory access instead of two. */ + memcpy (&__libc_pthread_functions, functions, + sizeof (__libc_pthread_functions)); +#endif +} diff --git a/pthread/pt-initialize.c b/pthread/pt-initialize.c index cf32b8b..f0ef8f8 100644 --- a/pthread/pt-initialize.c +++ b/pthread/pt-initialize.c @@ -23,11 +23,61 @@ #include #include +#include +#include + DEFINE_HOOK (__pthread_init, (void)); +#ifdef IS_IN_libpthread +#ifdef SHARED +static const struct pthread_functions pthread_functions = + { + .ptr_pthread_attr_destroy = __pthread_attr_destroy, + .ptr_pthread_attr_init = __pthread_attr_init, + .ptr_pthread_attr_getdetachstate = __pthread_attr_getdetachstate, + .ptr_pthread_attr_setdetachstate = __pthread_attr_setdetachstate, + .ptr_pthread_attr_getinheritsched = __pthread_attr_getinheritsched, + .ptr_pthread_attr_setinheritsched = __pthread_attr_setinheritsched, + .ptr_pthread_attr_getschedparam = __pthread_attr_getschedparam, + .ptr_pthread_attr_setschedparam = __pthread_attr_setschedparam, + .ptr_pthread_attr_getschedpolicy = __pthread_attr_getschedpolicy, + .ptr_pthread_attr_setschedpolicy = __pthread_attr_setschedpolicy, + .ptr_pthread_attr_getscope = __pthread_attr_getscope, + .ptr_pthread_attr_setscope = __pthread_attr_setscope, + .ptr_pthread_condattr_destroy = __pthread_condattr_destroy, + .ptr_pthread_condattr_init = __pthread_condattr_init, + .ptr_pthread_cond_broadcast = __pthread_cond_broadcast, + .ptr_pthread_cond_destroy = __pthread_cond_destroy, + .ptr_pthread_cond_init = __pthread_cond_init, + .ptr_pthread_cond_signal = __pthread_cond_signal, + .ptr_pthread_cond_wait = __pthread_cond_wait, + .ptr_pthread_cond_timedwait = __pthread_cond_timedwait, + .ptr_pthread_equal = __pthread_equal, + .ptr_pthread_exit = __pthread_exit, + .ptr_pthread_getschedparam = __pthread_getschedparam, + .ptr_pthread_setschedparam = __pthread_setschedparam, + .ptr_pthread_mutex_destroy = _pthread_mutex_destroy, + .ptr_pthread_mutex_init = _pthread_mutex_init, + .ptr_pthread_mutex_lock = __pthread_mutex_lock, + .ptr_pthread_mutex_trylock = __pthread_mutex_trylock, + .ptr_pthread_mutex_unlock = __pthread_mutex_unlock, + .ptr_pthread_self = __pthread_self, + .ptr_pthread_setcancelstate = __pthread_setcancelstate, + .ptr_pthread_setcanceltype = __pthread_setcanceltype, + .ptr___pthread_get_cleanup_stack = __pthread_get_cleanup_stack, + }; +# define ptr_pthread_functions &pthread_functions +#else +# define ptr_pthread_functions NULL +#endif +#endif /* IS_IN_libpthread */ + /* Initialize the pthreads library. */ void __pthread_initialize (void) { +#ifdef IS_IN_libpthread + __libc_pthread_init(ptr_pthread_functions); +#endif RUN_HOOK (__pthread_init, ()); } diff --git a/pthread/pthread-functions.h b/pthread/pthread-functions.h new file mode 100644 index 0000000..c0ba858 --- /dev/null +++ b/pthread/pthread-functions.h @@ -0,0 +1,116 @@ +/* Copyright (C) 2003, 2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _PTHREAD_FUNCTIONS_H +#define _PTHREAD_FUNCTIONS_H 1 + +#include + +int __pthread_attr_destroy (pthread_attr_t *); +int __pthread_attr_init (pthread_attr_t *); +int __pthread_attr_getdetachstate (const pthread_attr_t *, int *); +int __pthread_attr_setdetachstate (pthread_attr_t *, int); +int __pthread_attr_getinheritsched (const pthread_attr_t *, int *); +int __pthread_attr_setinheritsched (pthread_attr_t *, int); +int __pthread_attr_getschedparam (const pthread_attr_t *, + struct sched_param *); +int __pthread_attr_setschedparam (pthread_attr_t *, + const struct sched_param *); +int __pthread_attr_getschedpolicy (const pthread_attr_t *, int *); +int __pthread_attr_setschedpolicy (pthread_attr_t *, int); +int __pthread_attr_getscope (const pthread_attr_t *, int *); +int __pthread_attr_setscope (pthread_attr_t *, int); +int __pthread_condattr_destroy (pthread_condattr_t *); +int __pthread_condattr_init (pthread_condattr_t *); +int __pthread_cond_broadcast (pthread_cond_t *); +int __pthread_cond_destroy (pthread_cond_t *); +int __pthread_cond_init (pthread_cond_t *, + const pthread_condattr_t *); +int __pthread_cond_signal (pthread_cond_t *); +int __pthread_cond_wait (pthread_cond_t *, pthread_mutex_t *); +int __pthread_cond_timedwait (pthread_cond_t *, pthread_mutex_t *, + const struct timespec *); +int __pthread_equal (pthread_t, pthread_t); +void __pthread_exit (void *); +int __pthread_getschedparam (pthread_t, int *, struct sched_param *); +int __pthread_setschedparam (pthread_t, int, + const struct sched_param *); +int _pthread_mutex_destroy (pthread_mutex_t *); +int _pthread_mutex_init (pthread_mutex_t *, + const pthread_mutexattr_t *); +int __pthread_mutex_lock (pthread_mutex_t *); +int __pthread_mutex_trylock (pthread_mutex_t *); +int __pthread_mutex_unlock (pthread_mutex_t *); +pthread_t __pthread_self (void); +int __pthread_setcancelstate (int, int *); +int __pthread_setcanceltype (int, int *); +struct __pthread_cancelation_handler **__pthread_get_cleanup_stack (void); + +/* Data type shared with libc. The libc uses it to pass on calls to + the thread functions. Wine pokes directly into this structure, + so if possible avoid breaking it and append new hooks to the end. */ +struct pthread_functions +{ + int (*ptr_pthread_attr_destroy) (pthread_attr_t *); + int (*ptr_pthread_attr_init) (pthread_attr_t *); + int (*ptr_pthread_attr_getdetachstate) (const pthread_attr_t *, int *); + int (*ptr_pthread_attr_setdetachstate) (pthread_attr_t *, int); + int (*ptr_pthread_attr_getinheritsched) (const pthread_attr_t *, int *); + int (*ptr_pthread_attr_setinheritsched) (pthread_attr_t *, int); + int (*ptr_pthread_attr_getschedparam) (const pthread_attr_t *, + struct sched_param *); + int (*ptr_pthread_attr_setschedparam) (pthread_attr_t *, + const struct sched_param *); + int (*ptr_pthread_attr_getschedpolicy) (const pthread_attr_t *, int *); + int (*ptr_pthread_attr_setschedpolicy) (pthread_attr_t *, int); + int (*ptr_pthread_attr_getscope) (const pthread_attr_t *, int *); + int (*ptr_pthread_attr_setscope) (pthread_attr_t *, int); + int (*ptr_pthread_condattr_destroy) (pthread_condattr_t *); + int (*ptr_pthread_condattr_init) (pthread_condattr_t *); + int (*ptr_pthread_cond_broadcast) (pthread_cond_t *); + int (*ptr_pthread_cond_destroy) (pthread_cond_t *); + int (*ptr_pthread_cond_init) (pthread_cond_t *, + const pthread_condattr_t *); + int (*ptr_pthread_cond_signal) (pthread_cond_t *); + int (*ptr_pthread_cond_wait) (pthread_cond_t *, pthread_mutex_t *); + int (*ptr_pthread_cond_timedwait) (pthread_cond_t *, pthread_mutex_t *, + const struct timespec *); + int (*ptr_pthread_equal) (pthread_t, pthread_t); + void (*ptr_pthread_exit) (void *); + int (*ptr_pthread_getschedparam) (pthread_t, int *, struct sched_param *); + int (*ptr_pthread_setschedparam) (pthread_t, int, + const struct sched_param *); + int (*ptr_pthread_mutex_destroy) (pthread_mutex_t *); + int (*ptr_pthread_mutex_init) (pthread_mutex_t *, + const pthread_mutexattr_t *); + int (*ptr_pthread_mutex_lock) (pthread_mutex_t *); + int (*ptr_pthread_mutex_trylock) (pthread_mutex_t *); + int (*ptr_pthread_mutex_unlock) (pthread_mutex_t *); + pthread_t (*ptr_pthread_self) (void); + int (*ptr_pthread_setcancelstate) (int, int *); + int (*ptr_pthread_setcanceltype) (int, int *); + struct __pthread_cancelation_handler **(*ptr___pthread_get_cleanup_stack) (void); +}; + +/* Variable in libc.so. */ +extern struct pthread_functions __libc_pthread_functions attribute_hidden; + +void __libc_pthread_init (const struct pthread_functions *functions); + +#endif /* pthread-functions.h */ diff --git a/shlib-versions b/shlib-versions new file mode 100644 index 0000000..b320be0 --- /dev/null +++ b/shlib-versions @@ -0,0 +1 @@ +.*-.*-.* libpthread=0.3 diff --git a/sysdeps/i386/Implies b/sysdeps/i386/Implies new file mode 100644 index 0000000..d799fa1 --- /dev/null +++ b/sysdeps/i386/Implies @@ -0,0 +1 @@ +ia32 diff --git a/sysdeps/mach/hurd/Implies b/sysdeps/mach/hurd/Implies new file mode 100644 index 0000000..16b8348 --- /dev/null +++ b/sysdeps/mach/hurd/Implies @@ -0,0 +1 @@ +hurd diff --git a/sysdeps/mach/hurd/i386/Implies b/sysdeps/mach/hurd/i386/Implies new file mode 100644 index 0000000..d799fa1 --- /dev/null +++ b/sysdeps/mach/hurd/i386/Implies @@ -0,0 +1 @@ +ia32 -- cgit v1.2.3 From dbaf5693972d2cbfad0ad48b966e5693b770127e Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sun, 22 Apr 2012 00:22:47 +0200 Subject: __pthread_timedblock: add an argument for the clock id To make `__pthread_timedblock' properly measure time using the right clock, add a new argument representing the clock to use. * pthread/pt-internal.h (__pthread_timedblock): New argument CLOCK_ID. * sysdeps/l4/pt-timedblock.c (__pthread_timedblock): Likewise. * sysdeps/mach/pt-timedblock.c (__pthread_timedblock): Likewise. * sysdeps/generic/pt-cond-timedwait.c (__pthread_cond_timedwait_internal): Pass the clock of the `pthread_cond' to `__pthread_timedblock'. * sysdeps/generic/pt-mutex-timedlock.c (__pthread_mutex_timedlock_internal): Pass CLOCK_REALTIME to `__pthread_timedblock'. * sysdeps/generic/pt-rwlock-timedrdlock.c (__pthread_rwlock_timedrdlock_internal): Likewise. * sysdeps/generic/pt-rwlock-timedwrlock.c (__pthread_rwlock_timedwrlock_internal): Likewise. * sysdeps/generic/sem-timedwait.c (__sem_timedwait_internal): Likewise. --- pthread/pt-internal.h | 3 ++- sysdeps/generic/pt-cond-timedwait.c | 5 ++++- sysdeps/generic/pt-mutex-timedlock.c | 2 +- sysdeps/generic/pt-rwlock-timedrdlock.c | 2 +- sysdeps/generic/pt-rwlock-timedwrlock.c | 2 +- sysdeps/generic/sem-timedwait.c | 2 +- sysdeps/l4/pt-timedblock.c | 3 ++- sysdeps/mach/pt-timedblock.c | 3 ++- 8 files changed, 14 insertions(+), 8 deletions(-) (limited to 'pthread') diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index 6186c86..a1e90aa 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -254,7 +254,8 @@ extern void __pthread_block (struct __pthread *thread); /* Block THREAD until *ABSTIME is reached. */ extern error_t __pthread_timedblock (struct __pthread *__restrict thread, - const struct timespec *__restrict abstime); + const struct timespec *__restrict abstime, + clockid_t clock_id); /* Wakeup THREAD. */ extern void __pthread_wakeup (struct __pthread *thread); diff --git a/sysdeps/generic/pt-cond-timedwait.c b/sysdeps/generic/pt-cond-timedwait.c index 483f277..56eb1ec 100644 --- a/sysdeps/generic/pt-cond-timedwait.c +++ b/sysdeps/generic/pt-cond-timedwait.c @@ -46,6 +46,7 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond, { error_t err; int canceltype; + clockid_t clock_id = __pthread_default_condattr.clock; void cleanup (void *arg) { @@ -68,6 +69,8 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond, /* Add ourselves to the list of waiters. */ __pthread_spin_lock (&cond->__lock); __pthread_enqueue (&cond->__queue, self); + if (cond->__attr) + clock_id = cond->__attr->clock; __pthread_spin_unlock (&cond->__lock); __pthread_mutex_unlock (mutex); @@ -79,7 +82,7 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond, if (abstime) { - err = __pthread_timedblock (self, abstime); + err = __pthread_timedblock (self, abstime, clock_id); if (err) /* We timed out. We may need to disconnect ourself from the waiter queue. diff --git a/sysdeps/generic/pt-mutex-timedlock.c b/sysdeps/generic/pt-mutex-timedlock.c index 883e50a..48bffaf 100644 --- a/sysdeps/generic/pt-mutex-timedlock.c +++ b/sysdeps/generic/pt-mutex-timedlock.c @@ -130,7 +130,7 @@ __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex, { error_t err; - err = __pthread_timedblock (self, abstime); + err = __pthread_timedblock (self, abstime, CLOCK_REALTIME); if (err) /* We timed out. We may need to disconnect ourself from the waiter queue. diff --git a/sysdeps/generic/pt-rwlock-timedrdlock.c b/sysdeps/generic/pt-rwlock-timedrdlock.c index ba610fa..a110213 100644 --- a/sysdeps/generic/pt-rwlock-timedrdlock.c +++ b/sysdeps/generic/pt-rwlock-timedrdlock.c @@ -73,7 +73,7 @@ __pthread_rwlock_timedrdlock_internal (struct __pthread_rwlock *rwlock, { error_t err; - err = __pthread_timedblock (self, abstime); + err = __pthread_timedblock (self, abstime, CLOCK_REALTIME); if (err) /* We timed out. We may need to disconnect ourself from the waiter queue. diff --git a/sysdeps/generic/pt-rwlock-timedwrlock.c b/sysdeps/generic/pt-rwlock-timedwrlock.c index 04eab51..a5cc579 100644 --- a/sysdeps/generic/pt-rwlock-timedwrlock.c +++ b/sysdeps/generic/pt-rwlock-timedwrlock.c @@ -59,7 +59,7 @@ __pthread_rwlock_timedwrlock_internal (struct __pthread_rwlock *rwlock, { error_t err; - err = __pthread_timedblock (self, abstime); + err = __pthread_timedblock (self, abstime, CLOCK_REALTIME); if (err) /* We timed out. We may need to disconnect ourself from the waiter queue. diff --git a/sysdeps/generic/sem-timedwait.c b/sysdeps/generic/sem-timedwait.c index e34539a..94e6dee 100644 --- a/sysdeps/generic/sem-timedwait.c +++ b/sysdeps/generic/sem-timedwait.c @@ -55,7 +55,7 @@ __sem_timedwait_internal (sem_t *restrict sem, { error_t err; - err = __pthread_timedblock (self, timeout); + err = __pthread_timedblock (self, timeout, CLOCK_REALTIME); if (err) /* We timed out. We may need to disconnect ourself from the waiter queue. diff --git a/sysdeps/l4/pt-timedblock.c b/sysdeps/l4/pt-timedblock.c index ce7972b..951644f 100644 --- a/sysdeps/l4/pt-timedblock.c +++ b/sysdeps/l4/pt-timedblock.c @@ -27,7 +27,8 @@ /* Block THREAD. */ error_t __pthread_timedblock (struct __pthread *thread, - const struct timespec *abstime) + const struct timespec *abstime, + clockid_t clock_id) { #warning Need gettimeofday to implement properly. __pthread_block (thread); diff --git a/sysdeps/mach/pt-timedblock.c b/sysdeps/mach/pt-timedblock.c index 6f54726..88beaa2 100644 --- a/sysdeps/mach/pt-timedblock.c +++ b/sysdeps/mach/pt-timedblock.c @@ -30,7 +30,8 @@ /* Block THREAD. */ error_t __pthread_timedblock (struct __pthread *thread, - const struct timespec *abstime) + const struct timespec *abstime, + clockid_t clock_id) { error_t err; mach_msg_header_t msg; -- cgit v1.2.3 From 71dcdb6d0189761ecc27691932502eacdf7e6b2c Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 23 Apr 2012 18:00:21 +0000 Subject: Rename __pthread_initialize into __pthread_init The former conflicts with usage in glibc. * pthread/pt-initialize.c (__pthread_initialize): Rename into __pthread_init. * pthread/pt-internal.h (__pthread_initialize): Likewise. * sysdeps/l4/hurd/pt-sysdep.c (init_routine): Likewise. * sysdeps/mach/hurd/pt-sysdep.c (init_routine): Likewise. --- pthread/pt-initialize.c | 2 +- pthread/pt-internal.h | 2 +- sysdeps/l4/hurd/pt-sysdep.c | 2 +- sysdeps/mach/hurd/pt-sysdep.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'pthread') diff --git a/pthread/pt-initialize.c b/pthread/pt-initialize.c index f0ef8f8..39f1aed 100644 --- a/pthread/pt-initialize.c +++ b/pthread/pt-initialize.c @@ -74,7 +74,7 @@ static const struct pthread_functions pthread_functions = /* Initialize the pthreads library. */ void -__pthread_initialize (void) +__pthread_init (void) { #ifdef IS_IN_libpthread __libc_pthread_init(ptr_pthread_functions); diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index a1e90aa..a1da377 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -188,7 +188,7 @@ extern struct __pthread *_pthread_self (void); /* Initialize the pthreads library. */ -extern void __pthread_initialize (void); +extern void __pthread_init (void); /* Internal version of pthread_create. Rather than return the new tid, we return the whole __pthread structure in *PTHREAD. */ diff --git a/sysdeps/l4/hurd/pt-sysdep.c b/sysdeps/l4/hurd/pt-sysdep.c index c23364c..1df6c2e 100644 --- a/sysdeps/l4/hurd/pt-sysdep.c +++ b/sysdeps/l4/hurd/pt-sysdep.c @@ -45,7 +45,7 @@ static void init_routine (void (*entry) (void *), void *arg) { /* Initialize the library. */ - __pthread_initialize (); + __pthread_init(); struct __pthread *thread; int err; diff --git a/sysdeps/mach/hurd/pt-sysdep.c b/sysdeps/mach/hurd/pt-sysdep.c index 5e07006..95a4d36 100644 --- a/sysdeps/mach/hurd/pt-sysdep.c +++ b/sysdeps/mach/hurd/pt-sysdep.c @@ -45,7 +45,7 @@ init_routine (void) int err; /* Initialize the library. */ - __pthread_initialize (); + __pthread_init (); /* Create the pthread structure for the main thread (i.e. us). */ err = __pthread_create_internal (&thread, 0, 0, 0); -- cgit v1.2.3 From e84c82a43e671c7506401936ac097b55d0fb47bf Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 27 Apr 2012 01:28:16 +0000 Subject: Always pass the pthread_functions structure * pthread/pt-initialize.c (pthread_functions): Always define. (__pthread_init): Always pass address of pthread_functions. --- pthread/pt-initialize.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'pthread') diff --git a/pthread/pt-initialize.c b/pthread/pt-initialize.c index 39f1aed..831a63d 100644 --- a/pthread/pt-initialize.c +++ b/pthread/pt-initialize.c @@ -29,7 +29,6 @@ DEFINE_HOOK (__pthread_init, (void)); #ifdef IS_IN_libpthread -#ifdef SHARED static const struct pthread_functions pthread_functions = { .ptr_pthread_attr_destroy = __pthread_attr_destroy, @@ -66,10 +65,6 @@ static const struct pthread_functions pthread_functions = .ptr_pthread_setcanceltype = __pthread_setcanceltype, .ptr___pthread_get_cleanup_stack = __pthread_get_cleanup_stack, }; -# define ptr_pthread_functions &pthread_functions -#else -# define ptr_pthread_functions NULL -#endif #endif /* IS_IN_libpthread */ /* Initialize the pthreads library. */ @@ -77,7 +72,7 @@ void __pthread_init (void) { #ifdef IS_IN_libpthread - __libc_pthread_init(ptr_pthread_functions); + __libc_pthread_init(&pthread_functions); #endif RUN_HOOK (__pthread_init, ()); } -- cgit v1.2.3 From 25260994c812050a5d7addf125cdc90c911ca5c1 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 27 Apr 2012 01:32:54 +0000 Subject: Store self in __thread variable instead of threadvar * sysdeps/mach/hurd/pt-sysdep.h (_HURD_THREADVAR_THREAD): Remove macro. (___pthread_self): Declare new __thread variable. (_pthread_self): Take self pointer from ___pthread_self instead of threadvar. * sysdeps/mach/hurd/pt-sysdep.c (___pthread_self): Define new __thread variable. (init_routine): Set ___pthread_self to initial thread structure. * pthread/pt-internal.h (__pthread_setup): Add `self' parameter to `entry_point' parameter. * pthread/pt-create.c (entry_point): Add `self' parameter. Store it in ___pthread_self. * sysdeps/l4/hurd/ia32/pt-setup.c (stack_setup): Add `self parameter to `entry_point' parameter. Pass it the `thread' parameter. (__pthread_setup): Likewise. * sysdeps/l4/hurd/powerpc/pt-setup.c (struct start_info): Add `self' field. (first_entry_1): Pass `self' parameter. (stack_setup): Add `self' parameter to `entry_point' parameter, pass it the `thread' parameter. (__pthread_setup): Likewise. * sysdeps/mach/hurd/ia32/pt-setup.c (stack_setup): Pass `thread' parameter to the start routine. (stack_setup): Add `self' parameter to `entry_point' paramter. --- pthread/pt-create.c | 6 +++++- pthread/pt-internal.h | 3 ++- sysdeps/l4/hurd/ia32/pt-setup.c | 5 +++-- sysdeps/l4/hurd/powerpc/pt-setup.c | 7 +++++-- sysdeps/mach/hurd/ia32/pt-setup.c | 12 +++++------- sysdeps/mach/hurd/pt-sysdep.c | 5 +++-- sysdeps/mach/hurd/pt-sysdep.h | 6 ++---- 7 files changed, 25 insertions(+), 19 deletions(-) (limited to 'pthread') diff --git a/pthread/pt-create.c b/pthread/pt-create.c index ca6b66c..4d81a95 100644 --- a/pthread/pt-create.c +++ b/pthread/pt-create.c @@ -38,8 +38,12 @@ __atomic_t __pthread_total; /* The entry-point for new threads. */ static void -entry_point (void *(*start_routine)(void *), void *arg) +entry_point (struct __pthread *self, void *(*start_routine)(void *), void *arg) { +#ifdef ENABLE_TLS + ___pthread_self = self; +#endif + #ifdef HAVE_USELOCALE /* A fresh thread needs to be bound to the global locale. */ uselocale (LC_GLOBAL_LOCALE); diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index a1da377..f5766e9 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -217,7 +217,8 @@ extern void __pthread_stack_dealloc (void *stackaddr, size_t stacksize); /* Setup thread THREAD's context. */ extern int __pthread_setup (struct __pthread *__restrict thread, - void (*entry_point)(void *(*)(void *), + void (*entry_point)(struct __pthread *, + void *(*)(void *), void *), void *(*start_routine)(void *), void *__restrict arg); diff --git a/sysdeps/l4/hurd/ia32/pt-setup.c b/sysdeps/l4/hurd/ia32/pt-setup.c index 579905c..de7359c 100644 --- a/sysdeps/l4/hurd/ia32/pt-setup.c +++ b/sysdeps/l4/hurd/ia32/pt-setup.c @@ -65,7 +65,7 @@ __pthread_entry_point:\n\ static void * stack_setup (struct __pthread *thread, void *(*start_routine)(void *), void *arg, - void (*entry_point)(void *(*)(void *), void *)) + void (*entry_point)(struct __pthread *, void *(*)(void *), void *)) { uintptr_t *top; @@ -80,6 +80,7 @@ stack_setup (struct __pthread *thread, /* Set up call frame. */ *--top = (uintptr_t) arg; /* Argument to START_ROUTINE. */ *--top = (uintptr_t) start_routine; + *--top = (uintptr_t) thread; *--top = 0; /* Fake return address. */ *--top = (uintptr_t) entry_point; } @@ -89,7 +90,7 @@ stack_setup (struct __pthread *thread, int __pthread_setup (struct __pthread *thread, - void (*entry_point)(void *(*)(void *), void *), + void (*entry_point)(struct __pthread *, void *(*)(void *), void *), void *(*start_routine)(void *), void *arg) { thread->mcontext.pc = (void *) &_pthread_entry_point; diff --git a/sysdeps/l4/hurd/powerpc/pt-setup.c b/sysdeps/l4/hurd/powerpc/pt-setup.c index d3cf4ec..d309216 100644 --- a/sysdeps/l4/hurd/powerpc/pt-setup.c +++ b/sysdeps/l4/hurd/powerpc/pt-setup.c @@ -28,6 +28,7 @@ struct start_info { void (*entry_point) (void *(*)(void *), void *); + struct __pthread *self; void *(*start_routine) (void *); void *arg; }; @@ -41,6 +42,7 @@ first_entry_1: ;\ lwz 0, 0(1) ;\ lwz 3, 4(1) ;\ lwz 4, 8(1) ;\ + lwz 5, 12(1) ;\ mtctr 0 ;\ bctrl ;\ "); @@ -51,7 +53,7 @@ first_entry_1: ;\ opportunity to install THREAD in our utcb. */ static void * stack_setup (struct __pthread *thread, - void (*entry_point)(void *(*)(void *), void *), + void (*entry_point)(struct __pthread *, void *(*)(void *), void *), void *(*start_routine)(void *), void *arg) { l4_word_t *top; @@ -68,6 +70,7 @@ stack_setup (struct __pthread *thread, struct start_info *info = ((struct start_info *) top) - 1; info->entry_point = entry_point; + info->self = thread; info->start_routine = start_routine; info->arg = arg; return (void *) info; @@ -77,7 +80,7 @@ stack_setup (struct __pthread *thread, int __pthread_setup (struct __pthread *thread, - void (*entry_point)(void *(*)(void *), void *), + void (*entry_point)(struct __pthread *, void *(*)(void *), void *), void *(*start_routine)(void *), void *arg) { thread->mcontext.pc = first_entry_1; diff --git a/sysdeps/mach/hurd/ia32/pt-setup.c b/sysdeps/mach/hurd/ia32/pt-setup.c index 5420dc8..73fd43d 100644 --- a/sysdeps/mach/hurd/ia32/pt-setup.c +++ b/sysdeps/mach/hurd/ia32/pt-setup.c @@ -57,16 +57,14 @@ stack_setup (struct __pthread *thread, /* Next, make room for the TSDs. */ top -= __hurd_threadvar_max; - /* Save the self pointer. */ - top[_HURD_THREADVAR_THREAD] = (uintptr_t) thread; - if (start_routine) { /* And then the call frame. */ - top -= 2; + top -= 3; top = (uintptr_t *) ((uintptr_t) top & ~0xf); - top[1] = (uintptr_t) arg; /* Argument to START_ROUTINE. */ - top[0] = (uintptr_t) start_routine; + top[2] = (uintptr_t) arg; /* Argument to START_ROUTINE. */ + top[1] = (uintptr_t) start_routine; + top[0] = (uintptr_t) thread; *--top = 0; /* Fake return address. */ } @@ -82,7 +80,7 @@ stack_setup (struct __pthread *thread, int __pthread_setup (struct __pthread *thread, - void (*entry_point)(void *(*)(void *), void *), + void (*entry_point)(struct __pthread *, void *(*)(void *), void *), void *(*start_routine)(void *), void *arg) { error_t err; diff --git a/sysdeps/mach/hurd/pt-sysdep.c b/sysdeps/mach/hurd/pt-sysdep.c index 95a4d36..f40fee5 100644 --- a/sysdeps/mach/hurd/pt-sysdep.c +++ b/sysdeps/mach/hurd/pt-sysdep.c @@ -28,6 +28,8 @@ #include +__thread struct __pthread *___pthread_self; + /* Forward. */ static void *init_routine (void); @@ -51,8 +53,7 @@ init_routine (void) err = __pthread_create_internal (&thread, 0, 0, 0); assert_perror (err); - ((void **) (__hurd_threadvar_stack_offset))[_HURD_THREADVAR_THREAD] - = thread; + ___pthread_self = thread; /* Decrease the number of threads, to take into account that the signal thread (which will be created by the glibc startup code diff --git a/sysdeps/mach/hurd/pt-sysdep.h b/sysdeps/mach/hurd/pt-sysdep.h index 13e235d..bec1b40 100644 --- a/sysdeps/mach/hurd/pt-sysdep.h +++ b/sysdeps/mach/hurd/pt-sysdep.h @@ -35,15 +35,13 @@ mach_msg_header_t wakeupmsg; \ int have_kernel_resources; -#define _HURD_THREADVAR_THREAD _HURD_THREADVAR_DYNAMIC_USER - +extern __thread struct __pthread *___pthread_self; #define _pthread_self() \ ({ \ struct __pthread *thread; \ \ assert (__pthread_threads); \ - thread = *(struct __pthread **) \ - __hurd_threadvar_location (_HURD_THREADVAR_THREAD); \ + thread = ___pthread_self; \ \ assert (thread); \ assert (({ mach_port_t ktid = __mach_thread_self (); \ -- cgit v1.2.3 From f42e3ba3cb16bd892957f3b018e2d8ae1e06d022 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 8 Jul 2012 20:45:56 +0200 Subject: Comment on deviation from standard * pthread/pt-internal.h (guardsize): Mention that we depart from the standard which says guardsize is in addition to stacksize. --- pthread/pt-internal.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pthread') diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index f5766e9..067fb73 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -84,6 +84,8 @@ struct __pthread size_t guardsize; /* Included in STACKSIZE (i.e. total stack memory is STACKSIZE, not STACKSIZE + GUARDSIZE). */ + /* FIXME: standard says that guardsize is in + addition to stacksize. */ int stack; /* Nonzero if the stack was allocated. */ /* Exit status. */ -- cgit v1.2.3