]> git.cworth.org Git - apitrace/blobdiff - common/os_time.hpp
retrace: Sleep when polling for input.
[apitrace] / common / os_time.hpp
index 75175d85f6ecb15d8fc69622e10526b23ab5bb3d..13cc733ae05488312b4fb5554d08fcb8fd49bc2d 100644 (file)
 
 
 #if defined(_WIN32)
-#include <windows.h>
-#elif defined(__linux__)
-#include <time.h>
-#elif defined(__APPLE__)
-#include <mach/mach_time.h>
+#  include <windows.h>
 #else
-#include <sys/time.h>
+#  if defined(__linux__)
+#    include <time.h>
+#  elif defined(__APPLE__)
+#    include <mach/mach_time.h>
+#  else
+#    include <sys/time.h>
+#  endif
+#  include <unistd.h>
 #endif
 
 
@@ -88,6 +91,15 @@ namespace os {
 #endif
     }
 
+    // Suspend execution
+    inline void
+    sleep(unsigned long usecs) {
+#if defined(_WIN32)
+        Sleep((usecs + 999) / 1000);
+#else
+        usleep(usecs);
+#endif
+    }
 
 } /* namespace os */