diff options
author | neal <neal> | 2008-01-01 17:42:41 +0000 |
---|---|---|
committer | neal <neal> | 2008-01-01 17:42:41 +0000 |
commit | 4b3f8b0904d1b3e8b7b6837e31e940f8180bd5bf (patch) | |
tree | dbeacac5f7eef49e64cc90a4151b975b28fcaeea /libpthread/sysdeps/generic/pt-mutex-trylock.c | |
parent | abd5f5b37175397568c948002385f734d5f1ecbc (diff) |
2008-01-01 Neal H. Walfield <neal@gnu.org>
* sysdeps/generic/pt-mutex-timedlock.c
(__pthread_mutex_timedlock_internal): Add additional asserts.
[! NDEBUG]: Keep MUTEX->OWNER up to date.
* sysdeps/generic/pt-mutex-trylock.c (__pthread_mutex_trylock):
Add additional asserts.
[! NDEBUG]: Keep MUTEX->OWNER up to date.
* sysdeps/generic/pt-mutex-unlock.c (__pthread_mutex_unlock): Add
additional asserts.
[! NDEBUG]: Keep MUTEX->OWNER up to date.
Diffstat (limited to 'libpthread/sysdeps/generic/pt-mutex-trylock.c')
-rw-r--r-- | libpthread/sysdeps/generic/pt-mutex-trylock.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libpthread/sysdeps/generic/pt-mutex-trylock.c b/libpthread/sysdeps/generic/pt-mutex-trylock.c index d56f6e1..5264dc7 100644 --- a/libpthread/sysdeps/generic/pt-mutex-trylock.c +++ b/libpthread/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) { |