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]; |
jar (doing other things)
2012/10/03 00:33:04
Here this is declared to be length 32, but on line
|
+ char cpu_brand[0x30]; |
jar (doing other things)
2012/10/03 00:33:04
Please use decimal, rather than hex here. 48 is m
|
// __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; |
Mark Mentovai
2012/10/03 00:33:17
“flag” isn’t a good name. Thcpuid documentation us
|
+ |
+ for (int index = 0; index < 3; index++) { |
Mark Mentovai
2012/10/03 00:33:17
Why don’t you just write the loop by initializing
|
+ __cpuid(cpu_info, start_flag + index); |
+ *(reinterpret_cast<int*>(cpu_brand + index*16)) = cpu_info[0]; |
jar (doing other things)
2012/10/03 00:33:04
nit: spaces around an arithmetic operator "*"
Bet
Mark Mentovai
2012/10/03 00:33:17
I can see that this was copied from line 101, but
|
+ *(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; |
jar (doing other things)
2012/10/03 00:33:04
How about declaring cpu_brand to be:
int cup_brand
|
+ } |
} |
#endif |
} |