| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_OS_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
| 7 | 7 |
| 8 #include "vm/os.h" | 8 #include "vm/os.h" |
| 9 | 9 |
| 10 #include <android/log.h> // NOLINT | 10 #include <android/log.h> // NOLINT |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 return retval; | 312 return retval; |
| 313 } | 313 } |
| 314 | 314 |
| 315 | 315 |
| 316 int OS::NumberOfAvailableProcessors() { | 316 int OS::NumberOfAvailableProcessors() { |
| 317 return sysconf(_SC_NPROCESSORS_ONLN); | 317 return sysconf(_SC_NPROCESSORS_ONLN); |
| 318 } | 318 } |
| 319 | 319 |
| 320 | 320 |
| 321 void OS::Sleep(int64_t millis) { | 321 void OS::Sleep(int64_t millis) { |
| 322 // TODO(5411554): For now just use usleep we may have to revisit this. | 322 int64_t micros = millis * kMicrosecondsPerMillisecond; |
| 323 usleep(millis * 1000); | 323 SleepMicros(micros); |
| 324 } | 324 } |
| 325 | 325 |
| 326 | 326 |
| 327 void OS::SleepMicros(int64_t micros) { |
| 328 // We must loop here because SIGPROF will interrupt usleep. |
| 329 int64_t start = GetCurrentTimeMicros(); |
| 330 while (micros > 0) { |
| 331 usleep(micros); |
| 332 int64_t now = GetCurrentTimeMicros(); |
| 333 int64_t delta = now - start; |
| 334 ASSERT(delta >= 0); |
| 335 start = now; |
| 336 micros -= delta; |
| 337 } |
| 338 } |
| 339 |
| 340 |
| 327 void OS::DebugBreak() { | 341 void OS::DebugBreak() { |
| 328 UNIMPLEMENTED(); | 342 UNIMPLEMENTED(); |
| 329 } | 343 } |
| 330 | 344 |
| 331 | 345 |
| 332 char* OS::StrNDup(const char* s, intptr_t n) { | 346 char* OS::StrNDup(const char* s, intptr_t n) { |
| 333 return strndup(s, n); | 347 return strndup(s, n); |
| 334 } | 348 } |
| 335 | 349 |
| 336 | 350 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 } | 476 } |
| 463 | 477 |
| 464 | 478 |
| 465 void OS::Exit(int code) { | 479 void OS::Exit(int code) { |
| 466 exit(code); | 480 exit(code); |
| 467 } | 481 } |
| 468 | 482 |
| 469 } // namespace dart | 483 } // namespace dart |
| 470 | 484 |
| 471 #endif // defined(TARGET_OS_ANDROID) | 485 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |