]> git.proxmox.com Git - rustc.git/blame - src/libcompiler_builtins/compiler-rt/lib/tsan/rtl/tsan_mman.h
New upstream version 1.25.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / lib / tsan / rtl / tsan_mman.h
CommitLineData
1a4d82fc
JJ
1//===-- tsan_mman.h ---------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file is a part of ThreadSanitizer (TSan), a race detector.
11//
12//===----------------------------------------------------------------------===//
13#ifndef TSAN_MMAN_H
14#define TSAN_MMAN_H
15
16#include "tsan_defs.h"
17
18namespace __tsan {
19
20const uptr kDefaultAlignment = 16;
21
22void InitializeAllocator();
5bcae85e 23void InitializeAllocatorLate();
92a42be0 24void ReplaceSystemMalloc();
5bcae85e
SL
25void AllocatorProcStart(Processor *proc);
26void AllocatorProcFinish(Processor *proc);
1a4d82fc
JJ
27void AllocatorPrintStats();
28
29// For user allocations.
2c00a5a8
XL
30void *user_alloc_internal(ThreadState *thr, uptr pc, uptr sz,
31 uptr align = kDefaultAlignment, bool signal = true);
1a4d82fc 32// Does not accept NULL.
92a42be0 33void user_free(ThreadState *thr, uptr pc, void *p, bool signal = true);
2c00a5a8
XL
34// Interceptor implementations.
35void *user_alloc(ThreadState *thr, uptr pc, uptr sz);
36void *user_calloc(ThreadState *thr, uptr pc, uptr sz, uptr n);
1a4d82fc 37void *user_realloc(ThreadState *thr, uptr pc, void *p, uptr sz);
2c00a5a8
XL
38void *user_memalign(ThreadState *thr, uptr pc, uptr align, uptr sz);
39int user_posix_memalign(ThreadState *thr, uptr pc, void **memptr, uptr align,
40 uptr sz);
41void *user_aligned_alloc(ThreadState *thr, uptr pc, uptr align, uptr sz);
42void *user_valloc(ThreadState *thr, uptr pc, uptr sz);
43void *user_pvalloc(ThreadState *thr, uptr pc, uptr sz);
92a42be0 44uptr user_alloc_usable_size(const void *p);
1a4d82fc
JJ
45
46// Invoking malloc/free hooks that may be installed by the user.
47void invoke_malloc_hook(void *ptr, uptr size);
48void invoke_free_hook(void *ptr);
49
50enum MBlockType {
51 MBlockScopedBuf,
52 MBlockString,
53 MBlockStackTrace,
54 MBlockShadowStack,
55 MBlockSync,
56 MBlockClock,
57 MBlockThreadContex,
58 MBlockDeadInfo,
59 MBlockRacyStacks,
60 MBlockRacyAddresses,
61 MBlockAtExit,
62 MBlockFlag,
63 MBlockReport,
64 MBlockReportMop,
65 MBlockReportThread,
66 MBlockReportMutex,
67 MBlockReportLoc,
68 MBlockReportStack,
69 MBlockSuppression,
70 MBlockExpectRace,
71 MBlockSignal,
1a4d82fc
JJ
72 MBlockJmpBuf,
73
74 // This must be the last.
75 MBlockTypeCount
76};
77
78// For internal data structures.
79void *internal_alloc(MBlockType typ, uptr sz);
80void internal_free(void *p);
81
82template<typename T>
83void DestroyAndFree(T *&p) {
84 p->~T();
85 internal_free(p);
86 p = 0;
87}
88
89} // namespace __tsan
90#endif // TSAN_MMAN_H