diff options
author | Neal H. Walfield <neal@gnu.org> | 2008-06-22 09:05:31 +0000 |
---|---|---|
committer | Neal H. Walfield <neal@gnu.org> | 2008-06-22 09:05:31 +0000 |
commit | 362912127aa75b78d4f42493ee1783bab9135cd1 (patch) | |
tree | 612fc3ddaa1826199afdbe8d8189e1b3898f4bb6 /sysdeps/generic/pt-mutex-trylock.c | |
parent | 9830b3b2eb53aa7ad2eeb4cc11fbb44ba323cf4e (diff) |
2008-06-22 Neal H. Walfield <neal@gnu.org>
* sysdeps/generic/pt-mutex-timedlock.c
(__pthread_mutex_timedlock_internal) [! NDEBUG]: Set MUTEX->OWNER
appropriately and assert that it is consistent.
* sysdeps/generic/pt-mutex-unlock.c (__pthread_mutex_unlock) [!
NDEBUG]: Set MUTEX->OWNER appropriately and assert that it is
consistent.
* sysdeps/generic/pt-mutex-trylock.c (__pthread_mutex_trylock) [!
NDEBUG]: Set MUTEX->OWNER.
Diffstat (limited to 'sysdeps/generic/pt-mutex-trylock.c')
-rw-r--r-- | sysdeps/generic/pt-mutex-trylock.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sysdeps/generic/pt-mutex-trylock.c b/sysdeps/generic/pt-mutex-trylock.c index d56f6e1..5264dc7 100644 --- a/sysdeps/generic/pt-mutex-trylock.c +++ b/sysdeps/generic/pt-mutex-trylock.c @@ -1,5 +1,5 @@ /* Try to Lock a mutex. Generic version. - Copyright (C) 2002, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2005, 2008 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 @@ -34,6 +34,18 @@ __pthread_mutex_trylock (struct __pthread_mutex *mutex) if (__pthread_spin_trylock (&mutex->__held) == 0) /* Acquired the lock. */ { +#ifndef NDEBUG + self = _pthread_self (); + if (self) + /* The main thread may take a lock before the library is fully + initialized, in particular, before the main thread has a + TCB. */ + { + assert (! mutex->owner); + mutex->owner = _pthread_self (); + } +#endif + if (mutex->attr) switch (mutex->attr->mutex_type) { |