37#ifndef CASA_HOSTINFOOSF1_H
38#define CASA_HOSTINFOOSF1_H
40#if defined(HOSTINFO_DO_IMPLEMENT)
57#include <mach/mach_types.h>
58#include <mach/vm_statistics.h>
59#include <mach/host_info.h>
84extern "C" kern_return_t host_info(
int,
int, host_info_t,
unsigned int *);
85extern "C" int host_self();
86extern "C" int vm_statistics(
long,
struct vm_statistics *);
93#define pagetok(size) ((size) << pageshift)
95class HostMachineInfo {
96 friend class HostInfo;
104 ptrdiff_t swap_total;
108 ptrdiff_t memory_total;
109 ptrdiff_t memory_used;
110 ptrdiff_t memory_free;
117HostMachineInfo::HostMachineInfo() : valid(1) {
120 struct tbl_sysinfo sibuf;
123 struct host_basic_info basic_info;
124 unsigned int count = HOST_BASIC_INFO_COUNT;
127 pagesize = getpagesize();
129 while (pagesize > 1) {
135 pageshift -= LOG1024;
137 ret = host_info(host_self(), HOST_BASIC_INFO, (host_info_t)&basic_info, &count);
138 if (ret != KERN_SUCCESS) {
141 memory_total = basic_info.memory_size / 1024;
142 cpus = basic_info.avail_cpus;
146void HostMachineInfo::update_info() {
147 struct tbl_swapinfo swbuf;
148 vm_statistics_data_t vmstats;
149 int swappages = 0, swapfree = 0, i;
156 (void)vm_statistics(task_self(), &vmstats);
163 while (table(TBL_SWAPINFO, i, &swbuf, 1,
sizeof(
struct tbl_swapinfo)) > 0) {
164 swappages += swbuf.size;
165 swapfree += swbuf.free;
169 swap_total = pagetok(swappages);
170 swap_used = pagetok(swappages - swapfree);
171 swap_free = pagetok(swapfree);
173 memory_free = pagetok(vmstats.free_count);
174 memory_used = memory_total - memory_free;
For temporary backward namespace compatibility, use casa as alias for casacore.