]> git.proxmox.com Git - wasi-libc.git/blobdiff - libc-top-half/musl/src/thread/pthread_mutex_consistent.c
Update to musl 1.1.22.
[wasi-libc.git] / libc-top-half / musl / src / thread / pthread_mutex_consistent.c
index 96b83b52851b202aed9f817447129792833d1da1..27c74e5b6a0100ed18d826eeff3b994917160617 100644 (file)
@@ -1,10 +1,14 @@
 #include "pthread_impl.h"
+#include "atomic.h"
 
 int pthread_mutex_consistent(pthread_mutex_t *m)
 {
-       if (!(m->_m_type & 8)) return EINVAL;
-       if ((m->_m_lock & 0x7fffffff) != __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 &= ~8U;
+       a_and(&m->_m_lock, ~0x40000000);
        return 0;
 }