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

Side by Side Diff: base/sys_info_openbsd.cc

Issue 13945012: Implement missing SysInfo methods on OpenBSD (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Try upload again Created 7 years, 8 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 | « no previous file | no next file » | 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 <sys/param.h> 7 #include <sys/param.h>
8 #include <sys/shm.h> 8 #include <sys/shm.h>
9 #include <sys/sysctl.h> 9 #include <sys/sysctl.h>
10 10
(...skipping 16 matching lines...) Expand all
27 long pages = sysconf(_SC_PHYS_PAGES); 27 long pages = sysconf(_SC_PHYS_PAGES);
28 long page_size = sysconf(_SC_PAGESIZE); 28 long page_size = sysconf(_SC_PAGESIZE);
29 if (pages == -1 || page_size == -1) { 29 if (pages == -1 || page_size == -1) {
30 NOTREACHED(); 30 NOTREACHED();
31 return 0; 31 return 0;
32 } 32 }
33 33
34 return static_cast<int64>(pages) * page_size; 34 return static_cast<int64>(pages) * page_size;
35 } 35 }
36 36
37 // static
38 int64 SysInfo::AmountOfAvailablePhysicalMemory() {
39 long available_pages = sysconf(_SC_AVPHYS_PAGES);
Mark Mentovai 2013/04/09 20:37:08 Other than the constant used on this line, this is
Paweł Hajdan Jr. 2013/04/09 20:42:53 +1
mdempsky_google 2013/04/09 21:21:54 Done for sys_info_openbsd.cc. Let me know if you
40 long page_size = sysconf(_SC_PAGESIZE);
41 if (available_pages == -1 || page_size == -1) {
42 NOTREACHED();
43 return 0;
44 }
45 return static_cast<int64>(available_pages) * page_size;
46 }
47
37 size_t SysInfo::MaxSharedMemorySize() { 48 size_t SysInfo::MaxSharedMemorySize() {
38 int mib[] = { CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX }; 49 int mib[] = { CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX };
39 size_t limit; 50 size_t limit;
40 size_t size = sizeof(limit); 51 size_t size = sizeof(limit);
41 if (sysctl(mib, arraysize(mib), &limit, &size, NULL, 0) < 0) { 52 if (sysctl(mib, arraysize(mib), &limit, &size, NULL, 0) < 0) {
42 NOTREACHED(); 53 NOTREACHED();
43 return 0; 54 return 0;
44 } 55 }
45 return limit; 56 return limit;
46 } 57 }
47 58
59 // static
60 std::string SysInfo::CPUModelName() {
61 int mib[] = { CTL_HW, HW_MODEL };
Mark Mentovai 2013/04/09 20:37:08 Can this be const? Same on line 49.
mdempsky_google 2013/04/09 21:21:54 Sort of. The sysctl() interface on OpenBSD (curre
62 char name[256];
63 size_t len = arraysize(name);
64 if (sysctl(mib, arraysize(mib), name, &len, NULL, 0) == 0)
65 return name;
Mark Mentovai 2013/04/09 20:37:08 Matching the function above, test for the failure
mdempsky_google 2013/04/09 21:21:54 Done.
66 return std::string();
67 }
68
48 } // namespace base 69 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698