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