Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Invert the sense of the bit to mark if LOCKDEBUG is enab...



details:   https://anonhg.NetBSD.org/src/rev/cb57d4f75e8e
branches:  trunk
changeset: 751463:cb57d4f75e8e
user:      skrll <skrll%NetBSD.org@localhost>
date:      Fri Feb 05 06:43:16 2010 +0000

description:
Invert the sense of the bit to mark if LOCKDEBUG is enabled to disabled.

This will help my fellow developers spot "use before initialised" problems
that hppa picks up very well.

diffstat:

 sys/kern/kern_mutex.c  |  18 +++++++++---------
 sys/kern/kern_rwlock.c |  12 ++++++------
 sys/sys/mutex.h        |   4 ++--
 sys/sys/rwlock.h       |  12 ++++++------
 4 files changed, 23 insertions(+), 23 deletions(-)

diffs (141 lines):

diff -r 6514b56ba031 -r cb57d4f75e8e sys/kern/kern_mutex.c
--- a/sys/kern/kern_mutex.c     Fri Feb 05 03:49:11 2010 +0000
+++ b/sys/kern/kern_mutex.c     Fri Feb 05 06:43:16 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_mutex.c,v 1.46 2009/11/04 13:29:45 pooka Exp $    */
+/*     $NetBSD: kern_mutex.c,v 1.47 2010/02/05 06:43:16 skrll Exp $    */
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 #define        __MUTEX_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.46 2009/11/04 13:29:45 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.47 2010/02/05 06:43:16 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -157,15 +157,15 @@
 
 #define        MUTEX_INITIALIZE_ADAPTIVE(mtx, dodebug)                         \
 do {                                                                   \
-       if (dodebug)                                                    \
-               (mtx)->mtx_owner |= MUTEX_BIT_DEBUG;                    \
+       if (!dodebug)                                                   \
+               (mtx)->mtx_owner |= MUTEX_BIT_NODEBUG;                  \
 } while (/* CONSTCOND */ 0);
 
 #define        MUTEX_INITIALIZE_SPIN(mtx, dodebug, ipl)                        \
 do {                                                                   \
        (mtx)->mtx_owner = MUTEX_BIT_SPIN;                              \
-       if (dodebug)                                                    \
-               (mtx)->mtx_owner |= MUTEX_BIT_DEBUG;                    \
+       if (!dodebug)                                                   \
+               (mtx)->mtx_owner |= MUTEX_BIT_NODEBUG;                  \
        (mtx)->mtx_ipl = makeiplcookie((ipl));                          \
        __cpu_simple_lock_init(&(mtx)->mtx_lock);                       \
 } while (/* CONSTCOND */ 0)
@@ -180,10 +180,10 @@
 #define        MUTEX_ADAPTIVE_P(mtx)           \
     (((mtx)->mtx_owner & MUTEX_BIT_SPIN) == 0)
 
-#define        MUTEX_DEBUG_P(mtx)      (((mtx)->mtx_owner & MUTEX_BIT_DEBUG) != 0)
+#define        MUTEX_DEBUG_P(mtx)      (((mtx)->mtx_owner & MUTEX_BIT_NODEBUG) == 0)
 #if defined(LOCKDEBUG)
-#define        MUTEX_OWNED(owner)              (((owner) & ~MUTEX_BIT_DEBUG) != 0)
-#define        MUTEX_INHERITDEBUG(new, old)    (new) |= (old) & MUTEX_BIT_DEBUG
+#define        MUTEX_OWNED(owner)              (((owner) & ~MUTEX_BIT_NODEBUG) != 0)
+#define        MUTEX_INHERITDEBUG(new, old)    (new) |= (old) & MUTEX_BIT_NODEBUG
 #else /* defined(LOCKDEBUG) */
 #define        MUTEX_OWNED(owner)              ((owner) != 0)
 #define        MUTEX_INHERITDEBUG(new, old)    /* nothing */
diff -r 6514b56ba031 -r cb57d4f75e8e sys/kern/kern_rwlock.c
--- a/sys/kern/kern_rwlock.c    Fri Feb 05 03:49:11 2010 +0000
+++ b/sys/kern/kern_rwlock.c    Fri Feb 05 06:43:16 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_rwlock.c,v 1.33 2009/11/04 13:29:45 pooka Exp $   */
+/*     $NetBSD: kern_rwlock.c,v 1.34 2010/02/05 06:43:16 skrll Exp $   */
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.33 2009/11/04 13:29:45 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.34 2010/02/05 06:43:16 skrll Exp $");
 
 #define        __RWLOCK_PRIVATE
 
