]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/lib/tsan/rtl/tsan_mman.h
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / 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();
92a42be0 23void ReplaceSystemMalloc();
1a4d82fc
JJ
24void AllocatorThreadStart(ThreadState *thr);
25void AllocatorThreadFinish(ThreadState *thr);
26void AllocatorPrintStats();
27
28// For user allocations.
29void *user_alloc(ThreadState *thr, uptr pc, uptr sz,
92a42be0
SL
30 uptr align = kDefaultAlignment, bool signal = true);
31void *user_calloc(ThreadState *thr, uptr pc, uptr sz, uptr n);
1a4d82fc 32// Does not accept NULL.
92a42be0 33void user_free(ThreadState *thr, uptr pc, void *p, bool signal = true);
1a4d82fc
JJ
34void *user_realloc(ThreadState *thr, uptr pc, void *p, uptr sz);
35void *user_alloc_aligned(ThreadState *thr, uptr pc, uptr sz, uptr align);
92a42be0 36uptr user_alloc_usable_size(const void *p);
1a4d82fc
JJ
37
38// Invoking malloc/free hooks that may be installed by the user.
39void invoke_malloc_hook(void *ptr, uptr size);
40void invoke_free_hook(void *ptr);
41
42enum MBlockType {
43 MBlockScopedBuf,
44 MBlockString,
45 MBlockStackTrace,
46 MBlockShadowStack,
47 MBlockSync,
48 MBlockClock,
49 MBlockThreadContex,
50 MBlockDeadInfo,
51 MBlockRacyStacks,
52 MBlockRacyAddresses,
53 MBlockAtExit,
54 MBlockFlag,
55 MBlockReport,
56 MBlockReportMop,
57 MBlockReportThread,
58 MBlockReportMutex,
59 MBlockReportLoc,
60 MBlockReportStack,
61 MBlockSuppression,
62 MBlockExpectRace,
63 MBlockSignal,
1a4d82fc
JJ
64 MBlockJmpBuf,
65
66 // This must be the last.
67 MBlockTypeCount
68};
69
70// For internal data structures.
71void *internal_alloc(MBlockType typ, uptr sz);
72void internal_free(void *p);
73
74template<typename T>
75void DestroyAndFree(T *&p) {
76 p->~T();
77 internal_free(p);
78 p = 0;
79}
80
81} // namespace __tsan
82#endif // TSAN_MMAN_H