[SIGAR-47] Fix sigar_mem_get on 64-bit FreeBSD

This commit is contained in:
Doug MacEachern 2007-04-06 23:38:23 +00:00
parent 71829d95ce
commit 1e922146a6
2 changed files with 14 additions and 10 deletions

View File

@ -1,3 +1,7 @@
2007-04-06 Doug MacEachern <dougm@hyperic.com>
* [SIGAR-47] Fix sigar_mem_get on 64-bit FreeBSD
2007-04-05 Doug MacEachern <dougm@hyperic.com> 2007-04-05 Doug MacEachern <dougm@hyperic.com>
* Add net_listen_address function to lookup bind address of a listen socket * Add net_listen_address function to lookup bind address of a listen socket

View File

@ -250,9 +250,10 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
vm_statistics_data_t vmstat; vm_statistics_data_t vmstat;
kern_return_t status; kern_return_t status;
mach_msg_type_number_t count = sizeof(vmstat) / sizeof(integer_t); mach_msg_type_number_t count = sizeof(vmstat) / sizeof(integer_t);
uint64_t value64; uint64_t mem_total;
#else #else
unsigned long value; unsigned long mem_total;
int mem_free;
#endif #endif
int mib[2]; int mib[2];
size_t len; size_t len;
@ -267,17 +268,15 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
#ifdef DARWIN #ifdef DARWIN
mib[1] = HW_MEMSIZE; mib[1] = HW_MEMSIZE;
# define MEM_VAL value64
#else #else
mib[1] = HW_PHYSMEM; mib[1] = HW_PHYSMEM;
# define MEM_VAL value
#endif #endif
len = sizeof(MEM_VAL); len = sizeof(mem_total);
if (sysctl(mib, NMIB(mib), &MEM_VAL, &len, NULL, 0) < 0) { if (sysctl(mib, NMIB(mib), &mem_total, &len, NULL, 0) < 0) {
return errno; return errno;
} }
mem->total = MEM_VAL; mem->total = mem_total;
#ifdef DARWIN #ifdef DARWIN
status = host_statistics(sigar->mach_port, HOST_VM_INFO, status = host_statistics(sigar->mach_port, HOST_VM_INFO,
@ -289,14 +288,15 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
mem->free = vmstat.free_count * sigar->pagesize; mem->free = vmstat.free_count * sigar->pagesize;
#else #else
len = sizeof(value); len = sizeof(mem_free);
if (sysctlbyname("vm.stats.vm.v_free_count", if (sysctlbyname("vm.stats.vm.v_free_count",
&value, &len, NULL, 0) == -1) &mem_free, &len, NULL, 0) == -1)
{ {
mem->free = 0; /*XXX*/ mem->free = 0; /*XXX*/
} }
else { else {
mem->free = value * sigar->pagesize; mem->free = mem_free;
mem->free *= sigar->pagesize;
} }
#endif #endif