2024-10-04 15:58:17 +08:00
|
|
|
#include "memory.h"
|
|
|
|
|
#include "common/sysctl.h"
|
|
|
|
|
|
2024-10-11 14:14:51 +08:00
|
|
|
#include <sys/param.h>
|
2025-01-13 18:29:18 +08:00
|
|
|
#include <uvm/uvm_extern.h>
|
2024-10-28 15:19:05 +08:00
|
|
|
|
2024-10-04 15:58:17 +08:00
|
|
|
const char* ffDetectMemory(FFMemoryResult* ram)
|
|
|
|
|
{
|
2024-10-11 14:14:51 +08:00
|
|
|
struct uvmexp buf;
|
|
|
|
|
size_t length = sizeof(buf);
|
|
|
|
|
if (sysctl((int[]){ CTL_VM, VM_UVMEXP }, 2, &buf, &length, NULL, 0) < 0)
|
|
|
|
|
return "sysctl(CTL_VM, VM_UVMEXP) failed";
|
2024-10-04 15:58:17 +08:00
|
|
|
|
2024-10-11 14:14:51 +08:00
|
|
|
ram->bytesTotal = (uint64_t) buf.npages * instance.state.platform.sysinfo.pageSize;
|
2025-01-13 18:29:18 +08:00
|
|
|
ram->bytesUsed = ((uint64_t) buf.active + (uint64_t) buf.inactive + (uint64_t) buf.wired) * instance.state.platform.sysinfo.pageSize;
|
2024-10-04 15:58:17 +08:00
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|