X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fthread%2Fpthread_mutex_lock.c;h=638d4b8697d843afcb3e035cf6d2222bfb952dee;hb=f70375df85d26235a45e74559afd69be59e5ff99;hp=82556141e463b8a9a0d7ea4f7dcacebf5c296bdd;hpb=d4f9e0b3642a81d07c95302cd9aa0dcaf7de1a05;p=musl diff --git a/src/thread/pthread_mutex_lock.c b/src/thread/pthread_mutex_lock.c index 82556141..638d4b86 100644 --- a/src/thread/pthread_mutex_lock.c +++ b/src/thread/pthread_mutex_lock.c @@ -1,13 +1,12 @@ #include "pthread_impl.h" -int pthread_mutex_lock(pthread_mutex_t *m) +int __pthread_mutex_lock(pthread_mutex_t *m) { - int r; - while ((r=pthread_mutex_trylock(m)) == EBUSY) { - if (m->_m_type == PTHREAD_MUTEX_ERRORCHECK - && m->_m_owner == pthread_self()->tid) - return EDEADLK; - __wait(&m->_m_lock, &m->_m_waiters, 1, 0); - } - return r; + if ((m->_m_type&15) == PTHREAD_MUTEX_NORMAL + && !a_cas(&m->_m_lock, 0, EBUSY)) + return 0; + + return __pthread_mutex_timedlock(m, 0); } + +weak_alias(__pthread_mutex_lock, pthread_mutex_lock);