Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/sommerfeld_i386mp_1]: src/sys/arch/i386/i386 Add assert to check that lo...
details: https://anonhg.NetBSD.org/src/rev/fa9f8160946d
branches: sommerfeld_i386mp_1
changeset: 482346:fa9f8160946d
user: sommerfeld <sommerfeld%NetBSD.org@localhost>
date: Sun Jan 07 18:16:02 2001 +0000
description:
Add assert to check that lock is either __SIMPLELOCK_LOCKED or
__SIMPLELOCK_UNLOCKED to catch cases where we smash a lock value.
diffstat:
sys/arch/i386/i386/lock_machdep.c | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
diffs (57 lines):
diff -r fba16066d876 -r fa9f8160946d sys/arch/i386/i386/lock_machdep.c
--- a/sys/arch/i386/i386/lock_machdep.c Thu Jan 04 06:07:45 2001 +0000
+++ b/sys/arch/i386/i386/lock_machdep.c Sun Jan 07 18:16:02 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lock_machdep.c,v 1.1.2.5 2000/08/18 03:30:19 sommerfeld Exp $ */
+/* $NetBSD: lock_machdep.c,v 1.1.2.6 2001/01/07 18:16:02 sommerfeld Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -72,14 +72,20 @@
__cpu_simple_lock(lockp)
__cpu_simple_lock_t *lockp;
{
-#if defined (DEBUG) && defined(DDB)
+#if defined (DEBUG)
+#if defined(DDB)
int spincount = 0;
int cpu = cpu_number();
int limit = spin_limit * (cpu + 1);
+#endif
+ __cpu_simple_lock_t v = *lockp;
+ KASSERT((v == __SIMPLELOCK_LOCKED) || (v == __SIMPLELOCK_UNLOCKED));
+#if defined(DDB)
wantlock[cpu] = lockp;
#endif
-
+#endif
+
while (i386_atomic_testset_i(lockp, __SIMPLELOCK_LOCKED)
== __SIMPLELOCK_LOCKED) {
#if defined(DEBUG) && defined(DDB)
@@ -108,6 +114,11 @@
__cpu_simple_lock_try(lockp)
__cpu_simple_lock_t *lockp;
{
+#ifdef DEBUG
+ __cpu_simple_lock_t v = *lockp;
+
+ KASSERT((v == __SIMPLELOCK_LOCKED) || (v == __SIMPLELOCK_UNLOCKED));
+#endif
if (i386_atomic_testset_i(lockp, __SIMPLELOCK_LOCKED)
== __SIMPLELOCK_UNLOCKED)
@@ -119,6 +130,12 @@
__cpu_simple_unlock(lockp)
__cpu_simple_lock_t *lockp;
{
+#ifdef DEBUG
+ __cpu_simple_lock_t v = *lockp;
+
+ KASSERT((v == __SIMPLELOCK_LOCKED) || (v == __SIMPLELOCK_UNLOCKED));
+#endif
+
*lockp = __SIMPLELOCK_UNLOCKED;
}
Home |
Main Index |
Thread Index |
Old Index