* k5-thread.h (k5_debug_assert_locked, k5_debug_assert_unlocked): New macros.
authorKen Raeburn <raeburn@mit.edu>
Wed, 30 Jun 2004 21:21:56 +0000 (21:21 +0000)
committerKen Raeburn <raeburn@mit.edu>
Wed, 30 Jun 2004 21:21:56 +0000 (21:21 +0000)
(k5_assert_locked, k5_assert_unlocked): New macros, may or may not call the
debug macros.

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

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

index a29ede113446c67ab3468722ce305b11b57daf60..b19e00342d9face00eac4a0c51b0ed0ecaaca973 100644 (file)
@@ -1,3 +1,10 @@
+2004-06-30  Ken Raeburn  <raeburn@mit.edu>
+
+       * k5-thread.h (k5_debug_assert_locked, k5_debug_assert_unlocked):
+       New macros.
+       (k5_assert_locked, k5_assert_unlocked): New macros, may or may not
+       call the debug macros.
+
 2004-06-25  Ken Raeburn  <raeburn@mit.edu>
 
        * k5-platform.h (JOIN4, JOIN4_2, JOIN3, JOIN3_2): Unused macros
index dcdd49283bc111bf31418082b1e41072b26b4685..4746f7d2ca7f42f9b85bc30ee6f1679d6d78525d 100644 (file)
@@ -179,6 +179,13 @@ typedef struct {
 #define k5_mutex_debug_unlock(M)                               \
        (k5_mutex_debug_check_init(M),                          \
         k5_mutex_debug_update_loc(M), 0)
+#define k5_debug_assert_locked(M)                              \
+       (assert((M)->initialized == 1),                         \
+        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),                         \
+        assert((M)->locked == K5_MUTEX_DEBUG_UNLOCKED), 0)
 
 typedef enum {
     K5_KEY_COM_ERR,
@@ -207,6 +214,8 @@ typedef pthread_mutex_t k5_mutex_t;
 #define k5_mutex_destroy(M)    pthread_mutex_destroy(M)
 #define k5_mutex_lock(M)       pthread_mutex_lock(M)
 #define k5_mutex_unlock(M)     pthread_mutex_unlock(M)
+#define k5_assert_locked(M)    (0)
+#define k5_assert_unlocked(M)  (0)
 
 #else /* DEBUG_THREADS */
 
@@ -236,6 +245,8 @@ typedef struct {
                                 (M)->debug.locked = K5_MUTEX_DEBUG_UNLOCKED, \
                                 assert(0==pthread_mutex_unlock(&(M)->lock)), \
                                 0)
+#define k5_assert_locked(M)    (k5_debug_assert_locked(&(M)->debug))
+#define k5_assert_unlocked(M)  (k5_debug_assert_unlocked(&(M)->debug))
 
 #if defined(__mips) && defined(__sgi) && (defined(_SYSTYPE_SVR4) || defined(__SYSTYPE_SVR4__))
 /* IRIX 6.5 stub pthread support in libc is really annoying.
@@ -332,6 +343,8 @@ typedef pthread_once_t k5_once_t;
 #define k5_mutex_destroy       k5_mutex_debug_destroy
 #define k5_mutex_lock          k5_mutex_debug_lock
 #define k5_mutex_unlock                k5_mutex_debug_unlock
+#define k5_assert_locked       k5_debug_assert_locked
+#define k5_assert_unlocked     k5_debug_assert_unlocked
 
 #define k5_once_t      unsigned char
 #define K5_ONCE_INIT   2
@@ -350,6 +363,8 @@ typedef char k5_mutex_t;
 #define k5_mutex_destroy(M)    (0)
 #define k5_mutex_lock(M)       (0)
 #define k5_mutex_unlock(M)     (0)
+#define k5_assert_locked(M)    (0)
+#define k5_assert_unlocked(M)  (0)
 
 #define k5_once_t      unsigned char
 #define K5_ONCE_INIT   2