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_POSIX | 10 #if V8_OS_POSIX |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 } | 108 } |
109 } | 109 } |
110 fclose(fp); | 110 fclose(fp); |
111 } | 111 } |
112 return result; | 112 return result; |
113 } | 113 } |
114 | 114 |
115 #endif // V8_HOST_ARCH_ARM | 115 #endif // V8_HOST_ARCH_ARM |
116 | 116 |
117 // Extract the information exposed by the kernel via /proc/cpuinfo. | 117 // Extract the information exposed by the kernel via /proc/cpuinfo. |
118 class CPUInfo V8_FINAL BASE_EMBEDDED { | 118 class CPUInfo V8_FINAL { |
119 public: | 119 public: |
120 CPUInfo() : datalen_(0) { | 120 CPUInfo() : datalen_(0) { |
121 // Get the size of the cpuinfo file by reading it until the end. This is | 121 // Get the size of the cpuinfo file by reading it until the end. This is |
122 // required because files under /proc do not always return a valid size | 122 // required because files under /proc do not always return a valid size |
123 // when using fseek(0, SEEK_END) + ftell(). Nor can the be mmap()-ed. | 123 // when using fseek(0, SEEK_END) + ftell(). Nor can the be mmap()-ed. |
124 static const char PATHNAME[] = "/proc/cpuinfo"; | 124 static const char PATHNAME[] = "/proc/cpuinfo"; |
125 FILE* fp = fopen(PATHNAME, "r"); | 125 FILE* fp = fopen(PATHNAME, "r"); |
126 if (fp != NULL) { | 126 if (fp != NULL) { |
127 for (;;) { | 127 for (;;) { |
128 char buffer[256]; | 128 char buffer[256]; |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 if (end == part) { | 489 if (end == part) { |
490 part_ = 0; | 490 part_ = 0; |
491 } | 491 } |
492 delete[] part; | 492 delete[] part; |
493 } | 493 } |
494 | 494 |
495 #endif | 495 #endif |
496 } | 496 } |
497 | 497 |
498 } } // namespace v8::base | 498 } } // namespace v8::base |
OLD | NEW |