From 99f8b61727dbe33fbd69b24f4b0b7043eeee3b47 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 28 May 2019 00:14:50 -0700 Subject: [PATCH] Trying to unify the getCPUID function in CPUIdent --- libraries/shared/src/CPUIdent.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/libraries/shared/src/CPUIdent.cpp b/libraries/shared/src/CPUIdent.cpp index 2545f0c56b..81a2a8a869 100644 --- a/libraries/shared/src/CPUIdent.cpp +++ b/libraries/shared/src/CPUIdent.cpp @@ -18,6 +18,9 @@ void getCPUID(int32_t* p, int32_t ax) { __cpuid(p, ax); } +void getCPUIDEX(int32_t* p, int32_t ax, int32_t ecx) { + __cpuidex(p, ax, ecx); +} #elif defined(Q_OS_MAC) void getCPUID(int32_t* p, int32_t ax) { @@ -30,6 +33,9 @@ void getCPUID(int32_t* p, int32_t ax) { : "0" (ax) ); } +void getCPUIDEX(int32_t* p, int32_t ax, int32_t ecx) { + getCPUID(p, ax, ecx); +} #elif defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) void getCPUID(int32_t* p, int32_t ax) { @@ -42,12 +48,20 @@ void getCPUID(int32_t* p, int32_t ax) { : "0" (ax) ); } +void getCPUIDEX(int32_t* p, int32_t ax, int32_t ecx) { + getCPUID(p, ax, ecx); +} + #else void getCPUID(int32_t* p, int32_t ax) { if (p) { memset(p, 0, 4*4); } } +void getCPUIDEX(int32_t* p, int32_t ax, int32_t ecx) { + getCPUID(p, ax, ecx); +} + #endif @@ -135,7 +149,7 @@ CPUIdent::CPUIdent_Internal::CPUIdent_Internal() nIds_ = cpui[0]; for (int i = 0; i <= nIds_; ++i) { - __cpuidex(cpui.data(), i, 0); + getCPUIDEX(cpui.data(), i, 0); data_.push_back(cpui); } @@ -167,14 +181,14 @@ CPUIdent::CPUIdent_Internal::CPUIdent_Internal() // Calling __cpuid with 0x80000000 as the function_id argument // gets the number of the highest valid extended ID. - __cpuid(cpui.data(), 0x80000000); + getCPUID(cpui.data(), 0x80000000); nExIds_ = cpui[0]; char brand[0x40]; memset(brand, 0, sizeof(brand)); for (int i = 0x80000000; i <= nExIds_; ++i) { - __cpuidex(cpui.data(), i, 0); + getCPUIDEX(cpui.data(), i, 0); extdata_.push_back(cpui); }