From bfb1f4fee34556ca290bafd330e5bfa6e59ac35b Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 16 Feb 2016 18:20:17 -0800 Subject: [PATCH] Fix transposed size Add check for availability --- include/Math.hpp | 4 ++-- src/Math.cpp | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/Math.hpp b/include/Math.hpp index b939261..a9ea559 100644 --- a/include/Math.hpp +++ b/include/Math.hpp @@ -16,8 +16,8 @@ namespace Zeus { struct CPUInfo { -const char cpuBrand [32] = {0}; -const char cpuVendor[64] = {0}; +const char cpuBrand [48] = {0}; +const char cpuVendor[32] = {0}; const bool isIntel = false; const bool SSE1 = false; const bool SSE2 = false; diff --git a/src/Math.cpp b/src/Math.cpp index b23e220..30c8f50 100644 --- a/src/Math.cpp +++ b/src/Math.cpp @@ -35,16 +35,20 @@ void detectCPU() *reinterpret_cast((char*)g_cpuFeatures.cpuVendor) = regs[1]; *reinterpret_cast((char*)g_cpuFeatures.cpuVendor + 4) = regs[3]; *reinterpret_cast((char*)g_cpuFeatures.cpuVendor + 8) = regs[2]; - for (unsigned int i = 0x80000002; i <= 0x80000004; i++) + getCpuInfo(0x80000000, regs); + if (regs[0] >= 0x80000004) { - getCpuInfo(i, regs); - // Interpret CPU brand string and cache information. - if (i == 0x80000002) - memcpy((char*)g_cpuFeatures.cpuBrand, regs, sizeof(regs)); - else if( i == 0x80000003 ) - memcpy((char*)g_cpuFeatures.cpuBrand + 16, regs, sizeof(regs)); - else if( i == 0x80000004 ) - memcpy((char*)g_cpuFeatures.cpuBrand + 32, regs, sizeof(regs)); + for (unsigned int i = 0x80000002; i <= 0x80000004; i++) + { + getCpuInfo(i, regs); + // Interpret CPU brand string and cache information. + if (i == 0x80000002) + memcpy((char*)g_cpuFeatures.cpuBrand, regs, sizeof(regs)); + else if( i == 0x80000003 ) + memcpy((char*)g_cpuFeatures.cpuBrand + 16, regs, sizeof(regs)); + else if( i == 0x80000004 ) + memcpy((char*)g_cpuFeatures.cpuBrand + 32, regs, sizeof(regs)); + } } getCpuInfo(1, regs);