summaryrefslogtreecommitdiff
path: root/sysdeps/generic/pt-mutex-trylock.c
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@gnu.org>2008-01-01 17:42:41 +0000
committerThomas Schwinge <tschwinge@gnu.org>2009-04-07 23:11:53 +0200
commit00905beb9fabe556ae905b5eaa14e8c76dff7d79 (patch)
tree1f1f2349dd65fe62a938f9bf9b725131b3875d43 /sysdeps/generic/pt-mutex-trylock.c
parent580da795e84996d81b3db9ef1878d8569a4b9530 (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 'sysdeps/generic/pt-mutex-trylock.c')
-rw-r--r--sysdeps/generic/pt-mutex-trylock.c14
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)
{