| 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() { |
| 183 struct timespec ts; |
| 184 if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { |
| 185 UNREACHABLE(); |
| 186 return 0; |
| 187 } |
| 188 // Convert to microseconds. |
| 189 int64_t result = ts.tv_sec; |
| 190 result *= kMicrosecondsPerSecond; |
| 191 result += (ts.tv_nsec / kNanosecondsPerMicrosecond); |
| 192 return result; |
| 193 } |
| 194 |
| 195 |
| 182 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { | 196 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { |
| 183 const int kMinimumAlignment = 16; | 197 const int kMinimumAlignment = 16; |
| 184 ASSERT(Utils::IsPowerOfTwo(alignment)); | 198 ASSERT(Utils::IsPowerOfTwo(alignment)); |
| 185 ASSERT(alignment >= kMinimumAlignment); | 199 ASSERT(alignment >= kMinimumAlignment); |
| 186 void* p = memalign(alignment, size); | 200 void* p = memalign(alignment, size); |
| 187 if (p == NULL) { | 201 if (p == NULL) { |
| 188 UNREACHABLE(); | 202 UNREACHABLE(); |
| 189 } | 203 } |
| 190 return p; | 204 return p; |
| 191 } | 205 } |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 } | 456 } |
| 443 | 457 |
| 444 | 458 |
| 445 void OS::Exit(int code) { | 459 void OS::Exit(int code) { |
| 446 exit(code); | 460 exit(code); |
| 447 } | 461 } |
| 448 | 462 |
| 449 } // namespace dart | 463 } // namespace dart |
| 450 | 464 |
| 451 #endif // defined(TARGET_OS_ANDROID) | 465 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |