mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
posix: replace timex in pthread_cond
This commit is contained in:
parent
30be4f7673
commit
29d84a6865
@ -120,15 +120,12 @@ int pthread_cond_wait(pthread_cond_t *cond, mutex_t *mutex)
|
|||||||
|
|
||||||
int pthread_cond_timedwait(pthread_cond_t *cond, mutex_t *mutex, const struct timespec *abstime)
|
int pthread_cond_timedwait(pthread_cond_t *cond, mutex_t *mutex, const struct timespec *abstime)
|
||||||
{
|
{
|
||||||
timex_t now, then, reltime;
|
uint64_t now = xtimer_now_usec64();
|
||||||
|
uint64_t then = ((uint64_t)abstime->tv_sec * US_PER_SEC) +
|
||||||
xtimer_now_timex(&now);
|
(abstime->tv_nsec / NS_PER_US);
|
||||||
then.seconds = abstime->tv_sec;
|
|
||||||
then.microseconds = abstime->tv_nsec / 1000u;
|
|
||||||
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_cond_wait(cond, mutex);
|
int result = pthread_cond_wait(cond, mutex);
|
||||||
xtimer_remove(&timer);
|
xtimer_remove(&timer);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user