Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: runtime/vm/os_android.cc

Issue 109803002: Profiler Take 2 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/os.h ('k') | runtime/vm/os_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 struct timespec req; // requested.
329 struct timespec rem; // remainder.
330 int64_t seconds = micros / kMicrosecondsPerSecond;
331 micros = micros - seconds * kMicrosecondsPerSecond;
332 int64_t nanos = micros * kNanosecondsPerMicrosecond;
333 req.tv_sec = seconds;
334 req.tv_nsec = nanos;
335 while (true) {
336 int r = nanosleep(&req, &rem);
337 if (r == 0) {
338 break;
339 }
340 // We should only ever see an interrupt error.
341 ASSERT(errno == EINTR);
342 // Copy remainder into requested and repeat.
343 req = rem;
344 }
345 }
346
347
327 void OS::DebugBreak() { 348 void OS::DebugBreak() {
328 UNIMPLEMENTED(); 349 UNIMPLEMENTED();
329 } 350 }
330 351
331 352
332 char* OS::StrNDup(const char* s, intptr_t n) { 353 char* OS::StrNDup(const char* s, intptr_t n) {
333 return strndup(s, n); 354 return strndup(s, n);
334 } 355 }
335 356
336 357
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 483 }
463 484
464 485
465 void OS::Exit(int code) { 486 void OS::Exit(int code) {
466 exit(code); 487 exit(code);
467 } 488 }
468 489
469 } // namespace dart 490 } // namespace dart
470 491
471 #endif // defined(TARGET_OS_ANDROID) 492 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/vm/os.h ('k') | runtime/vm/os_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698