diff options
Diffstat (limited to 'libc-top-half/musl/src/thread/pthread_rwlock_tryrdlock.c')
-rw-r--r-- | libc-top-half/musl/src/thread/pthread_rwlock_tryrdlock.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/thread/pthread_rwlock_tryrdlock.c b/libc-top-half/musl/src/thread/pthread_rwlock_tryrdlock.c new file mode 100644 index 0000000..c13bc9c --- /dev/null +++ b/libc-top-half/musl/src/thread/pthread_rwlock_tryrdlock.c @@ -0,0 +1,15 @@ +#include "pthread_impl.h" + +int __pthread_rwlock_tryrdlock(pthread_rwlock_t *rw) +{ + int val, cnt; + do { + val = rw->_rw_lock; + cnt = val & 0x7fffffff; + if (cnt == 0x7fffffff) return EBUSY; + if (cnt == 0x7ffffffe) return EAGAIN; + } while (a_cas(&rw->_rw_lock, val, val+1) != val); + return 0; +} + +weak_alias(__pthread_rwlock_tryrdlock, pthread_rwlock_tryrdlock); |