Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2995)

Unified Diff: base/cpu.cc

Issue 11009011: Use the cpuid instruction to generate the CPU brand string. And (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/cpu.cc
===================================================================
--- base/cpu.cc (revision 159378)
+++ base/cpu.cc (working copy)
@@ -85,6 +85,7 @@
#if defined(ARCH_CPU_X86_FAMILY)
int cpu_info[4] = {-1};
char cpu_string[0x20];
+ char cpu_brand[0x30];
// __cpuid with an InfoType argument of 0 returns the number of
// valid Ids in CPUInfo[0] and the CPU identification string in
@@ -118,6 +119,23 @@
has_ssse3_ = (cpu_info[2] & 0x00000200) != 0;
has_sse41_ = (cpu_info[2] & 0x00080000) != 0;
has_sse42_ = (cpu_info[2] & 0x00100000) != 0;
+
+ // get the brand string of the cpu.
+ __cpuid(cpu_info, 0x80000000);
+
+ if (cpu_info[0] >= 0x80000004) {
+ memset(cpu_brand, 0, sizeof(cpu_brand));
+ int start_flag = 0x80000002;
+
+ for (int index = 0; index < 3; index++) {
+ __cpuid(cpu_info, start_flag + index);
+ *(reinterpret_cast<int*>(cpu_brand + index*16)) = cpu_info[0];
+ *(reinterpret_cast<int*>(cpu_brand + index*16 + 4)) = cpu_info[1];
+ *(reinterpret_cast<int*>(cpu_brand + index*16 + 8)) = cpu_info[2];
+ *(reinterpret_cast<int*>(cpu_brand + index*16 + 12)) = cpu_info[3];
+ }
+ cpu_brand_ = cpu_brand;
+ }
}
#endif
}
« base/cpu.h ('K') | « base/cpu.h ('k') | content/browser/gpu/gpu_blacklist.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698