1 // Copyright 2021 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "partition_alloc/partition_alloc_base/memory/page_size.h" 6 7 #include <unistd.h> 8 9 namespace partition_alloc::internal::base { 10 GetPageSize()11size_t GetPageSize() { 12 static const size_t pagesize = []() -> size_t { 13 // For more information see getpagesize(2). Portable applications should use 14 // sysconf(_SC_PAGESIZE) rather than getpagesize() if it's available. 15 #if defined(_SC_PAGESIZE) 16 return static_cast<size_t>(sysconf(_SC_PAGESIZE)); 17 #else 18 return getpagesize(); 19 #endif 20 }(); 21 return pagesize; 22 } 23 24 } // namespace partition_alloc::internal::base 25