From: Eduardo Ramos Testillano Date: Fri, 25 Jul 2014 14:03:00 +0000 (+0200) Subject: hardwareClock fixed X-Git-Tag: REFACTORING_TESTING_LIBRARY~244 X-Git-Url: https://git.teslayout.com/public/public/public/?a=commitdiff_plain;h=307e1038b1ed9aa9274abd5ac7eb7086ad5e363b;p=anna.git hardwareClock fixed --- 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; }