synccall: add separate exit_sem to fix thread release logic bug
[musl.git] / src / thread / pthread_mutex_consistent.c
blob27c74e5b6a0100ed18d826eeff3b994917160617
1 #include "pthread_impl.h"
2 #include "atomic.h"
4 int pthread_mutex_consistent(pthread_mutex_t *m)
6 int old = m->_m_lock;
7 int own = old & 0x3fffffff;
8 if (!(m->_m_type & 4) || !own || !(old & 0x40000000))
9 return EINVAL;
10 if (own != __pthread_self()->tid)
11 return EPERM;
12 a_and(&m->_m_lock, ~0x40000000);
13 return 0;