| Index: runtime/bin/utils_macos.cc
|
| diff --git a/runtime/bin/utils_macos.cc b/runtime/bin/utils_macos.cc
|
| index c47feddf830425eec9c97a6cbbe5720b65bd5ce1..1c83afd508465f482d5f828bb6f4111e1230fa19 100644
|
| --- a/runtime/bin/utils_macos.cc
|
| +++ b/runtime/bin/utils_macos.cc
|
| @@ -98,7 +98,17 @@ int64_t TimerUtils::GetCurrentTimeMicros() {
|
| }
|
|
|
| void TimerUtils::Sleep(int64_t millis) {
|
| - usleep(millis * 1000);
|
| + // We must loop here because SIGPROF will interrupt usleep.
|
| + int64_t micros = millis * 1000;
|
| + int64_t start = GetCurrentTimeMicros();
|
| + while (micros > 0) {
|
| + usleep(micros);
|
| + int64_t now = GetCurrentTimeMicros();
|
| + int64_t delta = now - start;
|
| + ASSERT(delta >= 0);
|
| + start = now;
|
| + micros -= delta;
|
| + }
|
| }
|
|
|
| } // namespace bin
|
|
|