[Clean-up] Remove NetworkStats code, which has been dead code since July 2014.
[chromium-blink-merge.git] / base / sys_info_openbsd.cc
blob68d2ea14886ff832ab00d3dc88e78c90c10aba52
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
3 // found in the LICENSE file.
5 #include "base/sys_info.h"
7 #include <sys/param.h>
8 #include <sys/shm.h>
9 #include <sys/sysctl.h>
11 #include "base/logging.h"
13 namespace {
15 int64 AmountOfMemory(int pages_name) {
16 long pages = sysconf(pages_name);
17 long page_size = sysconf(_SC_PAGESIZE);
18 if (pages == -1 || page_size == -1) {
19 NOTREACHED();
20 return 0;
22 return static_cast<int64>(pages) * page_size;
25 } // namespace
27 namespace base {
29 // static
30 int SysInfo::NumberOfProcessors() {
31 int mib[] = { CTL_HW, HW_NCPU };
32 int ncpu;
33 size_t size = sizeof(ncpu);
34 if (sysctl(mib, arraysize(mib), &ncpu, &size, NULL, 0) < 0) {
35 NOTREACHED();
36 return 1;
38 return ncpu;
41 // static
42 int64 SysInfo::AmountOfPhysicalMemory() {
43 return AmountOfMemory(_SC_PHYS_PAGES);
46 // static
47 int64 SysInfo::AmountOfAvailablePhysicalMemory() {
48 return AmountOfMemory(_SC_AVPHYS_PAGES);
51 bool SysInfo::HasSeekPenalty(const FilePath& path, bool* has_seek_penalty) {
52 return false;
55 // static
56 size_t SysInfo::MaxSharedMemorySize() {
57 int mib[] = { CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX };
58 size_t limit;
59 size_t size = sizeof(limit);
60 if (sysctl(mib, arraysize(mib), &limit, &size, NULL, 0) < 0) {
61 NOTREACHED();
62 return 0;
64 return limit;
67 // static
68 std::string SysInfo::CPUModelName() {
69 int mib[] = { CTL_HW, HW_MODEL };
70 char name[256];
71 size_t len = arraysize(name);
72 if (sysctl(mib, arraysize(mib), name, &len, NULL, 0) < 0) {
73 NOTREACHED();
74 return std::string();
76 return name;
79 } // namespace base