* k5-thread.h (k5_pthread_assert_locked): Only call pthread_equal if
authorKen Raeburn <raeburn@mit.edu>
Fri, 14 Jan 2005 05:03:48 +0000 (05:03 +0000)
committerKen Raeburn <raeburn@mit.edu>
Fri, 14 Jan 2005 05:03:48 +0000 (05:03 +0000)
thread support is loaded.
(k5_pthread_mutex_unlock): Use k5_pthread_assert_locked instead of
duplicating it.

ticket: 2878
status: open

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

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

index 95d117b8cb9e1c57535f7ca5568fa40e325f1fba..0c2ba2c8a9885a2bceabc19f68934feabade8d6e 100644 (file)
@@ -4,7 +4,7 @@
        if DEBUG_THREADS.
        (k5_pthread_mutex_lock, k5_pthread_mutex_unlock,
        k5_pthread_assert_locked): New macros/functions; if DEBUG_THREADS,
-       set or check the owner field.
+       and thread support loaded, set or check the owner field.
        (K5_OS_MUTEX_PARTIAL_INITIALIZER) [pthread case && DEBUG_THREADS]:
        Set the owner field.  If PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
        is defined, use it.
index 32b793d376a6f76483d99e18e57ac8fda38b1c39..88a14caabdc1cd8d24dae66551662e655f5fcfa7 100644 (file)
@@ -489,11 +489,13 @@ k5_pthread_mutex_lock(k5_os_mutex *m)
     return 0;
 }
 # endif
-# define k5_pthread_assert_locked(M) \
-       (assert(pthread_equal((M)->owner, pthread_self())))
-# define k5_pthread_mutex_unlock(M) \
-       (assert(pthread_equal((M)->owner, pthread_self())), \
-        (M)->owner = (pthread_t) 0,                        \
+# define k5_pthread_assert_locked(M)                           \
+       (K5_PTHREADS_LOADED                                     \
+        ? assert(pthread_equal((M)->owner, pthread_self()))    \
+        : (void)0)
+# define k5_pthread_mutex_unlock(M)    \
+       (k5_pthread_assert_locked(M),   \
+        (M)->owner = (pthread_t) 0,    \
         pthread_mutex_unlock(&(M)->p))
 #else
 # define k5_pthread_mutex_lock(M) pthread_mutex_lock(&(M)->p)