diff options
author | rpj <rpj> | 2004-05-17 01:38:02 +0000 |
---|---|---|
committer | rpj <rpj> | 2004-05-17 01:38:02 +0000 |
commit | 771465fed0cf50ee2dd790723245fc091699c324 (patch) | |
tree | d8c18d095a33fe7c4564bd90c5f313bb9e4057dd /pthread_rwlock_init.c | |
parent | 8b14911744f58cbe3730703f3fcc41cd969fd0f3 (diff) |
re-indentation, bug fixes, hooks for pre-emptive async cancelation
Diffstat (limited to 'pthread_rwlock_init.c')
-rw-r--r-- | pthread_rwlock_init.c | 111 |
1 files changed, 56 insertions, 55 deletions
diff --git a/pthread_rwlock_init.c b/pthread_rwlock_init.c index 3a71ff2..8c27cac 100644 --- a/pthread_rwlock_init.c +++ b/pthread_rwlock_init.c @@ -41,69 +41,70 @@ #include "implement.h" int -pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) +pthread_rwlock_init (pthread_rwlock_t * rwlock, + const pthread_rwlockattr_t * attr) { - int result; - pthread_rwlock_t rwl = 0; - - if (rwlock == NULL) - { - return EINVAL; - } - - if (attr != NULL && *attr != NULL) - { - result = EINVAL; /* Not supported */ - goto DONE; - } - - rwl = (pthread_rwlock_t) calloc(1, sizeof(*rwl)); - - if (rwl == NULL) - { - result = ENOMEM; - goto DONE; - } - - rwl->nSharedAccessCount = 0; - rwl->nExclusiveAccessCount = 0; - rwl->nCompletedSharedAccessCount = 0; - - result = pthread_mutex_init(&rwl->mtxExclusiveAccess, NULL); - if (result != 0) - { - goto FAIL0; - } - - result = pthread_mutex_init(&rwl->mtxSharedAccessCompleted, NULL); - if (result != 0) - { - goto FAIL1; - } - - result = pthread_cond_init(&rwl->cndSharedAccessCompleted, NULL); - if (result != 0) - { - goto FAIL2; - } - - rwl->nMagic = PTW32_RWLOCK_MAGIC; - - result = 0; - goto DONE; + int result; + pthread_rwlock_t rwl = 0; + + if (rwlock == NULL) + { + return EINVAL; + } + + if (attr != NULL && *attr != NULL) + { + result = EINVAL; /* Not supported */ + goto DONE; + } + + rwl = (pthread_rwlock_t) calloc (1, sizeof (*rwl)); + + if (rwl == NULL) + { + result = ENOMEM; + goto DONE; + } + + rwl->nSharedAccessCount = 0; + rwl->nExclusiveAccessCount = 0; + rwl->nCompletedSharedAccessCount = 0; + + result = pthread_mutex_init (&rwl->mtxExclusiveAccess, NULL); + if (result != 0) + { + goto FAIL0; + } + + result = pthread_mutex_init (&rwl->mtxSharedAccessCompleted, NULL); + if (result != 0) + { + goto FAIL1; + } + + result = pthread_cond_init (&rwl->cndSharedAccessCompleted, NULL); + if (result != 0) + { + goto FAIL2; + } + + rwl->nMagic = PTW32_RWLOCK_MAGIC; + + result = 0; + goto DONE; FAIL2: - (void) pthread_mutex_destroy(&(rwl->mtxSharedAccessCompleted)); + (void) pthread_mutex_destroy (&(rwl->mtxSharedAccessCompleted)); FAIL1: - (void) pthread_mutex_destroy(&(rwl->mtxExclusiveAccess)); + (void) pthread_mutex_destroy (&(rwl->mtxExclusiveAccess)); FAIL0: - (void) free(rwl); - rwl = NULL; + (void) free (rwl); + rwl = NULL; DONE: - *rwlock = rwl; + *rwlock = rwl; - return result; + return result; } |