From 307e1038b1ed9aa9274abd5ac7eb7086ad5e363b Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Testillano Date: Fri, 25 Jul 2014 16:03:00 +0200 Subject: [PATCH] hardwareClock fixed --- include/anna/core/functions.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/anna/core/functions.hpp b/include/anna/core/functions.hpp index 512499d..ebe12d8 100644 --- a/include/anna/core/functions.hpp +++ b/include/anna/core/functions.hpp @@ -441,7 +441,14 @@ struct functions { */ static Microsecond hardwareClock() throw() { timespec ts; - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts); + //clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts); // DONT works (original) + //clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); // DONT works + //clock_gettime(CLOCK_MONOTONIC, &ts); // works + // Note that CLOCK_MONOTONIC is subject to discontinuities from system time + // adjustment in Linux. CLOCK_MONOTONIC_RAW was defined to get around this + // (gets hardware time not adjusted by NTP). + clock_gettime(CLOCK_MONOTONIC_RAW, &ts); // works + Microsecond result((Microsecond::type_t)1000000 * ts.tv_sec + ts.tv_nsec / 1000); return result; } -- 2.20.1