1 #include "pthread_impl.h"
3 void __vm_lock_impl(int);
4 void __vm_unlock_impl(void);
6 int pthread_mutex_unlock(pthread_mutex_t *m)
9 int waiters = m->_m_waiters;
12 int type = m->_m_type & 15;
13 int priv = (m->_m_type & 128) ^ 128;
15 if (type != PTHREAD_MUTEX_NORMAL) {
18 self = __pthread_self();
19 if ((m->_m_lock&0x1fffffff) != self->tid)
21 if ((type&3) == PTHREAD_MUTEX_RECURSIVE && m->_m_count)
22 return m->_m_count--, 0;
25 self->robust_list.pending = &m->_m_next;
26 *(void **)m->_m_prev = m->_m_next;
27 if (m->_m_next) ((void **)m->_m_next)[-1] = m->_m_prev;
31 cont = a_swap(&m->_m_lock, 0);
33 self->robust_list.pending = 0;
36 if (waiters || cont<0)
37 __wake(&m->_m_lock, 1, priv);