try un-teaching TSAN about Mac semaphores
Now using dispatch_semaphore_t, maybe it already knows?
Change-Id: I65499ceaee195293541a37704ae424bbee7c8740
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/248456
Auto-Submit: Mike Klein <mtklein@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
diff --git a/src/core/SkSemaphore.cpp b/src/core/SkSemaphore.cpp
index 55d77d2..692cbfc 100644
--- a/src/core/SkSemaphore.cpp
+++ b/src/core/SkSemaphore.cpp
@@ -11,34 +11,14 @@
#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
#include <dispatch/dispatch.h>
- // We've got to teach TSAN that there is a happens-before edge between
- // dispatch_semaphore_signal() and dispatch_semaphore_wait().
- #if __has_feature(thread_sanitizer)
- extern "C" void AnnotateHappensBefore(const char*, int, void*);
- extern "C" void AnnotateHappensAfter (const char*, int, void*);
- #else
- static void AnnotateHappensBefore(const char*, int, void*) {}
- static void AnnotateHappensAfter (const char*, int, void*) {}
- #endif
-
struct SkSemaphore::OSSemaphore {
dispatch_semaphore_t fSemaphore;
- OSSemaphore() {
- fSemaphore = dispatch_semaphore_create(0/*initial count*/);
- }
+ OSSemaphore() { fSemaphore = dispatch_semaphore_create(0/*initial count*/); }
~OSSemaphore() { dispatch_release(fSemaphore); }
- void signal(int n) {
- while (n-- > 0) {
- AnnotateHappensBefore(__FILE__, __LINE__, &fSemaphore);
- dispatch_semaphore_signal(fSemaphore);
- }
- }
- void wait() {
- dispatch_semaphore_wait(fSemaphore, DISPATCH_TIME_FOREVER);
- AnnotateHappensAfter(__FILE__, __LINE__, &fSemaphore);
- }
+ void signal(int n) { while (n --> 0) { dispatch_semaphore_signal(fSemaphore); } }
+ void wait() { dispatch_semaphore_wait(fSemaphore, DISPATCH_TIME_FOREVER); }
};
#elif defined(SK_BUILD_FOR_WIN)
struct SkSemaphore::OSSemaphore {