X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=include%2Fanna%2Fcore%2Ffunctions.hpp;fp=include%2Fanna%2Fcore%2Ffunctions.hpp;h=ebe12d881ba19f2f22ec20ea3c2ed9af0ab906e6;hb=307e1038b1ed9aa9274abd5ac7eb7086ad5e363b;hp=512499d5f6da20d620847ea8754193ed5732e4eb;hpb=0425aba8476e68b396cc6df5f1ce4ee077aa0990;p=anna.git 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; }