OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/sys_info.h" | 6 #include "base/sys_info.h" |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 | 8 |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 NOTREACHED(); | 45 NOTREACHED(); |
46 return 1; | 46 return 1; |
47 } | 47 } |
48 | 48 |
49 return static_cast<int>(res); | 49 return static_cast<int>(res); |
50 #endif | 50 #endif |
51 } | 51 } |
52 | 52 |
53 // static | 53 // static |
54 int64 SysInfo::AmountOfPhysicalMemory() { | 54 int64 SysInfo::AmountOfPhysicalMemory() { |
55 // _SC_PHYS_PAGES is not part of POSIX and not available on OS X | 55 // _SC_PHYS_PAGES is not part of POSIX and not available on OS X or |
| 56 // FreeBSD |
56 #if defined(OS_MACOSX) | 57 #if defined(OS_MACOSX) |
57 struct host_basic_info hostinfo; | 58 struct host_basic_info hostinfo; |
58 mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; | 59 mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; |
59 int result = host_info(mach_host_self(), | 60 int result = host_info(mach_host_self(), |
60 HOST_BASIC_INFO, | 61 HOST_BASIC_INFO, |
61 reinterpret_cast<host_info_t>(&hostinfo), | 62 reinterpret_cast<host_info_t>(&hostinfo), |
62 &count); | 63 &count); |
63 DCHECK_EQ(HOST_BASIC_INFO_COUNT, count); | 64 DCHECK_EQ(HOST_BASIC_INFO_COUNT, count); |
64 if (result != KERN_SUCCESS) { | 65 if (result != KERN_SUCCESS) { |
65 NOTREACHED(); | 66 NOTREACHED(); |
66 return 0; | 67 return 0; |
67 } | 68 } |
68 | 69 |
69 return static_cast<int64>(hostinfo.max_mem); | 70 return static_cast<int64>(hostinfo.max_mem); |
| 71 #elif defined(OS_FREEBSD) |
| 72 // TODO(benl): I have no idea how to get this |
| 73 NOTIMPLEMENTED(); |
| 74 return 0; |
70 #else | 75 #else |
71 long pages = sysconf(_SC_PHYS_PAGES); | 76 long pages = sysconf(_SC_PHYS_PAGES); |
72 long page_size = sysconf(_SC_PAGE_SIZE); | 77 long page_size = sysconf(_SC_PAGE_SIZE); |
73 if (pages == -1 || page_size == -1) { | 78 if (pages == -1 || page_size == -1) { |
74 NOTREACHED(); | 79 NOTREACHED(); |
75 return 0; | 80 return 0; |
76 } | 81 } |
77 | 82 |
78 return static_cast<int64>(pages) * page_size; | 83 return static_cast<int64>(pages) * page_size; |
79 #endif | 84 #endif |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 file_util::ReadFileToString(FilePath("/proc/sys/kernel/shmmax"), &contents); | 167 file_util::ReadFileToString(FilePath("/proc/sys/kernel/shmmax"), &contents); |
163 limit = strtoul(contents.c_str(), NULL, 0); | 168 limit = strtoul(contents.c_str(), NULL, 0); |
164 limit_valid = true; | 169 limit_valid = true; |
165 } | 170 } |
166 | 171 |
167 return limit; | 172 return limit; |
168 } | 173 } |
169 #endif | 174 #endif |
170 | 175 |
171 } // namespace base | 176 } // namespace base |
OLD | NEW |