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

22 lines
695 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
2023-05-11 20:39:54 +08:00
const char* ffDetectMemory(FFMemoryResult* ram)
2022-09-19 22:23:31 +02:00
{
2023-05-11 20:39:54 +08:00
uint32_t pageSize;
uint64_t length = sizeof(pageSize);
if (sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &pageSize, &length, NULL, 0))
return "Failed to read hw.pagesize";
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)
2023-05-11 20:39:54 +08:00
return "Failed to read vm.stats.vm.v_page_count";
2022-09-20 15:12:24 +02:00
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
;
2023-05-11 20:39:54 +08:00
return NULL;
2022-09-20 15:12:24 +02:00
}