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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 // gettimeofday has microsecond resolution. | 389 // gettimeofday has microsecond resolution. |
390 struct timeval tv; | 390 struct timeval tv; |
391 if (gettimeofday(&tv, NULL) < 0) { | 391 if (gettimeofday(&tv, NULL) < 0) { |
392 UNREACHABLE(); | 392 UNREACHABLE(); |
393 return 0; | 393 return 0; |
394 } | 394 } |
395 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; | 395 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; |
396 } | 396 } |
397 | 397 |
398 | 398 |
399 int64_t OS::GetCurrentTraceMicros() { | 399 int64_t OS::GetCurrentMonotonicMicros() { |
400 struct timespec ts; | 400 struct timespec ts; |
401 if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { | 401 if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { |
402 UNREACHABLE(); | 402 UNREACHABLE(); |
403 return 0; | 403 return 0; |
404 } | 404 } |
405 // Convert to microseconds. | 405 // Convert to microseconds. |
406 int64_t result = ts.tv_sec; | 406 int64_t result = ts.tv_sec; |
407 result *= kMicrosecondsPerSecond; | 407 result *= kMicrosecondsPerSecond; |
408 result += (ts.tv_nsec / kNanosecondsPerMicrosecond); | 408 result += (ts.tv_nsec / kNanosecondsPerMicrosecond); |
409 return result; | 409 return result; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 } | 647 } |
648 | 648 |
649 | 649 |
650 void OS::Exit(int code) { | 650 void OS::Exit(int code) { |
651 exit(code); | 651 exit(code); |
652 } | 652 } |
653 | 653 |
654 } // namespace dart | 654 } // namespace dart |
655 | 655 |
656 #endif // defined(TARGET_OS_LINUX) | 656 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |