diff options
Diffstat (limited to 'pthread_barrier_init.c')
-rw-r--r-- | pthread_barrier_init.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/pthread_barrier_init.c b/pthread_barrier_init.c index d8d7877..3603ac3 100644 --- a/pthread_barrier_init.c +++ b/pthread_barrier_init.c @@ -39,9 +39,8 @@ int -pthread_barrier_init(pthread_barrier_t * barrier, - const pthread_barrierattr_t * attr, - unsigned int count) +pthread_barrier_init (pthread_barrier_t * barrier, + const pthread_barrierattr_t * attr, unsigned int count) { pthread_barrier_t b; @@ -50,11 +49,10 @@ pthread_barrier_init(pthread_barrier_t * barrier, return EINVAL; } - if (NULL != (b = (pthread_barrier_t) calloc(1, sizeof(*b)))) + if (NULL != (b = (pthread_barrier_t) calloc (1, sizeof (*b)))) { b->pshared = (attr != NULL && *attr != NULL - ? (*attr)->pshared - : PTHREAD_PROCESS_PRIVATE); + ? (*attr)->pshared : PTHREAD_PROCESS_PRIVATE); b->nCurrentBarrierHeight = b->nInitialBarrierHeight = count; b->iStep = 0; @@ -67,18 +65,17 @@ pthread_barrier_init(pthread_barrier_t * barrier, * If some threads decide to eat their lunch before moving * then the other threads have to wait. */ - if (0 == sem_init(&(b->semBarrierBreeched[0]), b->pshared, 0)) - { - if (0 == sem_init(&(b->semBarrierBreeched[1]), b->pshared, 0)) - { - *barrier = b; - return 0; - } - (void) sem_destroy(&(b->semBarrierBreeched[0])); - } - (void) free(b); + if (0 == sem_init (&(b->semBarrierBreeched[0]), b->pshared, 0)) + { + if (0 == sem_init (&(b->semBarrierBreeched[1]), b->pshared, 0)) + { + *barrier = b; + return 0; + } + (void) sem_destroy (&(b->semBarrierBreeched[0])); + } + (void) free (b); } return ENOMEM; } - |