projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
in clock_getres, check for null pointer before storing result
[musl]
/
src
/
thread
/
pthread_mutex_consistent.c
diff --git
a/src/thread/pthread_mutex_consistent.c
b/src/thread/pthread_mutex_consistent.c
index
7dfb904
..
27c74e5
100644
(file)
--- a/
src/thread/pthread_mutex_consistent.c
+++ b/
src/thread/pthread_mutex_consistent.c
@@
-1,10
+1,14
@@
#include "pthread_impl.h"
#include "pthread_impl.h"
+#include "atomic.h"
int pthread_mutex_consistent(pthread_mutex_t *m)
{
int pthread_mutex_consistent(pthread_mutex_t *m)
{
- if (m->_m_type < 8) return EINVAL;
- if ((m->_m_lock & 0x3fffffff) != pthread_self()->tid)
+ int old = m->_m_lock;
+ int own = old & 0x3fffffff;
+ if (!(m->_m_type & 4) || !own || !(old & 0x40000000))
+ return EINVAL;
+ if (own != __pthread_self()->tid)
return EPERM;
return EPERM;
-
m->_m_type -= 8
;
+
a_and(&m->_m_lock, ~0x40000000)
;
return 0;
}
return 0;
}