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

Side by Side Diff: base/sys_info_openbsd.cc

Issue 2558043007: Fix free memory calculation. (Closed)
Patch Set: Fix integer overflow in unittest. 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.
51 return AmountOfMemory(_SC_AVPHYS_PAGES); 53 return AmountOfMemory(_SC_AVPHYS_PAGES);
52 } 54 }
53 55
54 // static 56 // static
55 uint64_t SysInfo::MaxSharedMemorySize() { 57 uint64_t SysInfo::MaxSharedMemorySize() {
56 int mib[] = { CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX }; 58 int mib[] = { CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX };
57 size_t limit; 59 size_t limit;
58 size_t size = sizeof(limit); 60 size_t size = sizeof(limit);
59 if (sysctl(mib, arraysize(mib), &limit, &size, NULL, 0) < 0) { 61 if (sysctl(mib, arraysize(mib), &limit, &size, NULL, 0) < 0) {
60 NOTREACHED(); 62 NOTREACHED();
61 return 0; 63 return 0;
62 } 64 }
63 return static_cast<uint64_t>(limit); 65 return static_cast<uint64_t>(limit);
64 } 66 }
65 67
66 // static 68 // static
67 std::string SysInfo::CPUModelName() { 69 std::string SysInfo::CPUModelName() {
68 int mib[] = { CTL_HW, HW_MODEL }; 70 int mib[] = { CTL_HW, HW_MODEL };
69 char name[256]; 71 char name[256];
70 size_t len = arraysize(name); 72 size_t len = arraysize(name);
71 if (sysctl(mib, arraysize(mib), name, &len, NULL, 0) < 0) { 73 if (sysctl(mib, arraysize(mib), name, &len, NULL, 0) < 0) {
72 NOTREACHED(); 74 NOTREACHED();
73 return std::string(); 75 return std::string();
74 } 76 }
75 return name; 77 return name;
76 } 78 }
77 79
78 } // namespace base 80 } // 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