Use vm_region_64 on 64-bit arch; cache memory for longer

This is a port of the Apple patches at
http://www.opensource.apple.com/source/net_snmp/net_snmp-140.1/patches/darwin64.patch
1. Use vm_region_64 instead of vm_region on __ppc64__ or __x86_64__
2. Use 300 second timeout for the cache.

This comment about the code being incredibly expensive is
very true: on a 1.7 GHz i7 with 8 GB of RAM (admittedly a
small machine) it took 17 seconds to calculate and
return HOST-RESOURCES-MIB::hrMemorySize.0.  Most SNMP
clients would give up long before getting this answer.
diff --git a/agent/mibgroup/hardware/memory/hw_mem.c b/agent/mibgroup/hardware/memory/hw_mem.c
index badc775..1f4474f 100644
--- a/agent/mibgroup/hardware/memory/hw_mem.c
+++ b/agent/mibgroup/hardware/memory/hw_mem.c
@@ -14,9 +14,16 @@
 netsnmp_memory_info *_mem_head  = NULL;
 netsnmp_cache       *_mem_cache = NULL;
 
+#ifdef darwin
+/* the code in memory_darwin.c is *very* expensive */
+#define	MEMORY_CACHE_SECONDS	300
+#else
+#define	MEMORY_CACHE_SECONDS	5
+#endif
+
 void init_hw_mem( void ) {
     oid nsMemory[] = { 1, 3, 6, 1, 4, 1, 8072, 1, 31 };
-    _mem_cache = netsnmp_cache_create( 5, netsnmp_mem_arch_load, NULL,
+    _mem_cache = netsnmp_cache_create( MEMORY_CACHE_SECONDS, netsnmp_mem_arch_load, NULL,
                                           nsMemory, OID_LENGTH(nsMemory));
 }
 
diff --git a/agent/mibgroup/hardware/memory/memory_darwin.c b/agent/mibgroup/hardware/memory/memory_darwin.c
index 5a55974..4462c45 100644
--- a/agent/mibgroup/hardware/memory/memory_darwin.c
+++ b/agent/mibgroup/hardware/memory/memory_darwin.c
@@ -78,7 +78,11 @@
             for (address = 0;; address += size) {
                 /* Get memory region. */
                 count = VM_REGION_EXTENDED_INFO_COUNT; 
+#if defined(__ppc64__) || defined(__x86_64__)
+                if (vm_region_64(tasks[j], &address, &size, VM_REGION_EXTENDED_INFO, &info, &count, &object_name) != KERN_SUCCESS) {
+#else
                 if (vm_region(tasks[j], &address, &size, VM_REGION_EXTENDED_INFO, &info, &count, &object_name) != KERN_SUCCESS) {
+#endif
                     /* No more memory regions. */
                     break;
                 }