summaryrefslogtreecommitdiffstats
path: root/compiler-rt/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
commitcecb7faea23bd055ca4a2bc08b313f5dbaadde31 (patch)
tree478a6053bda883aa03279c109d09a759cc1939ba /compiler-rt/lib/tsan
parent33c15c91a674045a47eadb559d41c77d5997af66 (diff)
downloadbcm5719-llvm-cecb7faea23bd055ca4a2bc08b313f5dbaadde31.tar.gz
bcm5719-llvm-cecb7faea23bd055ca4a2bc08b313f5dbaadde31.zip
[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 llvm-svn: 265660
Diffstat (limited to 'compiler-rt/lib/tsan')
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc72
1 files changed, 72 insertions, 0 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc b/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc
index 2b4dc3413aa..abfc82fc358 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc
+++ b/compiler-rt/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
OpenPOWER on IntegriCloud