]> rtime.felk.cvut.cz Git - orte.git/blobdiff - orte/liborte/htimerNtp.c
Use CLOCK_MONOTONIC rather than CLOCK_REALTIME
[orte.git] / orte / liborte / htimerNtp.c
index bf73b1de32846a7fe193f95b34a2fd358fcb40ed..57facaf6a6337015e49a5aecba21a095676209d4 100644 (file)
@@ -260,18 +260,26 @@ getActualNtpTime(void)
 {
   NtpTime               result;
 
+#if HAVE_DECL_CLOCK_MONOTONIC
+  struct timespec       time;
+
+  clock_gettime(CLOCK_MONOTONIC, &time);
+  /* FIXME: Introduce NtpTimeAssembFromNs ather than using division. */
+  NtpTimeAssembFromUs(result, time.tv_sec, time.tv_nsec / 1000);
+#else /* !HAVE_DECL_CLOCK_MONOTONIC */
 #ifndef CONFIG_ORTE_RT
   struct timeval        time;
 
   gettimeofday(&time, NULL);
   NtpTimeAssembFromUs(result, time.tv_sec, time.tv_usec);
   NtpTimeAssembFromUs(result, time.tv_sec, time.tv_usec);
-#else
+#else /* !CONFIG_ORTE_RT */
   struct timespec        time;
 
   clock_gettime(CLOCK_REALTIME, &time);
   time.tv_nsec /= 1000;  //conver to us
   NtpTimeAssembFromUs(result, time.tv_sec, time.tv_nsec);
-#endif
+#endif /* CONFIG_ORTE_RT */
+#endif /* HAVE_DECL_CLOCK_MONOTONIC */
   return result;
 }