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;
13 if (m->_m_type != PTHREAD_MUTEX_NORMAL) {
16 self = __pthread_self();
17 if ((m->_m_lock&0x1fffffff) != self->tid)
19 if ((m->_m_type&3) == PTHREAD_MUTEX_RECURSIVE && m->_m_count)
20 return m->_m_count--, 0;
21 if (m->_m_type >= 4) {
23 self->robust_list.pending = &m->_m_next;
24 *(void **)m->_m_prev = m->_m_next;
25 if (m->_m_next) ((void **)m->_m_next)[-1] = m->_m_prev;
29 cont = a_swap(&m->_m_lock, 0);
31 self->robust_list.pending = 0;
34 if (waiters || cont<0)
35 __wake(&m->_m_lock, 1, 0);