38 #ifndef CASA_HOSTINFOHURD_H
39 #define CASA_HOSTINFOHURD_H
41 # if defined(HOSTINFO_DO_IMPLEMENT)
49 #include <mach/mach.h>
82 #define pagetok(size) ((size) << pageshift)
84 class HostMachineInfo {
85 friend class HostInfo;
93 ptrdiff_t memory_total;
94 ptrdiff_t memory_used;
95 ptrdiff_t memory_free;
105 HostMachineInfo::HostMachineInfo( ) : valid(1) {
109 struct host_basic_info basic_info;
110 mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
113 pagesize_ = pagesize = getpagesize();
122 pageshift -= LOG1024;
124 ret = host_info( mach_host_self(), HOST_BASIC_INFO, (host_info_t) &basic_info, &count );
125 if ( ret != KERN_SUCCESS ) {
128 memory_total = basic_info.memory_size / 1024;
129 cpus = basic_info.avail_cpus;
133 void HostMachineInfo::update_info( ) {
135 vm_statistics_data_t vmstats;
139 kr = vm_statistics( mach_task_self(), &vmstats);
140 if ( kr != KERN_SUCCESS ) {
145 memory_used = pagetok(vmstats.active_count + vmstats.wire_count);
146 memory_free = memory_total - memory_used;
147 swap_used = pagetok( vmstats.active_count + vmstats.inactive_count + vmstats.wire_count );
148 swap_free = pagetok( vmstats.free_count );
149 swap_total = pagetok( vmstats.active_count + vmstats.inactive_count +
150 vmstats.wire_count + vmstats.free_count );
this file contains all the compiler specific defines