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

Side by Side Diff: base/sys_info_openbsd.cc

Issue 2766623002: Revert of Fix free memory calculation. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « base/sys_info_mac.mm ('k') | base/sys_info_unittest.cc » ('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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <sys/param.h> 9 #include <sys/param.h>
10 #include <sys/shm.h> 10 #include <sys/shm.h>
(...skipping 30 matching lines...) Expand all
41 return ncpu; 41 return ncpu;
42 } 42 }
43 43
44 // static 44 // static
45 int64_t SysInfo::AmountOfPhysicalMemory() { 45 int64_t SysInfo::AmountOfPhysicalMemory() {
46 return AmountOfMemory(_SC_PHYS_PAGES); 46 return AmountOfMemory(_SC_PHYS_PAGES);
47 } 47 }
48 48
49 // static 49 // static
50 int64_t SysInfo::AmountOfAvailablePhysicalMemory() { 50 int64_t SysInfo::AmountOfAvailablePhysicalMemory() {
51 // We should add inactive file-backed memory also but there is no such
52 // information from OpenBSD unfortunately.
53 return AmountOfMemory(_SC_AVPHYS_PAGES); 51 return AmountOfMemory(_SC_AVPHYS_PAGES);
54 } 52 }
55 53
56 // static 54 // static
57 uint64_t SysInfo::MaxSharedMemorySize() { 55 uint64_t SysInfo::MaxSharedMemorySize() {
58 int mib[] = { CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX }; 56 int mib[] = { CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX };
59 size_t limit; 57 size_t limit;
60 size_t size = sizeof(limit); 58 size_t size = sizeof(limit);
61 if (sysctl(mib, arraysize(mib), &limit, &size, NULL, 0) < 0) { 59 if (sysctl(mib, arraysize(mib), &limit, &size, NULL, 0) < 0) {
62 NOTREACHED(); 60 NOTREACHED();
63 return 0; 61 return 0;
64 } 62 }
65 return static_cast<uint64_t>(limit); 63 return static_cast<uint64_t>(limit);
66 } 64 }
67 65
68 // static 66 // static
69 std::string SysInfo::CPUModelName() { 67 std::string SysInfo::CPUModelName() {
70 int mib[] = { CTL_HW, HW_MODEL }; 68 int mib[] = { CTL_HW, HW_MODEL };
71 char name[256]; 69 char name[256];
72 size_t len = arraysize(name); 70 size_t len = arraysize(name);
73 if (sysctl(mib, arraysize(mib), name, &len, NULL, 0) < 0) { 71 if (sysctl(mib, arraysize(mib), name, &len, NULL, 0) < 0) {
74 NOTREACHED(); 72 NOTREACHED();
75 return std::string(); 73 return std::string();
76 } 74 }
77 return name; 75 return name;
78 } 76 }
79 77
80 } // namespace base 78 } // namespace base
OLDNEW
« no previous file with comments | « base/sys_info_mac.mm ('k') | base/sys_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698