musl/src/thread/pthread_mutex_unlock.c

16 lines
349 B
C
Raw Normal View History

2011-02-12 00:22:29 -05:00
#include "pthread_impl.h"
int pthread_mutex_unlock(pthread_mutex_t *m)
{
if (m->_m_type != PTHREAD_MUTEX_NORMAL) {
if (!m->_m_lock || m->_m_lock != __pthread_self()->tid)
return EPERM;
if (m->_m_type == PTHREAD_MUTEX_RECURSIVE && --m->_m_count)
return 0;
2011-02-12 00:22:29 -05:00
}
m->_m_lock = 0;
if (m->_m_waiters) __wake(&m->_m_lock, 1, 0);
2011-02-12 00:22:29 -05:00
return 0;
}