gfx/skia/trunk/include/core/SkDynamicAnnotations.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 * Copyright 2014 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #ifndef SkDynamicAnnotations_DEFINED
michael@0 9 #define SkDynamicAnnotations_DEFINED
michael@0 10
michael@0 11 // This file contains macros used to send out-of-band signals to dynamic instrumentation systems,
michael@0 12 // namely thread sanitizer. This is a cut-down version of the full dynamic_annotations library with
michael@0 13 // only the features used by Skia.
michael@0 14
michael@0 15 // We check the same define to know to enable the annotations, but prefix all our macros with SK_.
michael@0 16 #if DYNAMIC_ANNOTATIONS_ENABLED
michael@0 17
michael@0 18 extern "C" {
michael@0 19 // TSAN provides these hooks.
michael@0 20 void AnnotateIgnoreReadsBegin(const char* file, int line);
michael@0 21 void AnnotateIgnoreReadsEnd(const char* file, int line);
michael@0 22 } // extern "C"
michael@0 23
michael@0 24 // SK_ANNOTATE_UNPROTECTED_READ can wrap any variable read to tell TSAN to ignore that it appears to
michael@0 25 // be a racy read. This should be used only when we can make an external guarantee that though this
michael@0 26 // particular read is racy, it is being used as part of a mechanism which is thread safe. Examples:
michael@0 27 // - the first check in double-checked locking;
michael@0 28 // - checking if a ref count is equal to 1.
michael@0 29 // Note that in both these cases, we must still add terrifyingly subtle memory barriers to provide
michael@0 30 // that overall thread safety guarantee. Using this macro to shut TSAN up without providing such an
michael@0 31 // external guarantee is pretty much never correct.
michael@0 32 template <typename T>
michael@0 33 inline T SK_ANNOTATE_UNPROTECTED_READ(const volatile T& x) {
michael@0 34 AnnotateIgnoreReadsBegin(__FILE__, __LINE__);
michael@0 35 T read = x;
michael@0 36 AnnotateIgnoreReadsEnd(__FILE__, __LINE__);
michael@0 37 return read;
michael@0 38 }
michael@0 39
michael@0 40 #else // !DYNAMIC_ANNOTATIONS_ENABLED
michael@0 41
michael@0 42 #define SK_ANNOTATE_UNPROTECTED_READ(x) (x)
michael@0 43
michael@0 44 #endif
michael@0 45
michael@0 46 #endif//SkDynamicAnnotations_DEFINED

mercurial