1 //===-- sanitizer_allocator.h -----------------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // Specialized memory allocator for ThreadSanitizer, MemorySanitizer, etc.
10 //===----------------------------------------------------------------------===//
12 #ifndef SANITIZER_ALLOCATOR_H
13 #define SANITIZER_ALLOCATOR_H
15 #include "sanitizer_internal_defs.h"
16 #include "sanitizer_common.h"
17 #include "sanitizer_libc.h"
18 #include "sanitizer_list.h"
19 #include "sanitizer_mutex.h"
20 #include "sanitizer_lfstack.h"
21 #include "sanitizer_procmaps.h"
23 namespace __sanitizer
{
25 // Returns true if ReportAllocatorCannotReturnNull(true) was called.
26 // Can be use to avoid memory hungry operations.
27 bool IsReportingOOM();
29 // Prints error message and kills the program.
30 void NORETURN
ReportAllocatorCannotReturnNull(bool out_of_memory
);
32 // Allocators call these callbacks on mmap/munmap.
33 struct NoOpMapUnmapCallback
{
34 void OnMap(uptr p
, uptr size
) const { }
35 void OnUnmap(uptr p
, uptr size
) const { }
38 // Callback type for iterating over chunks.
39 typedef void (*ForEachChunkCallback
)(uptr chunk
, void *arg
);
41 // Returns true if calloc(size, n) should return 0 due to overflow in size*n.
42 bool CallocShouldReturnNullDueToOverflow(uptr size
, uptr n
);
44 #include "sanitizer_allocator_size_class_map.h"
45 #include "sanitizer_allocator_stats.h"
46 #include "sanitizer_allocator_primary64.h"
47 #include "sanitizer_allocator_bytemap.h"
48 #include "sanitizer_allocator_primary32.h"
49 #include "sanitizer_allocator_local_cache.h"
50 #include "sanitizer_allocator_secondary.h"
51 #include "sanitizer_allocator_combined.h"
53 } // namespace __sanitizer
55 #endif // SANITIZER_ALLOCATOR_H