diff options
Diffstat (limited to 'ports/unix/unix_mphal.c')
| -rw-r--r-- | ports/unix/unix_mphal.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ports/unix/unix_mphal.c b/ports/unix/unix_mphal.c index f43067f64..3fe2fa9fe 100644 --- a/ports/unix/unix_mphal.c +++ b/ports/unix/unix_mphal.c @@ -216,6 +216,7 @@ mp_uint_t mp_hal_ticks_us(void) { } uint64_t mp_hal_time_ns(void) { - time_t now = time(NULL); - return (uint64_t)now * 1000000000ULL; + struct timeval tv; + gettimeofday(&tv, NULL); + return (uint64_t)tv.tv_sec * 1000000000ULL + (uint64_t)tv.tv_usec * 1000ULL; } |
