PrismLauncher/libraries/systeminfo/src/sys_apple.cpp

68 lines
1.4 KiB
C++
Raw Normal View History

#include "sys.h"
#include <sys/utsname.h>
#include <QString>
#include <QStringList>
Sys::KernelInfo Sys::getKernelInfo()
{
2018-07-15 13:51:05 +01:00
Sys::KernelInfo out;
struct utsname buf;
uname(&buf);
out.kernelType = KernelType::Darwin;
2018-07-15 13:51:05 +01:00
out.kernelName = buf.sysname;
QString release = out.kernelVersion = buf.release;
// TODO: figure out how to detect cursed-ness (macOS emulated on linux via mad hacks and so on)
out.isCursed = false;
out.kernelMajor = 0;
out.kernelMinor = 0;
out.kernelPatch = 0;
auto sections = release.split('-');
if(sections.size() >= 1) {
auto versionParts = sections[0].split('.');
if(sections.size() >= 3) {
out.kernelMajor = sections[0].toInt();
out.kernelMinor = sections[1].toInt();
out.kernelPatch = sections[2].toInt();
}
}
2018-07-15 13:51:05 +01:00
return out;
}
#include <sys/sysctl.h>
uint64_t Sys::getSystemRam()
{
2018-07-15 13:51:05 +01:00
uint64_t memsize;
size_t memsizesize = sizeof(memsize);
if(!sysctlbyname("hw.memsize", &memsize, &memsizesize, NULL, 0))
{
return memsize;
}
else
{
return 0;
}
}
bool Sys::isCPU64bit()
{
2018-07-15 13:51:05 +01:00
// not even going to pretend I'm going to support anything else
return true;
}
bool Sys::isSystem64bit()
{
2018-07-15 13:51:05 +01:00
// yep. maybe when we have 128bit CPUs on consumer devices.
return true;
}
Sys::DistributionInfo Sys::getDistributionInfo()
{
2018-07-15 13:51:05 +01:00
DistributionInfo result;
return result;
}