mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 19:55:07 +02:00
new mac os stubs
This commit is contained in:
parent
0d97543ece
commit
8b1cdb03cc
2 changed files with 119 additions and 0 deletions
86
libraries/platform/src/MACOSPlatform.cpp
Normal file
86
libraries/platform/src/MACOSPlatform.cpp
Normal file
|
@ -0,0 +1,86 @@
|
|||
//
|
||||
// Created by Amer Cerkic 05/02/2019
|
||||
// Copyright 2019 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "MACOSPlatform.h"
|
||||
#include <intrin.h>
|
||||
#include <thread>
|
||||
#include <GPUIdent.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
using namespace platform;
|
||||
using namespace nlohmann;
|
||||
|
||||
bool MACOSInstance::enumeratePlatform() {
|
||||
enumerateCpu();
|
||||
enumerateGpu();
|
||||
enumerateRam();
|
||||
return true;
|
||||
}
|
||||
|
||||
void WINInstance::enumerateCpu() {
|
||||
json *cpu= new json();
|
||||
int CPUInfo[4] = { -1 };
|
||||
unsigned nExIds;
|
||||
unsigned int i = 0;
|
||||
char CPUBrandString[16];
|
||||
char CPUModelString[16];
|
||||
char CPUClockString[16];
|
||||
|
||||
// Get the information associated with each extended ID.
|
||||
__cpuid(CPUInfo, 0x80000000);
|
||||
nExIds = CPUInfo[0];
|
||||
|
||||
for (i = 0x80000000; i <= nExIds; ++i) {
|
||||
__cpuid(CPUInfo, i);
|
||||
// Interpret CPU brand string
|
||||
if (i == 0x80000002) {
|
||||
memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
|
||||
} else if (i == 0x80000003) {
|
||||
memcpy(CPUModelString, CPUInfo, sizeof(CPUInfo));
|
||||
} else if (i == 0x80000004) {
|
||||
memcpy(CPUClockString, CPUInfo, sizeof(CPUInfo));
|
||||
}
|
||||
}
|
||||
|
||||
(*cpu)["brand"] = CPUBrandString;
|
||||
(*cpu)["model"] = CPUModelString;
|
||||
(*cpu)["clockSpeed"] = CPUClockString;
|
||||
(*cpu)["numCores"] = getNumLogicalCores();
|
||||
|
||||
_cpu.push_back(cpu);
|
||||
}
|
||||
|
||||
unsigned int WINInstance::getNumLogicalCores() {
|
||||
return std::thread::hardware_concurrency();
|
||||
}
|
||||
|
||||
void WINInstance::enumerateGpu() {
|
||||
|
||||
GPUIdent* ident = GPUIdent::getInstance();
|
||||
|
||||
json *gpu = new json();
|
||||
(*gpu)["name"] = ident->getName().toUtf8().constData();
|
||||
(*gpu)["memory"] = ident->getMemory();
|
||||
(*gpu)["driver"] = ident->getDriver().toUtf8().constData();
|
||||
|
||||
_gpu.push_back(gpu);
|
||||
_display = ident->getOutput();
|
||||
}
|
||||
|
||||
void WINInstance::enumerateRam() {
|
||||
json* ram = new json();
|
||||
|
||||
MEMORYSTATUSEX statex;
|
||||
statex.dwLength = sizeof(statex);
|
||||
GlobalMemoryStatusEx(&statex);
|
||||
int totalRam = statex.ullTotalPhys / 1024 / 1024;
|
||||
(*ram)["totalMem"] = totalRam;
|
||||
|
||||
_memory.push_back(ram);
|
||||
}
|
33
libraries/platform/src/MACOSPlatform.h
Normal file
33
libraries/platform/src/MACOSPlatform.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// Created by Amer Cerkic 05/02/2019
|
||||
// Copyright 2019 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_WinPlatform_h
|
||||
#define hifi_WinPlatform_h
|
||||
|
||||
#include "platform.h"
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace platform {
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
class MACOSInstance : public Instance {
|
||||
|
||||
public:
|
||||
bool enumeratePlatform();
|
||||
|
||||
private:
|
||||
unsigned int getNumLogicalCores();
|
||||
void enumerateCpu();
|
||||
void enumerateRam();
|
||||
void enumerateGpu();
|
||||
};
|
||||
|
||||
} // namespace platform
|
||||
|
||||
#endif //hifi_winplatform_h
|
Loading…
Reference in a new issue