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 17 matching lines...) Expand all Loading... |
28 #include <sys/statvfs.h> | 28 #include <sys/statvfs.h> |
29 #endif | 29 #endif |
30 | 30 |
31 #if defined(OS_LINUX) | 31 #if defined(OS_LINUX) |
32 #include <linux/magic.h> | 32 #include <linux/magic.h> |
33 #include <sys/vfs.h> | 33 #include <sys/vfs.h> |
34 #endif | 34 #endif |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 #if !defined(OS_OPENBSD) | 38 #if !defined(OS_OPENBSD) && !defined(OS_FUCHSIA) |
39 int NumberOfProcessors() { | 39 int NumberOfProcessors() { |
40 // sysconf returns the number of "logical" (not "physical") processors on both | 40 // sysconf returns the number of "logical" (not "physical") processors on both |
41 // Mac and Linux. So we get the number of max available "logical" processors. | 41 // Mac and Linux. So we get the number of max available "logical" processors. |
42 // | 42 // |
43 // Note that the number of "currently online" processors may be fewer than the | 43 // Note that the number of "currently online" processors may be fewer than the |
44 // returned value of NumberOfProcessors(). On some platforms, the kernel may | 44 // returned value of NumberOfProcessors(). On some platforms, the kernel may |
45 // make some processors offline intermittently, to save power when system | 45 // make some processors offline intermittently, to save power when system |
46 // loading is low. | 46 // loading is low. |
47 // | 47 // |
48 // One common use case that needs to know the processor count is to create | 48 // One common use case that needs to know the processor count is to create |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 ? std::numeric_limits<int64_t>::max() | 121 ? std::numeric_limits<int64_t>::max() |
122 : static_cast<int64_t>(stats.f_blocks) * stats.f_frsize; | 122 : static_cast<int64_t>(stats.f_blocks) * stats.f_frsize; |
123 } | 123 } |
124 return true; | 124 return true; |
125 } | 125 } |
126 | 126 |
127 } // namespace | 127 } // namespace |
128 | 128 |
129 namespace base { | 129 namespace base { |
130 | 130 |
131 #if !defined(OS_OPENBSD) | 131 #if !defined(OS_OPENBSD) && !defined(OS_FUCHSIA) |
132 int SysInfo::NumberOfProcessors() { | 132 int SysInfo::NumberOfProcessors() { |
133 return g_lazy_number_of_processors.Get().value(); | 133 return g_lazy_number_of_processors.Get().value(); |
134 } | 134 } |
135 #endif | 135 #endif |
136 | 136 |
137 // static | 137 // static |
138 int64_t SysInfo::AmountOfVirtualMemory() { | 138 int64_t SysInfo::AmountOfVirtualMemory() { |
139 return g_lazy_virtual_memory.Get().value(); | 139 return g_lazy_virtual_memory.Get().value(); |
140 } | 140 } |
141 | 141 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 224 } |
225 return arch; | 225 return arch; |
226 } | 226 } |
227 | 227 |
228 // static | 228 // static |
229 size_t SysInfo::VMAllocationGranularity() { | 229 size_t SysInfo::VMAllocationGranularity() { |
230 return getpagesize(); | 230 return getpagesize(); |
231 } | 231 } |
232 | 232 |
233 } // namespace base | 233 } // namespace base |
OLD | NEW |