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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 int __detect_mips_arch_revision(void) { | 134 int __detect_mips_arch_revision(void) { |
135 // TODO(dusmil): Do the specific syscall as soon as it is implemented in mips | 135 // TODO(dusmil): Do the specific syscall as soon as it is implemented in mips |
136 // kernel. Currently fail-back to the least common denominator which is | 136 // kernel. Currently fail-back to the least common denominator which is |
137 // mips32 revision 1. | 137 // mips32 revision 1. |
138 return 1; | 138 return 1; |
139 } | 139 } |
140 #endif | 140 #endif |
141 | 141 |
142 // Extract the information exposed by the kernel via /proc/cpuinfo. | 142 // Extract the information exposed by the kernel via /proc/cpuinfo. |
143 class CPUInfo V8_FINAL { | 143 class CPUInfo FINAL { |
144 public: | 144 public: |
145 CPUInfo() : datalen_(0) { | 145 CPUInfo() : datalen_(0) { |
146 // Get the size of the cpuinfo file by reading it until the end. This is | 146 // Get the size of the cpuinfo file by reading it until the end. This is |
147 // required because files under /proc do not always return a valid size | 147 // required because files under /proc do not always return a valid size |
148 // when using fseek(0, SEEK_END) + ftell(). Nor can the be mmap()-ed. | 148 // when using fseek(0, SEEK_END) + ftell(). Nor can the be mmap()-ed. |
149 static const char PATHNAME[] = "/proc/cpuinfo"; | 149 static const char PATHNAME[] = "/proc/cpuinfo"; |
150 FILE* fp = fopen(PATHNAME, "r"); | 150 FILE* fp = fopen(PATHNAME, "r"); |
151 if (fp != NULL) { | 151 if (fp != NULL) { |
152 for (;;) { | 152 for (;;) { |
153 char buffer[256]; | 153 char buffer[256]; |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 if (end == part) { | 519 if (end == part) { |
520 part_ = 0; | 520 part_ = 0; |
521 } | 521 } |
522 delete[] part; | 522 delete[] part; |
523 } | 523 } |
524 | 524 |
525 #endif | 525 #endif |
526 } | 526 } |
527 | 527 |
528 } } // namespace v8::base | 528 } } // namespace v8::base |
OLD | NEW |