| 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 "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
| 7 | 7 |
| 8 #include <mach-o/dyld.h> | 8 #include <mach-o/dyld.h> |
| 9 #include <sys/types.h> |
| 10 #include <sys/sysctl.h> |
| 9 | 11 |
| 10 #include "bin/file.h" | 12 #include "bin/file.h" |
| 11 #include "bin/platform.h" | 13 #include "bin/platform.h" |
| 12 | 14 |
| 13 #include <crt_externs.h> // NOLINT | 15 #include <crt_externs.h> // NOLINT |
| 14 #include <signal.h> // NOLINT | 16 #include <signal.h> // NOLINT |
| 15 #include <string.h> // NOLINT | 17 #include <string.h> // NOLINT |
| 16 #include <unistd.h> // NOLINT | 18 #include <unistd.h> // NOLINT |
| 17 | 19 |
| 18 #include "bin/fdutils.h" | 20 #include "bin/fdutils.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 30 act.sa_handler = SIG_IGN; | 32 act.sa_handler = SIG_IGN; |
| 31 if (sigaction(SIGPIPE, &act, 0) != 0) { | 33 if (sigaction(SIGPIPE, &act, 0) != 0) { |
| 32 perror("Setting signal handler failed"); | 34 perror("Setting signal handler failed"); |
| 33 return false; | 35 return false; |
| 34 } | 36 } |
| 35 return true; | 37 return true; |
| 36 } | 38 } |
| 37 | 39 |
| 38 | 40 |
| 39 int Platform::NumberOfProcessors() { | 41 int Platform::NumberOfProcessors() { |
| 40 return sysconf(_SC_NPROCESSORS_ONLN); | 42 int32_t cpus = -1; |
| 43 size_t cpus_length = sizeof(cpus); |
| 44 if (sysctlbyname("hw.logicalcpu", &cpus, &cpus_length, NULL, 0) == 0) { |
| 45 return cpus; |
| 46 } else { |
| 47 // Failed, fallback to using sysconf. |
| 48 return sysconf(_SC_NPROCESSORS_ONLN); |
| 49 } |
| 41 } | 50 } |
| 42 | 51 |
| 43 | 52 |
| 44 const char* Platform::OperatingSystem() { | 53 const char* Platform::OperatingSystem() { |
| 45 return "macos"; | 54 return "macos"; |
| 46 } | 55 } |
| 47 | 56 |
| 48 | 57 |
| 49 const char* Platform::LibraryExtension() { | 58 const char* Platform::LibraryExtension() { |
| 50 return "dylib"; | 59 return "dylib"; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // Return the canonical path as the returned path might contain symlinks. | 115 // Return the canonical path as the returned path might contain symlinks. |
| 107 char* canon_path = File::GetCanonicalPath(path); | 116 char* canon_path = File::GetCanonicalPath(path); |
| 108 free(path); | 117 free(path); |
| 109 return canon_path; | 118 return canon_path; |
| 110 } | 119 } |
| 111 | 120 |
| 112 } // namespace bin | 121 } // namespace bin |
| 113 } // namespace dart | 122 } // namespace dart |
| 114 | 123 |
| 115 #endif // defined(TARGET_OS_MACOS) | 124 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |