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

Side by Side Diff: runtime/bin/utils_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
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 "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include <errno.h> // NOLINT 8 #include <errno.h> // NOLINT
9 #include <netdb.h> // NOLINT 9 #include <netdb.h> // NOLINT
10 #include <sys/time.h> // NOLINT 10 #include <sys/time.h> // NOLINT
11 #include <time.h> // NOLINT
11 12
12 #include "bin/utils.h" 13 #include "bin/utils.h"
13 #include "platform/assert.h" 14 #include "platform/assert.h"
14 15
15 16
16 namespace dart { 17 namespace dart {
17 namespace bin { 18 namespace bin {
18 19
19 OSError::OSError() : sub_system_(kSystem), code_(0), message_(NULL) { 20 OSError::OSError() : sub_system_(kSystem), code_(0), message_(NULL) {
20 set_sub_system(kSystem); 21 set_sub_system(kSystem);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 int64_t TimerUtils::GetCurrentTimeMicros() { 92 int64_t TimerUtils::GetCurrentTimeMicros() {
92 struct timeval tv; 93 struct timeval tv;
93 if (gettimeofday(&tv, NULL) < 0) { 94 if (gettimeofday(&tv, NULL) < 0) {
94 UNREACHABLE(); 95 UNREACHABLE();
95 return 0; 96 return 0;
96 } 97 }
97 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; 98 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec;
98 } 99 }
99 100
100 void TimerUtils::Sleep(int64_t millis) { 101 void TimerUtils::Sleep(int64_t millis) {
101 usleep(millis * 1000); 102 struct timespec req; // requested.
103 struct timespec rem; // remainder.
104 int64_t micros = millis * kMicrosecondsPerMillisecond;
105 int64_t seconds = micros / kMicrosecondsPerSecond;
106 micros = micros - seconds * kMicrosecondsPerSecond;
107 int64_t nanos = micros * kNanosecondsPerMicrosecond;
108 req.tv_sec = seconds;
109 req.tv_nsec = nanos;
110 while (true) {
111 int r = nanosleep(&req, &rem);
112 if (r == 0) {
113 break;
114 }
115 // We should only ever see an interrupt error.
116 ASSERT(errno == EINTR);
117 // Copy remainder into requested and repeat.
118 req = rem;
119 }
102 } 120 }
103 121
104 } // namespace bin 122 } // namespace bin
105 } // namespace dart 123 } // namespace dart
106 124
107 #endif // defined(TARGET_OS_ANDROID) 125 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« runtime/bin/file.cc ('K') | « runtime/bin/socket.cc ('k') | runtime/bin/utils_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698