summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMike Seplowitz <mseplowitz@bloomberg.net>2015-01-13 01:48:07 (GMT)
committerMike Seplowitz <mseplowitz@bloomberg.net>2015-08-19 12:43:58 (GMT)
commit94c10a6a18ceadf78d27245ce389610c67a7cf2e (patch)
tree5137b614e613f1d1675c6d4dea4da0fbe6d814a2 /src
parent164e7f9494a7a9b9c6ec38b4cd4700bdb2aec1c5 (diff)
downloadNinja-94c10a6a18ceadf78d27245ce389610c67a7cf2e.zip
Ninja-94c10a6a18ceadf78d27245ce389610c67a7cf2e.tar.gz
Ninja-94c10a6a18ceadf78d27245ce389610c67a7cf2e.tar.bz2
Implement GetLoadAverage on AIX using libperfstat
Diffstat (limited to 'src')
-rw-r--r--src/util.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc
index aa47f2f..d150fe2 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -45,6 +45,8 @@
#elif defined(__SVR4) && defined(__sun)
#include <unistd.h>
#include <sys/loadavg.h>
+#elif defined(_AIX)
+#include <libperfstat.h>
#elif defined(linux) || defined(__GLIBC__)
#include <sys/sysinfo.h>
#endif
@@ -573,6 +575,16 @@ double GetLoadAverage() {
return posix_compatible_load;
}
+#elif defined(_AIX)
+double GetLoadAverage() {
+ perfstat_cpu_total_t cpu_stats;
+ if (perfstat_cpu_total(NULL, &cpu_stats, sizeof(cpu_stats), 1) < 0) {
+ return -0.0f;
+ }
+
+ // Calculation taken from comment in libperfstats.h
+ return double(cpu_stats.loadavg[0]) / double(1 << SBITS);
+}
#else
double GetLoadAverage() {
double loadavg[3] = { 0.0f, 0.0f, 0.0f };