NOISSUE add some arch probing code

This commit is contained in:
Petr Mrázek 2023-09-02 03:16:53 +02:00
parent 9ec1d43565
commit f458204a52
4 changed files with 67 additions and 0 deletions

View File

@ -12,6 +12,18 @@ enum class KernelType {
Linux
};
enum class ArchitectureType {
Undetermined,
I386,
AMD64,
ARM64
};
struct Architecture {
ArchitectureType type;
QString raw;
};
struct KernelInfo
{
QString kernelName;
@ -57,6 +69,8 @@ DistributionInfo getDistributionInfo();
uint64_t getSystemRam();
Architecture systemArchitecture();
bool isSystem64bit();
bool isCPU64bit();

View File

@ -77,3 +77,21 @@ bool Sys::lookupSystemStatusCode(uint64_t code, std::string &name, std::string &
{
return false;
}
Sys::Architecture Sys::systemArchitecture() {
struct utsname buf;
uname(&buf);
QString arch = buf.machine;
if (arch == "x86_64") {
return { ArchitectureType::AMD64, arch };
}
else if (arch == "i386") {
return { ArchitectureType::I386, arch };
}
else if (arch == "arm64") {
return { ArchitectureType::ARM64, arch };
}
else {
return { ArchitectureType::Undetermined, arch };
}
}

View File

@ -117,6 +117,22 @@ Sys::DistributionInfo Sys::getDistributionInfo()
return result;
}
Sys::Architecture Sys::systemArchitecture() {
QString qtArch = QSysInfo::currentCpuArchitecture();
if (qtArch == "x86_64") {
return { ArchitectureType::AMD64, qtArch };
}
else if (qtArch == "i386") {
return { ArchitectureType::I386, qtArch };
}
else if (qtArch == "arm64") {
return { ArchitectureType::ARM64, qtArch };
}
else {
return { ArchitectureType::Undetermined, qtArch };
}
}
bool Sys::lookupSystemStatusCode(uint64_t code, std::string &name, std::string &description)
{
return false;

View File

@ -94,3 +94,22 @@ bool Sys::lookupSystemStatusCode(uint64_t code, std::string &name, std::string &
return hasCodeName || hasDescription;
}
Sys::Architecture Sys::systemArchitecture() {
SYSTEM_INFO info;
ZeroMemory(&info, sizeof(SYSTEM_INFO));
GetNativeSystemInfo(&info);
auto arch = info.wProcessorArchitecture;
QString qtArch = QSysInfo::currentCpuArchitecture();
switch (arch) {
case PROCESSOR_ARCHITECTURE_AMD64:
return { ArchitectureType::AMD64, "x86_64" };
case PROCESSOR_ARCHITECTURE_ARM64:
return { ArchitectureType::ARM64, "arm64" };
case PROCESSOR_ARCHITECTURE_INTEL:
return { ArchitectureType::I386, "i386" };
default:
return { ArchitectureType::Undetermined, qtArch };
}
}