Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: webrtc/rtc_base/thread_annotations.h

Issue 3007363002: Remove definitions of thread annotation macros without RTC_ prefix (Closed)
Patch Set: Rebase Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine.h ('k') | webrtc/rtc_base/thread_checker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // 1 //
2 // Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 // Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 // 3 //
4 // Use of this source code is governed by a BSD-style license 4 // Use of this source code is governed by a BSD-style license
5 // that can be found in the LICENSE file in the root of the source 5 // that can be found in the LICENSE file in the root of the source
6 // tree. An additional intellectual property rights grant can be found 6 // tree. An additional intellectual property rights grant can be found
7 // in the file PATENTS. All contributing project authors may 7 // in the file PATENTS. All contributing project authors may
8 // be found in the AUTHORS file in the root of the source tree. 8 // be found in the AUTHORS file in the root of the source tree.
9 // 9 //
10 // Borrowed from 10 // Borrowed from
(...skipping 12 matching lines...) Expand all
23 #define RTC_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) 23 #define RTC_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
24 #else 24 #else
25 #define RTC_THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op 25 #define RTC_THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
26 #endif 26 #endif
27 27
28 // Document if a shared variable/field needs to be protected by a lock. 28 // Document if a shared variable/field needs to be protected by a lock.
29 // GUARDED_BY allows the user to specify a particular lock that should be 29 // GUARDED_BY allows the user to specify a particular lock that should be
30 // held when accessing the annotated variable, while GUARDED_VAR only 30 // held when accessing the annotated variable, while GUARDED_VAR only
31 // indicates a shared variable should be guarded (by any lock). GUARDED_VAR 31 // indicates a shared variable should be guarded (by any lock). GUARDED_VAR
32 // is primarily used when the client cannot express the name of the lock. 32 // is primarily used when the client cannot express the name of the lock.
33 #if !defined(GUARDED_BY)
34 #define GUARDED_BY(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
35 #endif
36 #define RTC_GUARDED_BY(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) 33 #define RTC_GUARDED_BY(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
37 #if !defined(GUARDED_VAR)
38 #define GUARDED_VAR RTC_THREAD_ANNOTATION_ATTRIBUTE__(guarded_var)
39 #endif
40 #define RTC_GUARDED_VAR RTC_THREAD_ANNOTATION_ATTRIBUTE__(guarded_var) 34 #define RTC_GUARDED_VAR RTC_THREAD_ANNOTATION_ATTRIBUTE__(guarded_var)
41 35
42 // Document if the memory location pointed to by a pointer should be guarded 36 // Document if the memory location pointed to by a pointer should be guarded
43 // by a lock when dereferencing the pointer. Similar to GUARDED_VAR, 37 // by a lock when dereferencing the pointer. Similar to GUARDED_VAR,
44 // PT_GUARDED_VAR is primarily used when the client cannot express the name 38 // PT_GUARDED_VAR is primarily used when the client cannot express the name
45 // of the lock. Note that a pointer variable to a shared memory location 39 // of the lock. Note that a pointer variable to a shared memory location
46 // could itself be a shared variable. For example, if a shared global pointer 40 // could itself be a shared variable. For example, if a shared global pointer
47 // q, which is guarded by mu1, points to a shared memory location that is 41 // q, which is guarded by mu1, points to a shared memory location that is
48 // guarded by mu2, q should be annotated as follows: 42 // guarded by mu2, q should be annotated as follows:
49 // int *q GUARDED_BY(mu1) PT_GUARDED_BY(mu2); 43 // int *q GUARDED_BY(mu1) PT_GUARDED_BY(mu2);
50 #if !defined(PT_GUARDED_BY)
51 #define PT_GUARDED_BY(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
52 #endif
53 #define RTC_PT_GUARDED_BY(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) 44 #define RTC_PT_GUARDED_BY(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
54 #if !defined(PT_GUARDED_VAR)
55 #define PT_GUARDED_VAR RTC_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_var)
56 #endif
57 #define RTC_PT_GUARDED_VAR RTC_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_var) 45 #define RTC_PT_GUARDED_VAR RTC_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_var)
58 46
59 // Document the acquisition order between locks that can be held 47 // Document the acquisition order between locks that can be held
60 // simultaneously by a thread. For any two locks that need to be annotated 48 // simultaneously by a thread. For any two locks that need to be annotated
61 // to establish an acquisition order, only one of them needs the annotation. 49 // to establish an acquisition order, only one of them needs the annotation.
62 // (i.e. You don't have to annotate both locks with both ACQUIRED_AFTER 50 // (i.e. You don't have to annotate both locks with both ACQUIRED_AFTER
63 // and ACQUIRED_BEFORE.) 51 // and ACQUIRED_BEFORE.)
64 #if !defined(ACQUIRED_AFTER)
65 #define ACQUIRED_AFTER(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(x))
66 #endif
67 #define RTC_ACQUIRED_AFTER(x) \ 52 #define RTC_ACQUIRED_AFTER(x) \
68 RTC_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(x)) 53 RTC_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(x))
69 #if !defined(ACQUIRED_BEFORE)
70 #define ACQUIRED_BEFORE(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(x))
71 #endif
72 #define RTC_ACQUIRED_BEFORE(x) \ 54 #define RTC_ACQUIRED_BEFORE(x) \
73 RTC_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(x)) 55 RTC_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(x))
74 56
75 // The following three annotations document the lock requirements for 57 // The following three annotations document the lock requirements for
76 // functions/methods. 58 // functions/methods.
77 59
78 // Document if a function expects certain locks to be held before it is called 60 // Document if a function expects certain locks to be held before it is called
79 #if !defined(EXCLUSIVE_LOCKS_REQUIRED)
80 #define EXCLUSIVE_LOCKS_REQUIRED(...) \
81 RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(__VA_ARGS__))
82 #endif
83 #define RTC_EXCLUSIVE_LOCKS_REQUIRED(...) \ 61 #define RTC_EXCLUSIVE_LOCKS_REQUIRED(...) \
84 RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(__VA_ARGS__)) 62 RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(__VA_ARGS__))
85 #if !defined(SHARED_LOCKS_REQUIRED)
86 #define SHARED_LOCKS_REQUIRED(...) \
87 RTC_THREAD_ANNOTATION_ATTRIBUTE__(shared_locks_required(__VA_ARGS__))
88 #endif
89 #define RTC_SHARED_LOCKS_REQUIRED(...) \ 63 #define RTC_SHARED_LOCKS_REQUIRED(...) \
90 RTC_THREAD_ANNOTATION_ATTRIBUTE__(shared_locks_required(__VA_ARGS__)) 64 RTC_THREAD_ANNOTATION_ATTRIBUTE__(shared_locks_required(__VA_ARGS__))
91 65
92 // Document the locks acquired in the body of the function. These locks 66 // Document the locks acquired in the body of the function. These locks
93 // cannot be held when calling this function (as google3's Mutex locks are 67 // cannot be held when calling this function (as google3's Mutex locks are
94 // non-reentrant). 68 // non-reentrant).
95 #if !defined(LOCKS_EXCLUDED)
96 #define LOCKS_EXCLUDED(...) \
97 RTC_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
98 #endif
99 #define RTC_LOCKS_EXCLUDED(...) \ 69 #define RTC_LOCKS_EXCLUDED(...) \
100 RTC_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__)) 70 RTC_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
101 71
102 // Document the lock the annotated function returns without acquiring it. 72 // Document the lock the annotated function returns without acquiring it.
103 #if !defined(LOCK_RETURNED)
104 #define LOCK_RETURNED(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
105 #endif
106 #define RTC_LOCK_RETURNED(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) 73 #define RTC_LOCK_RETURNED(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
107 74
108 // Document if a class/type is a lockable type (such as the Mutex class). 75 // Document if a class/type is a lockable type (such as the Mutex class).
109 #if !defined(LOCKABLE)
110 #define LOCKABLE RTC_THREAD_ANNOTATION_ATTRIBUTE__(lockable)
111 #endif
112 #define RTC_LOCKABLE RTC_THREAD_ANNOTATION_ATTRIBUTE__(lockable) 76 #define RTC_LOCKABLE RTC_THREAD_ANNOTATION_ATTRIBUTE__(lockable)
113 77
114 // Document if a class is a scoped lockable type (such as the MutexLock class). 78 // Document if a class is a scoped lockable type (such as the MutexLock class).
115 #if !defined(SCOPED_LOCKABLE)
116 #define SCOPED_LOCKABLE RTC_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
117 #endif
118 #define RTC_SCOPED_LOCKABLE RTC_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) 79 #define RTC_SCOPED_LOCKABLE RTC_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
119 80
120 // The following annotations specify lock and unlock primitives. 81 // The following annotations specify lock and unlock primitives.
121 #if !defined(EXCLUSIVE_LOCK_FUNCTION)
122 #define EXCLUSIVE_LOCK_FUNCTION(...) \
123 RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__))
124 #endif
125 #define RTC_EXCLUSIVE_LOCK_FUNCTION(...) \ 82 #define RTC_EXCLUSIVE_LOCK_FUNCTION(...) \
126 RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__)) 83 RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__))
127 84
128 #if !defined(SHARED_LOCK_FUNCTION)
129 #define SHARED_LOCK_FUNCTION(...) \
130 RTC_THREAD_ANNOTATION_ATTRIBUTE__(shared_lock_function(__VA_ARGS__))
131 #endif
132 #define RTC_SHARED_LOCK_FUNCTION(...) \ 85 #define RTC_SHARED_LOCK_FUNCTION(...) \
133 RTC_THREAD_ANNOTATION_ATTRIBUTE__(shared_lock_function(__VA_ARGS__)) 86 RTC_THREAD_ANNOTATION_ATTRIBUTE__(shared_lock_function(__VA_ARGS__))
134 87
135 #if !defined(EXCLUSIVE_TRYLOCK_FUNCTION)
136 #define EXCLUSIVE_TRYLOCK_FUNCTION(...) \
137 RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__))
138 #endif
139 #define RTC_EXCLUSIVE_TRYLOCK_FUNCTION(...) \ 88 #define RTC_EXCLUSIVE_TRYLOCK_FUNCTION(...) \
140 RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__)) 89 RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__))
141 90
142 #if !defined(SHARED_TRYLOCK_FUNCTION)
143 #define SHARED_TRYLOCK_FUNCTION(...) \
144 RTC_THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__))
145 #endif
146 #define RTC_SHARED_TRYLOCK_FUNCTION(...) \ 91 #define RTC_SHARED_TRYLOCK_FUNCTION(...) \
147 RTC_THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__)) 92 RTC_THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__))
148 93
149 #if !defined(UNLOCK_FUNCTION)
150 #define UNLOCK_FUNCTION(...) \
151 RTC_THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__))
152 #endif
153 #define RTC_UNLOCK_FUNCTION(...) \ 94 #define RTC_UNLOCK_FUNCTION(...) \
154 RTC_THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__)) 95 RTC_THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__))
155 96
156 // An escape hatch for thread safety analysis to ignore the annotated function. 97 // An escape hatch for thread safety analysis to ignore the annotated function.
157 #if !defined(NO_THREAD_SAFETY_ANALYSIS)
158 #define NO_THREAD_SAFETY_ANALYSIS \
159 RTC_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
160 #endif
161 #define RTC_NO_THREAD_SAFETY_ANALYSIS \ 98 #define RTC_NO_THREAD_SAFETY_ANALYSIS \
162 RTC_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) 99 RTC_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
163 100
164 #endif // WEBRTC_RTC_BASE_THREAD_ANNOTATIONS_H_ 101 #endif // WEBRTC_RTC_BASE_THREAD_ANNOTATIONS_H_
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine.h ('k') | webrtc/rtc_base/thread_checker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698