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

Side by Side Diff: base/sys_info_posix.cc

Issue 7238021: Solaris patch (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 6 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 | Annotate | Revision Log
OLDNEW
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 <string.h> 8 #include <string.h>
9 #include <sys/param.h> 9 #include <sys/param.h>
10 #include <sys/utsname.h> 10 #include <sys/utsname.h>
11 #include <unistd.h> 11 #include <unistd.h>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 17
18 #if defined(OS_ANDROID) 18 #if defined(OS_ANDROID)
19 #include <sys/vfs.h> 19 #include <sys/vfs.h>
20 #define statvfs statfs // Android uses a statvfs-like statfs struct and call. 20 #define statvfs statfs // Android uses a statvfs-like statfs struct and call.
21 #else 21 #else
22 #include <sys/statvfs.h> 22 #include <sys/statvfs.h>
23 #endif
24
25 #if defined(OS_OPENBSD) || defined(OS_FREEBSD)
23 #include <sys/sysctl.h> 26 #include <sys/sysctl.h>
24 #endif 27 #endif
25 28
26 namespace base { 29 namespace base {
27 30
28 #if !defined(OS_OPENBSD) 31 #if !defined(OS_OPENBSD)
29 int SysInfo::NumberOfProcessors() { 32 int SysInfo::NumberOfProcessors() {
30 // It seems that sysconf returns the number of "logical" processors on both 33 // It seems that sysconf returns the number of "logical" processors on both
31 // Mac and Linux. So we get the number of "online logical" processors. 34 // Mac and Linux. So we get the number of "online logical" processors.
32 long res = sysconf(_SC_NPROCESSORS_ONLN); 35 long res = sysconf(_SC_NPROCESSORS_ONLN);
(...skipping 11 matching lines...) Expand all
44 struct statvfs stats; 47 struct statvfs stats;
45 if (statvfs(path.value().c_str(), &stats) != 0) { 48 if (statvfs(path.value().c_str(), &stats) != 0) {
46 return -1; 49 return -1;
47 } 50 }
48 return static_cast<int64>(stats.f_bavail) * stats.f_frsize; 51 return static_cast<int64>(stats.f_bavail) * stats.f_frsize;
49 } 52 }
50 53
51 #if !defined(OS_MACOSX) 54 #if !defined(OS_MACOSX)
52 // static 55 // static
53 std::string SysInfo::OperatingSystemName() { 56 std::string SysInfo::OperatingSystemName() {
54 utsname info; 57 struct utsname info;
55 if (uname(&info) < 0) { 58 if (uname(&info) < 0) {
56 NOTREACHED(); 59 NOTREACHED();
57 return ""; 60 return "";
58 } 61 }
59 return std::string(info.sysname); 62 return std::string(info.sysname);
60 } 63 }
61 64
62 // static 65 // static
63 std::string SysInfo::OperatingSystemVersion() { 66 std::string SysInfo::OperatingSystemVersion() {
64 utsname info; 67 struct utsname info;
65 if (uname(&info) < 0) { 68 if (uname(&info) < 0) {
66 NOTREACHED(); 69 NOTREACHED();
67 return ""; 70 return "";
68 } 71 }
69 return std::string(info.release); 72 return std::string(info.release);
70 } 73 }
71 #endif 74 #endif
72 75
73 // static 76 // static
74 std::string SysInfo::CPUArchitecture() { 77 std::string SysInfo::CPUArchitecture() {
75 utsname info; 78 struct utsname info;
76 if (uname(&info) < 0) { 79 if (uname(&info) < 0) {
77 NOTREACHED(); 80 NOTREACHED();
78 return ""; 81 return "";
79 } 82 }
80 return std::string(info.machine); 83 return std::string(info.machine);
81 } 84 }
82 85
83 // static 86 // static
84 size_t SysInfo::VMAllocationGranularity() { 87 size_t SysInfo::VMAllocationGranularity() {
85 return getpagesize(); 88 return getpagesize();
86 } 89 }
87 90
88 } // namespace base 91 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698