summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2004-06-30 21:21:56 +0000
committerKen Raeburn <raeburn@mit.edu>2004-06-30 21:21:56 +0000
commitf8d9ab540ba7e5195443ae4987f4e3bfbcfb71ca (patch)
tree249a1dd7d8361cd12a5efead69a46584893548db /src/include
parentc8aeb2ac933ccee9e583835b51ef2b235a904218 (diff)
downloadkrb5-f8d9ab540ba7e5195443ae4987f4e3bfbcfb71ca.tar.gz
krb5-f8d9ab540ba7e5195443ae4987f4e3bfbcfb71ca.tar.xz
krb5-f8d9ab540ba7e5195443ae4987f4e3bfbcfb71ca.zip
* 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. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16533 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/include')
-rw-r--r--src/include/ChangeLog7
-rw-r--r--src/include/k5-thread.h15
2 files changed, 22 insertions, 0 deletions
diff --git a/src/include/ChangeLog b/src/include/ChangeLog
index a29ede113..b19e00342 100644
--- a/src/include/ChangeLog
+++ b/src/include/ChangeLog
@@ -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
diff --git a/src/include/k5-thread.h b/src/include/k5-thread.h
index dcdd49283..4746f7d2c 100644
--- a/src/include/k5-thread.h
+++ b/src/include/k5-thread.h
@@ -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