use a_swap rather than old name a_xchg
[oweals/musl.git] / src / thread / pthread_rwlock_trywrlock.c
index c029b87408081b30c9ddcc39ed637e3b5e47d8ae..bb3d3a992d1f3dd8a4919de9945b7fad75786a6a 100644 (file)
@@ -2,12 +2,6 @@
 
 int pthread_rwlock_trywrlock(pthread_rwlock_t *rw)
 {
-       if (a_xchg(&rw->__wrlock, 1))
-               return EAGAIN;
-       if (rw->__readers) {
-               a_store(&rw->__wrlock, 0);
-               return EAGAIN;
-       }
-       rw->__owner = pthread_self()->tid;
+       if (a_cas(&rw->_rw_lock, 0, 0x7fffffff)) return EBUSY;
        return 0;
 }