@@ -103,10 +103,10 @@
 
 #endif /* DIAGNOSTIC */
 
-#define        RW_SETDEBUG(rw, on)             ((rw)->rw_owner |= (on) ? RW_DEBUG : 0)
-#define        RW_DEBUG_P(rw)                  (((rw)->rw_owner & RW_DEBUG) != 0)
+#define        RW_SETDEBUG(rw, on)             ((rw)->rw_owner |= (on) ? 0 : RW_NODEBUG)
+#define        RW_DEBUG_P(rw)                  (((rw)->rw_owner & RW_NODEBUG) == 0)
 #if defined(LOCKDEBUG)
-#define        RW_INHERITDEBUG(new, old)       (new) |= (old) & RW_DEBUG
+#define        RW_INHERITDEBUG(new, old)       (new) |= (old) & RW_NODEBUG
 #else /* defined(LOCKDEBUG) */
 #define        RW_INHERITDEBUG(new, old)       /* nothing */
 #endif /* defined(LOCKDEBUG) */
@@ -218,7 +218,7 @@
 rw_destroy(krwlock_t *rw)
 {
 
-       RW_ASSERT(rw, (rw->rw_owner & ~RW_DEBUG) == 0);
+       RW_ASSERT(rw, (rw->rw_owner & ~RW_NODEBUG) == 0);
        LOCKDEBUG_FREE(RW_DEBUG_P(rw), rw);
 }
 
diff -r 6514b56ba031 -r cb57d4f75e8e sys/sys/mutex.h
--- a/sys/sys/mutex.h   Fri Feb 05 03:49:11 2010 +0000
+++ b/sys/sys/mutex.h   Fri Feb 05 06:43:16 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mutex.h,v 1.17 2009/05/11 22:37:21 ad Exp $    */
+/*     $NetBSD: mutex.h,v 1.18 2010/02/05 06:43:17 skrll Exp $ */
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -160,7 +160,7 @@
 
 #define        MUTEX_BIT_SPIN                  0x01
 #define        MUTEX_BIT_WAITERS               0x02
-#define        MUTEX_BIT_DEBUG                 0x04
+#define        MUTEX_BIT_NODEBUG               0x04
 
 #define        MUTEX_SPIN_IPL(mtx)             ((mtx)->mtx_ipl)
 #define        MUTEX_SPIN_OLDSPL(ci)           ((ci)->ci_mtx_oldspl)
diff -r 6514b56ba031 -r cb57d4f75e8e sys/sys/rwlock.h
--- a/sys/sys/rwlock.h  Fri Feb 05 03:49:11 2010 +0000
+++ b/sys/sys/rwlock.h  Fri Feb 05 06:43:16 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rwlock.h,v 1.7 2009/04/19 08:36:04 ad Exp $    */
+/*     $NetBSD: rwlock.h,v 1.8 2010/02/05 06:43:17 skrll Exp $ */
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,15 +67,15 @@
  * WRITE_LOCKED bit is clear, then the owner field is actually a count of
  * the number of readers.  The rw_owner field is laid out like so:
  *
- *      N                    4       3        2        1      0
- *     +------------------------------------------------------+
- *     | owner or read count | debug | wrlock | wrwant | wait |
- *     +------------------------------------------------------+
+ *      N                    4        3        2        1        0
+ *     +---------------------------------------------------------+
+ *     | owner or read count | nodbug | wrlock | wrwant |  wait  |
+ *     +---------------------------------------------------------+
  */
 #define        RW_HAS_WAITERS          0x01UL  /* lock has waiters */
 #define        RW_WRITE_WANTED         0x02UL  /* >= 1 waiter is a writer */
 #define        RW_WRITE_LOCKED         0x04UL  /* lock is currently write locked */
-#define        RW_DEBUG                0x08UL  /* LOCKDEBUG enabled */
+#define        RW_NODEBUG              0x08UL  /* LOCKDEBUG disabled */
 
 #define        RW_READ_COUNT_SHIFT     4
 #define        RW_READ_INCR            (1UL << RW_READ_COUNT_SHIFT)



Home | Main Index | Thread Index | Old Index