Utils.cpp (764B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "mozjemalloc.h" 8 9 #include <mozilla/Assertions.h> 10 11 #ifdef XP_WIN 12 # include <sysinfoapi.h> 13 #else 14 # include <unistd.h> 15 #endif 16 17 size_t GetKernelPageSize() { 18 static size_t kernel_page_size = ([]() { 19 #ifdef XP_WIN 20 SYSTEM_INFO info; 21 GetSystemInfo(&info); 22 return info.dwPageSize; 23 #else 24 long result = sysconf(_SC_PAGESIZE); 25 MOZ_ASSERT(result != -1); 26 return result; 27 #endif 28 })(); 29 return kernel_page_size; 30 }