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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // gettimeofday has microsecond resolution. | 172 // gettimeofday has microsecond resolution. |
173 struct timeval tv; | 173 struct timeval tv; |
174 if (gettimeofday(&tv, NULL) < 0) { | 174 if (gettimeofday(&tv, NULL) < 0) { |
175 UNREACHABLE(); | 175 UNREACHABLE(); |
176 return 0; | 176 return 0; |
177 } | 177 } |
178 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; | 178 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; |
179 } | 179 } |
180 | 180 |
181 | 181 |
182 int64_t OS::GetCurrentTraceMicros() { | 182 int64_t OS::GetCurrentMonotonicMicros() { |
183 struct timespec ts; | 183 struct timespec ts; |
184 if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { | 184 if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { |
185 UNREACHABLE(); | 185 UNREACHABLE(); |
186 return 0; | 186 return 0; |
187 } | 187 } |
188 // Convert to microseconds. | 188 // Convert to microseconds. |
189 int64_t result = ts.tv_sec; | 189 int64_t result = ts.tv_sec; |
190 result *= kMicrosecondsPerSecond; | 190 result *= kMicrosecondsPerSecond; |
191 result += (ts.tv_nsec / kNanosecondsPerMicrosecond); | 191 result += (ts.tv_nsec / kNanosecondsPerMicrosecond); |
192 return result; | 192 return result; |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 } | 456 } |
457 | 457 |
458 | 458 |
459 void OS::Exit(int code) { | 459 void OS::Exit(int code) { |
460 exit(code); | 460 exit(code); |
461 } | 461 } |
462 | 462 |
463 } // namespace dart | 463 } // namespace dart |
464 | 464 |
465 #endif // defined(TARGET_OS_ANDROID) | 465 #endif // defined(TARGET_OS_ANDROID) |
OLD | NEW |