make getaddrinfo support SOCK_RAW and other socket types
[musl] / src / thread / pthread_mutex_trylock.c
index 31587e1..cb93565 100644 (file)
@@ -22,7 +22,10 @@ int __pthread_mutex_trylock_owner(pthread_mutex_t *m)
        }
        if (own == 0x40000000) return ENOTRECOVERABLE;
 
-       self->robust_list.pending = &m->_m_next;
+       if (m->_m_type & 128) {
+               if (m->_m_waiters) tid |= 0x80000000;
+               self->robust_list.pending = &m->_m_next;
+       }
 
        if ((own && (!(own & 0x40000000) || !(type & 4)))
            || a_cas(&m->_m_lock, old, tid) != old) {
@@ -47,9 +50,11 @@ int __pthread_mutex_trylock_owner(pthread_mutex_t *m)
        return 0;
 }
 
-int pthread_mutex_trylock(pthread_mutex_t *m)
+int __pthread_mutex_trylock(pthread_mutex_t *m)
 {
        if ((m->_m_type&15) == PTHREAD_MUTEX_NORMAL)
                return a_cas(&m->_m_lock, 0, EBUSY) & EBUSY;
        return __pthread_mutex_trylock_owner(m);
 }
+
+weak_alias(__pthread_mutex_trylock, pthread_mutex_trylock);