locks: unix: provide a macro helper for a pattern used several times.
No functional change.
@@ -491,6 +491,8 @@ typedef struct {
apr_uint32_t cond_num_waiters;
#define proc_pthread_mutex_cond_num_waiters(m) \
(proc_pthread_cast(m)->cond_num_waiters)
+#define proc_pthread_mutex_is_cond(m) \
+ ((m)->pthread_refcounting && proc_pthread_mutex_cond_locked(m) != -1)
#endif /* APR_USE_PROC_PTHREAD_MUTEX_COND */
apr_uint32_t refcount;
#define proc_pthread_mutex_refcount(m) \
@@ -521,8 +523,7 @@ static apr_status_t proc_pthread_mutex_unref(void *mutex_)
apr_status_t rv;
#if APR_USE_PROC_PTHREAD_MUTEX_COND
- if (mutex->pthread_refcounting &&
- proc_pthread_mutex_cond_locked(mutex) != -1) {
+ if (proc_pthread_mutex_is_cond(mutex)) {
mutex->curr_locked = 0;
}
else
@@ -537,8 +538,7 @@ static apr_status_t proc_pthread_mutex_unref(void *mutex_)
}
if (!proc_pthread_mutex_dec(mutex)) {
#if APR_USE_PROC_PTHREAD_MUTEX_COND
- if (mutex->pthread_refcounting &&
- proc_pthread_mutex_cond_locked(mutex) != -1 &&
+ if (proc_pthread_mutex_is_cond(mutex) &&
(rv = pthread_cond_destroy(&proc_pthread_mutex_cond(mutex)))) {
#ifdef HAVE_ZOS_PTHREADS
rv = errno;
@@ -684,8 +684,7 @@ static apr_status_t proc_mutex_pthread_acquire_ex(apr_proc_mutex_t *mutex,
apr_status_t rv;
#if APR_USE_PROC_PTHREAD_MUTEX_COND
- if (mutex->pthread_refcounting &&
- proc_pthread_mutex_cond_locked(mutex) != -1) {
+ if (proc_pthread_mutex_is_cond(mutex)) {
if ((rv = pthread_mutex_lock(&proc_pthread_mutex(mutex)))) {
#ifdef HAVE_ZOS_PTHREADS
rv = errno;
@@ -835,8 +834,7 @@ static apr_status_t proc_mutex_pthread_release(apr_proc_mutex_t *mutex)
apr_status_t rv;
#if APR_USE_PROC_PTHREAD_MUTEX_COND
- if (mutex->pthread_refcounting &&
- proc_pthread_mutex_cond_locked(mutex) != -1) {
+ if (proc_pthread_mutex_is_cond(mutex)) {
if ((rv = pthread_mutex_lock(&proc_pthread_mutex(mutex)))) {
#ifdef HAVE_ZOS_PTHREADS
rv = errno;
