GithubHelp home page GithubHelp logo

how to get cpuid? about hwinfo HOT 3 CLOSED

lfreist avatar lfreist commented on August 19, 2024
how to get cpuid?

from hwinfo.

Comments (3)

lfreist avatar lfreist commented on August 19, 2024

What exactly do you mean by cpuid?

If you mean the x86 instruction: hwinfo uses it on x86 machines to get processor information and provides them in the ˋhwinfo::CPUˋ class.

from hwinfo.

xinsuinizhuan avatar xinsuinizhuan commented on August 19, 2024

yes, in x86, this code could get the cpu id:
void getCpuId(int cpuInfo[], int infoType)
{
#if 0
#ifdef Q_OS_WIN
// #include "intrin.h"
//__cpuid(cpuInfo, infoType);return;
#if _MSC_VER
int excValue = 0;
_asm {
mov edi, cpuInfo;
mov eax, infoType;
mov ecx, excValue;
cpuid;
mov [edi], eax;
mov [edi+4], ebx;
mov [edi+8], ecx;
mov [edi+12], edx;
}
#else
asm volatile
(
"cpuid"
: "=a"(cpuInfo[0]), "=b"(cpuInfo[1]), "=c"(cpuInfo[2]), "=d"(cpuInfo[3])
: "a"(infoType)
);
#endif
#endif
#endif
}

QString getCpuId2()
{
QString cpu_id;
int cpuInfo[4] = {0};
getCpuId(cpuInfo, 1);

QString str0 = QString::number((quint32)cpuInfo[3], 16).toUpper();
str0 = str0.rightJustified(8, '0');
QString str1 = QString::number((quint32)cpuInfo[0], 16).toUpper();
str1 = str1.rightJustified(8, '0');
cpu_id = str0 + str1;
return cpu_id;

}

but how to get the cpuid in linux?

from hwinfo.

lfreist avatar lfreist commented on August 19, 2024

Looks like this question is not related to hwinfo. Please consider using c++/x86/assembler related forums for this kind of questions.

However cpuid.h implements a platform independent cpuid call.

from hwinfo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.