From 8b0472932c1cb8cb2cc46322b21c0c4e21848522 Mon Sep 17 00:00:00 2001 From: Jens Gustedt Date: Sat, 6 Sep 2014 22:07:22 -0400 Subject: add C11 mutex functions --- src/thread/mtx_lock.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/thread/mtx_lock.c (limited to 'src/thread/mtx_lock.c') diff --git a/src/thread/mtx_lock.c b/src/thread/mtx_lock.c new file mode 100644 index 00000000..5c2415c1 --- /dev/null +++ b/src/thread/mtx_lock.c @@ -0,0 +1,12 @@ +#include "pthread_impl.h" +#include + +int mtx_lock(mtx_t *m) +{ + if (m->_m_type == PTHREAD_MUTEX_NORMAL && !a_cas(&m->_m_lock, 0, EBUSY)) + return thrd_success; + /* Calling mtx_timedlock with a null pointer is an extension. + * It is convenient, here to avoid duplication of the logic + * for return values. */ + return mtx_timedlock(m, 0); +} -- cgit v1.2.3-70-g09d2