reorganize pthread data structures and move the definitions to alltypes.h
[musl] / src / thread / pthread_rwlock_trywrlock.c
1 #include "pthread_impl.h"
2
3 int pthread_rwlock_trywrlock(pthread_rwlock_t *rw)
4 {
5         if (a_xchg(&rw->_rw_wrlock, 1))
6                 return EAGAIN;
7         if (rw->_rw_readers) {
8                 a_store(&rw->_rw_wrlock, 0);
9                 return EAGAIN;
10         }
11         rw->_rw_owner = pthread_self()->tid;
12         return 0;
13 }