+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
#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,
#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 */
(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.
#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
#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