diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-05-01 23:19:51 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-05-01 23:19:51 +0000 |
commit | 9a7178d611c8a9b2089cbd8288b623ec3e86da3f (patch) | |
tree | b33e5f3f63e777a1939eebcf23ee7351043861a8 /nptl | |
parent | cf20f569ae3e9c1893a45b58f5181ed336ca1c4d (diff) | |
download | glibc-9a7178d611c8a9b2089cbd8288b623ec3e86da3f.zip glibc-9a7178d611c8a9b2089cbd8288b623ec3e86da3f.tar.gz glibc-9a7178d611c8a9b2089cbd8288b623ec3e86da3f.tar.bz2 |
Update.
2003-05-01 Ulrich Drepper <drepper@redhat.com>
* sysdeps/i386/tls.h: Define THREAD_ID.
* sysdeps/ia64/tls.h: Likewise.
* sysdeps/powerpc/tls.h: Likewise.
* sysdeps/s390/tls.h: Likewise.
* sysdeps/sh/tls.h: Likewise.
* sysdeps/x86_64/tls.h: Likewise.
* pthread_mutex_lock.c: Use THREAD_ID instead of THREAD_SELF to
record ownership.
* pthread_mutex_timedlock.c: Likewise.
* pthread_mutex_trylock.c: Likewise.
* pthread_mutex_unlock.c: Likewise.
* pthread_rwlock_trywrlock.c: Likewise.
* sysdeps/pthread/pthread_rwlocklock_rdlock.c: Likewise.
* sysdeps/pthread/pthread_rwlock_timedrdlock.c: Likewise.
* sysdeps/pthread/pthread_rwlock_timedwrlock.c: Likewise.
* sysdeps/pthread/pthread_rwlock_wrlock.c: Likewise.
* sysdeps/pthread/createthread.c (create_thread): Use CLONE_SYSVSEM
flag.
Diffstat (limited to 'nptl')
-rw-r--r-- | nptl/ChangeLog | 22 | ||||
-rw-r--r-- | nptl/pthread_mutex_lock.c | 10 | ||||
-rw-r--r-- | nptl/pthread_mutex_timedlock.c | 10 | ||||
-rw-r--r-- | nptl/pthread_mutex_trylock.c | 8 | ||||
-rw-r--r-- | nptl/pthread_mutex_unlock.c | 11 | ||||
-rw-r--r-- | nptl/pthread_rwlock_trywrlock.c | 4 | ||||
-rw-r--r-- | nptl/sysdeps/i386/tls.h | 4 | ||||
-rw-r--r-- | nptl/sysdeps/ia64/tls.h | 4 | ||||
-rw-r--r-- | nptl/sysdeps/powerpc/tls.h | 4 | ||||
-rw-r--r-- | nptl/sysdeps/pthread/createthread.c | 8 | ||||
-rw-r--r-- | nptl/sysdeps/pthread/pthread_rwlock_rdlock.c | 2 | ||||
-rw-r--r-- | nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c | 2 | ||||
-rw-r--r-- | nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c | 4 | ||||
-rw-r--r-- | nptl/sysdeps/pthread/pthread_rwlock_wrlock.c | 4 | ||||
-rw-r--r-- | nptl/sysdeps/s390/tls.h | 4 | ||||
-rw-r--r-- | nptl/sysdeps/sh/tls.h | 7 | ||||
-rw-r--r-- | nptl/sysdeps/x86_64/tls.h | 4 |
17 files changed, 81 insertions, 31 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog index e627616..777e61e 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,25 @@ +2003-05-01 Ulrich Drepper <drepper@redhat.com> + + * sysdeps/i386/tls.h: Define THREAD_ID. + * sysdeps/ia64/tls.h: Likewise. + * sysdeps/powerpc/tls.h: Likewise. + * sysdeps/s390/tls.h: Likewise. + * sysdeps/sh/tls.h: Likewise. + * sysdeps/x86_64/tls.h: Likewise. + * pthread_mutex_lock.c: Use THREAD_ID instead of THREAD_SELF to + record ownership. + * pthread_mutex_timedlock.c: Likewise. + * pthread_mutex_trylock.c: Likewise. + * pthread_mutex_unlock.c: Likewise. + * pthread_rwlock_trywrlock.c: Likewise. + * sysdeps/pthread/pthread_rwlocklock_rdlock.c: Likewise. + * sysdeps/pthread/pthread_rwlock_timedrdlock.c: Likewise. + * sysdeps/pthread/pthread_rwlock_timedwrlock.c: Likewise. + * sysdeps/pthread/pthread_rwlock_wrlock.c: Likewise. + + * sysdeps/pthread/createthread.c (create_thread): Use CLONE_SYSVSEM + flag. + 2003-04-29 Jakub Jelinek <jakub@redhat.com> * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c index 5040232..f70445a 100644 --- a/nptl/pthread_mutex_lock.c +++ b/nptl/pthread_mutex_lock.c @@ -26,14 +26,14 @@ int __pthread_mutex_lock (mutex) pthread_mutex_t *mutex; { - struct pthread *pd = THREAD_SELF; + struct pthread *id = THREAD_ID; switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP)) { /* Recursive mutex. */ case PTHREAD_MUTEX_RECURSIVE_NP: /* Check whether we already hold the mutex. */ - if (mutex->__data.__owner == pd) + if (mutex->__data.__owner == id) { /* Just bump the counter. */ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0)) @@ -48,7 +48,7 @@ __pthread_mutex_lock (mutex) lll_mutex_lock (mutex->__data.__lock); /* Record the ownership. */ - mutex->__data.__owner = pd; + mutex->__data.__owner = id; mutex->__data.__count = 1; } break; @@ -56,7 +56,7 @@ __pthread_mutex_lock (mutex) /* Error checking mutex. */ case PTHREAD_MUTEX_ERRORCHECK_NP: /* Check whether we already hold the mutex. */ - if (mutex->__data.__owner == pd) + if (mutex->__data.__owner == id) return EDEADLK; /* FALLTHROUGH */ @@ -68,7 +68,7 @@ __pthread_mutex_lock (mutex) /* Normal mutex. */ lll_mutex_lock (mutex->__data.__lock); /* Record the ownership. */ - mutex->__data.__owner = pd; + mutex->__data.__owner = id; break; } diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c index a63b204..f24f91d 100644 --- a/nptl/pthread_mutex_timedlock.c +++ b/nptl/pthread_mutex_timedlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -27,7 +27,7 @@ pthread_mutex_timedlock (mutex, abstime) pthread_mutex_t *mutex; const struct timespec *abstime; { - struct pthread *pd = THREAD_SELF; + struct pthread *id = THREAD_ID; int result = 0; /* We must not check ABSTIME here. If the thread does not block @@ -38,7 +38,7 @@ pthread_mutex_timedlock (mutex, abstime) /* Recursive mutex. */ case PTHREAD_MUTEX_RECURSIVE_NP: /* Check whether we already hold the mutex. */ - if (mutex->__data.__owner == pd) + if (mutex->__data.__owner == id) { /* Just bump the counter. */ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0)) @@ -65,7 +65,7 @@ pthread_mutex_timedlock (mutex, abstime) /* Error checking mutex. */ case PTHREAD_MUTEX_ERRORCHECK_NP: /* Check whether we already hold the mutex. */ - if (mutex->__data.__owner == pd) + if (mutex->__data.__owner == id) return EDEADLK; /* FALLTHROUGH */ @@ -81,7 +81,7 @@ pthread_mutex_timedlock (mutex, abstime) if (result == 0) /* Record the ownership. */ - mutex->__data.__owner = pd; + mutex->__data.__owner = id; out: return result; diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c index 394a9cb..c61d7d5 100644 --- a/nptl/pthread_mutex_trylock.c +++ b/nptl/pthread_mutex_trylock.c @@ -26,14 +26,14 @@ int __pthread_mutex_trylock (mutex) pthread_mutex_t *mutex; { - struct pthread *pd = THREAD_SELF; + struct pthread *id = THREAD_ID; switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP)) { /* Recursive mutex. */ case PTHREAD_MUTEX_RECURSIVE_NP: /* Check whether we already hold the mutex. */ - if (mutex->__data.__owner == pd) + if (mutex->__data.__owner == id) { /* Just bump the counter. */ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0)) @@ -47,7 +47,7 @@ __pthread_mutex_trylock (mutex) if (lll_mutex_trylock (mutex->__data.__lock) == 0) { /* Record the ownership. */ - mutex->__data.__owner = pd; + mutex->__data.__owner = id; mutex->__data.__count = 1; return 0; } @@ -63,7 +63,7 @@ __pthread_mutex_trylock (mutex) if (lll_mutex_trylock (mutex->__data.__lock) == 0) { /* Record the ownership. */ - mutex->__data.__owner = pd; + mutex->__data.__owner = id; return 0; } diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c index 3595585..975127d 100644 --- a/nptl/pthread_mutex_unlock.c +++ b/nptl/pthread_mutex_unlock.c @@ -30,23 +30,19 @@ __pthread_mutex_unlock (mutex) { case PTHREAD_MUTEX_RECURSIVE_NP: /* Recursive mutex. */ - if (mutex->__data.__owner != THREAD_SELF) + if (mutex->__data.__owner != THREAD_ID) return EPERM; if (--mutex->__data.__count != 0) /* We still hold the mutex. */ return 0; - - mutex->__data.__owner = NULL; break; case PTHREAD_MUTEX_ERRORCHECK_NP: /* Error checking mutex. */ - if (mutex->__data.__owner != THREAD_SELF + if (mutex->__data.__owner != THREAD_ID || ! lll_mutex_islocked (mutex->__data.__lock)) return EPERM; - - mutex->__data.__owner = NULL; break; default: @@ -57,6 +53,9 @@ __pthread_mutex_unlock (mutex) break; } + /* Always reset the owner field. */ + mutex->__data.__owner = NULL; + /* Unlock. */ lll_mutex_unlock (mutex->__data.__lock); diff --git a/nptl/pthread_rwlock_trywrlock.c b/nptl/pthread_rwlock_trywrlock.c index 32fcbba..755af37 100644 --- a/nptl/pthread_rwlock_trywrlock.c +++ b/nptl/pthread_rwlock_trywrlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -32,7 +32,7 @@ __pthread_rwlock_trywrlock (rwlock) if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0) { - rwlock->__data.__writer = (pthread_t) THREAD_SELF; + rwlock->__data.__writer = (pthread_t) THREAD_ID; result = 0; } diff --git a/nptl/sysdeps/i386/tls.h b/nptl/sysdeps/i386/tls.h index 7ee2bca..03757bb 100644 --- a/nptl/sysdeps/i386/tls.h +++ b/nptl/sysdeps/i386/tls.h @@ -251,6 +251,10 @@ union user_desc_init : "i" (offsetof (struct pthread, header.self))); \ __self;}) +/* Identifier for the current thread. THREAD_SELF is usable but + sometimes more expensive than necessary. It is fine here. */ +# define THREAD_ID THREAD_SELF + /* Read member of the thread descriptor directly. */ # define THREAD_GETMEM(descr, member) \ diff --git a/nptl/sysdeps/ia64/tls.h b/nptl/sysdeps/ia64/tls.h index 8a13a59..5ce7473 100644 --- a/nptl/sysdeps/ia64/tls.h +++ b/nptl/sysdeps/ia64/tls.h @@ -113,6 +113,10 @@ register struct pthread *__thread_self __asm__("r13"); /* Return the thread descriptor for the current thread. */ # define THREAD_SELF (__thread_self - 1) +/* Identifier for the current thread. THREAD_SELF is usable but + sometimes more expensive than necessary as in this case. */ +# define THREAD_ID __thread_self + /* Access to data in the thread descriptor is easy. */ #define THREAD_GETMEM(descr, member) \ descr->member diff --git a/nptl/sysdeps/powerpc/tls.h b/nptl/sysdeps/powerpc/tls.h index 6573bb6..70aff09 100644 --- a/nptl/sysdeps/powerpc/tls.h +++ b/nptl/sysdeps/powerpc/tls.h @@ -129,6 +129,10 @@ register void *__thread_register __asm__ ("r13"); ((struct pthread *) (__thread_register \ - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)) +/* Identifier for the current thread. THREAD_SELF is usable but + sometimes more expensive than necessary as in this case. */ +# define THREAD_ID __thread_register + /* Read member of the thread descriptor directly. */ # define THREAD_GETMEM(descr, member) ((void)(descr), (THREAD_SELF)->member) diff --git a/nptl/sysdeps/pthread/createthread.c b/nptl/sysdeps/pthread/createthread.c index 9d00e4e..ea12138 100644 --- a/nptl/sysdeps/pthread/createthread.c +++ b/nptl/sysdeps/pthread/createthread.c @@ -78,8 +78,9 @@ create_thread (struct pthread *pd, STACK_VARIABLES_PARMS) if (ARCH_CLONE (start_thread_debug, STACK_VARIABLES_ARGS, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGNAL | CLONE_SETTLS | CLONE_PARENT_SETTID | - CLONE_CHILD_CLEARTID | CLONE_DETACHED | 0, - pd, &pd->tid, TLS_VALUE, &pd->tid) == -1) + CLONE_CHILD_CLEARTID | CLONE_DETACHED | + CLONE_SYSVSEM | 0, pd, &pd->tid, TLS_VALUE, + &pd->tid) == -1) /* Failed. */ return errno; @@ -151,7 +152,8 @@ create_thread (struct pthread *pd, STACK_VARIABLES_PARMS) if (ARCH_CLONE (start_thread, STACK_VARIABLES_ARGS, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGNAL | CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID | - CLONE_DETACHED | 0, pd, &pd->tid, TLS_VALUE, &pd->tid) == -1) + CLONE_DETACHED | CLONE_SYSVSEM | 0, pd, &pd->tid, TLS_VALUE, + &pd->tid) == -1) /* Failed. */ return errno; diff --git a/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c b/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c index 197af9c..7fb93df 100644 --- a/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c +++ b/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c @@ -57,7 +57,7 @@ __pthread_rwlock_rdlock (rwlock) a deadlock situation we recognize and report. */ if (rwlock->__data.__writer != 0 && __builtin_expect (rwlock->__data.__writer - == (pthread_t) THREAD_SELF, 0)) + == (pthread_t) THREAD_ID, 0)) { result = EDEADLK; break; diff --git a/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c b/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c index 9c18155..d5a75ba 100644 --- a/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c +++ b/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c @@ -60,7 +60,7 @@ pthread_rwlock_timedrdlock (rwlock, abstime) a deadlock situation we recognize and report. */ if (rwlock->__data.__writer != 0 && __builtin_expect (rwlock->__data.__writer - == (pthread_t) THREAD_SELF, 0)) + == (pthread_t) THREAD_ID, 0)) { result = EDEADLK; break; diff --git a/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c b/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c index e4d08ea..52308af 100644 --- a/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c +++ b/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c @@ -43,7 +43,7 @@ pthread_rwlock_timedwrlock (rwlock, abstime) if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0) { /* Mark self as writer. */ - rwlock->__data.__writer = (pthread_t) THREAD_SELF; + rwlock->__data.__writer = (pthread_t) THREAD_ID; break; } @@ -51,7 +51,7 @@ pthread_rwlock_timedwrlock (rwlock, abstime) a deadlock situation we recognize and report. */ if (rwlock->__data.__writer != 0 && __builtin_expect (rwlock->__data.__writer - == (pthread_t) THREAD_SELF, 0)) + == (pthread_t) THREAD_ID, 0)) { result = EDEADLK; break; diff --git a/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c b/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c index 03c37a1..171a14a 100644 --- a/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c +++ b/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c @@ -40,7 +40,7 @@ __pthread_rwlock_wrlock (rwlock) if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0) { /* Mark self as writer. */ - rwlock->__data.__writer = (pthread_t) THREAD_SELF; + rwlock->__data.__writer = (pthread_t) THREAD_ID; break; } @@ -48,7 +48,7 @@ __pthread_rwlock_wrlock (rwlock) a deadlock situation we recognize and report. */ if (rwlock->__data.__writer != 0 && __builtin_expect (rwlock->__data.__writer - == (pthread_t) THREAD_SELF, 0)) + == (pthread_t) THREAD_ID, 0)) { result = EDEADLK; break; diff --git a/nptl/sysdeps/s390/tls.h b/nptl/sysdeps/s390/tls.h index 06237ae..89e51ff 100644 --- a/nptl/sysdeps/s390/tls.h +++ b/nptl/sysdeps/s390/tls.h @@ -137,6 +137,10 @@ typedef struct /* Return the thread descriptor for the current thread. */ # define THREAD_SELF ((struct pthread *) __builtin_thread_pointer ()) +/* Identifier for the current thread. THREAD_SELF is usable but + sometimes more expensive than necessary. It is fine here. */ +# define THREAD_ID THREAD_SELF + /* Access to data in the thread descriptor is easy. */ #define THREAD_GETMEM(descr, member) \ descr->member diff --git a/nptl/sysdeps/sh/tls.h b/nptl/sysdeps/sh/tls.h index 1e27b98..a6cefa0 100644 --- a/nptl/sysdeps/sh/tls.h +++ b/nptl/sysdeps/sh/tls.h @@ -117,6 +117,13 @@ typedef struct __asm ("stc gbr,%0" : "=r" (__self)); \ __self - 1;}) +/* Identifier for the current thread. THREAD_SELF is usable but + sometimes more expensive than necessary as in this case. */ +# define THREAD_ID \ + ({ struct pthread *__self; \ + __asm ("stc gbr,%0" : "=r" (__self)); \ + __self;}) + /* Read member of the thread descriptor directly. */ # define THREAD_GETMEM(descr, member) (descr->member) diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h index ab13f25..074eb64 100644 --- a/nptl/sysdeps/x86_64/tls.h +++ b/nptl/sysdeps/x86_64/tls.h @@ -159,6 +159,10 @@ typedef struct : "i" (offsetof (struct pthread, header.self))); \ __self;}) +/* Identifier for the current thread. THREAD_SELF is usable but + sometimes more expensive than necessary. It is fine here. */ +# define THREAD_ID THREAD_SELF + /* Read member of the thread descriptor directly. */ # define THREAD_GETMEM(descr, member) \ |