From 771465fed0cf50ee2dd790723245fc091699c324 Mon Sep 17 00:00:00 2001 From: rpj Date: Mon, 17 May 2004 01:38:02 +0000 Subject: re-indentation, bug fixes, hooks for pre-emptive async cancelation --- pthread_rwlock_unlock.c | 79 +++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 39 deletions(-) (limited to 'pthread_rwlock_unlock.c') diff --git a/pthread_rwlock_unlock.c b/pthread_rwlock_unlock.c index 2d00ab0..1d61408 100644 --- a/pthread_rwlock_unlock.c +++ b/pthread_rwlock_unlock.c @@ -41,53 +41,54 @@ #include "implement.h" int -pthread_rwlock_unlock(pthread_rwlock_t * rwlock) +pthread_rwlock_unlock (pthread_rwlock_t * rwlock) { - int result, result1; - pthread_rwlock_t rwl; + int result, result1; + pthread_rwlock_t rwl; - if (rwlock == NULL || *rwlock == NULL) - { - return(EINVAL); - } + if (rwlock == NULL || *rwlock == NULL) + { + return (EINVAL); + } - if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) - { - /* - * Assume any race condition here is harmless. - */ - return 0; - } + if (*rwlock == PTHREAD_RWLOCK_INITIALIZER) + { + /* + * Assume any race condition here is harmless. + */ + return 0; + } - rwl = *rwlock; + rwl = *rwlock; - if (rwl->nMagic != PTW32_RWLOCK_MAGIC) - { - return EINVAL; - } + if (rwl->nMagic != PTW32_RWLOCK_MAGIC) + { + return EINVAL; + } - if (rwl->nExclusiveAccessCount == 0) - { - if ((result = pthread_mutex_lock(&(rwl->mtxSharedAccessCompleted))) != 0) - { - return result; - } + if (rwl->nExclusiveAccessCount == 0) + { + if ((result = + pthread_mutex_lock (&(rwl->mtxSharedAccessCompleted))) != 0) + { + return result; + } - if (++rwl->nCompletedSharedAccessCount == 0) - { - result = pthread_cond_signal(&(rwl->cndSharedAccessCompleted)); - } + if (++rwl->nCompletedSharedAccessCount == 0) + { + result = pthread_cond_signal (&(rwl->cndSharedAccessCompleted)); + } - result1 = pthread_mutex_unlock(&(rwl->mtxSharedAccessCompleted)); - } - else - { - rwl->nExclusiveAccessCount--; + result1 = pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted)); + } + else + { + rwl->nExclusiveAccessCount--; - result = pthread_mutex_unlock(&(rwl->mtxSharedAccessCompleted)); - result1 = pthread_mutex_unlock(&(rwl->mtxExclusiveAccess)); + result = pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted)); + result1 = pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); - } - - return ((result != 0) ? result : result1); + } + + return ((result != 0) ? result : result1); } -- cgit v1.2.3