52 lines
1.0 KiB
C++
52 lines
1.0 KiB
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: HWInfo.hpp
|
|
Date: 2021-6-19
|
|
Author: Reece
|
|
***/
|
|
#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();
|
|
}
|
|
} |