diff options
author | Kuba Brecka <kuba.brecka@gmail.com> | 2015-12-01 13:11:42 +0000 |
---|---|---|
committer | Kuba Brecka <kuba.brecka@gmail.com> | 2015-12-01 13:11:42 +0000 |
commit | 771833b0b7b419145784f3b40c3e775ef8d5490f (patch) | |
tree | d341c654712e56787bac3d1ceeb6ccee31fd1aeb /lib/tsan/rtl/tsan_libdispatch_mac.cc | |
parent | 627fd48e2b24f1356347de58c922cce6fe7ed3e1 (diff) |
[tsan] Add interceptors and sychronization for libdispatch semaphores on OS X
This patch adds release and acquire semantics for libdispatch semaphores and a test case.
Differential Revision: http://reviews.llvm.org/D14992
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254412 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/rtl/tsan_libdispatch_mac.cc')
-rw-r--r-- | lib/tsan/rtl/tsan_libdispatch_mac.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/tsan/rtl/tsan_libdispatch_mac.cc b/lib/tsan/rtl/tsan_libdispatch_mac.cc index aae199ba0..d388cf114 100644 --- a/lib/tsan/rtl/tsan_libdispatch_mac.cc +++ b/lib/tsan/rtl/tsan_libdispatch_mac.cc @@ -25,6 +25,8 @@ #include <dispatch/dispatch.h> #include <pthread.h> +typedef long long_t; // NOLINT + namespace __tsan { typedef struct { @@ -166,6 +168,21 @@ TSAN_INTERCEPTOR(void, dispatch_once_f, dispatch_once_t *predicate, }); } +TSAN_INTERCEPTOR(long_t, dispatch_semaphore_signal, + dispatch_semaphore_t dsema) { + SCOPED_TSAN_INTERCEPTOR(dispatch_semaphore_signal, dsema); + Release(thr, pc, (uptr)dsema); + return REAL(dispatch_semaphore_signal)(dsema); +} + +TSAN_INTERCEPTOR(long_t, dispatch_semaphore_wait, dispatch_semaphore_t dsema, + dispatch_time_t timeout) { + SCOPED_TSAN_INTERCEPTOR(dispatch_semaphore_wait, dsema, timeout); + long_t result = REAL(dispatch_semaphore_wait)(dsema, timeout); + if (result == 0) Acquire(thr, pc, (uptr)dsema); + return result; +} + } // namespace __tsan #endif // SANITIZER_MAC |