mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-10-06 06:50:16 +00:00
NOISSUE add some arch probing code
This commit is contained in:
parent
15dfdb5706
commit
fb13f11fed
@ -12,6 +12,18 @@ enum class KernelType {
|
|||||||
Linux
|
Linux
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class ArchitectureType {
|
||||||
|
Undetermined,
|
||||||
|
I386,
|
||||||
|
AMD64,
|
||||||
|
ARM64
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Architecture {
|
||||||
|
ArchitectureType type;
|
||||||
|
QString raw;
|
||||||
|
};
|
||||||
|
|
||||||
struct KernelInfo
|
struct KernelInfo
|
||||||
{
|
{
|
||||||
QString kernelName;
|
QString kernelName;
|
||||||
@ -57,6 +69,8 @@ DistributionInfo getDistributionInfo();
|
|||||||
|
|
||||||
uint64_t getSystemRam();
|
uint64_t getSystemRam();
|
||||||
|
|
||||||
|
Architecture systemArchitecture();
|
||||||
|
|
||||||
bool isSystem64bit();
|
bool isSystem64bit();
|
||||||
|
|
||||||
bool isCPU64bit();
|
bool isCPU64bit();
|
||||||
|
@ -77,3 +77,21 @@ bool Sys::lookupSystemStatusCode(uint64_t code, std::string &name, std::string &
|
|||||||
{
|
{
|
||||||
return false;
|
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 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -117,6 +117,22 @@ Sys::DistributionInfo Sys::getDistributionInfo()
|
|||||||
return result;
|
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)
|
bool Sys::lookupSystemStatusCode(uint64_t code, std::string &name, std::string &description)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -94,3 +94,22 @@ bool Sys::lookupSystemStatusCode(uint64_t code, std::string &name, std::string &
|
|||||||
|
|
||||||
return hasCodeName || hasDescription;
|
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 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user