mirror of
https://github.com/fluencelabs/musl
synced 2025-05-28 15:11:34 +00:00
to deal with the fact that the public headers may be used with pre-c99 compilers, __restrict is used in place of restrict, and defined appropriately for any supported compiler. we also avoid the form [restrict] since older versions of gcc rejected it due to a bug in the original c99 standard, and instead use the form *restrict.
17 lines
475 B
C
17 lines
475 B
C
#include "pthread_impl.h"
|
|
|
|
int pthread_rwlock_timedrdlock(pthread_rwlock_t *restrict rw, const struct timespec *restrict at)
|
|
{
|
|
int r, t;
|
|
while ((r=pthread_rwlock_tryrdlock(rw))==EBUSY) {
|
|
if (!(r=rw->_rw_lock) || (r&0x7fffffff)!=0x7fffffff) continue;
|
|
t = r | 0x80000000;
|
|
a_inc(&rw->_rw_waiters);
|
|
a_cas(&rw->_rw_lock, r, t);
|
|
r = __timedwait(&rw->_rw_lock, t, CLOCK_REALTIME, at, 0, 0, 0);
|
|
a_dec(&rw->_rw_waiters);
|
|
if (r && r != EINTR) return r;
|
|
}
|
|
return r;
|
|
}
|