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(HOST_OS_MACOS) |
7 | 7 |
8 #include "bin/platform.h" | 8 #include "bin/platform.h" |
9 | 9 |
10 #if !TARGET_OS_IOS | 10 #if !HOST_OS_IOS |
11 #include <crt_externs.h> // NOLINT | 11 #include <crt_externs.h> // NOLINT |
12 #endif // !TARGET_OS_IOS | 12 #endif // !HOST_OS_IOS |
13 #include <mach-o/dyld.h> | 13 #include <mach-o/dyld.h> |
14 #include <signal.h> // NOLINT | 14 #include <signal.h> // NOLINT |
15 #include <string.h> // NOLINT | 15 #include <string.h> // NOLINT |
16 #include <sys/sysctl.h> // NOLINT | 16 #include <sys/sysctl.h> // NOLINT |
17 #include <sys/types.h> // NOLINT | 17 #include <sys/types.h> // NOLINT |
18 #include <unistd.h> // NOLINT | 18 #include <unistd.h> // NOLINT |
19 | 19 |
20 #include "bin/fdutils.h" | 20 #include "bin/fdutils.h" |
21 #include "bin/file.h" | 21 #include "bin/file.h" |
22 | 22 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 if (sysctlbyname("hw.logicalcpu", &cpus, &cpus_length, NULL, 0) == 0) { | 73 if (sysctlbyname("hw.logicalcpu", &cpus, &cpus_length, NULL, 0) == 0) { |
74 return cpus; | 74 return cpus; |
75 } else { | 75 } else { |
76 // Failed, fallback to using sysconf. | 76 // Failed, fallback to using sysconf. |
77 return sysconf(_SC_NPROCESSORS_ONLN); | 77 return sysconf(_SC_NPROCESSORS_ONLN); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 | 81 |
82 const char* Platform::OperatingSystem() { | 82 const char* Platform::OperatingSystem() { |
83 #if TARGET_OS_IOS | 83 #if HOST_OS_IOS |
84 return "ios"; | 84 return "ios"; |
85 #else | 85 #else |
86 return "macos"; | 86 return "macos"; |
87 #endif | 87 #endif |
88 } | 88 } |
89 | 89 |
90 | 90 |
91 const char* Platform::LibraryPrefix() { | 91 const char* Platform::LibraryPrefix() { |
92 return "lib"; | 92 return "lib"; |
93 } | 93 } |
94 | 94 |
95 | 95 |
96 const char* Platform::LibraryExtension() { | 96 const char* Platform::LibraryExtension() { |
97 return "dylib"; | 97 return "dylib"; |
98 } | 98 } |
99 | 99 |
100 | 100 |
101 bool Platform::LocalHostname(char* buffer, intptr_t buffer_length) { | 101 bool Platform::LocalHostname(char* buffer, intptr_t buffer_length) { |
102 return gethostname(buffer, buffer_length) == 0; | 102 return gethostname(buffer, buffer_length) == 0; |
103 } | 103 } |
104 | 104 |
105 | 105 |
106 char** Platform::Environment(intptr_t* count) { | 106 char** Platform::Environment(intptr_t* count) { |
107 #if TARGET_OS_IOS | 107 #if HOST_OS_IOS |
108 // TODO(zra,chinmaygarde): On iOS, environment variables are seldom used. Wire | 108 // TODO(zra,chinmaygarde): On iOS, environment variables are seldom used. Wire |
109 // this up if someone needs it. In the meantime, we return an empty array. | 109 // this up if someone needs it. In the meantime, we return an empty array. |
110 char** result; | 110 char** result; |
111 result = reinterpret_cast<char**>(Dart_ScopeAllocate(1 * sizeof(*result))); | 111 result = reinterpret_cast<char**>(Dart_ScopeAllocate(1 * sizeof(*result))); |
112 if (result == NULL) { | 112 if (result == NULL) { |
113 return NULL; | 113 return NULL; |
114 } | 114 } |
115 result[0] = NULL; | 115 result[0] = NULL; |
116 *count = 0; | 116 *count = 0; |
117 return result; | 117 return result; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 159 } |
160 | 160 |
161 | 161 |
162 void Platform::Exit(int exit_code) { | 162 void Platform::Exit(int exit_code) { |
163 exit(exit_code); | 163 exit(exit_code); |
164 } | 164 } |
165 | 165 |
166 } // namespace bin | 166 } // namespace bin |
167 } // namespace dart | 167 } // namespace dart |
168 | 168 |
169 #endif // defined(TARGET_OS_MACOS) | 169 #endif // defined(HOST_OS_MACOS) |
OLD | NEW |