1 //===-- tsan_mman.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 // This file is a part of ThreadSanitizer (TSan), a race detector.
12 //===----------------------------------------------------------------------===//
16 #include "tsan_defs.h"
20 const uptr kDefaultAlignment = 16;
22 void InitializeAllocator();
23 void InitializeAllocatorLate();
24 void ReplaceSystemMalloc();
25 void AllocatorProcStart(Processor *proc);
26 void AllocatorProcFinish(Processor *proc);
27 void AllocatorPrintStats();
29 // For user allocations.
30 void *user_alloc_internal(ThreadState *thr, uptr pc, uptr sz,
31 uptr align = kDefaultAlignment, bool signal = true);
32 // Does not accept NULL.
33 void user_free(ThreadState *thr, uptr pc, void *p, bool signal = true);
34 // Interceptor implementations.
35 void *user_alloc(ThreadState *thr, uptr pc, uptr sz);
36 void *user_calloc(ThreadState *thr, uptr pc, uptr sz, uptr n);
37 void *user_realloc(ThreadState *thr, uptr pc, void *p, uptr sz);
38 void *user_memalign(ThreadState *thr, uptr pc, uptr align, uptr sz);
39 int user_posix_memalign(ThreadState *thr, uptr pc, void **memptr, uptr align,
41 void *user_aligned_alloc(ThreadState *thr, uptr pc, uptr align, uptr sz);
42 void *user_valloc(ThreadState *thr, uptr pc, uptr sz);
43 void *user_pvalloc(ThreadState *thr, uptr pc, uptr sz);
44 uptr user_alloc_usable_size(const void *p);
46 // Invoking malloc/free hooks that may be installed by the user.
47 void invoke_malloc_hook(void *ptr, uptr size);
48 void invoke_free_hook(void *ptr);
74 // This must be the last.
78 // For internal data structures.
79 void *internal_alloc(MBlockType typ, uptr sz);
80 void internal_free(void *p);
83 void DestroyAndFree(T *&p) {