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.
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.
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/
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.
25 * Informs TSan of a happens before/after relationship.
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))
32 * Gives TSan more information about thread names it can report the
33 * name of the thread in the warning report.
35 #define QEMU_TSAN_ANNOTATE_THREAD_NAME(name) \
36 AnnotateThreadName(__FILE__, __LINE__, (void *)(name))
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.
41 #define QEMU_TSAN_ANNOTATE_IGNORE_READS_BEGIN() \
42 AnnotateIgnoreReadsBegin(__FILE__, __LINE__)
43 #define QEMU_TSAN_ANNOTATE_IGNORE_READS_END() \
44 AnnotateIgnoreReadsEnd(__FILE__, __LINE__)
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
50 #define QEMU_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN() \
51 AnnotateIgnoreWritesBegin(__FILE__, __LINE__)
52 #define QEMU_TSAN_ANNOTATE_IGNORE_WRITES_END() \
53 AnnotateIgnoreWritesEnd(__FILE__, __LINE__)
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()
64 void AnnotateHappensBefore(const char *f
, int l
, void *addr
);
65 void AnnotateHappensAfter(const char *f
, int l
, void *addr
);
66 void AnnotateThreadName(const char *f
, int l
, char *name
);
67 void AnnotateIgnoreReadsBegin(const char *f
, int l
);
68 void AnnotateIgnoreReadsEnd(const char *f
, int l
);
69 void AnnotateIgnoreWritesBegin(const char *f
, int l
);
70 void AnnotateIgnoreWritesEnd(const char *f
, int l
);