WebKit merge 94748:94770
[chromium-blink-merge.git] / base / sys_info_freebsd.cc
blob66ab23bbae2f83ab57e869b7cac9b2ef3f127afa
1 // Copyright (c) 2009 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"
7 #include <sys/sysctl.h>
9 #include "base/logging.h"
11 namespace base {
13 int64 SysInfo::AmountOfPhysicalMemory() {
14 int pages, page_size;
15 size_t size = sizeof(pages);
16 sysctlbyname("vm.stats.vm.v_page_count", &pages, &size, NULL, 0);
17 sysctlbyname("vm.stats.vm.v_page_size", &page_size, &size, NULL, 0);
18 if (pages == -1 || page_size == -1) {
19 NOTREACHED();
20 return 0;
22 return static_cast<int64>(pages) * page_size;
25 // static
26 size_t SysInfo::MaxSharedMemorySize() {
27 size_t limit;
28 size_t size = sizeof(limit);
29 sysctlbyname("kern.ipc.shmmax", &limit, &size, NULL, 0);
30 return limit;
33 } // namespace base