Unbreak LLVM_ENABLE_THREADS=OFF builds.
[oota-llvm.git] / unittests / Support / TimerTest.cpp
index 00515f9aeb43c13d10eb4c05845fd692726663ba..f556a3f72c625e43c4c9f964327bde38cb2ce62d 100644 (file)
@@ -8,14 +8,30 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Support/Timer.h"
-#include "llvm/Support/thread.h"
 #include "gtest/gtest.h"
-#include <chrono>
+
+#if LLVM_ON_WIN32
+#include <windows.h>
+#else
+#include <time.h>
+#endif
 
 using namespace llvm;
 
 namespace {
 
+// FIXME: Put this somewhere in Support, it's also used in LockFileManager.
+void SleepMS() {
+#if LLVM_ON_WIN32
+  Sleep(1);
+#else
+  struct timespec Interval;
+  Interval.tv_sec = 0;
+  Interval.tv_nsec = 1000000;
+  nanosleep(&Interval, nullptr);
+#endif
+}
+
 TEST(Timer, Additivity) {
   Timer T1("T1");
 
@@ -26,7 +42,7 @@ TEST(Timer, Additivity) {
   auto TR1 = T1.getTotalTime();
 
   T1.startTimer();
-  std::this_thread::sleep_for(std::chrono::milliseconds(1));
+  SleepMS();
   T1.stopTimer();
   auto TR2 = T1.getTotalTime();