pthread_mutex_consistent.c 320 B

1234567891011121314
  1. #include "pthread_impl.h"
  2. #include "atomic.h"
  3. int pthread_mutex_consistent(pthread_mutex_t *m)
  4. {
  5. int old = m->_m_lock;
  6. int own = old & 0x3fffffff;
  7. if (!(m->_m_type & 4) || !own || !(old & 0x40000000))
  8. return EINVAL;
  9. if (own != __pthread_self()->tid)
  10. return EPERM;
  11. a_and(&m->_m_lock, ~0x40000000);
  12. return 0;
  13. }