diff options
Diffstat (limited to 'src/util.cc')
-rw-r--r-- | src/util.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/util.cc b/src/util.cc index aa47f2f..e31fd1f 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 @@ -224,8 +226,8 @@ bool CanonicalizePath(char* path, size_t* len, unsigned int* slash_bits, } if (dst == start) { - *err = "path canonicalizes to the empty path"; - return false; + *dst++ = '.'; + *dst++ = '\0'; } *len = dst - start - 1; @@ -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 }; |