OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2008 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 // Return the number of cpus available to the process. Since affinity can be | 104 // Return the number of cpus available to the process. Since affinity can be |
105 // changed on the fly, do not cache this value. | 105 // changed on the fly, do not cache this value. |
106 // Can be affected by heat. | 106 // Can be affected by heat. |
107 int SystemInfo::GetCurCpus() { | 107 int SystemInfo::GetCurCpus() { |
108 int cur_cpus = 0; | 108 int cur_cpus = 0; |
109 #if defined(WEBRTC_WIN) | 109 #if defined(WEBRTC_WIN) |
110 DWORD_PTR process_mask = 0; | 110 DWORD_PTR process_mask = 0; |
111 DWORD_PTR system_mask = 0; | 111 DWORD_PTR system_mask = 0; |
112 ::GetProcessAffinityMask(::GetCurrentProcess(), &process_mask, &system_mask); | 112 ::GetProcessAffinityMask(::GetCurrentProcess(), &process_mask, &system_mask); |
113 for (int i = 0; i < sizeof(DWORD_PTR) * 8; ++i) { | 113 for (size_t i = 0; i < sizeof(DWORD_PTR) * 8; ++i) { |
114 if (process_mask & 1) | 114 if (process_mask & 1) |
115 ++cur_cpus; | 115 ++cur_cpus; |
116 process_mask >>= 1; | 116 process_mask >>= 1; |
117 } | 117 } |
118 #elif defined(WEBRTC_MAC) | 118 #elif defined(WEBRTC_MAC) |
119 uint32_t sysctl_value; | 119 uint32_t sysctl_value; |
120 size_t length = sizeof(sysctl_value); | 120 size_t length = sizeof(sysctl_value); |
121 int error = sysctlbyname("hw.ncpu", &sysctl_value, &length, NULL, 0); | 121 int error = sysctlbyname("hw.ncpu", &sysctl_value, &length, NULL, 0); |
122 cur_cpus = !error ? static_cast<int>(sysctl_value) : 1; | 122 cur_cpus = !error ? static_cast<int>(sysctl_value) : 1; |
123 #else | 123 #else |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 int error = sysctlbyname("hw.model", buffer, &length, NULL, 0); | 204 int error = sysctlbyname("hw.model", buffer, &length, NULL, 0); |
205 if (!error) | 205 if (!error) |
206 return std::string(buffer, length - 1); | 206 return std::string(buffer, length - 1); |
207 return std::string(); | 207 return std::string(); |
208 #else | 208 #else |
209 return "Not available"; | 209 return "Not available"; |
210 #endif | 210 #endif |
211 } | 211 } |
212 | 212 |
213 } // namespace rtc | 213 } // namespace rtc |
OLD | NEW |