1 #include "pthread_impl.h"
3 static void unlock(pthread_cond_t *c)
6 if (c->_c_leavers) __wake(&c->_c_bcast, -1, 0);
9 int pthread_cond_broadcast(pthread_cond_t *c)
14 if (!c->_c_waiters) return 0;
21 a_store(&c->_c_block, 0);
25 /* If mutex ptr is not available, simply wake all waiters. */
26 if (m == (void *)-1) {
28 __wake(&c->_c_block, -1, 0);
32 /* Move waiter count to the mutex */
35 a_fetch_add(&m->_m_waiters, w);
36 if (a_cas(&c->_c_waiters, w, 0) == w) break;
37 a_fetch_add(&m->_m_waiters, -w);
40 /* Perform the futex requeue, waking one waiter if and only if
41 * the calling thread does not hold the mutex. */
42 __syscall(SYS_futex, &c->_c_block, FUTEX_REQUEUE,
43 m->_m_lock!=pthread_self()->tid, INT_MAX, &m->_m_lock);