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_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // gettimeofday has microsecond resolution. | 83 // gettimeofday has microsecond resolution. |
84 struct timeval tv; | 84 struct timeval tv; |
85 if (gettimeofday(&tv, NULL) < 0) { | 85 if (gettimeofday(&tv, NULL) < 0) { |
86 UNREACHABLE(); | 86 UNREACHABLE(); |
87 return 0; | 87 return 0; |
88 } | 88 } |
89 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; | 89 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; |
90 } | 90 } |
91 | 91 |
92 | 92 |
93 int64_t OS::GetCurrentTraceMicros() { | 93 int64_t OS::GetCurrentMonotonicMicros() { |
94 #if TARGET_OS_IOS | 94 #if TARGET_OS_IOS |
95 // On iOS mach_absolute_time stops while the device is sleeping. Instead use | 95 // On iOS mach_absolute_time stops while the device is sleeping. Instead use |
96 // now - KERN_BOOTTIME to get a time difference that is not impacted by clock | 96 // now - KERN_BOOTTIME to get a time difference that is not impacted by clock |
97 // changes. KERN_BOOTTIME will be updated by the system whenever the system | 97 // changes. KERN_BOOTTIME will be updated by the system whenever the system |
98 // clock change. | 98 // clock change. |
99 struct timeval boottime; | 99 struct timeval boottime; |
100 int mib[2] = {CTL_KERN, KERN_BOOTTIME}; | 100 int mib[2] = {CTL_KERN, KERN_BOOTTIME}; |
101 size_t size = sizeof(boottime); | 101 size_t size = sizeof(boottime); |
102 int kr = sysctl(mib, sizeof(mib) / sizeof(mib[0]), &boottime, &size, NULL, 0); | 102 int kr = sysctl(mib, sizeof(mib) / sizeof(mib[0]), &boottime, &size, NULL, 0); |
103 ASSERT(KERN_SUCCESS == kr); | 103 ASSERT(KERN_SUCCESS == kr); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 } | 373 } |
374 | 374 |
375 | 375 |
376 void OS::Exit(int code) { | 376 void OS::Exit(int code) { |
377 exit(code); | 377 exit(code); |
378 } | 378 } |
379 | 379 |
380 } // namespace dart | 380 } // namespace dart |
381 | 381 |
382 #endif // defined(TARGET_OS_MACOS) | 382 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |