37#ifndef CASA_HOSTINFOOSF1_H
38#define CASA_HOSTINFOOSF1_H
40# if defined(HOSTINFO_DO_IMPLEMENT)
56#include <mach/mach_types.h>
57#include <mach/vm_statistics.h>
58#include <mach/host_info.h>
83extern "C" kern_return_t host_info(
int,
int, host_info_t,
unsigned int *);
84extern "C" int host_self( );
85extern "C" int vm_statistics(
long,
struct vm_statistics *);
92#define pagetok(size) ((size) << pageshift)
94class HostMachineInfo {
103 ptrdiff_t swap_total;
107 ptrdiff_t memory_total;
108 ptrdiff_t memory_used;
109 ptrdiff_t memory_free;
117HostMachineInfo::HostMachineInfo( ) : valid(1) {
121 struct tbl_sysinfo sibuf;
124 struct host_basic_info basic_info;
125 unsigned int count = HOST_BASIC_INFO_COUNT;
128 pagesize = getpagesize();
137 pageshift -= LOG1024;
139 ret = host_info( host_self(), HOST_BASIC_INFO, (host_info_t) &basic_info, &count );
140 if ( ret != KERN_SUCCESS ) {
143 memory_total = basic_info.memory_size / 1024;
144 cpus = basic_info.avail_cpus;
148void HostMachineInfo::update_info( ) {
150 struct tbl_swapinfo swbuf;
151 vm_statistics_data_t vmstats;
152 int swappages=0,swapfree=0,i;
159 (void) vm_statistics(task_self(),&vmstats);
166 while(table(TBL_SWAPINFO,i,&swbuf,1,
sizeof(
struct tbl_swapinfo))>0) {
167 swappages += swbuf.size;
168 swapfree += swbuf.free;
172 swap_total = pagetok(swappages);
173 swap_used = pagetok(swappages - swapfree);
174 swap_free = pagetok(swapfree);
176 memory_free = pagetok(vmstats.free_count);
177 memory_used = memory_total - memory_free;
this file contains all the compiler specific defines