From 46578a4a3bf235fde35ed80c6e6cbe8fb5f06b48 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Mon, 4 May 2015 09:53:43 -0700 Subject: Fix NanoSleep and add test Fixed a bug where tv_nsec was't between 0 and 999,999,999. (cherry picked from commit 0b063d9ba7a11779667c0888e9f3495de0118b74) Bug: 14450052 Change-Id: I30b29a716bfa63c6b57d589dd1102d2ca934c061 --- runtime/utils.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/utils.cc') diff --git a/runtime/utils.cc b/runtime/utils.cc index e18af0069..650214f67 100644 --- a/runtime/utils.cc +++ b/runtime/utils.cc @@ -262,8 +262,8 @@ uint64_t ThreadCpuNanoTime() { void NanoSleep(uint64_t ns) { timespec tm; - tm.tv_sec = 0; - tm.tv_nsec = ns; + tm.tv_sec = ns / MsToNs(1000); + tm.tv_nsec = ns - static_cast(tm.tv_sec) * MsToNs(1000); nanosleep(&tm, nullptr); } -- cgit v1.2.3