Files
fastfetch/src/detection/memory/memory_bsd.c
T

25 lines
721 B
C
Raw Normal View History

2022-09-19 22:23:31 +02:00
#include "memory.h"
2022-09-19 23:16:43 +02:00
#include "common/sysctl.h"
2022-09-19 22:23:31 +02:00
2022-12-28 15:55:31 +08:00
void ffDetectMemory(FFMemoryStorage* ram)
2022-09-19 22:23:31 +02:00
{
2022-09-20 11:16:08 +02:00
uint32_t pageSize = (uint32_t) ffSysctlGetInt("hw.pagesize", 0);
2022-09-20 15:12:24 +02:00
if(pageSize == 0)
{
ffStrbufAppendS(&ram->error, "Failed to read hw.pagesize");
return;
}
2022-09-20 11:16:08 +02:00
2022-09-29 11:35:59 +02:00
ram->bytesTotal = (uint64_t) ffSysctlGetInt64("vm.stats.vm.v_page_count", 0) * pageSize;
2022-09-20 15:12:24 +02:00
if(ram->bytesTotal == 0)
{
ffStrbufAppendS(&ram->error, "Failed to read vm.stats.vm.v_page_count");
return;
}
2022-09-29 12:24:00 +02:00
ram->bytesUsed = ram->bytesTotal
2022-09-20 11:16:08 +02:00
- (uint64_t) ffSysctlGetInt64("vm.stats.vm.v_free_count", 0) * pageSize
- (uint64_t) ffSysctlGetInt64("vm.stats.vm.v_inactive_count", 0) * pageSize
;
2022-09-20 15:12:24 +02:00
}