Go to the documentation of this file.
19#ifndef THREAD_SAFETY_ANALYSIS_MUTEX_H
20#define THREAD_SAFETY_ANALYSIS_MUTEX_H
24#if defined(__clang__) && (!defined(SWIG))
25#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
27#define THREAD_ANNOTATION_ATTRIBUTE__(x)
30#define CAPABILITY(x) \
31 THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
33#define SCOPED_CAPABILITY \
34 THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
36#define GUARDED_BY(x) \
37 THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
39#define PT_GUARDED_BY(x) \
40 THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
42#define ACQUIRED_BEFORE(...) \
43 THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))
45#define ACQUIRED_AFTER(...) \
46 THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
48#define REQUIRES(...) \
49 THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
51#define REQUIRES_SHARED(...) \
52 THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
55 THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
57#define ACQUIRE_SHARED(...) \
58 THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
61 THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
63#define RELEASE_SHARED(...) \
64 THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
66#define RELEASE_GENERIC(...) \
67 THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(__VA_ARGS__))
69#define TRY_ACQUIRE(...) \
70 THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))
72#define TRY_ACQUIRE_SHARED(...) \
73 THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))
75#define EXCLUDES(...) \
76 THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
78#define ASSERT_CAPABILITY(x) \
79 THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))
81#define ASSERT_SHARED_CAPABILITY(x) \
82 THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
84#define RETURN_CAPABILITY(x) \
85 THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
87#define NO_THREAD_SAFETY_ANALYSIS \
88 THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
91#ifdef USE_LOCK_STYLE_THREAD_SAFETY_ATTRIBUTES
97#define PT_GUARDED_VAR \
98 THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_var)
102 THREAD_ANNOTATION_ATTRIBUTE__(guarded_var)
105#define EXCLUSIVE_LOCKS_REQUIRED(...) \
106 THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(__VA_ARGS__))
109#define SHARED_LOCKS_REQUIRED(...) \
110 THREAD_ANNOTATION_ATTRIBUTE__(shared_locks_required(__VA_ARGS__))
114 THREAD_ANNOTATION_ATTRIBUTE__(lockable)
117#define SCOPED_LOCKABLE \
118 THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
121#define EXCLUSIVE_LOCK_FUNCTION(...) \
122 THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__))
125#define SHARED_LOCK_FUNCTION(...) \
126 THREAD_ANNOTATION_ATTRIBUTE__(shared_lock_function(__VA_ARGS__))
129#define UNLOCK_FUNCTION(...) \
130 THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__))
133#define EXCLUSIVE_TRYLOCK_FUNCTION(...) \
134 THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__))
137#define SHARED_TRYLOCK_FUNCTION(...) \
138 THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__))
141#define ASSERT_EXCLUSIVE_LOCK(...) \
142 THREAD_ANNOTATION_ATTRIBUTE__(assert_exclusive_lock(__VA_ARGS__))
145#define ASSERT_SHARED_LOCK(...) \
146 THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_lock(__VA_ARGS__))
149#define LOCKS_EXCLUDED(...) \
150 THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
153#define LOCK_RETURNED(x) \
154 THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))