1 // Copyright 2018 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 // Holds functions for generating OOM errors from PartitionAlloc. This is 6 // distinct from oom.h in that it is meant only for use in PartitionAlloc. 7 8 #ifndef PARTITION_ALLOC_PARTITION_OOM_H_ 9 #define PARTITION_ALLOC_PARTITION_OOM_H_ 10 11 #include <cstddef> 12 13 #include "build/build_config.h" 14 #include "partition_alloc/partition_alloc_base/compiler_specific.h" 15 #include "partition_alloc/partition_alloc_base/component_export.h" 16 17 namespace partition_alloc { 18 19 using OomFunction = void (*)(size_t); 20 21 namespace internal { 22 23 // g_oom_handling_function is invoked when PartitionAlloc hits OutOfMemory. 24 extern OomFunction g_oom_handling_function; 25 26 [[noreturn]] PA_NOINLINE PA_COMPONENT_EXPORT( 27 PARTITION_ALLOC) void PartitionExcessiveAllocationSize(size_t size); 28 29 #if !defined(ARCH_CPU_64_BITS) 30 [[noreturn]] PA_NOINLINE void PartitionOutOfMemoryWithLotsOfUncommitedPages( 31 size_t size); 32 [[noreturn]] PA_NOINLINE void PartitionOutOfMemoryWithLargeVirtualSize( 33 size_t virtual_size); 34 #endif 35 36 } // namespace internal 37 38 } // namespace partition_alloc 39 40 #endif // PARTITION_ALLOC_PARTITION_OOM_H_ 41