32#ifndef CASA_HOSTINFOBSD_H
33#define CASA_HOSTINFOBSD_H
35# if defined(HOSTINFO_DO_IMPLEMENT)
38#include <sys/sysctl.h>
39#include <sys/vmmeter.h>
75class HostMachineInfo {
84 ptrdiff_t memory_total;
85 ptrdiff_t memory_used;
86 ptrdiff_t memory_free;
96HostMachineInfo::HostMachineInfo( ) : valid(1) {
99 pagesize = getpagesize();
100 page_kb = pagesize / 1024;
103 if (sysctlbyname(
"hw.ncpu", &cpus, &len, NULL, 0) == -1)
106 len =
sizeof(memory_total);
107 if (sysctlbyname(
"hw.physmem", &memory_total, &len, NULL, 0) == -1)
110 memory_total /= 1024;
114void HostMachineInfo::update_info( ) {
117 struct vmtotal total;
118 struct kvm_swap swapary[1];
123 if (sysctlbyname(
"vm.vmtotal", &total, &len, NULL, 0) == -1)
126 memory_used = total.t_rm * page_kb;
127 memory_free = total.t_free * page_kb;
129 kd = kvm_open(NULL, _PATH_DEVNULL, NULL, O_RDONLY,
"kvm_open");
131 kvm_getswapinfo(kd, swapary, 1, 0);
133 swap_total = swapary[0].ksw_total * page_kb;
134 swap_used = swapary[0].ksw_used * page_kb;
135 swap_free = swap_total - swap_used;
this file contains all the compiler specific defines