summaryrefslogtreecommitdiffstats
path: root/src/util.cc
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2015-11-12 01:19:00 (GMT)
committerEvan Martin <martine@danga.com>2015-11-12 01:19:00 (GMT)
commit4ffe56d387dce2bc5126fc4079ad2f2b31fba30e (patch)
treeb23e4182918a3d35c9f9feb470194c63f4be68f0 /src/util.cc
parenta65240d52c451f69d9b2f1252738d67eb99a296c (diff)
parentaa14d6e067c6491555150c1f40de1388c3491124 (diff)
downloadNinja-4ffe56d387dce2bc5126fc4079ad2f2b31fba30e.zip
Ninja-4ffe56d387dce2bc5126fc4079ad2f2b31fba30e.tar.gz
Ninja-4ffe56d387dce2bc5126fc4079ad2f2b31fba30e.tar.bz2
Merge pull request #1007 from mikesep/aix
Support for AIX
Diffstat (limited to 'src/util.cc')
-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 };