X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=inline;f=src%2Fthread%2Fpthread_mutex_consistent.c;h=27c74e5b6a0100ed18d826eeff3b994917160617;hb=2412638bb39eb799b2600393bbd71cca8ae96bb2;hp=baea0ff44ff9efd108355fb15b56dac45a79e806;hpb=bc09d58c0432a4eca5f6a1e536679a527f971116;p=musl diff --git a/src/thread/pthread_mutex_consistent.c b/src/thread/pthread_mutex_consistent.c index baea0ff4..27c74e5b 100644 --- a/src/thread/pthread_mutex_consistent.c +++ b/src/thread/pthread_mutex_consistent.c @@ -1,10 +1,14 @@ #include "pthread_impl.h" +#include "atomic.h" int pthread_mutex_consistent(pthread_mutex_t *m) { - if ((m->_m_type & 15) < 8) return EINVAL; - if ((m->_m_lock & 0x3fffffff) != __pthread_self()->tid) + int old = m->_m_lock; + int own = old & 0x3fffffff; + if (!(m->_m_type & 4) || !own || !(old & 0x40000000)) + return EINVAL; + if (own != __pthread_self()->tid) return EPERM; - m->_m_type -= 8; + a_and(&m->_m_lock, ~0x40000000); return 0; }