40#ifndef CASA_HOSTINFODARWIN_H
41#define CASA_HOSTINFODARWIN_H
43#if defined(HOSTINFO_DO_IMPLEMENT)
81#define pagetok(size) ((size) << pageshift)
83class HostMachineInfo {
84 friend class HostInfo;
92 ptrdiff_t memory_total;
93 ptrdiff_t memory_used;
94 ptrdiff_t memory_free;
103HostMachineInfo::HostMachineInfo() : valid(1) {
107 struct host_basic_info basic_info;
108 unsigned int count = HOST_BASIC_INFO_COUNT;
111 pagesize_ = pagesize = sysconf(_SC_PAGESIZE);
113 while (pagesize > 1) {
119 pageshift -= LOG1024;
122 ret = host_info(mach_host_self(), HOST_BASIC_INFO, (host_info64_t)&basic_info, &count);
124 ret = host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&basic_info, &count);
126 if (ret != KERN_SUCCESS) {
130 memory_total = basic_info.max_mem / 1024;
132 memory_total = basic_info.memory_size / 1024;
134 cpus = basic_info.avail_cpus;
138void HostMachineInfo::update_info() {
140 struct vm_statistics64 vmstats;
142 struct vm_statistics vmstats;
152 count =
sizeof(vmstats) /
sizeof(integer_t);
155 kr = host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t)&vmstats, &count);
157 kr = host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmstats, &count);
159 if (kr != KERN_SUCCESS) {
179 memory_used = pagetok(vmstats.active_count + vmstats.wire_count);
180 memory_free = memory_total - memory_used;
181 swap_used = pagetok(vmstats.active_count + vmstats.inactive_count + vmstats.wire_count);
182 swap_free = pagetok(vmstats.free_count);
183 swap_total = pagetok(vmstats.active_count + vmstats.inactive_count + vmstats.wire_count +
For temporary backward namespace compatibility, use casa as alias for casacore.