]> git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/lib/tsan/dd/dd_rtl.h
New upstream version 1.20.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / lib / tsan / dd / dd_rtl.h
1 //===-- dd_rtl.h ----------------------------------------------------------===//
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 #ifndef DD_RTL_H
10 #define DD_RTL_H
11
12 #include "sanitizer_common/sanitizer_internal_defs.h"
13 #include "sanitizer_common/sanitizer_deadlock_detector_interface.h"
14 #include "sanitizer_common/sanitizer_flags.h"
15 #include "sanitizer_common/sanitizer_allocator_internal.h"
16 #include "sanitizer_common/sanitizer_addrhashmap.h"
17 #include "sanitizer_common/sanitizer_mutex.h"
18
19 namespace __dsan {
20
21 typedef DDFlags Flags;
22
23 struct Mutex {
24 DDMutex dd;
25 };
26
27 struct Thread {
28 DDPhysicalThread *dd_pt;
29 DDLogicalThread *dd_lt;
30
31 bool ignore_interceptors;
32 };
33
34 struct Callback : DDCallback {
35 Thread *thr;
36
37 Callback(Thread *thr);
38 u32 Unwind() override;
39 };
40
41 typedef AddrHashMap<Mutex, 31051> MutexHashMap;
42
43 struct Context {
44 DDetector *dd;
45
46 BlockingMutex report_mutex;
47 MutexHashMap mutex_map;
48 };
49
50 inline Flags* flags() {
51 static Flags flags;
52 return &flags;
53 }
54
55 void Initialize();
56 void InitializeInterceptors();
57
58 void ThreadInit(Thread *thr);
59 void ThreadDestroy(Thread *thr);
60
61 void MutexBeforeLock(Thread *thr, uptr m, bool writelock);
62 void MutexAfterLock(Thread *thr, uptr m, bool writelock, bool trylock);
63 void MutexBeforeUnlock(Thread *thr, uptr m, bool writelock);
64 void MutexDestroy(Thread *thr, uptr m);
65
66 } // namespace __dsan
67 #endif // DD_RTL_H