From 6c545460483af0a6959bafe89dff2696383fc523 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Sun, 4 May 2014 01:25:52 +0200 Subject: [PATCH] Added Util::getNTP() to timing library. --- lib/timing.cpp | 6 ++++++ lib/timing.h | 1 + 2 files changed, 7 insertions(+) diff --git a/lib/timing.cpp b/lib/timing.cpp index 27fbef4e..b1cc7ca8 100644 --- a/lib/timing.cpp +++ b/lib/timing.cpp @@ -35,6 +35,12 @@ void Util::sleep(int ms){ nanosleep( &T, 0); } +long long Util::getNTP(){ + struct timespec t; + clock_gettime(CLOCK_REALTIME, &t); + return ((((long long int)t.tv_sec) + 2208988800) << 32) + (t.tv_nsec*4.2949); +} + /// Gets the current time in milliseconds. long long int Util::getMS(){ struct timespec t; diff --git a/lib/timing.h b/lib/timing.h index 9cb0c837..4e141e50 100644 --- a/lib/timing.h +++ b/lib/timing.h @@ -8,5 +8,6 @@ namespace Util { long long int getMS(); ///< Gets the current time in milliseconds. long long unsigned int getMicros();///