mirror of git://sourceware.org/git/glibc.git
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.
This commit is contained in:
parent
cf20f569ae
commit
9a7178d611
|
|
@ -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>
|
2003-04-29 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h
|
* sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,14 @@ int
|
||||||
__pthread_mutex_lock (mutex)
|
__pthread_mutex_lock (mutex)
|
||||||
pthread_mutex_t *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))
|
switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP))
|
||||||
{
|
{
|
||||||
/* Recursive mutex. */
|
/* Recursive mutex. */
|
||||||
case PTHREAD_MUTEX_RECURSIVE_NP:
|
case PTHREAD_MUTEX_RECURSIVE_NP:
|
||||||
/* Check whether we already hold the mutex. */
|
/* Check whether we already hold the mutex. */
|
||||||
if (mutex->__data.__owner == pd)
|
if (mutex->__data.__owner == id)
|
||||||
{
|
{
|
||||||
/* Just bump the counter. */
|
/* Just bump the counter. */
|
||||||
if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
|
if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
|
||||||
|
|
@ -48,7 +48,7 @@ __pthread_mutex_lock (mutex)
|
||||||
lll_mutex_lock (mutex->__data.__lock);
|
lll_mutex_lock (mutex->__data.__lock);
|
||||||
|
|
||||||
/* Record the ownership. */
|
/* Record the ownership. */
|
||||||
mutex->__data.__owner = pd;
|
mutex->__data.__owner = id;
|
||||||
mutex->__data.__count = 1;
|
mutex->__data.__count = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -56,7 +56,7 @@ __pthread_mutex_lock (mutex)
|
||||||
/* Error checking mutex. */
|
/* Error checking mutex. */
|
||||||
case PTHREAD_MUTEX_ERRORCHECK_NP:
|
case PTHREAD_MUTEX_ERRORCHECK_NP:
|
||||||
/* Check whether we already hold the mutex. */
|
/* Check whether we already hold the mutex. */
|
||||||
if (mutex->__data.__owner == pd)
|
if (mutex->__data.__owner == id)
|
||||||
return EDEADLK;
|
return EDEADLK;
|
||||||
|
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
|
|
@ -68,7 +68,7 @@ __pthread_mutex_lock (mutex)
|
||||||
/* Normal mutex. */
|
/* Normal mutex. */
|
||||||
lll_mutex_lock (mutex->__data.__lock);
|
lll_mutex_lock (mutex->__data.__lock);
|
||||||
/* Record the ownership. */
|
/* Record the ownership. */
|
||||||
mutex->__data.__owner = pd;
|
mutex->__data.__owner = id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
||||||
|
|
||||||
|
|
@ -27,7 +27,7 @@ pthread_mutex_timedlock (mutex, abstime)
|
||||||
pthread_mutex_t *mutex;
|
pthread_mutex_t *mutex;
|
||||||
const struct timespec *abstime;
|
const struct timespec *abstime;
|
||||||
{
|
{
|
||||||
struct pthread *pd = THREAD_SELF;
|
struct pthread *id = THREAD_ID;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
/* We must not check ABSTIME here. If the thread does not block
|
/* We must not check ABSTIME here. If the thread does not block
|
||||||
|
|
@ -38,7 +38,7 @@ pthread_mutex_timedlock (mutex, abstime)
|
||||||
/* Recursive mutex. */
|
/* Recursive mutex. */
|
||||||
case PTHREAD_MUTEX_RECURSIVE_NP:
|
case PTHREAD_MUTEX_RECURSIVE_NP:
|
||||||
/* Check whether we already hold the mutex. */
|
/* Check whether we already hold the mutex. */
|
||||||
if (mutex->__data.__owner == pd)
|
if (mutex->__data.__owner == id)
|
||||||
{
|
{
|
||||||
/* Just bump the counter. */
|
/* Just bump the counter. */
|
||||||
if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
|
if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
|
||||||
|
|
@ -65,7 +65,7 @@ pthread_mutex_timedlock (mutex, abstime)
|
||||||
/* Error checking mutex. */
|
/* Error checking mutex. */
|
||||||
case PTHREAD_MUTEX_ERRORCHECK_NP:
|
case PTHREAD_MUTEX_ERRORCHECK_NP:
|
||||||
/* Check whether we already hold the mutex. */
|
/* Check whether we already hold the mutex. */
|
||||||
if (mutex->__data.__owner == pd)
|
if (mutex->__data.__owner == id)
|
||||||
return EDEADLK;
|
return EDEADLK;
|
||||||
|
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
|
|
@ -81,7 +81,7 @@ pthread_mutex_timedlock (mutex, abstime)
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
/* Record the ownership. */
|
/* Record the ownership. */
|
||||||
mutex->__data.__owner = pd;
|
mutex->__data.__owner = id;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,14 @@ int
|
||||||
__pthread_mutex_trylock (mutex)
|
__pthread_mutex_trylock (mutex)
|
||||||
pthread_mutex_t *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))
|
switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP))
|
||||||
{
|
{
|
||||||
/* Recursive mutex. */
|
/* Recursive mutex. */
|
||||||
case PTHREAD_MUTEX_RECURSIVE_NP:
|
case PTHREAD_MUTEX_RECURSIVE_NP:
|
||||||
/* Check whether we already hold the mutex. */
|
/* Check whether we already hold the mutex. */
|
||||||
if (mutex->__data.__owner == pd)
|
if (mutex->__data.__owner == id)
|
||||||
{
|
{
|
||||||
/* Just bump the counter. */
|
/* Just bump the counter. */
|
||||||
if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
|
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)
|
if (lll_mutex_trylock (mutex->__data.__lock) == 0)
|
||||||
{
|
{
|
||||||
/* Record the ownership. */
|
/* Record the ownership. */
|
||||||
mutex->__data.__owner = pd;
|
mutex->__data.__owner = id;
|
||||||
mutex->__data.__count = 1;
|
mutex->__data.__count = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -63,7 +63,7 @@ __pthread_mutex_trylock (mutex)
|
||||||
if (lll_mutex_trylock (mutex->__data.__lock) == 0)
|
if (lll_mutex_trylock (mutex->__data.__lock) == 0)
|
||||||
{
|
{
|
||||||
/* Record the ownership. */
|
/* Record the ownership. */
|
||||||
mutex->__data.__owner = pd;
|
mutex->__data.__owner = id;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,23 +30,19 @@ __pthread_mutex_unlock (mutex)
|
||||||
{
|
{
|
||||||
case PTHREAD_MUTEX_RECURSIVE_NP:
|
case PTHREAD_MUTEX_RECURSIVE_NP:
|
||||||
/* Recursive mutex. */
|
/* Recursive mutex. */
|
||||||
if (mutex->__data.__owner != THREAD_SELF)
|
if (mutex->__data.__owner != THREAD_ID)
|
||||||
return EPERM;
|
return EPERM;
|
||||||
|
|
||||||
if (--mutex->__data.__count != 0)
|
if (--mutex->__data.__count != 0)
|
||||||
/* We still hold the mutex. */
|
/* We still hold the mutex. */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
mutex->__data.__owner = NULL;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PTHREAD_MUTEX_ERRORCHECK_NP:
|
case PTHREAD_MUTEX_ERRORCHECK_NP:
|
||||||
/* Error checking mutex. */
|
/* Error checking mutex. */
|
||||||
if (mutex->__data.__owner != THREAD_SELF
|
if (mutex->__data.__owner != THREAD_ID
|
||||||
|| ! lll_mutex_islocked (mutex->__data.__lock))
|
|| ! lll_mutex_islocked (mutex->__data.__lock))
|
||||||
return EPERM;
|
return EPERM;
|
||||||
|
|
||||||
mutex->__data.__owner = NULL;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -57,6 +53,9 @@ __pthread_mutex_unlock (mutex)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Always reset the owner field. */
|
||||||
|
mutex->__data.__owner = NULL;
|
||||||
|
|
||||||
/* Unlock. */
|
/* Unlock. */
|
||||||
lll_mutex_unlock (mutex->__data.__lock);
|
lll_mutex_unlock (mutex->__data.__lock);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
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)
|
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;
|
result = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -251,6 +251,10 @@ union user_desc_init
|
||||||
: "i" (offsetof (struct pthread, header.self))); \
|
: "i" (offsetof (struct pthread, header.self))); \
|
||||||
__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. */
|
/* Read member of the thread descriptor directly. */
|
||||||
# define THREAD_GETMEM(descr, member) \
|
# define THREAD_GETMEM(descr, member) \
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,10 @@ register struct pthread *__thread_self __asm__("r13");
|
||||||
/* Return the thread descriptor for the current thread. */
|
/* Return the thread descriptor for the current thread. */
|
||||||
# define THREAD_SELF (__thread_self - 1)
|
# 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. */
|
/* Access to data in the thread descriptor is easy. */
|
||||||
#define THREAD_GETMEM(descr, member) \
|
#define THREAD_GETMEM(descr, member) \
|
||||||
descr->member
|
descr->member
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,10 @@ register void *__thread_register __asm__ ("r13");
|
||||||
((struct pthread *) (__thread_register \
|
((struct pthread *) (__thread_register \
|
||||||
- TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
|
- 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. */
|
/* Read member of the thread descriptor directly. */
|
||||||
# define THREAD_GETMEM(descr, member) ((void)(descr), (THREAD_SELF)->member)
|
# define THREAD_GETMEM(descr, member) ((void)(descr), (THREAD_SELF)->member)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,8 +78,9 @@ create_thread (struct pthread *pd, STACK_VARIABLES_PARMS)
|
||||||
if (ARCH_CLONE (start_thread_debug, STACK_VARIABLES_ARGS,
|
if (ARCH_CLONE (start_thread_debug, STACK_VARIABLES_ARGS,
|
||||||
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGNAL |
|
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGNAL |
|
||||||
CLONE_SETTLS | CLONE_PARENT_SETTID |
|
CLONE_SETTLS | CLONE_PARENT_SETTID |
|
||||||
CLONE_CHILD_CLEARTID | CLONE_DETACHED | 0,
|
CLONE_CHILD_CLEARTID | CLONE_DETACHED |
|
||||||
pd, &pd->tid, TLS_VALUE, &pd->tid) == -1)
|
CLONE_SYSVSEM | 0, pd, &pd->tid, TLS_VALUE,
|
||||||
|
&pd->tid) == -1)
|
||||||
/* Failed. */
|
/* Failed. */
|
||||||
return errno;
|
return errno;
|
||||||
|
|
||||||
|
|
@ -151,7 +152,8 @@ create_thread (struct pthread *pd, STACK_VARIABLES_PARMS)
|
||||||
if (ARCH_CLONE (start_thread, STACK_VARIABLES_ARGS,
|
if (ARCH_CLONE (start_thread, STACK_VARIABLES_ARGS,
|
||||||
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGNAL |
|
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGNAL |
|
||||||
CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID |
|
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. */
|
/* Failed. */
|
||||||
return errno;
|
return errno;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ __pthread_rwlock_rdlock (rwlock)
|
||||||
a deadlock situation we recognize and report. */
|
a deadlock situation we recognize and report. */
|
||||||
if (rwlock->__data.__writer != 0
|
if (rwlock->__data.__writer != 0
|
||||||
&& __builtin_expect (rwlock->__data.__writer
|
&& __builtin_expect (rwlock->__data.__writer
|
||||||
== (pthread_t) THREAD_SELF, 0))
|
== (pthread_t) THREAD_ID, 0))
|
||||||
{
|
{
|
||||||
result = EDEADLK;
|
result = EDEADLK;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ pthread_rwlock_timedrdlock (rwlock, abstime)
|
||||||
a deadlock situation we recognize and report. */
|
a deadlock situation we recognize and report. */
|
||||||
if (rwlock->__data.__writer != 0
|
if (rwlock->__data.__writer != 0
|
||||||
&& __builtin_expect (rwlock->__data.__writer
|
&& __builtin_expect (rwlock->__data.__writer
|
||||||
== (pthread_t) THREAD_SELF, 0))
|
== (pthread_t) THREAD_ID, 0))
|
||||||
{
|
{
|
||||||
result = EDEADLK;
|
result = EDEADLK;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ pthread_rwlock_timedwrlock (rwlock, abstime)
|
||||||
if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0)
|
if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0)
|
||||||
{
|
{
|
||||||
/* Mark self as writer. */
|
/* Mark self as writer. */
|
||||||
rwlock->__data.__writer = (pthread_t) THREAD_SELF;
|
rwlock->__data.__writer = (pthread_t) THREAD_ID;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ pthread_rwlock_timedwrlock (rwlock, abstime)
|
||||||
a deadlock situation we recognize and report. */
|
a deadlock situation we recognize and report. */
|
||||||
if (rwlock->__data.__writer != 0
|
if (rwlock->__data.__writer != 0
|
||||||
&& __builtin_expect (rwlock->__data.__writer
|
&& __builtin_expect (rwlock->__data.__writer
|
||||||
== (pthread_t) THREAD_SELF, 0))
|
== (pthread_t) THREAD_ID, 0))
|
||||||
{
|
{
|
||||||
result = EDEADLK;
|
result = EDEADLK;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ __pthread_rwlock_wrlock (rwlock)
|
||||||
if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0)
|
if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0)
|
||||||
{
|
{
|
||||||
/* Mark self as writer. */
|
/* Mark self as writer. */
|
||||||
rwlock->__data.__writer = (pthread_t) THREAD_SELF;
|
rwlock->__data.__writer = (pthread_t) THREAD_ID;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,7 +48,7 @@ __pthread_rwlock_wrlock (rwlock)
|
||||||
a deadlock situation we recognize and report. */
|
a deadlock situation we recognize and report. */
|
||||||
if (rwlock->__data.__writer != 0
|
if (rwlock->__data.__writer != 0
|
||||||
&& __builtin_expect (rwlock->__data.__writer
|
&& __builtin_expect (rwlock->__data.__writer
|
||||||
== (pthread_t) THREAD_SELF, 0))
|
== (pthread_t) THREAD_ID, 0))
|
||||||
{
|
{
|
||||||
result = EDEADLK;
|
result = EDEADLK;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,10 @@ typedef struct
|
||||||
/* Return the thread descriptor for the current thread. */
|
/* Return the thread descriptor for the current thread. */
|
||||||
# define THREAD_SELF ((struct pthread *) __builtin_thread_pointer ())
|
# 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. */
|
/* Access to data in the thread descriptor is easy. */
|
||||||
#define THREAD_GETMEM(descr, member) \
|
#define THREAD_GETMEM(descr, member) \
|
||||||
descr->member
|
descr->member
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,13 @@ typedef struct
|
||||||
__asm ("stc gbr,%0" : "=r" (__self)); \
|
__asm ("stc gbr,%0" : "=r" (__self)); \
|
||||||
__self - 1;})
|
__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. */
|
/* Read member of the thread descriptor directly. */
|
||||||
# define THREAD_GETMEM(descr, member) (descr->member)
|
# define THREAD_GETMEM(descr, member) (descr->member)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,10 @@ typedef struct
|
||||||
: "i" (offsetof (struct pthread, header.self))); \
|
: "i" (offsetof (struct pthread, header.self))); \
|
||||||
__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. */
|
/* Read member of the thread descriptor directly. */
|
||||||
# define THREAD_GETMEM(descr, member) \
|
# define THREAD_GETMEM(descr, member) \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue