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

Side by Side Diff: src/base/sys-info.cc

Issue 521473003: More PNaCL fixes (without GYP/Makefile tweaks) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/base/platform/semaphore.cc ('k') | src/d8-posix.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project 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 "src/base/sys-info.h" 5 #include "src/base/sys-info.h"
6 6
7 #if V8_OS_POSIX 7 #if V8_OS_POSIX
8 #include <sys/resource.h> 8 #include <sys/resource.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/time.h> 10 #include <sys/time.h>
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 int64_t result = static_cast<int64_t>(memory_info.ullTotalPhys); 84 int64_t result = static_cast<int64_t>(memory_info.ullTotalPhys);
85 if (result < 0) result = std::numeric_limits<int64_t>::max(); 85 if (result < 0) result = std::numeric_limits<int64_t>::max();
86 return result; 86 return result;
87 #elif V8_OS_QNX 87 #elif V8_OS_QNX
88 struct stat stat_buf; 88 struct stat stat_buf;
89 if (stat("/proc", &stat_buf) != 0) { 89 if (stat("/proc", &stat_buf) != 0) {
90 UNREACHABLE(); 90 UNREACHABLE();
91 return 0; 91 return 0;
92 } 92 }
93 return static_cast<int64_t>(stat_buf.st_size); 93 return static_cast<int64_t>(stat_buf.st_size);
94 #elif V8_OS_NACL
95 // No support for _SC_PHYS_PAGES, assume 2GB.
96 return static_cast<int64_t>(1) << 31;
94 #elif V8_OS_POSIX 97 #elif V8_OS_POSIX
95 long pages = sysconf(_SC_PHYS_PAGES); // NOLINT(runtime/int) 98 long pages = sysconf(_SC_PHYS_PAGES); // NOLINT(runtime/int)
96 long page_size = sysconf(_SC_PAGESIZE); // NOLINT(runtime/int) 99 long page_size = sysconf(_SC_PAGESIZE); // NOLINT(runtime/int)
97 if (pages == -1 || page_size == -1) { 100 if (pages == -1 || page_size == -1) {
98 UNREACHABLE(); 101 UNREACHABLE();
99 return 0; 102 return 0;
100 } 103 }
101 return static_cast<int64_t>(pages) * page_size; 104 return static_cast<int64_t>(pages) * page_size;
102 #endif 105 #endif
103 } 106 }
104 107
105 108
106 // static 109 // static
107 int64_t SysInfo::AmountOfVirtualMemory() { 110 int64_t SysInfo::AmountOfVirtualMemory() {
108 #if V8_OS_NACL || V8_OS_WIN 111 #if V8_OS_NACL || V8_OS_WIN
109 return 0; 112 return 0;
110 #elif V8_OS_POSIX 113 #elif V8_OS_POSIX
111 struct rlimit rlim; 114 struct rlimit rlim;
112 int result = getrlimit(RLIMIT_DATA, &rlim); 115 int result = getrlimit(RLIMIT_DATA, &rlim);
113 if (result != 0) { 116 if (result != 0) {
114 UNREACHABLE(); 117 UNREACHABLE();
115 return 0; 118 return 0;
116 } 119 }
117 return (rlim.rlim_cur == RLIM_INFINITY) ? 0 : rlim.rlim_cur; 120 return (rlim.rlim_cur == RLIM_INFINITY) ? 0 : rlim.rlim_cur;
118 #endif 121 #endif
119 } 122 }
120 123
121 } // namespace base 124 } // namespace base
122 } // namespace v8 125 } // namespace v8
OLDNEW
« no previous file with comments | « src/base/platform/semaphore.cc ('k') | src/d8-posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698