Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Unified Diff: src/cpu.cc

Issue 23655004: Replace OS::NumberOfCores() with CPU::NumberOfProcessorsOnline(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/cpu.h ('k') | src/isolate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/cpu.h ('k') | src/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698