summaryrefslogtreecommitdiff
path: root/nptl/pthread_barrier_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/pthread_barrier_init.c')
-rw-r--r--nptl/pthread_barrier_init.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/nptl/pthread_barrier_init.c b/nptl/pthread_barrier_init.c
index 8fe15ecba5..822e17e495 100644
--- a/nptl/pthread_barrier_init.c
+++ b/nptl/pthread_barrier_init.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -18,7 +18,7 @@
#include <errno.h>
#include "pthreadP.h"
-#include <lowlevellock.h>
+#include <futex-internal.h>
#include <kernel-features.h>
@@ -29,34 +29,31 @@ static const struct pthread_barrierattr default_barrierattr =
int
-__pthread_barrier_init (barrier, attr, count)
- 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)
{
struct pthread_barrier *ibarrier;
- /* XXX EINVAL is not specified by POSIX as a possible error code. */
- if (__glibc_unlikely (count == 0))
+ /* XXX EINVAL is not specified by POSIX as a possible error code for COUNT
+ being too large. See pthread_barrier_wait for the reason for the
+ comparison with BARRIER_IN_THRESHOLD. */
+ if (__glibc_unlikely (count == 0 || count >= BARRIER_IN_THRESHOLD))
return EINVAL;
const struct pthread_barrierattr *iattr
= (attr != NULL
- ? iattr = (struct pthread_barrierattr *) attr
+ ? (struct pthread_barrierattr *) attr
: &default_barrierattr);
ibarrier = (struct pthread_barrier *) barrier;
/* Initialize the individual fields. */
- ibarrier->lock = LLL_LOCK_INITIALIZER;
- ibarrier->left = count;
- ibarrier->init_count = count;
- ibarrier->curr_event = 0;
-
- /* XXX Don't use FUTEX_SHARED or FUTEX_PRIVATE as long as there are still
- assembly implementations that expect the value determined below. */
- ibarrier->private = (iattr->pshared != PTHREAD_PROCESS_PRIVATE
- ? 0 : FUTEX_PRIVATE_FLAG);
+ ibarrier->in = 0;
+ ibarrier->out = 0;
+ ibarrier->count = count;
+ ibarrier->current_round = 0;
+ ibarrier->shared = (iattr->pshared == PTHREAD_PROCESS_PRIVATE
+ ? FUTEX_PRIVATE : FUTEX_SHARED);
return 0;
}