add GetProcessorCount() implementation for Solaris
authorAlex Caudill <alex.caudill@gmail.com>
Fri, 7 Sep 2012 19:46:17 +0000 (12:46 -0700)
committerEvan Martin <martine@danga.com>
Fri, 7 Sep 2012 19:46:17 +0000 (12:46 -0700)
src/util.cc

index 580f22ab9daa60b167ad529472f2f4917167f05e..0feb99dd01c64e17371c7b8783926e0c906a0b10 100644 (file)
@@ -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