summaryrefslogtreecommitdiff
path: root/libpthread/sysdeps/generic/pt-mutex-trylock.c
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2010-08-01 12:10:06 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2010-08-01 12:10:06 +0200
commit872345fd3c7bf57a6e6b87e35159b28ff290a965 (patch)
tree94c7a422cdff0ab544cb3fbd400ca5e9b06542f1 /libpthread/sysdeps/generic/pt-mutex-trylock.c
parent15705185f4d3e60620a4747bf6ea9831402a2edd (diff)
parentae5f861010e23248573efa3addbcd3f115c7d9d4 (diff)
Merge branch 'libpthread-moved' into upstream-merged
Diffstat (limited to 'libpthread/sysdeps/generic/pt-mutex-trylock.c')
-rw-r--r--libpthread/sysdeps/generic/pt-mutex-trylock.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/libpthread/sysdeps/generic/pt-mutex-trylock.c b/libpthread/sysdeps/generic/pt-mutex-trylock.c
index 5264dc7b..7a54cc9a 100644
--- a/libpthread/sysdeps/generic/pt-mutex-trylock.c
+++ b/libpthread/sysdeps/generic/pt-mutex-trylock.c
@@ -29,11 +29,18 @@ __pthread_mutex_trylock (struct __pthread_mutex *mutex)
{
int err;
struct __pthread *self;
+ const struct __pthread_mutexattr *attr = mutex->attr;
+
+ if (attr == __PTHREAD_ERRORCHECK_MUTEXATTR)
+ attr = &__pthread_errorcheck_mutexattr;
+ if (attr == __PTHREAD_RECURSIVE_MUTEXATTR)
+ attr = &__pthread_recursive_mutexattr;
__pthread_spin_lock (&mutex->__lock);
if (__pthread_spin_trylock (&mutex->__held) == 0)
/* Acquired the lock. */
{
+#if defined(ALWAYS_TRACK_MUTEX_OWNER)
#ifndef NDEBUG
self = _pthread_self ();
if (self)
@@ -45,9 +52,10 @@ __pthread_mutex_trylock (struct __pthread_mutex *mutex)
mutex->owner = _pthread_self ();
}
#endif
+#endif
- if (mutex->attr)
- switch (mutex->attr->mutex_type)
+ if (attr)
+ switch (attr->mutex_type)
{
case PTHREAD_MUTEX_NORMAL:
break;
@@ -68,10 +76,10 @@ __pthread_mutex_trylock (struct __pthread_mutex *mutex)
err = EBUSY;
- if (mutex->attr)
+ if (attr)
{
self = _pthread_self ();
- switch (mutex->attr->mutex_type)
+ switch (attr->mutex_type)
{
case PTHREAD_MUTEX_NORMAL:
break;