diff options
author | Kuba Brecka <kuba.brecka@gmail.com> | 2015-11-21 12:41:36 +0000 |
---|---|---|
committer | Kuba Brecka <kuba.brecka@gmail.com> | 2015-11-21 12:41:36 +0000 |
commit | 5cbe1224396b2dc8a70605587168b0428b9d456f (patch) | |
tree | bb82f5949fab41ad39f5d820674a82137449dff5 /compiler-rt/lib/tsan/tests/rtl | |
parent | 4e6adaac4c057ad600ce64e75f9c2a151eb456be (diff) | |
download | bcm5719-llvm-5cbe1224396b2dc8a70605587168b0428b9d456f.tar.gz bcm5719-llvm-5cbe1224396b2dc8a70605587168b0428b9d456f.zip |
[tsan] Fix detached threads in unit tests on OS X
We need to call the intercepted version of pthread_detach. Secondly, PTHREAD_CREATE_JOINABLE and PTHREAD_CREATE_DETACHED are not 0 and 1 on OS X, so we need to properly pass these constants and not just a bool.
Differential Revision: http://reviews.llvm.org/D14837
llvm-svn: 253775
Diffstat (limited to 'compiler-rt/lib/tsan/tests/rtl')
-rw-r--r-- | compiler-rt/lib/tsan/tests/rtl/tsan_test_util_posix.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler-rt/lib/tsan/tests/rtl/tsan_test_util_posix.cc b/compiler-rt/lib/tsan/tests/rtl/tsan_test_util_posix.cc index 414497b7a4d..c8be088d266 100644 --- a/compiler-rt/lib/tsan/tests/rtl/tsan_test_util_posix.cc +++ b/compiler-rt/lib/tsan/tests/rtl/tsan_test_util_posix.cc @@ -38,6 +38,7 @@ static __thread ReportType expect_report_type; #define __interceptor_memset wrap_memset #define __interceptor_pthread_create wrap_pthread_create #define __interceptor_pthread_join wrap_pthread_join +#define __interceptor_pthread_detach wrap_pthread_detach #define __interceptor_pthread_mutex_init wrap_pthread_mutex_init #define __interceptor_pthread_mutex_lock wrap_pthread_mutex_lock #define __interceptor_pthread_mutex_unlock wrap_pthread_mutex_unlock @@ -59,6 +60,7 @@ extern "C" int __interceptor_pthread_create(pthread_t *thread, void *(*start_routine)(void *), void *arg); extern "C" int __interceptor_pthread_join(pthread_t thread, void **value_ptr); +extern "C" int __interceptor_pthread_detach(pthread_t thread); extern "C" int __interceptor_pthread_mutex_init( pthread_mutex_t *mutex, const pthread_mutexattr_t *attr); @@ -410,7 +412,8 @@ ScopedThread::ScopedThread(bool detached, bool main) { if (!main) { pthread_attr_t attr; pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, detached); + pthread_attr_setdetachstate( + &attr, detached ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE); pthread_attr_setstacksize(&attr, 64*1024); __interceptor_pthread_create(&impl_->thread, &attr, ScopedThread::Impl::ScopedThreadCallback, impl_); @@ -431,7 +434,7 @@ void ScopedThread::Detach() { CHECK(!impl_->main); CHECK(!impl_->detached); impl_->detached = true; - pthread_detach(impl_->thread); + __interceptor_pthread_detach(impl_->thread); } void ScopedThread::Access(void *addr, bool is_write, |