summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Caudill <alex.caudill@gmail.com>2012-09-07 19:46:17 (GMT)
committerEvan Martin <martine@danga.com>2012-09-07 19:46:17 (GMT)
commit2c145bbf2ebd80e9d6223a0672600e37a4589d32 (patch)
treeefddf75a096b8e27698d98e7b47cc625030fea38
parent31330231f1955279a6296cf9425a1ea9221919b1 (diff)
downloadNinja-2c145bbf2ebd80e9d6223a0672600e37a4589d32.zip
Ninja-2c145bbf2ebd80e9d6223a0672600e37a4589d32.tar.gz
Ninja-2c145bbf2ebd80e9d6223a0672600e37a4589d32.tar.bz2
add GetProcessorCount() implementation for Solaris
-rw-r--r--src/util.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc
index 580f22a..0feb99d 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -36,6 +36,9 @@
#if defined(__APPLE__) || defined(__FreeBSD__)
#include <sys/sysctl.h>
+#elif defined(__SVR4) && defined(__sun)
+#include <unistd.h>
+#include <sys/loadavg.h>
#elif defined(linux)
#include <sys/sysinfo.h>
#endif
@@ -314,6 +317,12 @@ int GetProcessorCount() {
GetSystemInfo(&info);
return info.dwNumberOfProcessors;
}
+#else
+// This is what get_nprocs() should be doing in the Linux implementation
+// above, but in a more standard way.
+int GetProcessorCount() {
+ return sysconf(_SC_NPROCESSORS_ONLN);
+}
#endif
#ifdef _WIN32