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 ReplaceSystemMalloc();
24 void AllocatorThreadStart(ThreadState *thr);
25 void AllocatorThreadFinish(ThreadState *thr);
26 void AllocatorPrintStats();
28 // For user allocations.
29 void *user_alloc(ThreadState *thr, uptr pc, uptr sz,
30 uptr align = kDefaultAlignment, bool signal = true);
31 void *user_calloc(ThreadState *thr, uptr pc, uptr sz, uptr n);
32 // Does not accept NULL.
33 void user_free(ThreadState *thr, uptr pc, void *p, bool signal = true);
34 void *user_realloc(ThreadState *thr, uptr pc, void *p, uptr sz);
35 void *user_alloc_aligned(ThreadState *thr, uptr pc, uptr sz, uptr align);
36 uptr user_alloc_usable_size(const void *p);
38 // Invoking malloc/free hooks that may be installed by the user.
39 void invoke_malloc_hook(void *ptr, uptr size);
40 void invoke_free_hook(void *ptr);
66 // This must be the last.
70 // For internal data structures.
71 void *internal_alloc(MBlockType typ, uptr sz);
72 void internal_free(void *p);
75 void DestroyAndFree(T *&p) {