summaryrefslogtreecommitdiff
path: root/pthread_rwlock_unlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'pthread_rwlock_unlock.c')
-rw-r--r--pthread_rwlock_unlock.c79
1 files changed, 40 insertions, 39 deletions
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);
}