$OpenBSD: patch-j2se_src_solaris_bin_java_md_c,v 1.5 2008/03/17 03:21:25 kurt Exp $
--- j2se/src/solaris/bin/java_md.c.orig	Tue Feb 26 14:02:22 2008
+++ j2se/src/solaris/bin/java_md.c	Wed Feb 27 07:38:53 2008
@@ -1072,22 +1072,28 @@ void PrintMachineDependentOptions() {
 /* Compute physical memory by asking the OS */
 uint64_t
 physical_memory(void) {
-
 #if defined(_ALLBSD_SOURCE)
+  uint64_t result;
+  size_t len;
+#ifdef HW_PHYSMEM64
+  int64_t physmem;
+  int mib[2] = { CTL_HW, HW_PHYSMEM64 };
+#else
+  unsigned long physmem;
+  int mib[2] = { CTL_HW, HW_PHYSMEM };
+#endif
 
-  unsigned long result;
-  int mib[2];
-  size_t rlen;
-
   /* fetch sysctl(hw.physmem) value */
-  mib[0] = CTL_HW;
-  mib[1] = HW_PHYSMEM;
-  rlen = sizeof(result);
-  if (sysctl(mib, 2, &result, &rlen, NULL, 0) == -1)
-	result = 256 * MB;
+  len = sizeof(physmem);
+  if (sysctl(mib, 2, &physmem, &len, NULL, 0) == -1)
+	physmem = 256 * MB;
 
+  result = (uint64_t)physmem;
+
+# define UINT64_FORMAT "%" PRIu64
+
   if (_launcher_debug) {
-    printf( "  physical memory: %lu (%.3fGB)\n",
+    printf( "  physical memory: " UINT64_FORMAT " (%.3fGB)\n",
            result, result / (double) GB);
   }
 
@@ -1432,7 +1438,7 @@ physical_processors(void) {
     }
   }
   if (_launcher_debug) {
-    printf("physical processors: %lu\n", result);
+    printf("physical processors: %lu\n", (unsigned long)result);
   }
 
   return result;
