about summary refs log tree commit diff
path: root/nptl/pthread_mutex_lock.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-09-11 08:00:43 +0000
committerUlrich Drepper <drepper@redhat.com>2003-09-11 08:00:43 +0000
commit3892d906f71a23d794eb00bd7c88bcab9cc10b4a (patch)
tree9d7092f3be6b8e617bf46e0c1f52a19cc58c239f /nptl/pthread_mutex_lock.c
parent1fe4d5652dc109d04c3ef14985d37123a7dd6d9f (diff)
downloadglibc-3892d906f71a23d794eb00bd7c88bcab9cc10b4a.tar.gz
glibc-3892d906f71a23d794eb00bd7c88bcab9cc10b4a.tar.xz
glibc-3892d906f71a23d794eb00bd7c88bcab9cc10b4a.zip
Minor code rearrangements.
Diffstat (limited to 'nptl/pthread_mutex_lock.c')
-rw-r--r--nptl/pthread_mutex_lock.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
index 9c61aa75f6..ac770c5c00 100644
--- a/nptl/pthread_mutex_lock.c
+++ b/nptl/pthread_mutex_lock.c
@@ -17,6 +17,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <assert.h>
 #include <errno.h>
 #include "pthreadP.h"
 #include <lowlevellock.h>
@@ -46,19 +47,14 @@ __pthread_mutex_lock (mutex)
 	    return EAGAIN;
 
 	  ++mutex->__data.__count;
-	}
-      else
-	{
-	  /* We have to get the mutex.  */
-	  LLL_MUTEX_LOCK (mutex->__data.__lock);
 
-	  /* Record the ownership.  */
-	  mutex->__data.__owner = id;
-	  mutex->__data.__count = 1;
-#ifndef NO_INCR
-	  ++mutex->__data.__nusers;
-#endif
+	  return 0;
 	}
+
+      /* We have to get the mutex.  */
+      LLL_MUTEX_LOCK (mutex->__data.__lock);
+
+      mutex->__data.__count = 1;
       break;
 
       /* Error checking mutex.  */
@@ -75,14 +71,16 @@ __pthread_mutex_lock (mutex)
     case PTHREAD_MUTEX_ADAPTIVE_NP:
       /* Normal mutex.  */
       LLL_MUTEX_LOCK (mutex->__data.__lock);
-      /* Record the ownership.  */
-      mutex->__data.__owner = id;
-#ifndef NO_INCR
-      ++mutex->__data.__nusers;
-#endif
       break;
     }
 
+  /* Record the ownership.  */
+  assert (mutex->__data.__owner == 0);
+  mutex->__data.__owner = id;
+#ifndef NO_INCR
+  ++mutex->__data.__nusers;
+#endif
+
   return 0;
 }
 #ifndef __pthread_mutex_lock