diff --git a/CMakeLists.txt b/CMakeLists.txt index d524a7ada..d46d79153 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/detection/memory/memory_bsd.c b/src/detection/memory/memory_bsd.c index 587ca7f1f..0db20527a 100644 --- a/src/detection/memory/memory_bsd.c +++ b/src/detection/memory/memory_bsd.c @@ -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 diff --git a/src/detection/memory/memory_nbsd.c b/src/detection/memory/memory_nbsd.c new file mode 100644 index 000000000..651058686 --- /dev/null +++ b/src/detection/memory/memory_nbsd.c @@ -0,0 +1,18 @@ +#include "memory.h" +#include "common/sysctl.h" + +#include +#include + +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; +}