src/solaris/native/com/sun/management/UnixOperatingSystem_md.c

Print this page
rev 8725 : 8024854: Basic changes and files to build the class library on AIX
Contributed-by: luchsh@linux.vnet.ibm.com, spoole@linux.vnet.ibm.com, thomas.stuefe@sap.com
Reviewed-by: alanb, prr, sla, chegar, michaelm, mullan

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -39,11 +39,11 @@
 #include <sys/mount.h>
 #include <mach/mach.h>
 #include <sys/proc_info.h>
 #include <libproc.h>
 #endif
-#else
+#elif !defined(_AIX)
 #include <sys/swap.h>
 #endif
 #include <sys/resource.h>
 #include <sys/times.h>
 #ifndef _ALLBSD_SOURCE

@@ -55,13 +55,17 @@
 #include <fcntl.h>
 #include <limits.h>
 #include <stdlib.h>
 #include <unistd.h>
 
+#if defined(_AIX)
+#include <libperfstat.h>
+#endif
+
 static jlong page_size = 0;
 
-#if defined(_ALLBSD_SOURCE)
+#if defined(_ALLBSD_SOURCE) || defined(_AIX)
 #define MB      (1024UL * 1024UL)
 #else
 
 /* This gets us the new structured proc interfaces of 5.6 & later */
 /* - see comment in <sys/procfs.h> */

@@ -324,10 +328,16 @@
     /*
      * XXBSDL no way to do it in FreeBSD
      */
     // throw_internal_error(env, "unimplemented in FreeBSD")
     return (128 * MB);
+#elif defined(_AIX)
+    perfstat_memory_total_t memory_info;
+    if (-1 != perfstat_memory_total(NULL, &memory_info, sizeof(perfstat_memory_total_t), 1)) {
+        return (jlong)(memory_info.real_free * 4L * 1024L);
+    }
+    return -1;
 #else // solaris / linux
     jlong num_avail_physical_pages = sysconf(_SC_AVPHYS_PAGES);
     return (num_avail_physical_pages * page_size);
 #endif
 }

@@ -347,10 +357,16 @@
     if (sysctl(mib, 2, &result, &rlen, NULL, 0) != 0) {
         throw_internal_error(env, "sysctl failed");
         return -1;
     }
     return result;
+#elif defined(_AIX)
+    perfstat_memory_total_t memory_info;
+    if (-1 != perfstat_memory_total(NULL, &memory_info, sizeof(perfstat_memory_total_t), 1)) {
+        return (jlong)(memory_info.real_total * 4L * 1024L);
+    }
+    return -1;
 #else // solaris / linux
     jlong num_physical_pages = sysconf(_SC_PHYS_PAGES);
     return (num_physical_pages * page_size);
 #endif
 }