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;
11 int type = m->_m_type & 15;
12 int priv = (m->_m_type & 128) ^ 128;
14 if (type != PTHREAD_MUTEX_NORMAL) {
17 self = __pthread_self();
18 if ((m->_m_lock&0x7fffffff) != self->tid)
20 if ((type&3) == PTHREAD_MUTEX_RECURSIVE && m->_m_count)
21 return m->_m_count--, 0;
23 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;
29 cont = a_swap(&m->_m_lock, 0);
30 if (type != PTHREAD_MUTEX_NORMAL && !priv) {
31 self->robust_list.pending = 0;
34 if (waiters || cont<0)
35 __wake(&m->_m_lock, 1, priv);