summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/thread/pthread_mutex_trylock.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/thread/pthread_mutex_trylock.c b/src/thread/pthread_mutex_trylock.c
index af421472..6fc604fe 100644
--- a/src/thread/pthread_mutex_trylock.c
+++ b/src/thread/pthread_mutex_trylock.c
@@ -5,7 +5,7 @@ int pthread_mutex_trylock(pthread_mutex_t *m)
int tid;
if (m->_m_type == PTHREAD_MUTEX_NORMAL)
- return -a_xchg(&m->_m_lock, 1) & EBUSY;
+ return (m->_m_lock || a_swap(&m->_m_lock, 1)) ? EBUSY : 0;
tid = pthread_self()->tid;