| 54 | } pthread_barrier_t; |
| 55 | |
| 56 | static int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count) |
| 57 | { |
| 58 | (void) attr; |
| 59 | |
| 60 | if(count == 0) { |
| 61 | errno = EINVAL; |
| 62 | return -1; |
| 63 | } |
| 64 | |
| 65 | if(pthread_mutex_init(&barrier->mutex, 0) < 0) { |
| 66 | return -1; |
| 67 | } |
| 68 | if(pthread_cond_init(&barrier->cond, 0) < 0) { |
| 69 | pthread_mutex_destroy(&barrier->mutex); |
| 70 | return -1; |
| 71 | } |
| 72 | barrier->trip_count = count; |
| 73 | barrier->count = 0; |
| 74 | |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | static int pthread_barrier_destroy(pthread_barrier_t *barrier) |
| 79 | { |