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

Side by Side Diff: webrtc/base/systeminfo.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… Created 5 years, 2 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 | « webrtc/base/systeminfo.h ('k') | webrtc/base/task.h » ('j') | 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 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return std::string(reinterpret_cast<char*>(&cpu_info[0])); 154 return std::string(reinterpret_cast<char*>(&cpu_info[0]));
155 #elif defined(CPU_ARM) 155 #elif defined(CPU_ARM)
156 return "ARM"; 156 return "ARM";
157 #else 157 #else
158 return "Undefined"; 158 return "Undefined";
159 #endif 159 #endif
160 } 160 }
161 161
162 // Returns the amount of installed physical memory in Bytes. Cacheable. 162 // Returns the amount of installed physical memory in Bytes. Cacheable.
163 // Returns -1 on error. 163 // Returns -1 on error.
164 int64 SystemInfo::GetMemorySize() { 164 int64_t SystemInfo::GetMemorySize() {
165 int64 memory = -1; 165 int64_t memory = -1;
166 166
167 #if defined(WEBRTC_WIN) 167 #if defined(WEBRTC_WIN)
168 MEMORYSTATUSEX status = {0}; 168 MEMORYSTATUSEX status = {0};
169 status.dwLength = sizeof(status); 169 status.dwLength = sizeof(status);
170 170
171 if (GlobalMemoryStatusEx(&status)) { 171 if (GlobalMemoryStatusEx(&status)) {
172 memory = status.ullTotalPhys; 172 memory = status.ullTotalPhys;
173 } else { 173 } else {
174 LOG_GLE(LS_WARNING) << "GlobalMemoryStatusEx failed."; 174 LOG_GLE(LS_WARNING) << "GlobalMemoryStatusEx failed.";
175 } 175 }
176 176
177 #elif defined(WEBRTC_MAC) 177 #elif defined(WEBRTC_MAC)
178 size_t len = sizeof(memory); 178 size_t len = sizeof(memory);
179 int error = sysctlbyname("hw.memsize", &memory, &len, NULL, 0); 179 int error = sysctlbyname("hw.memsize", &memory, &len, NULL, 0);
180 if (error || memory == 0) 180 if (error || memory == 0)
181 memory = -1; 181 memory = -1;
182 #elif defined(WEBRTC_LINUX) 182 #elif defined(WEBRTC_LINUX)
183 memory = static_cast<int64>(sysconf(_SC_PHYS_PAGES)) * 183 memory = static_cast<int64_t>(sysconf(_SC_PHYS_PAGES)) *
184 static_cast<int64>(sysconf(_SC_PAGESIZE)); 184 static_cast<int64_t>(sysconf(_SC_PAGESIZE));
185 if (memory < 0) { 185 if (memory < 0) {
186 LOG(LS_WARNING) << "sysconf(_SC_PHYS_PAGES) failed." 186 LOG(LS_WARNING) << "sysconf(_SC_PHYS_PAGES) failed."
187 << "sysconf(_SC_PHYS_PAGES) " << sysconf(_SC_PHYS_PAGES) 187 << "sysconf(_SC_PHYS_PAGES) " << sysconf(_SC_PHYS_PAGES)
188 << "sysconf(_SC_PAGESIZE) " << sysconf(_SC_PAGESIZE); 188 << "sysconf(_SC_PAGESIZE) " << sysconf(_SC_PAGESIZE);
189 memory = -1; 189 memory = -1;
190 } 190 }
191 #endif 191 #endif
192 192
193 return memory; 193 return memory;
194 } 194 }
195 195
196 // Return the name of the machine model we are currently running on. 196 // Return the name of the machine model we are currently running on.
197 // This is a human readable string that consists of the name and version 197 // This is a human readable string that consists of the name and version
198 // number of the hardware, i.e 'MacBookAir1,1'. Returns an empty string if 198 // number of the hardware, i.e 'MacBookAir1,1'. Returns an empty string if
199 // model can not be determined. 199 // model can not be determined.
200 std::string SystemInfo::GetMachineModel() { 200 std::string SystemInfo::GetMachineModel() {
201 #if defined(WEBRTC_MAC) 201 #if defined(WEBRTC_MAC)
202 char buffer[128]; 202 char buffer[128];
203 size_t length = sizeof(buffer); 203 size_t length = sizeof(buffer);
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
OLDNEW
« no previous file with comments | « webrtc/base/systeminfo.h ('k') | webrtc/base/task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698