next step making barrier self-sync'd destruction safe
[musl] / src / thread / pthread_barrier_destroy.c
1 #include "pthread_impl.h"
2
3 void __vm_lock(int), __vm_unlock(void);
4
5 int pthread_barrier_destroy(pthread_barrier_t *b)
6 {
7         if (b->_b_limit < 0) {
8                 if (b->_b_lock) {
9                         int v;
10                         a_or(&b->_b_lock, INT_MIN);
11                         while ((v = b->_b_lock) & INT_MAX)
12                                 __wait(&b->_b_lock, 0, v, 0);
13                 }
14                 __vm_lock(-1);
15                 __vm_unlock();
16         }
17         return 0;
18 }