OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkDynamicAnnotations_DEFINED | 8 #ifndef SkDynamicAnnotations_DEFINED |
9 #define SkDynamicAnnotations_DEFINED | 9 #define SkDynamicAnnotations_DEFINED |
10 | 10 |
11 // This file contains macros used to send out-of-band signals to dynamic instrum
entation systems, | 11 // This file contains macros used to send out-of-band signals to dynamic instrum
entation systems, |
12 // namely thread sanitizer. This is a cut-down version of the full dynamic_anno
tations library with | 12 // namely thread sanitizer. This is a cut-down version of the full dynamic_anno
tations library with |
13 // only the features used by Skia. | 13 // only the features used by Skia. |
14 | 14 |
15 // We check the same define to know to enable the annotations, but prefix all ou
r macros with SK_. | 15 // We check the same define to know to enable the annotations, but prefix all ou
r macros with SK_. |
16 #if DYNAMIC_ANNOTATIONS_ENABLED | 16 #if DYNAMIC_ANNOTATIONS_ENABLED |
17 | 17 |
18 extern "C" { | 18 extern "C" { |
19 // TSAN provides these hooks. | 19 // TSAN provides these hooks. |
20 void AnnotateIgnoreReadsBegin(const char* file, int line); | 20 void AnnotateIgnoreReadsBegin(const char* file, int line); |
21 void AnnotateIgnoreReadsEnd(const char* file, int line); | 21 void AnnotateIgnoreReadsEnd(const char* file, int line); |
22 void AnnotateBenignRaceSized(const char* file, int line, | 22 void AnnotateBenignRaceSized(const char* file, int line, |
23 const volatile void* addr, long size, const char* d
esc); | 23 const void* addr, long size, const char* desc); |
24 } // extern "C" | 24 } // extern "C" |
25 | 25 |
26 // SK_ANNOTATE_UNPROTECTED_READ can wrap any variable read to tell TSAN to ignor
e that it appears to | 26 // SK_ANNOTATE_UNPROTECTED_READ can wrap any variable read to tell TSAN to ignor
e that it appears to |
27 // be a racy read. This should be used only when we can make an external guaran
tee that though this | 27 // be a racy read. This should be used only when we can make an external guaran
tee that though this |
28 // particular read is racy, it is being used as part of a mechanism which is thr
ead safe. Examples: | 28 // particular read is racy, it is being used as part of a mechanism which is thr
ead safe. Examples: |
29 // - the first check in double-checked locking; | 29 // - the first check in double-checked locking; |
30 // - checking if a ref count is equal to 1. | 30 // - checking if a ref count is equal to 1. |
31 // Note that in both these cases, we must still add terrifyingly subtle memory b
arriers to provide | 31 // Note that in both these cases, we must still add terrifyingly subtle memory b
arriers to provide |
32 // that overall thread safety guarantee. Using this macro to shut TSAN up witho
ut providing such an | 32 // that overall thread safety guarantee. Using this macro to shut TSAN up witho
ut providing such an |
33 // external guarantee is pretty much never correct. | 33 // external guarantee is pretty much never correct. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 T* get() { return &fVal; } | 75 T* get() { return &fVal; } |
76 | 76 |
77 const T* operator->() const { return &fVal; } | 77 const T* operator->() const { return &fVal; } |
78 T* operator->() { return &fVal; } | 78 T* operator->() { return &fVal; } |
79 | 79 |
80 private: | 80 private: |
81 T fVal; | 81 T fVal; |
82 }; | 82 }; |
83 | 83 |
84 #endif//SkDynamicAnnotations_DEFINED | 84 #endif//SkDynamicAnnotations_DEFINED |
OLD | NEW |