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

Side by Side Diff: webrtc/system_wrappers/source/cpu_info.cc

Issue 2978863002: Fix DetectNumberOfCores for 32-bit processes (Closed)
Patch Set: Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 14 matching lines...) Expand all
25 25
26 #include "webrtc/rtc_base/logging.h" 26 #include "webrtc/rtc_base/logging.h"
27 27
28 namespace internal { 28 namespace internal {
29 static int DetectNumberOfCores() { 29 static int DetectNumberOfCores() {
30 // We fall back on assuming a single core in case of errors. 30 // We fall back on assuming a single core in case of errors.
31 int number_of_cores = 1; 31 int number_of_cores = 1;
32 32
33 #if defined(WEBRTC_WIN) 33 #if defined(WEBRTC_WIN)
34 SYSTEM_INFO si; 34 SYSTEM_INFO si;
35 GetSystemInfo(&si); 35 GetNativeSystemInfo(&si);
36 number_of_cores = static_cast<int>(si.dwNumberOfProcessors); 36 number_of_cores = static_cast<int>(si.dwNumberOfProcessors);
37 #elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID) 37 #elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
38 number_of_cores = static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN)); 38 number_of_cores = static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN));
39 #elif defined(WEBRTC_MAC) 39 #elif defined(WEBRTC_MAC)
40 int name[] = {CTL_HW, HW_AVAILCPU}; 40 int name[] = {CTL_HW, HW_AVAILCPU};
41 size_t size = sizeof(number_of_cores); 41 size_t size = sizeof(number_of_cores);
42 if (0 != sysctl(name, 2, &number_of_cores, &size, NULL, 0)) { 42 if (0 != sysctl(name, 2, &number_of_cores, &size, NULL, 0)) {
43 LOG(LS_ERROR) << "Failed to get number of cores"; 43 LOG(LS_ERROR) << "Failed to get number of cores";
44 number_of_cores = 1; 44 number_of_cores = 1;
45 } 45 }
(...skipping 14 matching lines...) Expand all
60 // is running in a sandbox, we may only be able to read the value once (before 60 // is running in a sandbox, we may only be able to read the value once (before
61 // the sandbox is initialized) and not thereafter. 61 // the sandbox is initialized) and not thereafter.
62 // For more information see crbug.com/176522. 62 // For more information see crbug.com/176522.
63 static uint32_t logical_cpus = 0; 63 static uint32_t logical_cpus = 0;
64 if (!logical_cpus) 64 if (!logical_cpus)
65 logical_cpus = static_cast<uint32_t>(internal::DetectNumberOfCores()); 65 logical_cpus = static_cast<uint32_t>(internal::DetectNumberOfCores());
66 return logical_cpus; 66 return logical_cpus;
67 } 67 }
68 68
69 } // namespace webrtc 69 } // namespace webrtc
OLDNEW
« 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