mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
qemu/compiler: Absorb 'clang-tsa.h'
We already have "qemu/compiler.h" for compiler-specific arrangements, automatically included by "qemu/osdep.h" for each source file. No need to explicitly include a header for a Clang particularity. Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20250117170201.91182-1-philmd@linaro.org>
This commit is contained in:
parent
e8a0110293
commit
82c4d8a3b4
11 changed files with 96 additions and 125 deletions
|
@ -207,6 +207,102 @@
|
|||
# define QEMU_USED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* http://clang.llvm.org/docs/ThreadSafetyAnalysis.html
|
||||
*
|
||||
* TSA is available since clang 3.6-ish.
|
||||
*/
|
||||
#ifdef __clang__
|
||||
# define TSA(x) __attribute__((x))
|
||||
#else
|
||||
# define TSA(x) /* No TSA, make TSA attributes no-ops. */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* TSA_CAPABILITY() is used to annotate typedefs:
|
||||
*
|
||||
* typedef pthread_mutex_t TSA_CAPABILITY("mutex") tsa_mutex;
|
||||
*/
|
||||
#define TSA_CAPABILITY(x) TSA(capability(x))
|
||||
|
||||
/*
|
||||
* TSA_GUARDED_BY() is used to annotate global variables,
|
||||
* the data is guarded:
|
||||
*
|
||||
* Foo foo TSA_GUARDED_BY(mutex);
|
||||
*/
|
||||
#define TSA_GUARDED_BY(x) TSA(guarded_by(x))
|
||||
|
||||
/*
|
||||
* TSA_PT_GUARDED_BY() is used to annotate global pointers, the data
|
||||
* behind the pointer is guarded.
|
||||
*
|
||||
* Foo* ptr TSA_PT_GUARDED_BY(mutex);
|
||||
*/
|
||||
#define TSA_PT_GUARDED_BY(x) TSA(pt_guarded_by(x))
|
||||
|
||||
/*
|
||||
* The TSA_REQUIRES() is used to annotate functions: the caller of the
|
||||
* function MUST hold the resource, the function will NOT release it.
|
||||
*
|
||||
* More than one mutex may be specified, comma-separated.
|
||||
*
|
||||
* void Foo(void) TSA_REQUIRES(mutex);
|
||||
*/
|
||||
#define TSA_REQUIRES(...) TSA(requires_capability(__VA_ARGS__))
|
||||
#define TSA_REQUIRES_SHARED(...) TSA(requires_shared_capability(__VA_ARGS__))
|
||||
|
||||
/*
|
||||
* TSA_EXCLUDES() is used to annotate functions: the caller of the
|
||||
* function MUST NOT hold resource, the function first acquires the
|
||||
* resource, and then releases it.
|
||||
*
|
||||
* More than one mutex may be specified, comma-separated.
|
||||
*
|
||||
* void Foo(void) TSA_EXCLUDES(mutex);
|
||||
*/
|
||||
#define TSA_EXCLUDES(...) TSA(locks_excluded(__VA_ARGS__))
|
||||
|
||||
/*
|
||||
* TSA_ACQUIRE() is used to annotate functions: the caller of the
|
||||
* function MUST NOT hold the resource, the function will acquire the
|
||||
* resource, but NOT release it.
|
||||
*
|
||||
* More than one mutex may be specified, comma-separated.
|
||||
*
|
||||
* void Foo(void) TSA_ACQUIRE(mutex);
|
||||
*/
|
||||
#define TSA_ACQUIRE(...) TSA(acquire_capability(__VA_ARGS__))
|
||||
#define TSA_ACQUIRE_SHARED(...) TSA(acquire_shared_capability(__VA_ARGS__))
|
||||
|
||||
/*
|
||||
* TSA_RELEASE() is used to annotate functions: the caller of the
|
||||
* function MUST hold the resource, but the function will then release it.
|
||||
*
|
||||
* More than one mutex may be specified, comma-separated.
|
||||
*
|
||||
* void Foo(void) TSA_RELEASE(mutex);
|
||||
*/
|
||||
#define TSA_RELEASE(...) TSA(release_capability(__VA_ARGS__))
|
||||
#define TSA_RELEASE_SHARED(...) TSA(release_shared_capability(__VA_ARGS__))
|
||||
|
||||
/*
|
||||
* TSA_NO_TSA is used to annotate functions. Use only when you need to.
|
||||
*
|
||||
* void Foo(void) TSA_NO_TSA;
|
||||
*/
|
||||
#define TSA_NO_TSA TSA(no_thread_safety_analysis)
|
||||
|
||||
/*
|
||||
* TSA_ASSERT() is used to annotate functions: This function will assert that
|
||||
* the lock is held. When it returns, the caller of the function is assumed to
|
||||
* already hold the resource.
|
||||
*
|
||||
* More than one mutex may be specified, comma-separated.
|
||||
*/
|
||||
#define TSA_ASSERT(...) TSA(assert_capability(__VA_ARGS__))
|
||||
#define TSA_ASSERT_SHARED(...) TSA(assert_shared_capability(__VA_ARGS__))
|
||||
|
||||
/*
|
||||
* Ugly CPP trick that is like "defined FOO", but also works in C
|
||||
* code. Useful to replace #ifdef with "if" statements; assumes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue