From: Cursor Agent Date: Tue, 4 Nov 2025 10:24:00 +0000 (+0000) Subject: feat: Add NetBSD memory usage support X-Git-Tag: 3.14.0~21^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=762cf115bbf773b9f36cc59db8b2927a0081a7ce;p=thirdparty%2Frspamd.git feat: Add NetBSD memory usage support Co-authored-by: v --- diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c index 12323f5dad..14d95a20f1 100644 --- a/src/lua/lua_util.c +++ b/src/lua/lua_util.c @@ -34,6 +34,9 @@ #ifdef __FreeBSD__ #include #endif +#ifdef __NetBSD__ +#include +#endif #endif #ifdef __APPLE__ #include @@ -2532,7 +2535,21 @@ lua_util_get_memory_usage(lua_State *L) lua_pushinteger(L, info.virtual_size); lua_settable(L, -3); } -#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) +#elif defined(__NetBSD__) + struct kinfo_proc2 kp; + size_t len = sizeof(kp); + int mib[6] = {CTL_KERN, KERN_PROC2, KERN_PROC_PID, getpid(), sizeof(struct kinfo_proc2), 1}; + + if (sysctl(mib, 6, &kp, &len, NULL, 0) == 0) { + lua_pushstring(L, "rss"); + lua_pushinteger(L, kp.p_vm_rssize * getpagesize()); + lua_settable(L, -3); + + lua_pushstring(L, "vsize"); + lua_pushinteger(L, kp.p_vm_vsize); + lua_settable(L, -3); + } +#elif defined(__FreeBSD__) || defined(__OpenBSD__) struct kinfo_proc kp; size_t len = sizeof(kp); int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()};