OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 "base/cpu.h" | 5 #include "base/cpu.h" |
6 | 6 |
| 7 #include <limits.h> |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
7 #include <stdlib.h> | 10 #include <stdlib.h> |
8 #include <string.h> | 11 #include <string.h> |
9 | 12 |
10 #include <algorithm> | 13 #include <algorithm> |
11 | 14 |
12 #include "base/basictypes.h" | 15 #include "base/macros.h" |
13 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
14 #include "build/build_config.h" | 17 #include "build/build_config.h" |
15 | 18 |
16 #if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) | 19 #if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) |
17 #include "base/files/file_util.h" | 20 #include "base/files/file_util.h" |
18 #include "base/lazy_instance.h" | 21 #include "base/lazy_instance.h" |
19 #endif | 22 #endif |
20 | 23 |
21 #if defined(ARCH_CPU_X86_FAMILY) | 24 #if defined(ARCH_CPU_X86_FAMILY) |
22 #if defined(_MSC_VER) | 25 #if defined(_MSC_VER) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 "cpuid\n" | 78 "cpuid\n" |
76 : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) | 79 : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) |
77 : "a"(info_type) | 80 : "a"(info_type) |
78 ); | 81 ); |
79 } | 82 } |
80 | 83 |
81 #endif | 84 #endif |
82 | 85 |
83 // _xgetbv returns the value of an Intel Extended Control Register (XCR). | 86 // _xgetbv returns the value of an Intel Extended Control Register (XCR). |
84 // Currently only XCR0 is defined by Intel so |xcr| should always be zero. | 87 // Currently only XCR0 is defined by Intel so |xcr| should always be zero. |
85 uint64 _xgetbv(uint32 xcr) { | 88 uint64_t _xgetbv(uint32_t xcr) { |
86 uint32 eax, edx; | 89 uint32_t eax, edx; |
87 | 90 |
88 __asm__ volatile ( | 91 __asm__ volatile ( |
89 "xgetbv" : "=a"(eax), "=d"(edx) : "c"(xcr)); | 92 "xgetbv" : "=a"(eax), "=d"(edx) : "c"(xcr)); |
90 return (static_cast<uint64>(edx) << 32) | eax; | 93 return (static_cast<uint64_t>(edx) << 32) | eax; |
91 } | 94 } |
92 | 95 |
93 #endif // !_MSC_VER | 96 #endif // !_MSC_VER |
94 #endif // ARCH_CPU_X86_FAMILY | 97 #endif // ARCH_CPU_X86_FAMILY |
95 | 98 |
96 #if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) | 99 #if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) |
97 class LazyCpuInfoValue { | 100 class LazyCpuInfoValue { |
98 public: | 101 public: |
99 LazyCpuInfoValue() : has_broken_neon_(false) { | 102 LazyCpuInfoValue() : has_broken_neon_(false) { |
100 // This function finds the value from /proc/cpuinfo under the key "model | 103 // This function finds the value from /proc/cpuinfo under the key "model |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 if (has_sse42()) return SSE42; | 287 if (has_sse42()) return SSE42; |
285 if (has_sse41()) return SSE41; | 288 if (has_sse41()) return SSE41; |
286 if (has_ssse3()) return SSSE3; | 289 if (has_ssse3()) return SSSE3; |
287 if (has_sse3()) return SSE3; | 290 if (has_sse3()) return SSE3; |
288 if (has_sse2()) return SSE2; | 291 if (has_sse2()) return SSE2; |
289 if (has_sse()) return SSE; | 292 if (has_sse()) return SSE; |
290 return PENTIUM; | 293 return PENTIUM; |
291 } | 294 } |
292 | 295 |
293 } // namespace base | 296 } // namespace base |
OLD | NEW |