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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 | 162 |
163 | 163 |
164 int64_t OS::GetCurrentMonotonicMicros() { | 164 int64_t OS::GetCurrentMonotonicMicros() { |
165 int64_t ticks = GetCurrentMonotonicTicks(); | 165 int64_t ticks = GetCurrentMonotonicTicks(); |
166 ASSERT(GetCurrentMonotonicFrequency() == kNanosecondsPerSecond); | 166 ASSERT(GetCurrentMonotonicFrequency() == kNanosecondsPerSecond); |
167 return ticks / kNanosecondsPerMicrosecond; | 167 return ticks / kNanosecondsPerMicrosecond; |
168 } | 168 } |
169 | 169 |
170 | 170 |
| 171 int64_t OS::GetCurrentThreadCPUMicros() { |
| 172 struct timespec ts; |
| 173 if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) != 0) { |
| 174 UNREACHABLE(); |
| 175 return -1; |
| 176 } |
| 177 int64_t result = ts.tv_sec; |
| 178 result *= kMicrosecondsPerSecond; |
| 179 result += (ts.tv_nsec / kNanosecondsPerMicrosecond); |
| 180 return result; |
| 181 } |
| 182 |
| 183 |
171 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { | 184 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { |
172 const int kMinimumAlignment = 16; | 185 const int kMinimumAlignment = 16; |
173 ASSERT(Utils::IsPowerOfTwo(alignment)); | 186 ASSERT(Utils::IsPowerOfTwo(alignment)); |
174 ASSERT(alignment >= kMinimumAlignment); | 187 ASSERT(alignment >= kMinimumAlignment); |
175 void* p = memalign(alignment, size); | 188 void* p = memalign(alignment, size); |
176 if (p == NULL) { | 189 if (p == NULL) { |
177 UNREACHABLE(); | 190 UNREACHABLE(); |
178 } | 191 } |
179 return p; | 192 return p; |
180 } | 193 } |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 } | 442 } |
430 | 443 |
431 | 444 |
432 void OS::Exit(int code) { | 445 void OS::Exit(int code) { |
433 exit(code); | 446 exit(code); |
434 } | 447 } |
435 | 448 |
436 } // namespace dart | 449 } // namespace dart |
437 | 450 |
438 #endif // defined(TARGET_OS_ANDROID) | 451 #endif // defined(TARGET_OS_ANDROID) |
OLD | NEW |