30#ifndef CASA_HOSTINFOBSD_H
31#define CASA_HOSTINFOBSD_H
33# if defined(HOSTINFO_DO_IMPLEMENT)
36#include <sys/sysctl.h>
37#include <sys/vmmeter.h>
73class HostMachineInfo {
82 ptrdiff_t memory_total;
83 ptrdiff_t memory_used;
84 ptrdiff_t memory_free;
94HostMachineInfo::HostMachineInfo( ) : valid(1) {
97 pagesize = getpagesize();
98 page_kb = pagesize / 1024;
101 if (sysctlbyname(
"hw.ncpu", &cpus, &len, NULL, 0) == -1)
104 len =
sizeof(memory_total);
105 if (sysctlbyname(
"hw.physmem", &memory_total, &len, NULL, 0) == -1)
108 memory_total /= 1024;
112void HostMachineInfo::update_info( ) {
115 struct vmtotal total;
116 struct kvm_swap swapary[1];
121 if (sysctlbyname(
"vm.vmtotal", &total, &len, NULL, 0) == -1)
124 memory_used = total.t_rm * page_kb;
125 memory_free = total.t_free * page_kb;
127 kd = kvm_open(NULL, _PATH_DEVNULL, NULL, O_RDONLY,
"kvm_open");
129 kvm_getswapinfo(kd, swapary, 1, 0);
131 swap_total = swapary[0].ksw_total * page_kb;
132 swap_used = swapary[0].ksw_used * page_kb;
133 swap_free = swap_total - swap_used;
this file contains all the compiler specific defines