head 1.1; access; symbols; locks; strict; comment @// @; 1.1 date 2026.09.10.09.15.32; author kikadf; state Exp; branches; next ; commitid C9x3BqVzlwrlv3VG; desc @@ 1.1 log @ waybar: fix memory info module @ text @$NetBSD$ * Fix get_free_memory on NetBSD, avoid underflow https://github.com/Alexays/Waybar/pull/5319 --- src/modules/memory/bsd.cpp.orig 2026-09-09 17:46:47.416277348 +0000 +++ src/modules/memory/bsd.cpp @@@@ -73,10 +73,16 @@@@ static uint64_t get_free_memory() { if (sysctl(mib, miblen, &uvmexp, &sz, NULL, 0)) { throw std::runtime_error("sysctl vm.uvmexp failed"); } +#ifdef VM_UVMEXP2 + uint64_t total = get_total_memory(); + uint64_t used = static_cast(uvmexp.active + uvmexp.wired) * uvmexp.pagesize; + return used < total ? total - used : 0; +#else return static_cast(uvmexp.free + uvmexp.inactive + uvmexp.filepages + uvmexp.execpages) * uvmexp.pagesize; #endif +#endif } void waybar::modules::Memory::parseMeminfo() { @