40#ifndef CASA_HOSTINFODARWIN_H
41#define CASA_HOSTINFODARWIN_H
43# if defined(HOSTINFO_DO_IMPLEMENT)
82#define pagetok(size) ((size) << pageshift)
84class HostMachineInfo {
93 ptrdiff_t memory_total;
94 ptrdiff_t memory_used;
95 ptrdiff_t memory_free;
105HostMachineInfo::HostMachineInfo( ) : valid(1) {
109 struct host_basic_info basic_info;
110 unsigned int count = HOST_BASIC_INFO_COUNT;
113 pagesize_ = pagesize = sysconf(_SC_PAGESIZE);
122 pageshift -= LOG1024;
125 ret = host_info( mach_host_self(), HOST_BASIC_INFO, (host_info64_t) &basic_info, &count );
127 ret = host_info( mach_host_self(), HOST_BASIC_INFO, (host_info_t) &basic_info, &count );
129 if ( ret != KERN_SUCCESS ) {
133 memory_total = basic_info.max_mem / 1024;
135 memory_total = basic_info.memory_size / 1024;
137 cpus = basic_info.avail_cpus;
141void HostMachineInfo::update_info( ) {
144 struct vm_statistics64 vmstats;
146 struct vm_statistics vmstats;
156 count =
sizeof(vmstats)/
sizeof(integer_t);
159 kr = host_statistics64( mach_host_self(), HOST_VM_INFO64, (host_info64_t) &vmstats, &count );
161 kr = host_statistics( mach_host_self(), HOST_VM_INFO, (host_info_t) &vmstats, &count );
163 if ( kr != KERN_SUCCESS ) {
183 memory_used = pagetok(vmstats.active_count + vmstats.wire_count);
184 memory_free = memory_total - memory_used;
185 swap_used = pagetok( vmstats.active_count + vmstats.inactive_count + vmstats.wire_count );
186 swap_free = pagetok( vmstats.free_count );
187 swap_total = pagetok( vmstats.active_count + vmstats.inactive_count +
188 vmstats.wire_count + vmstats.free_count );
this file contains all the compiler specific defines