Skip to content

Commit

Permalink
vm_native: simplify vm.overcommit sysctl
Browse files Browse the repository at this point in the history
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 */
  • Loading branch information
jbeich authored and Nekotekina committed Oct 11, 2021
1 parent 1a90adf commit 7a24642
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions rpcs3/util/vm_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7a24642

Please sign in to comment.