summaryrefslogtreecommitdiff
path: root/pthread_rwlock_unlock.c
diff options
context:
space:
mode:
authorrpj <rpj>2004-05-17 01:38:02 +0000
committerrpj <rpj>2004-05-17 01:38:02 +0000
commit771465fed0cf50ee2dd790723245fc091699c324 (patch)
treed8c18d095a33fe7c4564bd90c5f313bb9e4057dd /pthread_rwlock_unlock.c
parent8b14911744f58cbe3730703f3fcc41cd969fd0f3 (diff)
re-indentation, bug fixes, hooks for pre-emptive async cancelation
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);
}