posix: replace timex in pthread_rwlock
This commit is contained in:
parent
29d84a6865
commit
8253510f0b
@ -185,22 +185,16 @@ static int pthread_rwlock_timedlock(pthread_rwlock_t *rwlock,
|
|||||||
int incr_when_held,
|
int incr_when_held,
|
||||||
const struct timespec *abstime)
|
const struct timespec *abstime)
|
||||||
{
|
{
|
||||||
timex_t now, then;
|
uint64_t now = xtimer_now_usec64();
|
||||||
|
uint64_t then = ((uint64_t)abstime->tv_sec * US_PER_SEC) +
|
||||||
|
(abstime->tv_nsec / NS_PER_US);
|
||||||
|
|
||||||
then.seconds = abstime->tv_sec;
|
if ((then - now) <= 0) {
|
||||||
then.microseconds = abstime->tv_nsec / 1000u;
|
|
||||||
timex_normalize(&then);
|
|
||||||
|
|
||||||
xtimer_now_timex(&now);
|
|
||||||
|
|
||||||
if (timex_cmp(then, now) <= 0) {
|
|
||||||
return ETIMEDOUT;
|
return ETIMEDOUT;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
timex_t reltime = timex_sub(then, now);
|
|
||||||
|
|
||||||
xtimer_t timer;
|
xtimer_t timer;
|
||||||
xtimer_set_wakeup64(&timer, timex_uint64(reltime) , sched_active_pid);
|
xtimer_set_wakeup64(&timer, (then - now), sched_active_pid);
|
||||||
int result = pthread_rwlock_lock(rwlock, is_blocked, is_writer, incr_when_held, true);
|
int result = pthread_rwlock_lock(rwlock, is_blocked, is_writer, incr_when_held, true);
|
||||||
if (result != ETIMEDOUT) {
|
if (result != ETIMEDOUT) {
|
||||||
xtimer_remove(&timer);
|
xtimer_remove(&timer);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user