summaryrefslogtreecommitdiff
path: root/pthread_barrier_init.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_barrier_init.c
parent8b14911744f58cbe3730703f3fcc41cd969fd0f3 (diff)
re-indentation, bug fixes, hooks for pre-emptive async cancelation
Diffstat (limited to 'pthread_barrier_init.c')
-rw-r--r--pthread_barrier_init.c31
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;
}
-