remove no-longer-needed unblocking of signals in pthread_create
[musl] / src / thread / pthread_mutex_unlock.c
1 #include "pthread_impl.h"
2
3 int pthread_mutex_unlock(pthread_mutex_t *m)
4 {
5         pthread_t self;
6         int waiters = m->_m_waiters;
7         int cont;
8         int robust = 0;
9
10         if (m->_m_type != PTHREAD_MUTEX_NORMAL) {
11                 if (!m->_m_lock)
12                         return EPERM;
13                 self = pthread_self();
14                 if ((m->_m_lock&0x1fffffff) != self->tid)
15                         return EPERM;
16                 if ((m->_m_type&3) == PTHREAD_MUTEX_RECURSIVE && m->_m_count)
17                         return m->_m_count--, 0;
18                 if (m->_m_type >= 4) {
19                         robust = 1;
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;
23                 }
24         }
25         cont = a_swap(&m->_m_lock, 0);
26         if (robust)
27                 self->robust_list.pending = 0;
28         if (waiters || cont<0)
29                 __wake(&m->_m_lock, 1, 0);
30         return 0;
31 }