| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cpu.h" | 5 #include "cpu.h" |
| 6 | 6 |
| 7 #if V8_LIBC_MSVCRT | 7 #if V8_LIBC_MSVCRT |
| 8 #include <intrin.h> // __cpuid() | 8 #include <intrin.h> // __cpuid() |
| 9 #endif | 9 #endif |
| 10 #if V8_OS_POSIX | 10 #if V8_OS_POSIX |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 result[len] = '\0'; | 199 result[len] = '\0'; |
| 200 } | 200 } |
| 201 return result; | 201 return result; |
| 202 } | 202 } |
| 203 | 203 |
| 204 private: | 204 private: |
| 205 char* data_; | 205 char* data_; |
| 206 size_t datalen_; | 206 size_t datalen_; |
| 207 }; | 207 }; |
| 208 | 208 |
| 209 #if V8_HOST_ARCH_ARM || V8_HOST_ARCH_MIPS |
| 209 | 210 |
| 210 // Checks that a space-separated list of items contains one given 'item'. | 211 // Checks that a space-separated list of items contains one given 'item'. |
| 211 static bool HasListItem(const char* list, const char* item) { | 212 static bool HasListItem(const char* list, const char* item) { |
| 212 ssize_t item_len = strlen(item); | 213 ssize_t item_len = strlen(item); |
| 213 const char* p = list; | 214 const char* p = list; |
| 214 if (p != NULL) { | 215 if (p != NULL) { |
| 215 while (*p != '\0') { | 216 while (*p != '\0') { |
| 216 // Skip whitespace. | 217 // Skip whitespace. |
| 217 while (isspace(*p)) ++p; | 218 while (isspace(*p)) ++p; |
| 218 | 219 |
| 219 // Find end of current list item. | 220 // Find end of current list item. |
| 220 const char* q = p; | 221 const char* q = p; |
| 221 while (*q != '\0' && !isspace(*q)) ++q; | 222 while (*q != '\0' && !isspace(*q)) ++q; |
| 222 | 223 |
| 223 if (item_len == q - p && memcmp(p, item, item_len) == 0) { | 224 if (item_len == q - p && memcmp(p, item, item_len) == 0) { |
| 224 return true; | 225 return true; |
| 225 } | 226 } |
| 226 | 227 |
| 227 // Skip to next item. | 228 // Skip to next item. |
| 228 p = q; | 229 p = q; |
| 229 } | 230 } |
| 230 } | 231 } |
| 231 return false; | 232 return false; |
| 232 } | 233 } |
| 233 | 234 |
| 235 #endif // V8_HOST_ARCH_ARM || V8_HOST_ARCH_MIPS |
| 236 |
| 234 #endif // V8_OS_LINUX | 237 #endif // V8_OS_LINUX |
| 235 | 238 |
| 236 #endif // V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 | 239 #endif // V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 |
| 237 | 240 |
| 238 CPU::CPU() : stepping_(0), | 241 CPU::CPU() : stepping_(0), |
| 239 model_(0), | 242 model_(0), |
| 240 ext_model_(0), | 243 ext_model_(0), |
| 241 family_(0), | 244 family_(0), |
| 242 ext_family_(0), | 245 ext_family_(0), |
| 243 type_(0), | 246 type_(0), |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 #if V8_OS_WIN | 502 #if V8_OS_WIN |
| 500 SYSTEM_INFO info; | 503 SYSTEM_INFO info; |
| 501 GetSystemInfo(&info); | 504 GetSystemInfo(&info); |
| 502 return info.dwNumberOfProcessors; | 505 return info.dwNumberOfProcessors; |
| 503 #else | 506 #else |
| 504 return static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN)); | 507 return static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN)); |
| 505 #endif | 508 #endif |
| 506 } | 509 } |
| 507 | 510 |
| 508 } } // namespace v8::internal | 511 } } // namespace v8::internal |
| OLD | NEW |