Index: src/cpu.cc |
diff --git a/src/cpu.cc b/src/cpu.cc |
index 06a03115bbe8692d4d56e8298d423f8b3b647b44..26eca616e347e7175b94bb0ab1eeca3270d61da9 100644 |
--- a/src/cpu.cc |
+++ b/src/cpu.cc |
@@ -30,14 +30,21 @@ |
#if V8_CC_MSVC |
#include <intrin.h> // __cpuid() |
#endif |
+#if V8_OS_POSIX |
+#include <unistd.h> // sysconf() |
+#endif |
#include <algorithm> |
#include <cctype> |
+#include <climits> |
#include <cstdio> |
#include <cstdlib> |
#include <cstring> |
#include "checks.h" |
+#if V8_OS_WIN |
+#include "win32-headers.h" |
+#endif |
namespace v8 { |
namespace internal { |
@@ -444,4 +451,16 @@ CPU::CPU() : stepping_(0), |
#endif |
} |
+ |
+// static |
+int CPU::NumberOfProcessorsOnline() { |
tfarina
2013/08/31 22:10:46
looks like the ninja implementation is stronger.
Benedikt Meurer
2013/09/01 08:32:44
No, just unnecessarily complex:
- The BSDs impleme
|
+#if V8_OS_WIN |
+ SYSTEM_INFO info; |
+ GetSystemInfo(&info); |
+ return info.dwNumberOfProcessors; |
+#else |
+ return static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN)); |
+#endif |
+} |
+ |
} } // namespace v8::internal |