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

Unified Diff: base/sys_info_linux.cc

Issue 13945012: Implement missing SysInfo methods on OpenBSD (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert OpenBSD sysctl const; add AmountOfMemory() helpers to Linux and Windows 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/sys_info_openbsd.cc » ('j') | base/sys_info_openbsd.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info_linux.cc
diff --git a/base/sys_info_linux.cc b/base/sys_info_linux.cc
index 09ac3d65d6d34adbb6ef9b2e2155c87994d6a4db..7e623395571431e5029af8b17181c8774c1bcbc4 100644
--- a/base/sys_info_linux.cc
+++ b/base/sys_info_linux.cc
@@ -10,28 +10,30 @@
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
-namespace base {
+namespace {
-int64 SysInfo::AmountOfPhysicalMemory() {
- long pages = sysconf(_SC_PHYS_PAGES);
- long page_size = sysconf(_SC_PAGE_SIZE);
+int64 AmountOfMemory(int pages_name) {
+ long pages = sysconf(pages_name);
+ long page_size = sysconf(_SC_PAGESIZE);
mdempsky_google 2013/04/09 21:45:09 I intentionally changed this from _SC_PAGE_SIZE to
if (pages == -1 || page_size == -1) {
NOTREACHED();
return 0;
}
-
return static_cast<int64>(pages) * page_size;
}
+} // namespace
+
+namespace base {
+
+// static
+int64 SysInfo::AmountOfPhysicalMemory() {
+ return AmountOfMemory(_SC_PHYS_PAGES);
+}
+
// static
int64 SysInfo::AmountOfAvailablePhysicalMemory() {
- long available_pages = sysconf(_SC_AVPHYS_PAGES);
- long page_size = sysconf(_SC_PAGE_SIZE);
- if (available_pages == -1 || page_size == -1) {
- NOTREACHED();
- return 0;
- }
- return static_cast<int64>(available_pages) * page_size;
+ return AmountOfMemory(_SC_AVPHYS_PAGES);
}
// static
« no previous file with comments | « no previous file | base/sys_info_openbsd.cc » ('j') | base/sys_info_openbsd.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698