renamed libPlatform -> platform. stuck everything from libCEC in the CEC namespace...
[deb_libcec.git] / src / lib / platform / timeutils.h
similarity index 55%
rename from src/lib/util/timeutils.h
rename to src/lib/platform/timeutils.h
index f1c0e63c0d9fd408ad5b621c7a84aa7210a5dcda..c4140203736bc258e3551a31fda001009a985e45 100644 (file)
 #include <stdint.h>
 #include <time.h>
 
-inline int64_t GetTimeMs()
+namespace CEC
 {
-#ifdef __WINDOWS__
-  time_t rawtime;
-  time(&rawtime);
-
-  LARGE_INTEGER tickPerSecond;
-  LARGE_INTEGER tick;
-  if (QueryPerformanceFrequency(&tickPerSecond))
+  inline int64_t GetTimeMs()
   {
-    QueryPerformanceCounter(&tick);
-    return (int64_t) (tick.QuadPart / 1000.);
-  }
-  return -1;
-#else
-  struct timespec time;
-  clock_gettime(CLOCK_MONOTONIC, &time);
+  #ifdef __WINDOWS__
+    time_t rawtime;
+    time(&rawtime);
 
-  return ((int64_t)time.tv_sec * (int64_t)1000) + (int64_t)time.tv_nsec / (int64_t)1000;
-#endif
-}
+    LARGE_INTEGER tickPerSecond;
+    LARGE_INTEGER tick;
+    if (QueryPerformanceFrequency(&tickPerSecond))
+    {
+      QueryPerformanceCounter(&tick);
+      return (int64_t) (tick.QuadPart / 1000.);
+    }
+    return -1;
+  #else
+    struct timespec time;
+    clock_gettime(CLOCK_MONOTONIC, &time);
 
-template <class T>
-inline T GetTimeSec()
-{
-  return (T)GetTimeMs() / (T)1000.0;
-}
+    return ((int64_t)time.tv_sec * (int64_t)1000) + (int64_t)time.tv_nsec / (int64_t)1000;
+  #endif
+  }
 
-void USleep(int64_t usecs, volatile bool* stop = NULL);
+  template <class T>
+  inline T GetTimeSec()
+  {
+    return (T)GetTimeMs() / (T)1000.0;
+  }
+};