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

Side by Side Diff: include/core/SkDynamicAnnotations.h

Issue 810513002: Look at DYNAMIC_ANNOTATIONS_ENABLED now. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 | « gyp/common_conditions.gypi ('k') | no next file » | 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 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 // Make sure we see anything set via SkUserConfig.h (e.g. SK_DYNAMIC_ANNOTATIONS _ENABLED). 11 // Make sure we see anything set via SkUserConfig.h (e.g. DYNAMIC_ANNOTATIONS_EN ABLED).
12 #include "SkTypes.h" 12 #include "SkTypes.h"
13 13
14 // This file contains macros used to send out-of-band signals to dynamic instrum entation systems, 14 // This file contains macros used to send out-of-band signals to dynamic instrum entation systems,
15 // namely thread sanitizer. This is a cut-down version of the full dynamic_anno tations library with 15 // namely thread sanitizer. This is a cut-down version of the full dynamic_anno tations library with
16 // only the features used by Skia. 16 // only the features used by Skia.
17 17
18 #if SK_DYNAMIC_ANNOTATIONS_ENABLED 18 #if DYNAMIC_ANNOTATIONS_ENABLED
19 19
20 extern "C" { 20 extern "C" {
21 // TSAN provides these hooks. 21 // TSAN provides these hooks.
22 void AnnotateIgnoreReadsBegin(const char* file, int line); 22 void AnnotateIgnoreReadsBegin(const char* file, int line);
23 void AnnotateIgnoreReadsEnd(const char* file, int line); 23 void AnnotateIgnoreReadsEnd(const char* file, int line);
24 void AnnotateIgnoreWritesBegin(const char* file, int line); 24 void AnnotateIgnoreWritesBegin(const char* file, int line);
25 void AnnotateIgnoreWritesEnd(const char* file, int line); 25 void AnnotateIgnoreWritesEnd(const char* file, int line);
26 void AnnotateBenignRaceSized(const char* file, int line, 26 void AnnotateBenignRaceSized(const char* file, int line,
27 const volatile void* addr, long size, const char* d esc); 27 const volatile void* addr, long size, const char* d esc);
28 } // extern "C" 28 } // extern "C"
(...skipping 22 matching lines...) Expand all
51 AnnotateIgnoreWritesEnd(__FILE__, __LINE__); 51 AnnotateIgnoreWritesEnd(__FILE__, __LINE__);
52 } 52 }
53 53
54 // Ignore racy reads and racy writes to this pointer, indefinitely. 54 // Ignore racy reads and racy writes to this pointer, indefinitely.
55 // If at all possible, use the more precise SK_ANNOTATE_UNPROTECTED_READ. 55 // If at all possible, use the more precise SK_ANNOTATE_UNPROTECTED_READ.
56 template <typename T> 56 template <typename T>
57 void SK_ANNOTATE_BENIGN_RACE(T* ptr) { 57 void SK_ANNOTATE_BENIGN_RACE(T* ptr) {
58 AnnotateBenignRaceSized(__FILE__, __LINE__, ptr, sizeof(*ptr), "SK_ANNOTATE_ BENIGN_RACE"); 58 AnnotateBenignRaceSized(__FILE__, __LINE__, ptr, sizeof(*ptr), "SK_ANNOTATE_ BENIGN_RACE");
59 } 59 }
60 60
61 #else // !SK_DYNAMIC_ANNOTATIONS_ENABLED 61 #else // !DYNAMIC_ANNOTATIONS_ENABLED
62 62
63 #define SK_ANNOTATE_UNPROTECTED_READ(x) (x) 63 #define SK_ANNOTATE_UNPROTECTED_READ(x) (x)
64 #define SK_ANNOTATE_UNPROTECTED_WRITE(ptr, val) *(ptr) = (val) 64 #define SK_ANNOTATE_UNPROTECTED_WRITE(ptr, val) *(ptr) = (val)
65 #define SK_ANNOTATE_BENIGN_RACE(ptr) 65 #define SK_ANNOTATE_BENIGN_RACE(ptr)
66 66
67 #endif 67 #endif
68 68
69 // Can be used to wrap values that are intentionally racy, usually small mutable cached values, e.g. 69 // Can be used to wrap values that are intentionally racy, usually small mutable cached values, e.g.
70 // - SkMatrix type mask 70 // - SkMatrix type mask
71 // - SkPixelRef genIDs 71 // - SkPixelRef genIDs
72 template <typename T> 72 template <typename T>
73 class SkTRacy { 73 class SkTRacy {
74 public: 74 public:
75 operator const T() const { 75 operator const T() const {
76 return SK_ANNOTATE_UNPROTECTED_READ(fVal); 76 return SK_ANNOTATE_UNPROTECTED_READ(fVal);
77 } 77 }
78 78
79 SkTRacy& operator=(const T& val) { 79 SkTRacy& operator=(const T& val) {
80 SK_ANNOTATE_UNPROTECTED_WRITE(&fVal, val); 80 SK_ANNOTATE_UNPROTECTED_WRITE(&fVal, val);
81 return *this; 81 return *this;
82 } 82 }
83 83
84 private: 84 private:
85 T fVal; 85 T fVal;
86 }; 86 };
87 87
88 #endif//SkDynamicAnnotations_DEFINED 88 #endif//SkDynamicAnnotations_DEFINED
OLDNEW
« no previous file with comments | « gyp/common_conditions.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698