summaryrefslogtreecommitdiff
path: root/src/threads/mtx_trylock.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/threads/mtx_trylock.c')
-rw-r--r--src/threads/mtx_trylock.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/threads/mtx_trylock.c b/src/threads/mtx_trylock.c
index c04741d6..cf2b6005 100644
--- a/src/threads/mtx_trylock.c
+++ b/src/threads/mtx_trylock.c
@@ -1,7 +1,19 @@
#include <threads.h>
#include <pthread.h>
+#include <errno.h>
int mtx_trylock(mtx_t *mtx)
{
- return pthread_mutex_trylock(mtx);
+ switch (pthread_mutex_trylock(mtx)) {
+ case 0:
+ return thrd_success;
+
+ case EBUSY:
+ return thrd_busy;
+
+ default:
+ break;
+ }
+
+ return thrd_error;
}