1 #include "pthread_impl.h"
3 int pthread_mutex_unlock(pthread_mutex_t *m)
6 int waiters = m->_m_waiters;
10 if (m->_m_type != PTHREAD_MUTEX_NORMAL) {
13 self = pthread_self();
14 if ((m->_m_lock&0x1fffffff) != self->tid)
16 if ((m->_m_type&3) == PTHREAD_MUTEX_RECURSIVE && m->_m_count)
17 return m->_m_count--, 0;
18 if (m->_m_type >= 4) {
20 self->robust_list.pending = &m->_m_next;
21 *(void **)m->_m_prev = m->_m_next;
22 if (m->_m_next) ((void **)m->_m_next)[-1] = m->_m_prev;
25 cont = a_swap(&m->_m_lock, 0);
27 self->robust_list.pending = 0;
28 if (waiters || cont<0)
29 __wake(&m->_m_lock, 1, 0);