vm_native: simplify vm.overcommit sysctl

dragonfly$ sysctl vm.overcommit
sysctl: unknown oid 'vm.overcommit'

freebsd$ rg VM_OVERCOMMIT /usr/include
/usr/include/vm/vm_param.h
89:#define VM_OVERCOMMIT                12      /* vm.overcommit */
This commit is contained in:
Jan Beich 2021-10-11 22:37:10 +00:00 committed by Ivan
parent 1a90adfb5e
commit 7a24642c56

View File

@ -15,8 +15,9 @@
#include <sys/types.h>
#endif
#if !defined(__linux__) && !defined(_WIN32)
#if defined(__FreeBSD__)
#include <sys/sysctl.h>
#include <vm/vm_param.h>
#endif
#ifdef __linux__
@ -461,13 +462,10 @@ namespace utils
#if defined(__NetBSD__) || defined(__APPLE__)
// Always ON
vm_overcommit = 0;
#elif defined(__FreeBSD__) && defined(VM_OVERCOMMIT)
#elif defined(__FreeBSD__)
int mib[2]{CTL_VM, VM_OVERCOMMIT};
if (::sysctl(mib, 2, &vm_overcommit, &vm_sz, NULL, 0) != 0)
vm_overcommit = -1;
#elif defined(__FreeBSD__) || defined(__DragonFly__)
if (::sysctlbyname("vm.overcommit", &vm_overcommit, &vm_sz, NULL, 0) != 0)
vm_overcommit = -1;
#else
vm_overcommit = -1;
#endif