41 #ifndef CASA_HOSTINFODARWIN_H
42 #define CASA_HOSTINFODARWIN_H
44 # if defined(HOSTINFO_DO_IMPLEMENT)
51 #include <mach/mach.h>
83 #define pagetok(size) ((size) << pageshift)
85 class HostMachineInfo {
86 friend class HostInfo;
94 ptrdiff_t memory_total;
95 ptrdiff_t memory_used;
96 ptrdiff_t memory_free;
106 HostMachineInfo::HostMachineInfo( ) : valid(1) {
110 struct host_basic_info basic_info;
111 unsigned int count = HOST_BASIC_INFO_COUNT;
114 pagesize_ = pagesize = getpagesize();
123 pageshift -= LOG1024;
126 ret = host_info( mach_host_self(), HOST_BASIC_INFO, (host_info64_t) &basic_info, &count );
128 ret = host_info( mach_host_self(), HOST_BASIC_INFO, (host_info_t) &basic_info, &count );
130 if ( ret != KERN_SUCCESS ) {
134 memory_total = basic_info.max_mem / 1024;
136 memory_total = basic_info.memory_size / 1024;
138 cpus = basic_info.avail_cpus;
142 void HostMachineInfo::update_info( ) {
145 struct vm_statistics64 vmstats;
147 struct vm_statistics vmstats;
157 count =
sizeof(vmstats)/
sizeof(integer_t);
160 kr = host_statistics64( mach_host_self(), HOST_VM_INFO64, (host_info64_t) &vmstats, &count );
162 kr = host_statistics( mach_host_self(), HOST_VM_INFO, (host_info_t) &vmstats, &count );
164 if ( kr != KERN_SUCCESS ) {
184 memory_used = pagetok(vmstats.active_count + vmstats.wire_count);
185 memory_free = memory_total - memory_used;
186 swap_used = pagetok( vmstats.active_count + vmstats.inactive_count + vmstats.wire_count );
187 swap_free = pagetok( vmstats.free_count );
188 swap_total = pagetok( vmstats.active_count + vmstats.inactive_count +
189 vmstats.wire_count + vmstats.free_count );
#define casacore
<X11/Intrinsic.h> #defines true, false, casacore::Bool, and String.