summaryrefslogtreecommitdiff
path: root/lib/tsan
diff options
context:
space:
mode:
authorKuba Brecka <kuba.brecka@gmail.com>2016-04-07 11:38:53 +0000
committerKuba Brecka <kuba.brecka@gmail.com>2016-04-07 11:38:53 +0000
commita5e174787c3f92c370918da69e528c24285f83bb (patch)
tree413bf15bf27055c489dbad3f4e581fa801227055 /lib/tsan
parentfc2a80ee264e8390829178791d57c06a1ec875b6 (diff)
[tsan] Add support for dispatch event sources
GCD has APIs for event sources, we need some more release-acquire pairs to avoid false positives in TSan. Differential Revision: http://reviews.llvm.org/D18515 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@265660 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan')
-rw-r--r--lib/tsan/rtl/tsan_libdispatch_mac.cc72
1 files changed, 72 insertions, 0 deletions
diff --git a/lib/tsan/rtl/tsan_libdispatch_mac.cc b/lib/tsan/rtl/tsan_libdispatch_mac.cc
index 2b4dc3413..abfc82fc3 100644
--- a/lib/tsan/rtl/tsan_libdispatch_mac.cc
+++ b/lib/tsan/rtl/tsan_libdispatch_mac.cc
@@ -317,6 +317,78 @@ TSAN_INTERCEPTOR(void, dispatch_group_notify_f, dispatch_group_t group,
dispatch_callback_wrap);
}
+TSAN_INTERCEPTOR(void, dispatch_source_set_event_handler,
+ dispatch_source_t source, dispatch_block_t handler) {
+ SCOPED_TSAN_INTERCEPTOR(dispatch_source_set_event_handler, source, handler);
+ dispatch_block_t new_handler = ^(void) {
+ {
+ SCOPED_INTERCEPTOR_RAW(dispatch_source_set_event_handler_callback);
+ Acquire(thr, pc, (uptr)source);
+ }
+ handler();
+ };
+ Release(thr, pc, (uptr)source);
+ REAL(dispatch_source_set_event_handler)(source, new_handler);
+}
+
+TSAN_INTERCEPTOR(void, dispatch_source_set_event_handler_f,
+ dispatch_source_t source, dispatch_function_t handler) {
+ SCOPED_TSAN_INTERCEPTOR(dispatch_source_set_event_handler_f, source, handler);
+ dispatch_block_t block = ^(void) {
+ handler(dispatch_get_context(source));
+ };
+ WRAP(dispatch_source_set_event_handler)(source, block);
+}
+
+TSAN_INTERCEPTOR(void, dispatch_source_set_cancel_handler,
+ dispatch_source_t source, dispatch_block_t handler) {
+ SCOPED_TSAN_INTERCEPTOR(dispatch_source_set_cancel_handler, source, handler);
+ dispatch_block_t new_handler = ^(void) {
+ {
+ SCOPED_INTERCEPTOR_RAW(dispatch_source_set_cancel_handler_callback);
+ Acquire(thr, pc, (uptr)source);
+ }
+ handler();
+ };
+ Release(thr, pc, (uptr)source);
+ REAL(dispatch_source_set_cancel_handler)(source, new_handler);
+}
+
+TSAN_INTERCEPTOR(void, dispatch_source_set_cancel_handler_f,
+ dispatch_source_t source, dispatch_function_t handler) {
+ SCOPED_TSAN_INTERCEPTOR(dispatch_source_set_cancel_handler_f, source,
+ handler);
+ dispatch_block_t block = ^(void) {
+ handler(dispatch_get_context(source));
+ };
+ WRAP(dispatch_source_set_cancel_handler)(source, block);
+}
+
+TSAN_INTERCEPTOR(void, dispatch_source_set_registration_handler,
+ dispatch_source_t source, dispatch_block_t handler) {
+ SCOPED_TSAN_INTERCEPTOR(dispatch_source_set_registration_handler, source,
+ handler);
+ dispatch_block_t new_handler = ^(void) {
+ {
+ SCOPED_INTERCEPTOR_RAW(dispatch_source_set_registration_handler_callback);
+ Acquire(thr, pc, (uptr)source);
+ }
+ handler();
+ };
+ Release(thr, pc, (uptr)source);
+ REAL(dispatch_source_set_registration_handler)(source, new_handler);
+}
+
+TSAN_INTERCEPTOR(void, dispatch_source_set_registration_handler_f,
+ dispatch_source_t source, dispatch_function_t handler) {
+ SCOPED_TSAN_INTERCEPTOR(dispatch_source_set_registration_handler_f, source,
+ handler);
+ dispatch_block_t block = ^(void) {
+ handler(dispatch_get_context(source));
+ };
+ WRAP(dispatch_source_set_registration_handler)(source, block);
+}
+
} // namespace __tsan
#endif // SANITIZER_MAC