libi2ncommon: (gerd) add monotonic_clock_gettime_nano()
authorGerd v. Egidy <gerd.von.egidy@intra2net.com>
Thu, 28 Aug 2008 11:35:25 +0000 (11:35 +0000)
committerGerd v. Egidy <gerd.von.egidy@intra2net.com>
Thu, 28 Aug 2008 11:35:25 +0000 (11:35 +0000)
src/timefunc.cpp
src/timefunc.hxx

index 7713298..a9bc8df 100644 (file)
@@ -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.
index a3bc80b..9ceb753 100644 (file)
@@ -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);