From ffe887ce85ac9549a689e213c980d83d117f1e0e Mon Sep 17 00:00:00 2001 From: Denis Ivaykin Date: Mon, 31 Dec 2018 12:04:34 +1100 Subject: [PATCH] eliminate high-latency IDIV CPU instruction --- libs/exanic/time.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libs/exanic/time.c b/libs/exanic/time.c index 353fb2a..b409ba6 100644 --- a/libs/exanic/time.c +++ b/libs/exanic/time.c @@ -71,9 +71,7 @@ void exanic_cycles_to_timespec(exanic_t *exanic, exanic_cycles_t cycles, int64_t exanic_cycles_to_ns(exanic_t *exanic, exanic_cycles_t cycles) { - struct timespec ts; - exanic_cycles_to_timespec(exanic, cycles, &ts); - return ts.tv_sec * NANOS_PER_SEC + ts.tv_nsec; + return cycles * NANOS_PER_SEC / exanic->tick_hz; } int64_t exanic_cycles_to_ps(exanic_t *exanic, exanic_cycles_t cycles,