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

Side by Side Diff: base/sys_info_linux.cc

Issue 8382001: OpenBSD patches for base and build, part 2 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixes for prev. Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h"
9 10
10 namespace base { 11 namespace base {
11 12
12 int64 SysInfo::AmountOfPhysicalMemory() { 13 int64 SysInfo::AmountOfPhysicalMemory() {
13 long pages = sysconf(_SC_PHYS_PAGES); 14 long pages = sysconf(_SC_PHYS_PAGES);
14 long page_size = sysconf(_SC_PAGE_SIZE); 15 long page_size = sysconf(_SC_PAGE_SIZE);
15 if (pages == -1 || page_size == -1) { 16 if (pages == -1 || page_size == -1) {
16 NOTREACHED(); 17 NOTREACHED();
17 return 0; 18 return 0;
18 } 19 }
19 20
20 return static_cast<int64>(pages) * page_size; 21 return static_cast<int64>(pages) * page_size;
21 } 22 }
22 23
23 // static 24 // static
24 size_t SysInfo::MaxSharedMemorySize() { 25 size_t SysInfo::MaxSharedMemorySize() {
25 static size_t limit; 26 static int64 limit;
26 static bool limit_valid = false; 27 static bool limit_valid = false;
27 if (!limit_valid) { 28 if (!limit_valid) {
28 std::string contents; 29 std::string contents;
29 file_util::ReadFileToString(FilePath("/proc/sys/kernel/shmmax"), &contents); 30 file_util::ReadFileToString(FilePath("/proc/sys/kernel/shmmax"), &contents);
30 limit = strtoul(contents.c_str(), NULL, 0); 31 DCHECK(!contents.empty());
31 limit_valid = true; 32 if (base::StringToInt64(contents, &limit)) {
33 DCHECK(limit >= 0);
34 DCHECK(static_cast<size_t>(limit) <= sizeof(limit));
Mark Mentovai 2011/10/24 18:51:55 You didn’t really mean sizeof, did you?
Robert Nagy 2011/10/24 19:30:20 Done.
35 limit_valid = true;
36 } else {
37 NOTREACHED();
38 return 0;
39 }
32 } 40 }
33 return limit; 41 return static_cast<size_t>(limit);
34 } 42 }
35 43
36 } // namespace base 44 } // namespace base
OLDNEW
« no previous file with comments | « base/sys_info_freebsd.cc ('k') | base/sys_info_openbsd.cc » ('j') | build/common.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698