From b7e17426691375762ed0ea1e5525364b53f1b952 Mon Sep 17 00:00:00 2001 From: Gerd v. Egidy Date: Thu, 28 Aug 2008 11:35:25 +0000 Subject: [PATCH] libi2ncommon: (gerd) add monotonic_clock_gettime_nano() --- src/timefunc.cpp | 20 ++++++++++++++++++++ src/timefunc.hxx | 1 + 2 files changed, 21 insertions(+), 0 deletions(-) diff --git a/src/timefunc.cpp b/src/timefunc.cpp index 7713298..a9bc8df 100644 --- a/src/timefunc.cpp +++ b/src/timefunc.cpp @@ -832,6 +832,26 @@ bool monotonic_clock_gettime(long int& seconds, long int& nano_seconds) /** * @brief fetches the value from the monotonic clock source. + * @return the time since system start in nanoseconds, 0 if read was unsuccessful + */ +long long monotonic_clock_gettime_nano() +{ + long int seconds; + long int nano_seconds; + long long nano=0; + + if (monotonic_clock_gettime(seconds,nano_seconds)) + { + nano=seconds; + nano*=1000000000LL; + nano+=nano_seconds; + } + + return nano; +} + +/** + * @brief fetches the value from the monotonic clock source. * @param[out] seconds the seconds. * @param[out] nano_seconds the nano seconds. * @return @a true if the clock was successfully read. diff --git a/src/timefunc.hxx b/src/timefunc.hxx index a3bc80b..9ceb753 100644 --- a/src/timefunc.hxx +++ b/src/timefunc.hxx @@ -312,6 +312,7 @@ class Intervals bool monotonic_clock_gettime(long int& seconds, long int& nano_seconds); +long long monotonic_clock_gettime_nano(); bool realtime_clock_gettime(long int& seconds, long int& nano_seconds); -- 1.7.1