From 29c26b91df36522bf83d4a5ceb37f75c32b360ed Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sat, 18 Jun 2016 18:32:26 +0000 Subject: [PATCH] Fix SleepFor(...) helper when a monotonic clock is not available. Single threaded builds often don't provide a monotonic clock, so we can't always provide a monotonic SleepFor(...) implementation. Hopefully this won't cause the builds to hang. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273091 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/support/filesystem_test_helper.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/support/filesystem_test_helper.hpp b/test/support/filesystem_test_helper.hpp index fdab4d615..7e3c7399a 100644 --- a/test/support/filesystem_test_helper.hpp +++ b/test/support/filesystem_test_helper.hpp @@ -388,9 +388,13 @@ inline std::error_code GetTestEC() { // available in single-threaded mode. void SleepFor(std::chrono::seconds dur) { using namespace std::chrono; - const auto curr_time = steady_clock::now(); - auto wake_time = curr_time + dur; - while (steady_clock::now() < wake_time) +#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) + using Clock = system_clock; +#else + using Clock = steady_clock; +#endif + const auto wake_time = Clock::now() + dur; + while (Clock::now() < wake_time) ; }