OLD | NEW |
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 |
11 // https://code.google.com/p/gperftools/source/browse/src/base/thread_annotation
s.h | 11 // https://code.google.com/p/gperftools/source/browse/src/base/thread_annotation
s.h |
12 // but adapted for clang attributes instead of the gcc. | 12 // but adapted for clang attributes instead of the gcc. |
13 // | 13 // |
14 // This header file contains the macro definitions for thread safety | 14 // This header file contains the macro definitions for thread safety |
15 // annotations that allow the developers to document the locking policies | 15 // annotations that allow the developers to document the locking policies |
16 // of their multi-threaded code. The annotations can also help program | 16 // of their multi-threaded code. The annotations can also help program |
17 // analysis tools to identify potential thread safety issues. | 17 // analysis tools to identify potential thread safety issues. |
18 | 18 |
19 #ifndef BASE_THREAD_ANNOTATIONS_H_ | 19 #ifndef WEBRTC_BASE_THREAD_ANNOTATIONS_H_ |
20 #define BASE_THREAD_ANNOTATIONS_H_ | 20 #define WEBRTC_BASE_THREAD_ANNOTATIONS_H_ |
21 | 21 |
22 #if defined(__clang__) && (!defined(SWIG)) | 22 #if defined(__clang__) && (!defined(SWIG)) |
23 #define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) | 23 #define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) |
24 #else | 24 #else |
25 #define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op | 25 #define 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 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 #define SHARED_TRYLOCK_FUNCTION(...) \ | 90 #define SHARED_TRYLOCK_FUNCTION(...) \ |
91 THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__)) | 91 THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__)) |
92 | 92 |
93 #define UNLOCK_FUNCTION(...) \ | 93 #define UNLOCK_FUNCTION(...) \ |
94 THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__)) | 94 THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__)) |
95 | 95 |
96 // An escape hatch for thread safety analysis to ignore the annotated function. | 96 // An escape hatch for thread safety analysis to ignore the annotated function. |
97 #define NO_THREAD_SAFETY_ANALYSIS \ | 97 #define NO_THREAD_SAFETY_ANALYSIS \ |
98 THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) | 98 THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) |
99 | 99 |
100 #endif // BASE_THREAD_ANNOTATIONS_H_ | 100 #endif // WEBRTC_BASE_THREAD_ANNOTATIONS_H_ |
OLD | NEW |