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 TARGET_OS_IOS | 18 #if TARGET_OS_IOS |
19 #include <sys/sysctl.h> | 19 #include <sys/sysctl.h> // NOLINT |
| 20 #include <syslog.h> // NOLINT |
20 #endif | 21 #endif |
21 | 22 |
22 #include "platform/utils.h" | 23 #include "platform/utils.h" |
23 #include "vm/isolate.h" | 24 #include "vm/isolate.h" |
24 #include "vm/zone.h" | 25 #include "vm/zone.h" |
25 | 26 |
26 namespace dart { | 27 namespace dart { |
27 | 28 |
28 const char* OS::Name() { | 29 const char* OS::Name() { |
29 return "macos"; | 30 return "macos"; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 137 |
137 | 138 |
138 void OS::AlignedFree(void* ptr) { | 139 void OS::AlignedFree(void* ptr) { |
139 free(ptr); | 140 free(ptr); |
140 } | 141 } |
141 | 142 |
142 | 143 |
143 intptr_t OS::ActivationFrameAlignment() { | 144 intptr_t OS::ActivationFrameAlignment() { |
144 #if TARGET_OS_IOS | 145 #if TARGET_OS_IOS |
145 #if TARGET_ARCH_ARM | 146 #if TARGET_ARCH_ARM |
146 // Even if we generate code that maintains a strong alignment, we cannot | 147 // Even if we generate code that maintains a stronger alignment, we cannot |
147 // assert the stronger stack alignment because C++ code will not maintain it. | 148 // assert the stronger stack alignment because C++ code will not maintain it. |
148 return 8; | 149 return 8; |
149 #elif TARGET_ARCH_ARM64 | 150 #elif TARGET_ARCH_ARM64 |
150 return 16; | 151 return 16; |
151 #endif | 152 #endif |
152 #else // TARGET_OS_IOS | 153 #else // TARGET_OS_IOS |
153 // OS X activation frames must be 16 byte-aligned; see "Mac OS X ABI | 154 // OS X activation frames must be 16 byte-aligned; see "Mac OS X ABI |
154 // Function Call Guide". | 155 // Function Call Guide". |
155 return 16; | 156 return 16; |
156 #endif // TARGET_OS_IOS | 157 #endif // TARGET_OS_IOS |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } | 228 } |
228 result[len] = '\0'; | 229 result[len] = '\0'; |
229 return reinterpret_cast<char*>(memmove(result, s, len)); | 230 return reinterpret_cast<char*>(memmove(result, s, len)); |
230 #else // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ... | 231 #else // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ... |
231 return strndup(s, n); | 232 return strndup(s, n); |
232 #endif // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ... | 233 #endif // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ... |
233 } | 234 } |
234 | 235 |
235 | 236 |
236 void OS::Print(const char* format, ...) { | 237 void OS::Print(const char* format, ...) { |
| 238 #if TARGET_OS_IOS |
| 239 va_list args; |
| 240 va_start(args, format); |
| 241 vsyslog(LOG_INFO, format, args); |
| 242 va_end(args); |
| 243 #else |
237 va_list args; | 244 va_list args; |
238 va_start(args, format); | 245 va_start(args, format); |
239 VFPrint(stdout, format, args); | 246 VFPrint(stdout, format, args); |
240 va_end(args); | 247 va_end(args); |
| 248 #endif |
241 } | 249 } |
242 | 250 |
243 | 251 |
244 void OS::VFPrint(FILE* stream, const char* format, va_list args) { | 252 void OS::VFPrint(FILE* stream, const char* format, va_list args) { |
245 vfprintf(stream, format, args); | 253 vfprintf(stream, format, args); |
246 fflush(stream); | 254 fflush(stream); |
247 } | 255 } |
248 | 256 |
249 | 257 |
250 int OS::SNPrint(char* str, size_t size, const char* format, ...) { | 258 int OS::SNPrint(char* str, size_t size, const char* format, ...) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 *value = strtoll(str, &endptr, base); | 323 *value = strtoll(str, &endptr, base); |
316 return ((errno == 0) && (endptr != str) && (*endptr == 0)); | 324 return ((errno == 0) && (endptr != str) && (*endptr == 0)); |
317 } | 325 } |
318 | 326 |
319 | 327 |
320 void OS::RegisterCodeObservers() { | 328 void OS::RegisterCodeObservers() { |
321 } | 329 } |
322 | 330 |
323 | 331 |
324 void OS::PrintErr(const char* format, ...) { | 332 void OS::PrintErr(const char* format, ...) { |
| 333 #if TARGET_OS_IOS |
| 334 va_list args; |
| 335 va_start(args, format); |
| 336 vsyslog(LOG_ERR, format, args); |
| 337 va_end(args); |
| 338 #else |
325 va_list args; | 339 va_list args; |
326 va_start(args, format); | 340 va_start(args, format); |
327 VFPrint(stderr, format, args); | 341 VFPrint(stderr, format, args); |
328 va_end(args); | 342 va_end(args); |
| 343 #endif |
329 } | 344 } |
330 | 345 |
331 | 346 |
332 void OS::InitOnce() { | 347 void OS::InitOnce() { |
333 // TODO(5411554): For now we check that initonce is called only once, | 348 // TODO(5411554): For now we check that initonce is called only once, |
334 // Once there is more formal mechanism to call InitOnce we can move | 349 // Once there is more formal mechanism to call InitOnce we can move |
335 // this check there. | 350 // this check there. |
336 static bool init_once_called = false; | 351 static bool init_once_called = false; |
337 ASSERT(init_once_called == false); | 352 ASSERT(init_once_called == false); |
338 init_once_called = true; | 353 init_once_called = true; |
339 } | 354 } |
340 | 355 |
341 | 356 |
342 void OS::Shutdown() { | 357 void OS::Shutdown() { |
343 } | 358 } |
344 | 359 |
345 | 360 |
346 void OS::Abort() { | 361 void OS::Abort() { |
347 abort(); | 362 abort(); |
348 } | 363 } |
349 | 364 |
350 | 365 |
351 void OS::Exit(int code) { | 366 void OS::Exit(int code) { |
352 exit(code); | 367 exit(code); |
353 } | 368 } |
354 | 369 |
355 } // namespace dart | 370 } // namespace dart |
356 | 371 |
357 #endif // defined(TARGET_OS_MACOS) | 372 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |