| 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 |
| 11 #include <limits.h> // NOLINT | 11 #include <limits.h> // NOLINT |
| 12 #include <mach/mach.h> // NOLINT | 12 #include <mach/mach.h> // NOLINT |
| 13 #include <mach/clock.h> // NOLINT | 13 #include <mach/clock.h> // NOLINT |
| 14 #include <mach/mach_time.h> // NOLINT | 14 #include <mach/mach_time.h> // NOLINT |
| 15 #include <sys/time.h> // NOLINT | 15 #include <sys/time.h> // NOLINT |
| 16 #include <sys/resource.h> // NOLINT | 16 #include <sys/resource.h> // NOLINT |
| 17 #include <unistd.h> // NOLINT | 17 #include <unistd.h> // NOLINT |
| 18 #if defined(TARGET_OS_IOS) |
| 19 #include <sys/sysctl.h> |
| 20 #endif |
| 18 | 21 |
| 19 #include "platform/utils.h" | 22 #include "platform/utils.h" |
| 20 #include "vm/isolate.h" | 23 #include "vm/isolate.h" |
| 21 #include "vm/zone.h" | 24 #include "vm/zone.h" |
| 22 | 25 |
| 23 namespace dart { | 26 namespace dart { |
| 24 | 27 |
| 25 const char* OS::Name() { | 28 const char* OS::Name() { |
| 26 return "macos"; | 29 return "macos"; |
| 27 } | 30 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 87 |
| 85 int64_t OS::GetCurrentTraceMicros() { | 88 int64_t OS::GetCurrentTraceMicros() { |
| 86 #if defined(TARGET_OS_IOS) | 89 #if defined(TARGET_OS_IOS) |
| 87 // On iOS mach_absolute_time stops while the device is sleeping. Instead use | 90 // On iOS mach_absolute_time stops while the device is sleeping. Instead use |
| 88 // now - KERN_BOOTTIME to get a time difference that is not impacted by clock | 91 // now - KERN_BOOTTIME to get a time difference that is not impacted by clock |
| 89 // changes. KERN_BOOTTIME will be updated by the system whenever the system | 92 // changes. KERN_BOOTTIME will be updated by the system whenever the system |
| 90 // clock change. | 93 // clock change. |
| 91 struct timeval boottime; | 94 struct timeval boottime; |
| 92 int mib[2] = {CTL_KERN, KERN_BOOTTIME}; | 95 int mib[2] = {CTL_KERN, KERN_BOOTTIME}; |
| 93 size_t size = sizeof(boottime); | 96 size_t size = sizeof(boottime); |
| 94 int kr = sysctl(mib, arraysize(mib), &boottime, &size, NULL, 0); | 97 int kr = sysctl(mib, sizeof(mib) / sizeof(mib[0]), &boottime, &size, NULL, 0); |
| 95 ASSERT(KERN_SUCCESS == kr); | 98 ASSERT(KERN_SUCCESS == kr); |
| 96 int64_t now = GetCurrentTimeMicros(); | 99 int64_t now = GetCurrentTimeMicros(); |
| 97 int64_t origin = boottime.tv_sec * kMicrosecondsPerSecond; | 100 int64_t origin = boottime.tv_sec * kMicrosecondsPerSecond; |
| 98 origin += boottime.tv_usec; | 101 origin += boottime.tv_usec; |
| 99 return now - origin; | 102 return now - origin; |
| 100 #else | 103 #else |
| 101 static mach_timebase_info_data_t timebase_info; | 104 static mach_timebase_info_data_t timebase_info; |
| 102 if (timebase_info.denom == 0) { | 105 if (timebase_info.denom == 0) { |
| 103 // Zero-initialization of statics guarantees that denom will be 0 before | 106 // Zero-initialization of statics guarantees that denom will be 0 before |
| 104 // calling mach_timebase_info. mach_timebase_info will never set denom to | 107 // calling mach_timebase_info. mach_timebase_info will never set denom to |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 } | 338 } |
| 336 | 339 |
| 337 | 340 |
| 338 void OS::Exit(int code) { | 341 void OS::Exit(int code) { |
| 339 exit(code); | 342 exit(code); |
| 340 } | 343 } |
| 341 | 344 |
| 342 } // namespace dart | 345 } // namespace dart |
| 343 | 346 |
| 344 #endif // defined(TARGET_OS_MACOS) | 347 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |