aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkSharedMutex.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-09-19 12:56:37 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-19 18:05:50 +0000
commite395bf2d189e22822ddf2b46541c510d6d8fbcc0 (patch)
treedd3780a0b5b891e6b25b8b3237364ebba9f8d273 /src/core/SkSharedMutex.cpp
parent7028443d1d70a2497f315443dfd45a157f300854 (diff)
Mac TSAN support: annotate Sk[Base]Mutex as a mutex.
TSAN does not intercept Mach semaphore_t calls used to implement SkBaseMutex's fSemaphore (its OSSemaphore field). We can teach it that Sk[Base]Mutex is a mutex anyway with the same annotations we use for SkSharedMutex. Change-Id: Ib91928bb9fcfa94f5cea985b46dea31ff2b56963 Reviewed-on: https://skia-review.googlesource.com/48580 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkSharedMutex.cpp')
-rw-r--r--src/core/SkSharedMutex.cpp60
1 files changed, 1 insertions, 59 deletions
diff --git a/src/core/SkSharedMutex.cpp b/src/core/SkSharedMutex.cpp
index 17714a7185..8d6738f9e4 100644
--- a/src/core/SkSharedMutex.cpp
+++ b/src/core/SkSharedMutex.cpp
@@ -8,68 +8,10 @@
#include "SkSharedMutex.h"
#include "SkAtomics.h"
+#include "SkTSAN.h"
#include "SkTypes.h"
#include "SkSemaphore.h"
-#if !defined(__has_feature)
- #define __has_feature(x) 0
-#endif
-
-#if __has_feature(thread_sanitizer)
-
- /* Report that a lock has been created at address "lock". */
- #define ANNOTATE_RWLOCK_CREATE(lock) \
- AnnotateRWLockCreate(__FILE__, __LINE__, lock)
-
- /* Report that the lock at address "lock" is about to be destroyed. */
- #define ANNOTATE_RWLOCK_DESTROY(lock) \
- AnnotateRWLockDestroy(__FILE__, __LINE__, lock)
-
- /* Report that the lock at address "lock" has been acquired.
- is_w=1 for writer lock, is_w=0 for reader lock. */
- #define ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) \
- AnnotateRWLockAcquired(__FILE__, __LINE__, lock, is_w)
-
- /* Report that the lock at address "lock" is about to be released. */
- #define ANNOTATE_RWLOCK_RELEASED(lock, is_w) \
- AnnotateRWLockReleased(__FILE__, __LINE__, lock, is_w)
-
- #if defined(DYNAMIC_ANNOTATIONS_WANT_ATTRIBUTE_WEAK)
- #if defined(__GNUC__)
- #define DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK __attribute__((weak))
- #else
- /* TODO(glider): for Windows support we may want to change this macro in order
- to prepend __declspec(selectany) to the annotations' declarations. */
- #error weak annotations are not supported for your compiler
- #endif
- #else
- #define DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK
- #endif
-
- extern "C" {
- void AnnotateRWLockCreate(
- const char *file, int line,
- const volatile void *lock) DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK;
- void AnnotateRWLockDestroy(
- const char *file, int line,
- const volatile void *lock) DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK;
- void AnnotateRWLockAcquired(
- const char *file, int line,
- const volatile void *lock, long is_w) DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK;
- void AnnotateRWLockReleased(
- const char *file, int line,
- const volatile void *lock, long is_w) DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK;
- }
-
-#else
-
- #define ANNOTATE_RWLOCK_CREATE(lock)
- #define ANNOTATE_RWLOCK_DESTROY(lock)
- #define ANNOTATE_RWLOCK_ACQUIRED(lock, is_w)
- #define ANNOTATE_RWLOCK_RELEASED(lock, is_w)
-
-#endif
-
#ifdef SK_DEBUG
#include "SkThreadID.h"