summaryrefslogtreecommitdiff
path: root/src/memchecker.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-01-03 18:47:32 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2017-01-03 18:47:32 +0100
commitc6b6313f81949bea48d03e4d53ec2da53f6a9460 (patch)
treee2e59b5626e44da0d230044351e0c8dd7d8bdbda /src/memchecker.cc
parent2627a5eedd30c4506a8f6da60d3cbc7b00911c73 (diff)
Add MemChecker implementation for FreeBSD.
Diffstat (limited to 'src/memchecker.cc')
-rw-r--r--src/memchecker.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/memchecker.cc b/src/memchecker.cc
index 2bdbf34..f444f85 100644
--- a/src/memchecker.cc
+++ b/src/memchecker.cc
@@ -35,6 +35,10 @@
#include <mach/mach_types.h>
#include <mach/mach_init.h>
#include <mach/mach_host.h>
+#elif DG_PLATFORM == DG_PLATFORM_FREEBSD
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <sys/vmmeter.h>
#endif
#include <sndfile.h>
@@ -73,6 +77,18 @@ uint64_t MemChecker::calcFreeMemory() const
{
free_memory = (uint64_t)vm_stats.free_count * (uint64_t)page_size;
}
+#elif DG_PLATFORM == DG_PLATFORM_FREEBSD
+ u_int page_size;
+ struct vmtotal vmt;
+ size_t vmt_size, uint_size;
+
+ vmt_size = sizeof(vmt);
+ uint_size = sizeof(page_size);
+
+ sysctlbyname("vm.vmtotal", &vmt, &vmt_size, NULL, 0);
+ sysctlbyname("vm.stats.vm.v_page_size", &page_size, &uint_size, NULL, 0);
+
+ free_memory = vmt.t_free * (u_int64_t)page_size;
#elif DG_PLATFORM == DG_PLATFORM_UNIX
// TODO
#endif