1 //===-- tsan_mman.h ---------------------------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of ThreadSanitizer (TSan), a race detector.
10 //===----------------------------------------------------------------------===//
14 #include "tsan_defs.h"
18 const uptr kDefaultAlignment
= 16;
20 void InitializeAllocator();
21 void InitializeAllocatorLate();
22 void ReplaceSystemMalloc();
23 void AllocatorProcStart(Processor
*proc
);
24 void AllocatorProcFinish(Processor
*proc
);
25 void AllocatorPrintStats();
27 // For user allocations.
28 void *user_alloc_internal(ThreadState
*thr
, uptr pc
, uptr sz
,
29 uptr align
= kDefaultAlignment
, bool signal
= true);
30 // Does not accept NULL.
31 void user_free(ThreadState
*thr
, uptr pc
, void *p
, bool signal
= true);
32 // Interceptor implementations.
33 void *user_alloc(ThreadState
*thr
, uptr pc
, uptr sz
);
34 void *user_calloc(ThreadState
*thr
, uptr pc
, uptr sz
, uptr n
);
35 void *user_realloc(ThreadState
*thr
, uptr pc
, void *p
, uptr sz
);
36 void *user_memalign(ThreadState
*thr
, uptr pc
, uptr align
, uptr sz
);
37 int user_posix_memalign(ThreadState
*thr
, uptr pc
, void **memptr
, uptr align
,
39 void *user_aligned_alloc(ThreadState
*thr
, uptr pc
, uptr align
, uptr sz
);
40 void *user_valloc(ThreadState
*thr
, uptr pc
, uptr sz
);
41 void *user_pvalloc(ThreadState
*thr
, uptr pc
, uptr sz
);
42 uptr
user_alloc_usable_size(const void *p
);
44 // Invoking malloc/free hooks that may be installed by the user.
45 void invoke_malloc_hook(void *ptr
, uptr size
);
46 void invoke_free_hook(void *ptr
);
72 // This must be the last.
76 // For internal data structures.
77 void *internal_alloc(MBlockType typ
, uptr sz
);
78 void internal_free(void *p
);
81 void DestroyAndFree(T
*&p
) {