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

Unified Diff: include/core/SkDynamicAnnotations.h

Issue 144953005: TSAN: use somewhat pithier SK_ANNOTATE_UNPROTECTED_READ. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | include/core/SkOnce.h » ('j') | include/core/SkRefCnt.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkDynamicAnnotations.h
diff --git a/include/core/SkDynamicAnnotations.h b/include/core/SkDynamicAnnotations.h
new file mode 100644
index 0000000000000000000000000000000000000000..f3c7f034b639448dc8339e76ad5feecc84769d8f
--- /dev/null
+++ b/include/core/SkDynamicAnnotations.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkDynamicAnnotations_DEFINED
+#define SkDynamicAnnotations_DEFINED
+
+// We nabbed this code from the dynamic_annotations library, and in their honor
+// we check the same define. Add other macros you use here.
reed1 2014/02/04 14:57:55 I have no idea what this stuff does. Can we also n
+
+#if DYNAMIC_ANNOTATIONS_ENABLED
+
+extern "C" {
+// TSAN provides these hooks.
+void AnnotateIgnoreReadsBegin(const char* file, int line);
+void AnnotateIgnoreReadsEnd(const char* file, int line);
+} // extern "C"
+
+template <typename T>
+inline T SK_ANNOTATE_UNPROTECTED_READ(const volatile T& x) {
+ AnnotateIgnoreReadsBegin(__FILE__, __LINE__);
+ T read = x;
+ AnnotateIgnoreReadsEnd(__FILE__, __LINE__);
+ return read;
+}
+
+#else // !DYNAMIC_ANNOTATIONS_ENABLED
+
+#define SK_ANNOTATE_UNPROTECTED_READ(x) (x)
+
+#endif
+
+#endif//SkDynamicAnnotations_DEFINED
« no previous file with comments | « no previous file | include/core/SkOnce.h » ('j') | include/core/SkRefCnt.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698