Memory (NetBSD): change formula to be consistant with other systems

This commit is contained in:
carterli 2025-01-13 18:33:05 +08:00 committed by 李通洲
parent 41e22ea866
commit fc969b01c7
No known key found for this signature in database
GPG Key ID: 269AD4F5325A22A3
3 changed files with 20 additions and 8 deletions

View File

@ -752,7 +752,7 @@ elseif(NetBSD)
src/detection/localip/localip_linux.c
src/detection/gamepad/gamepad_nosupport.c
src/detection/media/media_linux.c
src/detection/memory/memory_obsd.c
src/detection/memory/memory_nbsd.c
src/detection/mouse/mouse_nosupport.c
src/detection/netio/netio_bsd.c
src/detection/opengl/opengl_linux.c

View File

@ -4,13 +4,7 @@
const char* ffDetectMemory(FFMemoryResult* ram)
{
size_t length = sizeof(ram->bytesTotal);
if (sysctl((int[]){ CTL_HW,
#if __NetBSD__
HW_PHYSMEM64
#else
HW_PHYSMEM
#endif
}, 2, &ram->bytesTotal, &length, NULL, 0))
if (sysctl((int[]){ CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, NULL, 0))
return "Failed to read hw.physmem";
// vm.stats.vm.* are int values

View File

@ -0,0 +1,18 @@
#include "memory.h"
#include "common/sysctl.h"
#include <sys/param.h>
#include <uvm/uvm_extern.h>
const char* ffDetectMemory(FFMemoryResult* ram)
{
struct uvmexp_sysctl buf;
size_t length = sizeof(buf);
if (sysctl((int[]){ CTL_VM, VM_UVMEXP2 }, 2, &buf, &length, NULL, 0) < 0)
return "sysctl(CTL_VM, VM_UVMEXP2) failed";
ram->bytesTotal = (uint64_t) buf.npages * instance.state.platform.sysinfo.pageSize;
ram->bytesUsed = ((uint64_t) buf.active + (uint64_t) buf.inactive + (uint64_t) buf.wired) * instance.state.platform.sysinfo.pageSize;
return NULL;
}