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) && !defined(OS_CHROMEOS) |
| 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 if (uname(&info) < 0) { |
| 193 NOTREACHED(); |
| 194 *major_version = 0; |
| 195 *minor_version = 0; |
| 196 *bugfix_version = 0; |
| 197 return; |
| 198 } |
| 199 int num_read = sscanf(info.release, "%d.%d.%d", major_version, minor_version, |
| 200 bugfix_version); |
| 201 if (num_read < 1) |
| 202 *major_version = 0; |
| 203 if (num_read < 2) |
| 204 *minor_version = 0; |
| 205 if (num_read < 3) |
| 206 *bugfix_version = 0; |
| 207 } |
| 208 #endif |
| 209 |
186 // static | 210 // static |
187 std::string SysInfo::OperatingSystemArchitecture() { | 211 std::string SysInfo::OperatingSystemArchitecture() { |
188 struct utsname info; | 212 struct utsname info; |
189 if (uname(&info) < 0) { | 213 if (uname(&info) < 0) { |
190 NOTREACHED(); | 214 NOTREACHED(); |
191 return std::string(); | 215 return std::string(); |
192 } | 216 } |
193 std::string arch(info.machine); | 217 std::string arch(info.machine); |
194 if (arch == "i386" || arch == "i486" || arch == "i586" || arch == "i686") { | 218 if (arch == "i386" || arch == "i486" || arch == "i586" || arch == "i686") { |
195 arch = "x86"; | 219 arch = "x86"; |
196 } else if (arch == "amd64") { | 220 } else if (arch == "amd64") { |
197 arch = "x86_64"; | 221 arch = "x86_64"; |
198 } | 222 } |
199 return arch; | 223 return arch; |
200 } | 224 } |
201 | 225 |
202 // static | 226 // static |
203 size_t SysInfo::VMAllocationGranularity() { | 227 size_t SysInfo::VMAllocationGranularity() { |
204 return getpagesize(); | 228 return getpagesize(); |
205 } | 229 } |
206 | 230 |
207 } // namespace base | 231 } // namespace base |
OLD | NEW |