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/sysdeps | |
parent | cf20f569ae3e9c1893a45b58f5181ed336ca1c4d (diff) | |
download | glibc-9a7178d611c8a9b2089cbd8288b623ec3e86da3f.tar.gz glibc-9a7178d611c8a9b2089cbd8288b623ec3e86da3f.tar.xz glibc-9a7178d611c8a9b2089cbd8288b623ec3e86da3f.zip |
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/sysdeps')
-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 |
11 files changed, 38 insertions, 9 deletions
diff --git a/nptl/sysdeps/i386/tls.h b/nptl/sysdeps/i386/tls.h index 7ee2bcac19..03757bb4c7 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 8a13a59d30..5ce74737a7 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 6573bb6b04..70aff09e24 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 9d00e4e135..ea1213896e 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 197af9c970..7fb93df1de 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 9c1815570f..d5a75ba3b2 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 e4d08ea657..52308aff91 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 03c37a1933..171a14adb1 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 06237ae15b..89e51ff228 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 1e27b987e0..a6cefa0b31 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 ab13f25431..074eb64a8c 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) \ |