diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2013-01-11 11:03:35 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2013-01-11 11:03:35 +0000 |
commit | a61ec8172611a75d80e86355352c7b2dd3cb8125 (patch) | |
tree | 0229cbb7d3db631c560466d7efe5099995265b62 /lib/sanitizer_common/sanitizer_mutex.h | |
parent | 175e6407c9d5f8bd0f36abd9c020e3888134ebd3 (diff) |
asan: faster quarantine
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@172192 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_mutex.h')
-rw-r--r-- | lib/sanitizer_common/sanitizer_mutex.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/sanitizer_common/sanitizer_mutex.h b/lib/sanitizer_common/sanitizer_mutex.h index 6b6c25ddd..4372a73c1 100644 --- a/lib/sanitizer_common/sanitizer_mutex.h +++ b/lib/sanitizer_common/sanitizer_mutex.h @@ -27,11 +27,15 @@ class StaticSpinMutex { } void Lock() { - if (atomic_exchange(&state_, 1, memory_order_acquire) == 0) + if (TryLock()) return; LockSlow(); } + bool TryLock() { + return atomic_exchange(&state_, 1, memory_order_acquire) == 0; + } + void Unlock() { atomic_store(&state_, 0, memory_order_release); } |