| OLD | NEW |
| 1 #include "pthread_impl.h" | 1 #include "pthread_impl.h" |
| 2 #include <threads.h> | 2 #include <threads.h> |
| 3 | 3 |
| 4 int __pthread_mutex_trylock(mtx_t *); | 4 int __pthread_mutex_trylock(mtx_t*); |
| 5 | 5 |
| 6 int mtx_trylock(mtx_t *m) | 6 int mtx_trylock(mtx_t* m) { |
| 7 { | 7 if (m->_m_type == PTHREAD_MUTEX_NORMAL) |
| 8 » if (m->_m_type == PTHREAD_MUTEX_NORMAL) | 8 return (a_cas(&m->_m_lock, 0, EBUSY) & EBUSY) ? thrd_busy : thrd_success; |
| 9 » » return (a_cas(&m->_m_lock, 0, EBUSY) & EBUSY) ? thrd_busy : thrd
_success; | |
| 10 | 9 |
| 11 » int ret = __pthread_mutex_trylock(m); | 10 int ret = __pthread_mutex_trylock(m); |
| 12 » switch (ret) { | 11 switch (ret) { |
| 13 » default: return thrd_error; | 12 default: |
| 14 » case 0: return thrd_success; | 13 return thrd_error; |
| 15 » case EBUSY: return thrd_busy; | 14 case 0: |
| 16 » } | 15 return thrd_success; |
| 16 case EBUSY: |
| 17 return thrd_busy; |
| 18 } |
| 17 } | 19 } |
| OLD | NEW |