* k5-thread.h (K5_MUTEX_DEBUG_INITIALIZER): Use current file and line.
authorKen Raeburn <raeburn@mit.edu>
Thu, 1 Jul 2004 01:22:47 +0000 (01:22 +0000)
committerKen Raeburn <raeburn@mit.edu>
Thu, 1 Jul 2004 01:22:47 +0000 (01:22 +0000)
(k5_mutex_debug_finish_init, k5_mutex_debug_init, k5_mutex_debug_destroy): Save
current file and line.
(k5_mutex_debug_lock): Verify that the lock was unlocked before, and set the
state to locked.
(k5_mutex_debug_unlock): Verify that the mutex was locked before, and set the
state to unlocked.
(k5_debug_assert_locked, k5_debug_assert_unlocked): Use
k5_mutex_debug_check_init instead of checking initialized==1.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16535 dc483132-0cff-0310-8789-dd5450dbe970

src/include/ChangeLog
src/include/k5-thread.h

index b19e00342d9face00eac4a0c51b0ed0ecaaca973..cf201aa71c784cce0c44eb26fc3533236f4e1d82 100644 (file)
@@ -4,6 +4,15 @@
        New macros.
        (k5_assert_locked, k5_assert_unlocked): New macros, may or may not
        call the debug macros.
+       (K5_MUTEX_DEBUG_INITIALIZER): Use current file and line.
+       (k5_mutex_debug_finish_init, k5_mutex_debug_init,
+       k5_mutex_debug_destroy): Save current file and line.
+       (k5_mutex_debug_lock): Verify that the lock was unlocked before,
+       and set the state to locked.
+       (k5_mutex_debug_unlock): Verify that the mutex was locked before,
+       and set the state to unlocked.
+       (k5_debug_assert_locked, k5_debug_assert_unlocked): Use
+       k5_mutex_debug_check_init instead of checking initialized==1.
 
 2004-06-25  Ken Raeburn  <raeburn@mit.edu>
 
index 4746f7d2ca7f42f9b85bc30ee6f1679d6d78525d..a64f862d4e9f52af682c251b422da82270366c15 100644 (file)
@@ -156,16 +156,18 @@ typedef struct {
     short initialized;
     enum k5_mutex_debug_states locked;
 } k5_mutex_debug_info;
-#define K5_MUTEX_DEBUG_INITIALIZER     { 0, 0, 2, K5_MUTEX_DEBUG_UNLOCKED }
-#define k5_mutex_debug_finish_init(M)          \
-       (assert((M)->initialized == 2), (M)->initialized = 1, 0)
+#define K5_MUTEX_DEBUG_INITIALIZER     { __FILE__, __LINE__, 2, K5_MUTEX_DEBUG_UNLOCKED }
+#define k5_mutex_debug_finish_init(M)                          \
+       (assert((M)->initialized == 2), (M)->initialized = 1,   \
+        k5_mutex_debug_update_loc(M), 0)
 #define k5_mutex_debug_init(M)                 \
        ((M)->initialized = 1,                  \
         (M)->locked = K5_MUTEX_DEBUG_UNLOCKED, \
-        (M)->lineno = 0, (M)->filename = 0, 0)
+        k5_mutex_debug_update_loc(M), 0)
 #define k5_mutex_debug_destroy(M)                              \
        (assert((M)->initialized == 1                           \
                && (M)->locked == K5_MUTEX_DEBUG_UNLOCKED),     \
+        k5_mutex_debug_update_loc(M),                          \
         (M)->initialized = 0)
 #define k5_mutex_debug_check_init(M)           \
        (assert((M)->initialized != 2),         \
@@ -174,17 +176,19 @@ typedef struct {
 #define k5_mutex_debug_update_loc(M)                           \
        ((M)->lineno = __LINE__, (M)->filename = __FILE__)
 #define k5_mutex_debug_lock(M)                                 \
-       (k5_mutex_debug_check_init(M),                          \
-        k5_mutex_debug_update_loc(M), 0)
+       (k5_debug_assert_unlocked(M),                           \
+        k5_mutex_debug_update_loc(M),                          \
+        (M)->locked = K5_MUTEX_DEBUG_LOCKED, 0)
 #define k5_mutex_debug_unlock(M)                               \
-       (k5_mutex_debug_check_init(M),                          \
-        k5_mutex_debug_update_loc(M), 0)
+       (k5_debug_assert_locked(M),                             \
+        k5_mutex_debug_update_loc(M),                          \
+        (M)->locked = K5_MUTEX_DEBUG_UNLOCKED, 0)
 #define k5_debug_assert_locked(M)                              \
-       (assert((M)->initialized == 1),                         \
+       (k5_mutex_debug_check_init(M),                          \
         assert((M)->locked != K5_MUTEX_DEBUG_UNLOCKED),        \
         assert((M)->locked == K5_MUTEX_DEBUG_LOCKED), 0)
 #define k5_debug_assert_unlocked(M)                            \
-       (assert((M)->initialized == 1),                         \
+       (k5_mutex_debug_check_init(M),                          \
         assert((M)->locked == K5_MUTEX_DEBUG_UNLOCKED), 0)
 
 typedef enum {