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