1 #include "pthread_impl.h"
3 int pthread_mutex_trylock(pthread_mutex_t *m)
7 if (m->_m_type == PTHREAD_MUTEX_NORMAL)
8 return (m->_m_lock || a_swap(&m->_m_lock, 1)) ? EBUSY : 0;
10 tid = pthread_self()->tid;
12 if (m->_m_lock == tid && m->_m_type == PTHREAD_MUTEX_RECURSIVE) {
13 if ((unsigned)m->_m_count >= INT_MAX) return EAGAIN;
18 if (m->_m_lock || a_cas(&m->_m_lock, 0, tid)) return EBUSY;