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