]> Git Repo - qemu.git/blame - include/qemu/tsan.h
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-12-21' into...
[qemu.git] / include / qemu / tsan.h
CommitLineData
e51345ee
RF
1#ifndef QEMU_TSAN_H
2#define QEMU_TSAN_H
3/*
4 * tsan.h
5 *
6 * This file defines macros used to give ThreadSanitizer
7 * additional information to help suppress warnings.
8 * This is necessary since TSan does not provide a header file
9 * for these annotations. The standard way to include these
10 * is via the below macros.
11 *
12 * Annotation examples can be found here:
13 * https://github.com/llvm/llvm-project/tree/master/compiler-rt/test/tsan
14 * annotate_happens_before.cpp or ignore_race.cpp are good places to start.
15 *
16 * The full set of annotations can be found here in tsan_interface_ann.cpp.
17 * https://github.com/llvm/llvm-project/blob/master/compiler-rt/lib/tsan/rtl/
18 *
19 * This work is licensed under the terms of the GNU GPL, version 2 or later.
20 * See the COPYING file in the top-level directory.
21 */
22
23#ifdef CONFIG_TSAN
24/*
25 * Informs TSan of a happens before/after relationship.
26 */
27#define QEMU_TSAN_ANNOTATE_HAPPENS_BEFORE(addr) \
28 AnnotateHappensBefore(__FILE__, __LINE__, (void *)(addr))
29#define QEMU_TSAN_ANNOTATE_HAPPENS_AFTER(addr) \
30 AnnotateHappensAfter(__FILE__, __LINE__, (void *)(addr))
31/*
32 * Gives TSan more information about thread names it can report the
33 * name of the thread in the warning report.
34 */
35#define QEMU_TSAN_ANNOTATE_THREAD_NAME(name) \
36 AnnotateThreadName(__FILE__, __LINE__, (void *)(name))
37/*
38 * Allows defining a region of code on which TSan will not record memory READS.
39 * This has the effect of disabling race detection for this section of code.
40 */
41#define QEMU_TSAN_ANNOTATE_IGNORE_READS_BEGIN() \
42 AnnotateIgnoreReadsBegin(__FILE__, __LINE__)
43#define QEMU_TSAN_ANNOTATE_IGNORE_READS_END() \
44 AnnotateIgnoreReadsEnd(__FILE__, __LINE__)
45/*
46 * Allows defining a region of code on which TSan will not record memory
47 * WRITES. This has the effect of disabling race detection for this
48 * section of code.
49 */
50#define QEMU_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN() \
51 AnnotateIgnoreWritesBegin(__FILE__, __LINE__)
52#define QEMU_TSAN_ANNOTATE_IGNORE_WRITES_END() \
53 AnnotateIgnoreWritesEnd(__FILE__, __LINE__)
54#else
55#define QEMU_TSAN_ANNOTATE_HAPPENS_BEFORE(addr)
56#define QEMU_TSAN_ANNOTATE_HAPPENS_AFTER(addr)
57#define QEMU_TSAN_ANNOTATE_THREAD_NAME(name)
58#define QEMU_TSAN_ANNOTATE_IGNORE_READS_BEGIN()
59#define QEMU_TSAN_ANNOTATE_IGNORE_READS_END()
60#define QEMU_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN()
61#define QEMU_TSAN_ANNOTATE_IGNORE_WRITES_END()
62#endif
63
64void AnnotateHappensBefore(const char *f, int l, void *addr);
65void AnnotateHappensAfter(const char *f, int l, void *addr);
66void AnnotateThreadName(const char *f, int l, char *name);
67void AnnotateIgnoreReadsBegin(const char *f, int l);
68void AnnotateIgnoreReadsEnd(const char *f, int l);
69void AnnotateIgnoreWritesBegin(const char *f, int l);
70void AnnotateIgnoreWritesEnd(const char *f, int l);
71#endif
This page took 0.064848 seconds and 4 git commands to generate.