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
3 // found in the LICENSE file.
5 #include "base/sys_info.h"
10 #include <sys/utsname.h>
13 #include "base/basictypes.h"
14 #include "base/file_util.h"
15 #include "base/logging.h"
16 #include "base/utf_string_conversions.h"
18 #if defined(OS_ANDROID)
20 #define statvfs statfs // Android uses a statvfs-like statfs struct and call.
22 #include <sys/statvfs.h>
27 #if !defined(OS_OPENBSD)
28 int SysInfo::NumberOfProcessors() {
29 // It seems that sysconf returns the number of "logical" processors on both
30 // Mac and Linux. So we get the number of "online logical" processors.
31 long res
= sysconf(_SC_NPROCESSORS_ONLN
);
37 return static_cast<int>(res
);
42 int64
SysInfo::AmountOfFreeDiskSpace(const FilePath
& path
) {
44 if (statvfs(path
.value().c_str(), &stats
) != 0) {
47 return static_cast<int64
>(stats
.f_bavail
) * stats
.f_frsize
;
50 #if !defined(OS_MACOSX)
52 std::string
SysInfo::OperatingSystemName() {
54 if (uname(&info
) < 0) {
58 return std::string(info
.sysname
);
62 std::string
SysInfo::OperatingSystemVersion() {
64 if (uname(&info
) < 0) {
68 return std::string(info
.release
);
73 std::string
SysInfo::CPUArchitecture() {
75 if (uname(&info
) < 0) {
79 return std::string(info
.machine
);
83 size_t SysInfo::VMAllocationGranularity() {