AuroraRuntime/Source/HWInfo/HWInfo.cpp

52 lines
1.0 KiB
C++
Raw Normal View History

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: HWInfo.hpp
Date: 2021-6-19
Author: Reece
***/
2021-09-30 14:57:41 +00:00
#include <Source/RuntimeInternal.hpp>
#include "HWInfo.hpp"
#include "CpuInfo.hpp"
#include "RamInfo.hpp"
#if defined(AURORA_IS_BSD_DERIVED)
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
namespace Aurora::HWInfo
{
template<typename T>
AuOptional<T> QueryBsdHwStat(int id)
{
#if defined(AURORA_IS_BSD_DERIVED)
int mib[4];
T stat;
size_t len = sizeof(stat);
mib[0] = CTL_HW;
mib[1] = id;
auto ret = sysctl(mib, 2, &stat, &len, NULL, 0);
return ret == 0 ? stat : {};
#else
return {};
#endif
}
template<>
AuOptional<AuUInt> QueryBsdHwStat(int id);
template<>
AuOptional<unsigned int> QueryBsdHwStat(int id);
template<>
AuOptional<uint64_t> QueryBsdHwStat(int id);
void Init()
{
InitCpuInfo();
InitRamInfo();
}
}