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