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

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: fixed some sysctl includes 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
« no previous file with comments | « base/sync_socket_posix.cc ('k') | base/third_party/nspr/prcpucfg_solaris.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 // 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 #include <sys/sysctl.h>
24 #endif 23 #endif
25 24
26 namespace base { 25 namespace base {
27 26
28 #if !defined(OS_OPENBSD) 27 #if !defined(OS_OPENBSD)
29 int SysInfo::NumberOfProcessors() { 28 int SysInfo::NumberOfProcessors() {
30 // It seems that sysconf returns the number of "logical" processors on both 29 // 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. 30 // Mac and Linux. So we get the number of "online logical" processors.
32 long res = sysconf(_SC_NPROCESSORS_ONLN); 31 long res = sysconf(_SC_NPROCESSORS_ONLN);
33 if (res == -1) { 32 if (res == -1) {
(...skipping 10 matching lines...) Expand all
44 struct statvfs stats; 43 struct statvfs stats;
45 if (statvfs(path.value().c_str(), &stats) != 0) { 44 if (statvfs(path.value().c_str(), &stats) != 0) {
46 return -1; 45 return -1;
47 } 46 }
48 return static_cast<int64>(stats.f_bavail) * stats.f_frsize; 47 return static_cast<int64>(stats.f_bavail) * stats.f_frsize;
49 } 48 }
50 49
51 #if !defined(OS_MACOSX) 50 #if !defined(OS_MACOSX)
52 // static 51 // static
53 std::string SysInfo::OperatingSystemName() { 52 std::string SysInfo::OperatingSystemName() {
54 utsname info; 53 struct utsname info;
55 if (uname(&info) < 0) { 54 if (uname(&info) < 0) {
56 NOTREACHED(); 55 NOTREACHED();
57 return ""; 56 return "";
58 } 57 }
59 return std::string(info.sysname); 58 return std::string(info.sysname);
60 } 59 }
61 60
62 // static 61 // static
63 std::string SysInfo::OperatingSystemVersion() { 62 std::string SysInfo::OperatingSystemVersion() {
64 utsname info; 63 struct utsname info;
65 if (uname(&info) < 0) { 64 if (uname(&info) < 0) {
66 NOTREACHED(); 65 NOTREACHED();
67 return ""; 66 return "";
68 } 67 }
69 return std::string(info.release); 68 return std::string(info.release);
70 } 69 }
71 #endif 70 #endif
72 71
73 // static 72 // static
74 std::string SysInfo::CPUArchitecture() { 73 std::string SysInfo::CPUArchitecture() {
75 utsname info; 74 struct utsname info;
76 if (uname(&info) < 0) { 75 if (uname(&info) < 0) {
77 NOTREACHED(); 76 NOTREACHED();
78 return ""; 77 return "";
79 } 78 }
80 return std::string(info.machine); 79 return std::string(info.machine);
81 } 80 }
82 81
83 // static 82 // static
84 size_t SysInfo::VMAllocationGranularity() { 83 size_t SysInfo::VMAllocationGranularity() {
85 return getpagesize(); 84 return getpagesize();
86 } 85 }
87 86
88 } // namespace base 87 } // namespace base
OLDNEW
« no previous file with comments | « base/sync_socket_posix.cc ('k') | base/third_party/nspr/prcpucfg_solaris.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698