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

Unified Diff: base/sys_info_linux.cc

Issue 1050233002: If sysconfig fails, fallback to sysinfo Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
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 401d55ce1b24bcb2a5fa741deaf8a78e4852ca6f..ea71e12dfc8eb494e3bcc4cf211cba41d922c4dc 100644
--- a/base/sys_info_linux.cc
+++ b/base/sys_info_linux.cc
@@ -5,6 +5,7 @@
#include "base/sys_info.h"
#include <limits>
+#include <sys/sysinfo.h>
#include "base/files/file_util.h"
#include "base/lazy_instance.h"
@@ -18,6 +19,14 @@ int64 AmountOfMemory(int pages_name) {
long pages = sysconf(pages_name);
danakj 2015/04/02 19:05:47 can you DCHECK up here that pages_name is _SC_PHYS
smcgruer2 2015/04/07 21:25:43 Done.
long page_size = sysconf(_SC_PAGESIZE);
if (pages == -1 || page_size == -1) {
+ struct sysinfo si;
+ if (sysinfo(&si)) {
danakj 2015/04/02 19:05:47 on success 0 is returned. so this won't work right
smcgruer2 2015/04/07 21:25:43 Whoops! Good eye, the original code was checking '
+ if (pages_name == _SC_PHYS_PAGES) {
+ return si.totalram * si.mem_unit;
danakj 2015/04/02 19:05:47 can you cast the totalram to an int64 before multi
smcgruer2 2015/04/07 21:25:43 Done.
+ } else if (pages_name == _SC_AVPHYS_PAGES) {
danakj 2015/04/02 19:05:47 just else should be sufficient? (can leave ..AVPHY
smcgruer2 2015/04/07 21:25:43 Done.
+ return si.freeram * si.mem_unit;
danakj 2015/04/02 19:05:47 dittos
smcgruer2 2015/04/07 21:25:43 Done.
+ }
+ }
NOTREACHED();
danakj 2015/04/02 19:05:47 can you restructure this code so we don't have NOT
smcgruer2 2015/04/07 21:25:43 Done.
return 0;
}
« 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