1 |
/* pthread_barrier_init. Generic version. |
/* pthread_barrier_init. Generic version. |
2 |
Copyright (C) 2002 Free Software Foundation, Inc. |
Copyright (C) 2002, 2005 Free Software Foundation, Inc. |
3 |
This file is part of the GNU C Library. |
This file is part of the GNU C Library. |
4 |
|
|
5 |
The GNU C Library is free software; you can redistribute it and/or |
The GNU C Library is free software; you can redistribute it and/or |
28 |
const pthread_barrierattr_t *attr, |
const pthread_barrierattr_t *attr, |
29 |
unsigned count) |
unsigned count) |
30 |
{ |
{ |
|
assert (attr->pshared == PTHREAD_PROCESS_PRIVATE); |
|
|
|
|
31 |
if (count == 0) |
if (count == 0) |
32 |
return EINVAL; |
return EINVAL; |
33 |
|
|
37 |
barrier->pending = count; |
barrier->pending = count; |
38 |
barrier->count = count; |
barrier->count = count; |
39 |
|
|
40 |
|
if (! attr |
41 |
|
|| memcmp (attr, &__pthread_default_barrierattr, sizeof (*attr) == 0)) |
42 |
|
/* Use the default attributes. */ |
43 |
|
return 0; |
44 |
|
|
45 |
|
/* Non-default attributes. */ |
46 |
|
|
47 |
|
barrier->attr = malloc (sizeof *attr); |
48 |
|
if (! barrier->attr) |
49 |
|
return ENOMEM; |
50 |
|
|
51 |
|
*barrier->attr = *attr; |
52 |
return 0; |
return 0; |
53 |
} |
} |