OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Macros for static thread-safety analysis. | 5 // Macros for static thread-safety analysis. |
6 // | 6 // |
7 // These are from http://clang.llvm.org/docs/ThreadSafetyAnalysis.html (and thus | 7 // These are from http://clang.llvm.org/docs/ThreadSafetyAnalysis.html (and thus |
8 // really derive from google3's thread_annotations.h). | 8 // really derive from google3's thread_annotations.h). |
9 // | 9 // |
10 // TODO(vtl): We're still using the old-fashioned, deprecated annotations | 10 // TODO(vtl): We're still using the old-fashioned, deprecated annotations |
11 // ("locks" instead of "capabilities"), since the new ones don't work yet (in | 11 // ("locks" instead of "capabilities"), since the new ones don't work yet (in |
12 // particular, |TRY_ACQUIRE()| doesn't work: b/19264527). | 12 // particular, |TRY_ACQUIRE()| doesn't work: b/19264527). |
13 // https://github.com/domokit/mojo/issues/314 | 13 // https://github.com/domokit/mojo/issues/314 |
14 | 14 |
15 #ifndef MOJO_EDK_SYSTEM_THREAD_ANNOTATIONS_H_ | 15 #ifndef MOJO_EDK_UTIL_THREAD_ANNOTATIONS_H_ |
16 #define MOJO_EDK_SYSTEM_THREAD_ANNOTATIONS_H_ | 16 #define MOJO_EDK_UTIL_THREAD_ANNOTATIONS_H_ |
17 | 17 |
18 // Enable thread-safety attributes only with clang. | 18 // Enable thread-safety attributes only with clang. |
19 // The attributes can be safely erased when compiling with other compilers. | 19 // The attributes can be safely erased when compiling with other compilers. |
20 #if defined(__clang__) | 20 #if defined(__clang__) |
21 #define MOJO_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) | 21 #define MOJO_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) |
22 #else | 22 #else |
23 #define MOJO_THREAD_ANNOTATION_ATTRIBUTE__(x) | 23 #define MOJO_THREAD_ANNOTATION_ATTRIBUTE__(x) |
24 #endif | 24 #endif |
25 | 25 |
26 #define MOJO_GUARDED_BY(x) MOJO_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) | 26 #define MOJO_GUARDED_BY(x) MOJO_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 MOJO_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) | 75 MOJO_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) |
76 | 76 |
77 // Use this in the header to annotate a function/method as not being | 77 // Use this in the header to annotate a function/method as not being |
78 // thread-safe. This is equivalent to |MOJO_NO_THREAD_SAFETY_ANALYSIS|, but | 78 // thread-safe. This is equivalent to |MOJO_NO_THREAD_SAFETY_ANALYSIS|, but |
79 // semantically different: it declares that the caller must abide by additional | 79 // semantically different: it declares that the caller must abide by additional |
80 // restrictions. Limitation: Unfortunately, you can't apply this to a method in | 80 // restrictions. Limitation: Unfortunately, you can't apply this to a method in |
81 // an interface (i.e., pure virtual method) and have it applied automatically to | 81 // an interface (i.e., pure virtual method) and have it applied automatically to |
82 // implementations. | 82 // implementations. |
83 #define MOJO_NOT_THREAD_SAFE MOJO_NO_THREAD_SAFETY_ANALYSIS | 83 #define MOJO_NOT_THREAD_SAFE MOJO_NO_THREAD_SAFETY_ANALYSIS |
84 | 84 |
85 #endif // MOJO_EDK_SYSTEM_THREAD_ANNOTATIONS_H_ | 85 #endif // MOJO_EDK_UTIL_THREAD_ANNOTATIONS_H_ |
OLD | NEW |