diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2012-11-09 14:11:51 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2012-11-09 14:11:51 +0000 |
commit | c43f2721a8cdad652b188d0e40f9f091ce35a48f (patch) | |
tree | ab3a27782b0cb7c4f102c90a1fb65bb27cb3f17b | |
parent | e337bf303dde9258bc7e2c87722a270fed96460b (diff) | |
download | compiler-rt-c43f2721a8cdad652b188d0e40f9f091ce35a48f.tar.gz |
tsan: switch to new memory_order constants (ABI compatible)
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@167614 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/tsan/rtl/tsan_interface_atomic.cc | 35 | ||||
-rw-r--r-- | lib/tsan/rtl/tsan_interface_atomic.h | 12 |
2 files changed, 34 insertions, 13 deletions
diff --git a/lib/tsan/rtl/tsan_interface_atomic.cc b/lib/tsan/rtl/tsan_interface_atomic.cc index b521fd557..c29f23ec2 100644 --- a/lib/tsan/rtl/tsan_interface_atomic.cc +++ b/lib/tsan/rtl/tsan_interface_atomic.cc @@ -39,12 +39,12 @@ typedef __tsan_atomic8 a8; typedef __tsan_atomic16 a16; typedef __tsan_atomic32 a32; typedef __tsan_atomic64 a64; -const int mo_relaxed = __tsan_memory_order_relaxed; -const int mo_consume = __tsan_memory_order_consume; -const int mo_acquire = __tsan_memory_order_acquire; -const int mo_release = __tsan_memory_order_release; -const int mo_acq_rel = __tsan_memory_order_acq_rel; -const int mo_seq_cst = __tsan_memory_order_seq_cst; +const morder mo_relaxed = __tsan_memory_order_relaxed; +const morder mo_consume = __tsan_memory_order_consume; +const morder mo_acquire = __tsan_memory_order_acquire; +const morder mo_release = __tsan_memory_order_release; +const morder mo_acq_rel = __tsan_memory_order_acq_rel; +const morder mo_seq_cst = __tsan_memory_order_seq_cst; static void AtomicStatInc(ThreadState *thr, uptr size, morder mo, StatType t) { StatInc(thr, StatAtomic); @@ -79,8 +79,29 @@ static bool IsAcquireOrder(morder mo) { || mo == mo_acq_rel || mo == mo_seq_cst; } +static morder ConvertOrder(morder mo) { + if (mo > (morder)100500) { + mo = morder(mo - 100500); + if (mo == morder(1 << 0)) + mo = mo_relaxed; + else if (mo == morder(1 << 1)) + mo = mo_consume; + else if (mo == morder(1 << 2)) + mo = mo_acquire; + else if (mo == morder(1 << 3)) + mo = mo_release; + else if (mo == morder(1 << 4)) + mo = mo_acq_rel; + else if (mo == morder(1 << 5)) + mo = mo_seq_cst; + } + CHECK_GE(mo, mo_relaxed); + CHECK_LE(mo, mo_seq_cst); + return mo; +} + #define SCOPED_ATOMIC(func, ...) \ - if ((u32)mo > 100500) mo = (morder)((u32)mo - 100500); \ + mo = ConvertOrder(mo); \ mo = flags()->force_seq_cst_atomics ? (morder)mo_seq_cst : mo; \ ThreadState *const thr = cur_thread(); \ const uptr pc = (uptr)__builtin_return_address(0); \ diff --git a/lib/tsan/rtl/tsan_interface_atomic.h b/lib/tsan/rtl/tsan_interface_atomic.h index d5c628275..b8d81af49 100644 --- a/lib/tsan/rtl/tsan_interface_atomic.h +++ b/lib/tsan/rtl/tsan_interface_atomic.h @@ -25,12 +25,12 @@ typedef long __tsan_atomic64; // NOLINT // Part of ABI, do not change. // http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/atomic?view=markup typedef enum { - __tsan_memory_order_relaxed = 1 << 0, - __tsan_memory_order_consume = 1 << 1, - __tsan_memory_order_acquire = 1 << 2, - __tsan_memory_order_release = 1 << 3, - __tsan_memory_order_acq_rel = 1 << 4, - __tsan_memory_order_seq_cst = 1 << 5 + __tsan_memory_order_relaxed, + __tsan_memory_order_consume, + __tsan_memory_order_acquire, + __tsan_memory_order_release, + __tsan_memory_order_acq_rel, + __tsan_memory_order_seq_cst } __tsan_memory_order; __tsan_atomic8 __tsan_atomic8_load(const volatile __tsan_atomic8 *a, |