OLD | NEW |
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 return result; | 81 return result; |
82 #elif V8_OS_QNX | 82 #elif V8_OS_QNX |
83 struct stat stat_buf; | 83 struct stat stat_buf; |
84 if (stat("/proc", &stat_buf) != 0) { | 84 if (stat("/proc", &stat_buf) != 0) { |
85 return 0; | 85 return 0; |
86 } | 86 } |
87 return static_cast<int64_t>(stat_buf.st_size); | 87 return static_cast<int64_t>(stat_buf.st_size); |
88 #elif V8_OS_NACL | 88 #elif V8_OS_NACL |
89 // No support for _SC_PHYS_PAGES, assume 2GB. | 89 // No support for _SC_PHYS_PAGES, assume 2GB. |
90 return static_cast<int64_t>(1) << 31; | 90 return static_cast<int64_t>(1) << 31; |
| 91 #elif V8_OS_AIX |
| 92 int64_t result = sysconf(_SC_AIX_REALMEM); |
| 93 return static_cast<int64_t>(result) * 1024L; |
91 #elif V8_OS_POSIX | 94 #elif V8_OS_POSIX |
92 long pages = sysconf(_SC_PHYS_PAGES); // NOLINT(runtime/int) | 95 long pages = sysconf(_SC_PHYS_PAGES); // NOLINT(runtime/int) |
93 long page_size = sysconf(_SC_PAGESIZE); // NOLINT(runtime/int) | 96 long page_size = sysconf(_SC_PAGESIZE); // NOLINT(runtime/int) |
94 if (pages == -1 || page_size == -1) { | 97 if (pages == -1 || page_size == -1) { |
95 return 0; | 98 return 0; |
96 } | 99 } |
97 return static_cast<int64_t>(pages) * page_size; | 100 return static_cast<int64_t>(pages) * page_size; |
98 #endif | 101 #endif |
99 } | 102 } |
100 | 103 |
101 | 104 |
102 // static | 105 // static |
103 int64_t SysInfo::AmountOfVirtualMemory() { | 106 int64_t SysInfo::AmountOfVirtualMemory() { |
104 #if V8_OS_NACL || V8_OS_WIN | 107 #if V8_OS_NACL || V8_OS_WIN |
105 return 0; | 108 return 0; |
106 #elif V8_OS_POSIX | 109 #elif V8_OS_POSIX |
107 struct rlimit rlim; | 110 struct rlimit rlim; |
108 int result = getrlimit(RLIMIT_DATA, &rlim); | 111 int result = getrlimit(RLIMIT_DATA, &rlim); |
109 if (result != 0) { | 112 if (result != 0) { |
110 return 0; | 113 return 0; |
111 } | 114 } |
112 return (rlim.rlim_cur == RLIM_INFINITY) ? 0 : rlim.rlim_cur; | 115 return (rlim.rlim_cur == RLIM_INFINITY) ? 0 : rlim.rlim_cur; |
113 #endif | 116 #endif |
114 } | 117 } |
115 | 118 |
116 } // namespace base | 119 } // namespace base |
117 } // namespace v8 | 120 } // namespace v8 |
OLD | NEW |