From: Ken Raeburn Date: Thu, 1 Jul 2004 01:22:47 +0000 (+0000) Subject: * k5-thread.h (K5_MUTEX_DEBUG_INITIALIZER): Use current file and line. X-Git-Tag: krb5-1.4-beta1~260 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=005a5f45a7663d311192d69afe719f1c7765b4d9;p=krb5.git * k5-thread.h (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. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16535 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/include/ChangeLog b/src/include/ChangeLog index b19e00342..cf201aa71 100644 --- a/src/include/ChangeLog +++ b/src/include/ChangeLog @@ -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 diff --git a/src/include/k5-thread.h b/src/include/k5-thread.h index 4746f7d2c..a64f862d4 100644 --- a/src/include/k5-thread.h +++ b/src/include/k5-thread.h @@ -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 {