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

Unified Diff: runtime/bin/platform_macos.cc

Issue 1181333004: Improve the reporting of the number of CPUs on Mac OS (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/platform_macos.cc
diff --git a/runtime/bin/platform_macos.cc b/runtime/bin/platform_macos.cc
index 0e7f2f8f6ea3b640e0094719e001cab4d1e3647e..6c83fc81b0be67333b94541fced18e36a4bbd719 100644
--- a/runtime/bin/platform_macos.cc
+++ b/runtime/bin/platform_macos.cc
@@ -6,6 +6,8 @@
#if defined(TARGET_OS_MACOS)
#include <mach-o/dyld.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
#include "bin/file.h"
#include "bin/platform.h"
@@ -37,7 +39,14 @@ bool Platform::Initialize() {
int Platform::NumberOfProcessors() {
- return sysconf(_SC_NPROCESSORS_ONLN);
+ int32_t cpus = -1;
+ size_t cpus_length = sizeof(cpus);
+ if (sysctlbyname("hw.logicalcpu", &cpus, &cpus_length, NULL, 0) == 0) {
+ return cpus;
+ } else {
+ // Failed, fallback to using sysconf.
+ return sysconf(_SC_NPROCESSORS_ONLN);
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698