[compiler-rt] r253659 - [tsan] Fix deadlock_detector_stress_test.cc testcase for OS X

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 20 03:13:36 PST 2015


Author: kuba.brecka
Date: Fri Nov 20 05:13:36 2015
New Revision: 253659

URL: http://llvm.org/viewvc/llvm-project?rev=253659&view=rev
Log:
[tsan] Fix deadlock_detector_stress_test.cc testcase for OS X

On OS X, we don't have pthread spinlocks, let's just use a regular mutex instead. Secondly, pthread_rwlock_t is much larger (200 bytes), so `char padding_[64 - sizeof(pthread_rwlock_t)]` actually underflows.

Differential Revision: http://reviews.llvm.org/D14862


Modified:
    compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc

Modified: compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc?rev=253659&r1=253658&r2=253659&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc (original)
+++ compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc Fri Nov 20 05:13:36 2015
@@ -56,6 +56,7 @@ class PthreadRecursiveMutex : public Pth
   static bool supports_recursive_lock() { return true; }
 };
 
+#ifndef __APPLE__
 class PthreadSpinLock {
  public:
   PthreadSpinLock() { assert(0 == pthread_spin_init(&mu_, 0)); }
@@ -76,6 +77,9 @@ class PthreadSpinLock {
   pthread_spinlock_t mu_;
   char padding_[64 - sizeof(pthread_spinlock_t)];
 };
+#else
+class PthreadSpinLock : public PthreadMutex { };
+#endif
 
 class PthreadRWLock {
  public:
@@ -95,7 +99,7 @@ class PthreadRWLock {
 
  private:
   pthread_rwlock_t mu_;
-  char padding_[64 - sizeof(pthread_rwlock_t)];
+  char padding_[256 - sizeof(pthread_rwlock_t)];
 };
 
 class LockTest {




More information about the llvm-commits mailing list