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 AllocatorThreadStart(ThreadState
*thr
);
22 void AllocatorThreadFinish(ThreadState
*thr
);
23 void AllocatorPrintStats();
25 // For user allocations.
26 void *user_alloc(ThreadState
*thr
, uptr pc
, uptr sz
,
27 uptr align
= kDefaultAlignment
);
28 // Does not accept NULL.
29 void user_free(ThreadState
*thr
, uptr pc
, void *p
);
30 void *user_realloc(ThreadState
*thr
, uptr pc
, void *p
, uptr sz
);
31 void *user_alloc_aligned(ThreadState
*thr
, uptr pc
, uptr sz
, uptr align
);
32 // Given the pointer p into a valid allocated block,
33 // returns the descriptor of the block.
34 MBlock
*user_mblock(ThreadState
*thr
, void *p
);
36 // Invoking malloc/free hooks that may be installed by the user.
37 void invoke_malloc_hook(void *ptr
, uptr size
);
38 void invoke_free_hook(void *ptr
);
64 // This must be the last.
68 // For internal data structures.
69 void *internal_alloc(MBlockType typ
, uptr sz
);
70 void internal_free(void *p
);
73 void DestroyAndFree(T
*&p
) {