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 "src/base/cpu.h" | 5 #include "src/base/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_LINUX | 10 #if V8_OS_LINUX |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 : "=m"(result) | 171 : "=m"(result) |
172 : | 172 : |
173 : "v0", "memory"); | 173 : "v0", "memory"); |
174 // Result is 0 on r6 architectures, 1 on other architecture revisions. | 174 // Result is 0 on r6 architectures, 1 on other architecture revisions. |
175 // Fall-back to the least common denominator which is mips32 revision 1. | 175 // Fall-back to the least common denominator which is mips32 revision 1. |
176 return result ? 1 : 6; | 176 return result ? 1 : 6; |
177 } | 177 } |
178 #endif | 178 #endif |
179 | 179 |
180 // Extract the information exposed by the kernel via /proc/cpuinfo. | 180 // Extract the information exposed by the kernel via /proc/cpuinfo. |
181 class CPUInfo FINAL { | 181 class CPUInfo final { |
182 public: | 182 public: |
183 CPUInfo() : datalen_(0) { | 183 CPUInfo() : datalen_(0) { |
184 // Get the size of the cpuinfo file by reading it until the end. This is | 184 // Get the size of the cpuinfo file by reading it until the end. This is |
185 // required because files under /proc do not always return a valid size | 185 // required because files under /proc do not always return a valid size |
186 // when using fseek(0, SEEK_END) + ftell(). Nor can the be mmap()-ed. | 186 // when using fseek(0, SEEK_END) + ftell(). Nor can the be mmap()-ed. |
187 static const char PATHNAME[] = "/proc/cpuinfo"; | 187 static const char PATHNAME[] = "/proc/cpuinfo"; |
188 FILE* fp = fopen(PATHNAME, "r"); | 188 FILE* fp = fopen(PATHNAME, "r"); |
189 if (fp != NULL) { | 189 if (fp != NULL) { |
190 for (;;) { | 190 for (;;) { |
191 char buffer[256]; | 191 char buffer[256]; |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 case POWER_5: | 685 case POWER_5: |
686 part_ = PPC_POWER5; | 686 part_ = PPC_POWER5; |
687 break; | 687 break; |
688 } | 688 } |
689 #endif // V8_OS_AIX | 689 #endif // V8_OS_AIX |
690 #endif // !USE_SIMULATOR | 690 #endif // !USE_SIMULATOR |
691 #endif // V8_HOST_ARCH_PPC | 691 #endif // V8_HOST_ARCH_PPC |
692 } | 692 } |
693 | 693 |
694 } } // namespace v8::base | 694 } } // namespace v8::base |
OLD | NEW |