1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys: newlib: use xtimer_now64() for gettimeofday()

This commit is contained in:
Kaspar Schleiser 2015-11-17 12:50:48 +01:00
parent 4ad2689144
commit f23f3c0d2f

View File

@ -38,6 +38,12 @@
#include "uart_stdio.h"
#ifdef MODULE_XTIMER
#include <sys/time.h>
#include "div.h"
#include "xtimer.h"
#endif
/**
* @brief manage the heap
*/
@ -322,3 +328,14 @@ int _kill(pid_t pid, int sig)
errno = ESRCH; /* not implemented yet */
return -1;
}
#ifdef MODULE_XTIMER
int _gettimeofday_r(struct _reent *r, struct timeval *restrict tp, void *restrict tzp)
{
(void)tzp;
uint64_t now = xtimer_now64();
tp->tv_sec = div_u64_by_1000000(now);
tp->tv_usec = now - (tp->tv_sec * SEC_IN_USEC);
return 0;
}
#endif