diff options
author | Yann Ylavic <ylavic@apache.org> | 2017-04-25 15:17:56 +0000 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2017-04-25 15:17:56 +0000 |
commit | 265eeeb57774f0e2626f5b68b4e90a2cd056a699 (patch) | |
tree | 745ec3359f02c06a03fd192f85988deb36a8b882 /locks | |
parent | 3cae3e68b3aa6772f49879286810b6aa67ff8b15 (diff) | |
download | apr-265eeeb57774f0e2626f5b68b4e90a2cd056a699.tar.gz |
locks: unix: provide a macro helper for a pattern used several times.
No functional change.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1792621 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'locks')
-rw-r--r-- | locks/unix/proc_mutex.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/locks/unix/proc_mutex.c b/locks/unix/proc_mutex.c index 3dedbefca..5ed289b60 100644 --- a/locks/unix/proc_mutex.c +++ b/locks/unix/proc_mutex.c @@ -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; |