diff options
author | Nico Weber <nicolasweber@gmx.de> | 2015-12-23 01:04:53 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2015-12-23 01:04:53 +0000 |
commit | 20aab1c40d741b3c36e9ed8c0f801c61d5a2857a (patch) | |
tree | 039bae93333c0bea416ef2fccc372abe47be84b5 /unittests/Support/TimerTest.cpp | |
parent | 97cdf9dc307204455ec70756226c9799afddcd4c (diff) |
Unbreak LLVM_ENABLE_THREADS=OFF builds.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256308 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Support/TimerTest.cpp')
-rw-r--r-- | unittests/Support/TimerTest.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/unittests/Support/TimerTest.cpp b/unittests/Support/TimerTest.cpp index 00515f9aeb43..f556a3f72c62 100644 --- a/unittests/Support/TimerTest.cpp +++ b/unittests/Support/TimerTest.cpp @@ -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(); |