From 047e434ef5fd5437a74f98f63c40a77a683f7f3f Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 17 Mar 2011 20:41:37 -0400 Subject: implement robust mutexes some of this code should be cleaned up, e.g. using macros for some of the bit flags, masks, etc. nonetheless, the code is believed to be working and correct at this point. --- src/thread/pthread_mutex_consistent.c | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/thread/pthread_mutex_consistent.c (limited to 'src/thread/pthread_mutex_consistent.c') diff --git a/src/thread/pthread_mutex_consistent.c b/src/thread/pthread_mutex_consistent.c new file mode 100644 index 00000000..7dfb904f --- /dev/null +++ b/src/thread/pthread_mutex_consistent.c @@ -0,0 +1,10 @@ +#include "pthread_impl.h" + +int pthread_mutex_consistent(pthread_mutex_t *m) +{ + if (m->_m_type < 8) return EINVAL; + if ((m->_m_lock & 0x3fffffff) != pthread_self()->tid) + return EPERM; + m->_m_type -= 8; + return 0; +} -- cgit v1.2.1