From 6e74f8455f1623f9020b7c9b9d45ccf58d51241f Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 6 Jan 2006 18:50:05 +0000 Subject: [PATCH] use HW_MEMSIZE on darwin for mem.total --- src/os/darwin/darwin_sigar.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index 16be384d..8199ba47 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -226,9 +226,11 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) vm_statistics_data_t vmstat; kern_return_t status; mach_msg_type_number_t count = sizeof(vmstat) / sizeof(integer_t); + uint64_t value64; +#else + unsigned long value; #endif int mib[2]; - unsigned long value; size_t len; mib[0] = CTL_HW; @@ -239,13 +241,19 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) return errno; } +#ifdef DARWIN + mib[1] = HW_MEMSIZE; +# define MEM_VAL value64 +#else mib[1] = HW_PHYSMEM; - len = sizeof(value); - if (sysctl(mib, NMIB(mib), &value, &len, NULL, 0) < 0) { +# define MEM_VAL value +#endif + len = sizeof(MEM_VAL); + if (sysctl(mib, NMIB(mib), &MEM_VAL, &len, NULL, 0) < 0) { return errno; } - mem->total = value; + mem->total = MEM_VAL; #ifdef DARWIN status = host_statistics(sigar->mach_port, HOST_VM_INFO,