[+] AuOptional<AuUInt> Aurora::HWInfo::GetSwapSize()

[+] AuOptional<AuUInt> Aurora::HWInfo::GetPhysicalSize()
utils
This commit is contained in:
Reece Wilson 2023-08-30 01:37:00 +01:00
parent 46850c9122
commit 627cdd069f
2 changed files with 39 additions and 2 deletions

View File

@ -29,19 +29,21 @@ namespace Aurora::HWInfo
*/
AUKN_SYM AuOptional<RamStat> GetMemStatSystem();
/**
* @brief Physical Memory Used / Total Physical Memory
* @return
*/
AUKN_SYM AuOptional<RamStat> GetMemStatPhysical();
/**
* @brief GetMemStatSystem at start-up
* @return
*/
AUKN_SYM AuOptional<RamStat> GetMemStatStartup();
AUKN_SYM AuOptional<AuUInt> GetSwapSize();
AUKN_SYM AuOptional<AuUInt> GetPhysicalSize();
AUKN_SYM AuUInt32 GetPageSize();
}

View File

@ -271,6 +271,41 @@ namespace Aurora::HWInfo
return gPageSize;
}
AUKN_SYM AuOptional<AuUInt> GetSwapSize()
{
static AuOptional<AuUInt> gCached;
if (gCached)
{
return gCached;
}
if (auto opt = GetMemStatSystem())
{
if (auto optPhys = GetMemStatPhysical())
{
return gCached = (opt.value().qwAvailable - optPhys.value().qwAvailable);
}
}
return {};
}
AUKN_SYM AuOptional<AuUInt> GetPhysicalSize()
{
static AuOptional<AuUInt> gCached;
if (gCached)
{
return gCached;
}
if (auto optPhys = GetMemStatPhysical())
{
return gCached = optPhys.value().qwAvailable;
}
return {};
}
static void SetPageSize()
{
#if defined(AURORA_IS_MODERNNT_DERIVED)