summaryrefslogtreecommitdiff
path: root/lib/libpthread/pthread_lock.c
diff options
context:
space:
mode:
authorad <ad@NetBSD.org>2007-08-16 23:37:08 +0000
committerad <ad@NetBSD.org>2007-08-16 23:37:08 +0000
commitcc383c5771f13db9cc226e80461bdf1f9b5bc835 (patch)
tree6ace2bf393b7141e4aa6f55f89c0cf1dfc613897 /lib/libpthread/pthread_lock.c
parente835604c2668e8890ee125d2b4da3e73947a1ee4 (diff)
Minor correction for debug code and a cosmetic change.
Diffstat (limited to 'lib/libpthread/pthread_lock.c')
-rw-r--r--lib/libpthread/pthread_lock.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/libpthread/pthread_lock.c b/lib/libpthread/pthread_lock.c
index c5f8d027881..9f441540bcb 100644
--- a/lib/libpthread/pthread_lock.c
+++ b/lib/libpthread/pthread_lock.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_lock.c,v 1.23 2007/08/16 13:54:17 ad Exp $ */
+/* $NetBSD: pthread_lock.c,v 1.24 2007/08/16 23:37:08 ad Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_lock.c,v 1.23 2007/08/16 13:54:17 ad Exp $");
+__RCSID("$NetBSD: pthread_lock.c,v 1.24 2007/08/16 23:37:08 ad Exp $");
#include <sys/types.h>
#include <sys/lock.h>
@@ -124,13 +124,12 @@ pthread_spinlock(pthread_spin_t *lock)
thread, lock, thread->pt_spinlocks));
pthread__assert(thread->pt_spinlocks >= 0);
thread->pt_spinlocks++;
+ PTHREADD_ADD(PTHREADD_SPINLOCKS);
#endif
if (pthread__atomic) {
- if (__predict_false(!__cpu_simple_lock_try(lock))) {
- pthread_spinlock_slow(lock);
+ if (__predict_true(__cpu_simple_lock_try(lock)))
return;
- }
} else {
__cpu_simple_lock_t old;
@@ -139,13 +138,11 @@ pthread_spinlock(pthread_spin_t *lock)
*lock = __SIMPLELOCK_LOCKED;
RAS_END(pthread__lock2);
- if (__predict_false(old != __SIMPLELOCK_UNLOCKED)) {
- pthread_spinlock_slow(lock);
+ if (__predict_true(old == __SIMPLELOCK_UNLOCKED))
return;
- }
}
-
- PTHREADD_ADD(PTHREADD_SPINLOCKS);
+
+ pthread_spinlock_slow(lock);
}
/*
@@ -186,8 +183,6 @@ pthread_spinlock_slow(pthread_spin_t *lock)
sched_yield();
#endif
} while (/*CONSTCOND*/ 1);
-
- PTHREADD_ADD(PTHREADD_SPINLOCKS);
}
int