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

Side by Side Diff: runtime/vm/os_macos.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 "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_OS_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "vm/os.h" 8 #include "vm/os.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 return retval; 124 return retval;
125 } 125 }
126 126
127 127
128 int OS::NumberOfAvailableProcessors() { 128 int OS::NumberOfAvailableProcessors() {
129 return sysconf(_SC_NPROCESSORS_ONLN); 129 return sysconf(_SC_NPROCESSORS_ONLN);
130 } 130 }
131 131
132 132
133 void OS::Sleep(int64_t millis) { 133 void OS::Sleep(int64_t millis) {
134 // TODO(5411554): For now just use usleep we may have to revisit this. 134 int64_t micros = millis * kMicrosecondsPerMillisecond;
135 usleep(millis * 1000); 135 SleepMicros(micros);
136 } 136 }
137 137
138 138
139 void OS::SleepMicros(int64_t micros) {
140 // We must loop here because SIGPROF will interrupt usleep.
141 int64_t start = GetCurrentTimeMicros();
142 while (micros > 0) {
143 usleep(micros);
144 int64_t now = GetCurrentTimeMicros();
145 int64_t delta = now - start;
146 ASSERT(delta >= 0);
147 start = now;
148 micros -= delta;
149 }
150 }
151
152
139 void OS::DebugBreak() { 153 void OS::DebugBreak() {
140 #if defined(HOST_ARCH_X64) || defined(HOST_ARCH_IA32) 154 #if defined(HOST_ARCH_X64) || defined(HOST_ARCH_IA32)
141 asm("int $3"); 155 asm("int $3");
142 #else 156 #else
143 #error Unsupported architecture. 157 #error Unsupported architecture.
144 #endif 158 #endif
145 } 159 }
146 160
147 161
148 char* OS::StrNDup(const char* s, intptr_t n) { 162 char* OS::StrNDup(const char* s, intptr_t n) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 265 }
252 266
253 267
254 void OS::Exit(int code) { 268 void OS::Exit(int code) {
255 exit(code); 269 exit(code);
256 } 270 }
257 271
258 } // namespace dart 272 } // namespace dart
259 273
260 #endif // defined(TARGET_OS_MACOS) 274 #endif // defined(TARGET_OS_MACOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698