| 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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 168 } |
| 169 | 169 |
| 170 | 170 |
| 171 int64_t OS::GetCurrentMonotonicMicros() { | 171 int64_t OS::GetCurrentMonotonicMicros() { |
| 172 int64_t ticks = GetCurrentMonotonicTicks(); | 172 int64_t ticks = GetCurrentMonotonicTicks(); |
| 173 ASSERT(GetCurrentMonotonicFrequency() == kNanosecondsPerSecond); | 173 ASSERT(GetCurrentMonotonicFrequency() == kNanosecondsPerSecond); |
| 174 return ticks / kNanosecondsPerMicrosecond; | 174 return ticks / kNanosecondsPerMicrosecond; |
| 175 } | 175 } |
| 176 | 176 |
| 177 | 177 |
| 178 int64_t OS::GetCurrentThreadCPUMicros() { |
| 179 struct timespec ts; |
| 180 if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) != 0) { |
| 181 UNREACHABLE(); |
| 182 return -1; |
| 183 } |
| 184 int64_t result = ts.tv_sec; |
| 185 result *= kMicrosecondsPerSecond; |
| 186 result += (ts.tv_nsec / kNanosecondsPerMicrosecond); |
| 187 return result; |
| 188 } |
| 189 |
| 190 |
| 178 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { | 191 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { |
| 179 const int kMinimumAlignment = 16; | 192 const int kMinimumAlignment = 16; |
| 180 ASSERT(Utils::IsPowerOfTwo(alignment)); | 193 ASSERT(Utils::IsPowerOfTwo(alignment)); |
| 181 ASSERT(alignment >= kMinimumAlignment); | 194 ASSERT(alignment >= kMinimumAlignment); |
| 182 void* p = memalign(alignment, size); | 195 void* p = memalign(alignment, size); |
| 183 if (p == NULL) { | 196 if (p == NULL) { |
| 184 UNREACHABLE(); | 197 UNREACHABLE(); |
| 185 } | 198 } |
| 186 return p; | 199 return p; |
| 187 } | 200 } |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 } | 420 } |
| 408 | 421 |
| 409 | 422 |
| 410 void OS::Exit(int code) { | 423 void OS::Exit(int code) { |
| 411 exit(code); | 424 exit(code); |
| 412 } | 425 } |
| 413 | 426 |
| 414 } // namespace dart | 427 } // namespace dart |
| 415 | 428 |
| 416 #endif // defined(TARGET_OS_LINUX) | 429 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |