1 #include "pthread_impl.h"
4 int __pthread_mutex_trylock(mtx_t *);
6 int mtx_trylock(mtx_t *m)
8 if (m->_m_type == PTHREAD_MUTEX_NORMAL)
9 return (a_cas(&m->_m_lock, 0, EBUSY) & EBUSY) ? thrd_busy : thrd_success;
11 int ret = __pthread_mutex_trylock(m);
13 default: return thrd_error;
14 case 0: return thrd_success;
15 case EBUSY: return thrd_busy;