Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/sys_info.h" | 5 #include "base/sys_info.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 std::string SysInfo::OperatingSystemVersion() { | 176 std::string SysInfo::OperatingSystemVersion() { |
| 177 struct utsname info; | 177 struct utsname info; |
| 178 if (uname(&info) < 0) { | 178 if (uname(&info) < 0) { |
| 179 NOTREACHED(); | 179 NOTREACHED(); |
| 180 return std::string(); | 180 return std::string(); |
| 181 } | 181 } |
| 182 return std::string(info.release); | 182 return std::string(info.release); |
| 183 } | 183 } |
| 184 #endif | 184 #endif |
| 185 | 185 |
| 186 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | |
| 187 // static | |
| 188 void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version, | |
| 189 int32_t* minor_version, | |
| 190 int32_t* bugfix_version) { | |
| 191 struct utsname info; | |
| 192 *major_version = 0; | |
| 193 *minor_version = 0; | |
| 194 *bugfix_version = 0; | |
| 195 if (uname(&info) < 0) { | |
| 196 NOTREACHED(); | |
| 197 return; | |
| 198 } | |
| 199 sscanf(info.release, "%d.%d.%d", major_version, minor_version, | |
|
dcheng
2017/03/21 06:51:17
Is the formatting of |release| guaranteed by some
dcheng
2017/03/21 06:53:37
Also, I'd probably prefer the approach that iOS us
romax
2017/03/21 18:17:33
Tried a search online and didn't find a standard f
| |
| 200 bugfix_version); | |
| 201 } | |
| 202 #endif | |
| 203 | |
| 186 // static | 204 // static |
| 187 std::string SysInfo::OperatingSystemArchitecture() { | 205 std::string SysInfo::OperatingSystemArchitecture() { |
| 188 struct utsname info; | 206 struct utsname info; |
| 189 if (uname(&info) < 0) { | 207 if (uname(&info) < 0) { |
| 190 NOTREACHED(); | 208 NOTREACHED(); |
| 191 return std::string(); | 209 return std::string(); |
| 192 } | 210 } |
| 193 std::string arch(info.machine); | 211 std::string arch(info.machine); |
| 194 if (arch == "i386" || arch == "i486" || arch == "i586" || arch == "i686") { | 212 if (arch == "i386" || arch == "i486" || arch == "i586" || arch == "i686") { |
| 195 arch = "x86"; | 213 arch = "x86"; |
| 196 } else if (arch == "amd64") { | 214 } else if (arch == "amd64") { |
| 197 arch = "x86_64"; | 215 arch = "x86_64"; |
| 198 } | 216 } |
| 199 return arch; | 217 return arch; |
| 200 } | 218 } |
| 201 | 219 |
| 202 // static | 220 // static |
| 203 size_t SysInfo::VMAllocationGranularity() { | 221 size_t SysInfo::VMAllocationGranularity() { |
| 204 return getpagesize(); | 222 return getpagesize(); |
| 205 } | 223 } |
| 206 | 224 |
| 207 } // namespace base | 225 } // namespace base |
| OLD | NEW |