Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: runtime/vm/os_macos.cc

Issue 1388973002: Use #if TARGET_OS_IOS instead of #ifdef TARGET_OS_IOS. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comment, rebase. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« runtime/platform/globals.h ('K') | « runtime/platform/globals.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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) 18 #if TARGET_OS_IOS
19 #include <sys/sysctl.h> 19 #include <sys/sysctl.h>
20 #endif 20 #endif
21 21
22 #include "platform/utils.h" 22 #include "platform/utils.h"
23 #include "vm/isolate.h" 23 #include "vm/isolate.h"
24 #include "vm/zone.h" 24 #include "vm/zone.h"
25 25
26 namespace dart { 26 namespace dart {
27 27
28 const char* OS::Name() { 28 const char* OS::Name() {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 struct timeval tv; 79 struct timeval tv;
80 if (gettimeofday(&tv, NULL) < 0) { 80 if (gettimeofday(&tv, NULL) < 0) {
81 UNREACHABLE(); 81 UNREACHABLE();
82 return 0; 82 return 0;
83 } 83 }
84 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec; 84 return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec;
85 } 85 }
86 86
87 87
88 int64_t OS::GetCurrentTraceMicros() { 88 int64_t OS::GetCurrentTraceMicros() {
89 #if defined(TARGET_OS_IOS) 89 #if TARGET_OS_IOS
90 // 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
91 // 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
92 // 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
93 // clock change. 93 // clock change.
94 struct timeval boottime; 94 struct timeval boottime;
95 int mib[2] = {CTL_KERN, KERN_BOOTTIME}; 95 int mib[2] = {CTL_KERN, KERN_BOOTTIME};
96 size_t size = sizeof(boottime); 96 size_t size = sizeof(boottime);
97 int kr = sysctl(mib, sizeof(mib) / sizeof(mib[0]), &boottime, &size, NULL, 0); 97 int kr = sysctl(mib, sizeof(mib) / sizeof(mib[0]), &boottime, &size, NULL, 0);
98 ASSERT(KERN_SUCCESS == kr); 98 ASSERT(KERN_SUCCESS == kr);
99 int64_t now = GetCurrentTimeMicros(); 99 int64_t now = GetCurrentTimeMicros();
(...skipping 11 matching lines...) Expand all
111 kern_return_t kr = mach_timebase_info(&timebase_info); 111 kern_return_t kr = mach_timebase_info(&timebase_info);
112 ASSERT(KERN_SUCCESS == kr); 112 ASSERT(KERN_SUCCESS == kr);
113 } 113 }
114 114
115 // timebase_info converts absolute time tick units into nanoseconds. Convert 115 // timebase_info converts absolute time tick units into nanoseconds. Convert
116 // to microseconds. 116 // to microseconds.
117 int64_t result = mach_absolute_time() / kNanosecondsPerMicrosecond; 117 int64_t result = mach_absolute_time() / kNanosecondsPerMicrosecond;
118 result *= timebase_info.numer; 118 result *= timebase_info.numer;
119 result /= timebase_info.denom; 119 result /= timebase_info.denom;
120 return result; 120 return result;
121 #endif // defined(TARGET_OS_IOS) 121 #endif // TARGET_OS_IOS
122 } 122 }
123 123
124 124
125 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) { 125 void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) {
126 const int kMinimumAlignment = 16; 126 const int kMinimumAlignment = 16;
127 ASSERT(Utils::IsPowerOfTwo(alignment)); 127 ASSERT(Utils::IsPowerOfTwo(alignment));
128 ASSERT(alignment >= kMinimumAlignment); 128 ASSERT(alignment >= kMinimumAlignment);
129 // Temporary workaround until xcode is upgraded. 129 // Temporary workaround until xcode is upgraded.
130 // Mac guarantees malloc returns a 16 byte aligned memory chunk. 130 // Mac guarantees malloc returns a 16 byte aligned memory chunk.
131 // Currently we only allocate with 16-bye alignment. 131 // Currently we only allocate with 16-bye alignment.
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 } 338 }
339 339
340 340
341 void OS::Exit(int code) { 341 void OS::Exit(int code) {
342 exit(code); 342 exit(code);
343 } 343 }
344 344
345 } // namespace dart 345 } // namespace dart
346 346
347 #endif // defined(TARGET_OS_MACOS) 347 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« runtime/platform/globals.h ('K') | « runtime/platform/globals.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698