platform: use gettimeofday() on darwin in GetAbsTime(), as it is specified in OS...
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 27 Feb 2012 14:32:13 +0000 (15:32 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Mon, 27 Feb 2012 14:32:13 +0000 (15:32 +0100)
src/lib/platform/posix/os-threads.h

index c37beed2bef14f5a0e998c30c953d43968210e2e..fc28fc9017235fcb4804797dbf217cd2da8897c3 100644 (file)
@@ -49,7 +49,14 @@ namespace PLATFORM
   inline struct timespec GetAbsTime(uint64_t iIncreaseBy = 0)
   {
     struct timespec now;
+    #ifdef __APPLE__
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    now.tv_sec  = tv.tv_sec + 0;
+    now.tv_nsec = 0;
+    #else
     clock_gettime(CLOCK_REALTIME, &now);
+    #endif
     now.tv_nsec += iIncreaseBy % 1000 * 1000000;
     now.tv_sec  += iIncreaseBy / 1000 + now.tv_nsec / 1000000000;
     now.tv_nsec %= 1000000000;