Chromium Code Reviews| Index: src/platform-posix.cc |
| diff --git a/src/platform-posix.cc b/src/platform-posix.cc |
| index fe27eaf71f437fcc099ffdebb8e24f60c999921f..09142edcb6a1f5fe2a12b0cd85d22c0942ff689d 100644 |
| --- a/src/platform-posix.cc |
| +++ b/src/platform-posix.cc |
| @@ -102,6 +102,48 @@ intptr_t OS::MaxVirtualMemory() { |
| } |
| +uintptr_t OS::TotalPhysicalMemory() { |
|
Benedikt Meurer
2013/09/24 13:47:15
Shouldn't this return an uint64_t? Otherwise this
rmcilroy
2013/09/24 14:39:23
You're right. For some reason I thought a uintptr
|
| +#if V8_OS_MACOSX |
| + int mib[2]; |
| + mib[0] = CTL_HW; |
| + mib[1] = HW_MEMSIZE; |
| + int64_t size = 0; |
| + size_t len = sizeof(size); |
| + if (sysctl(mib, 2, &size, &len, NULL, 0) != 0) { |
| + UNREACHABLE(); |
| + return 0; |
| + } |
| + return static_cast<uintptr_t> size; |
|
Benedikt Meurer
2013/09/24 13:47:15
This static_cast is missing parenthesis.
rmcilroy
2013/09/24 14:39:23
Done.
|
| +#elif V8_OS_FREEBSD |
| + int pages, page_size; |
| + size_t size = sizeof(pages); |
| + sysctlbyname("vm.stats.vm.v_page_count", &pages, &size, NULL, 0); |
| + sysctlbyname("vm.stats.vm.v_page_size", &page_size, &size, NULL, 0); |
| + if (pages == -1 || page_size == -1) { |
| + UNREACHABLE(); |
| + return 0; |
| + } |
| + return static_cast<uintptr_t>(pages) * page_size; |
| +#elif V8_OS_CYGWIN |
| + MEMORYSTATUS memory_info; |
| + memory_info.dwLength = sizeof(memory_info); |
| + if (!GlobalMemoryStatus(&memory_info)) { |
| + UNREACHABLE(); |
| + return 0; |
| + } |
| + return static_cast<uintptr_t>(memory_info.dwTotalPhys); |
| +#else |
| + intptr_t pages = sysconf(_SC_PHYS_PAGES); |
| + intptr_t page_size = sysconf(_SC_PAGESIZE); |
| + if (pages == -1 || page_size == -1) { |
| + UNREACHABLE(); |
| + return 0; |
| + } |
| + return static_cast<uintptr_t>(pages) * page_size; |
| +#endif |
| +} |
| + |
| + |
| int OS::ActivationFrameAlignment() { |
| #if V8_TARGET_ARCH_ARM |
| // On EABI ARM targets this is required for fp correctness in the |