| 1 | #include "pthread_impl.h" |
| 2 | |
| 3 | int __pthread_rwlock_tryrdlock(pthread_rwlock_t *rw) |
| 4 | { |
| 5 | 	int val, cnt; |
| 6 | 	do { |
| 7 | 		val = rw->_rw_lock; |
| 8 | 		cnt = val & 0x7fffffff; |
| 9 | 		if (cnt == 0x7fffffff) return EBUSY; |
| 10 | 		if (cnt == 0x7ffffffe) return EAGAIN; |
| 11 | 	} while (a_cas(&rw->_rw_lock, val, val+1) != val); |
| 12 | 	return 0; |
| 13 | } |
| 14 | |
| 15 | weak_alias(__pthread_rwlock_tryrdlock, pthread_rwlock_tryrdlock); |