summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/rtl
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/lib/tsan/rtl')
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_atomic.h140
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_defs.h18
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_interceptors.cc2
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_mutex.h2
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl.cc2
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_sync.h3
6 files changed, 5 insertions, 162 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_atomic.h b/compiler-rt/lib/tsan/rtl/tsan_atomic.h
deleted file mode 100644
index 6fcd9f9245b..00000000000
--- a/compiler-rt/lib/tsan/rtl/tsan_atomic.h
+++ /dev/null
@@ -1,140 +0,0 @@
-//===-- tsan_rtl.h ----------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file is a part of ThreadSanitizer (TSan), a race detector.
-//
-// Atomic operations. For now implies IA-32/Intel64.
-//===----------------------------------------------------------------------===//
-
-#ifndef TSAN_ATOMIC_H
-#define TSAN_ATOMIC_H
-
-#include "tsan_defs.h"
-
-namespace __tsan {
-
-const int kCacheLineSize = 64;
-
-enum memory_order {
- memory_order_relaxed = 1 << 0,
- memory_order_consume = 1 << 1,
- memory_order_acquire = 1 << 2,
- memory_order_release = 1 << 3,
- memory_order_acq_rel = 1 << 4,
- memory_order_seq_cst = 1 << 5,
-};
-
-struct atomic_uint32_t {
- typedef u32 Type;
- volatile Type val_dont_use;
-};
-
-struct atomic_uint64_t {
- typedef u64 Type;
- volatile Type val_dont_use;
-};
-
-struct atomic_uintptr_t {
- typedef uptr Type;
- volatile Type val_dont_use;
-};
-
-INLINE void atomic_signal_fence(memory_order) {
- __asm__ __volatile__("" ::: "memory");
-}
-
-INLINE void atomic_thread_fence(memory_order) {
- __asm__ __volatile__("mfence" ::: "memory");
-}
-
-INLINE void proc_yield(int cnt) {
- __asm__ __volatile__("" ::: "memory");
- for (int i = 0; i < cnt; i++)
- __asm__ __volatile__("pause");
- __asm__ __volatile__("" ::: "memory");
-}
-
-template<typename T>
-INLINE typename T::Type atomic_load(
- const volatile T *a, memory_order mo) {
- DCHECK(mo & (memory_order_relaxed | memory_order_consume
- | memory_order_acquire | memory_order_seq_cst));
- DCHECK(!((uptr)a % sizeof(*a)));
- typename T::Type v;
- if (mo == memory_order_relaxed) {
- v = a->val_dont_use;
- } else {
- atomic_signal_fence(memory_order_seq_cst);
- v = a->val_dont_use;
- atomic_signal_fence(memory_order_seq_cst);
- }
- return v;
-}
-
-template<typename T>
-INLINE void atomic_store(volatile T *a, typename T::Type v, memory_order mo) {
- DCHECK(mo & (memory_order_relaxed | memory_order_release
- | memory_order_seq_cst));
- DCHECK(!((uptr)a % sizeof(*a)));
- if (mo == memory_order_relaxed) {
- a->val_dont_use = v;
- } else {
- atomic_signal_fence(memory_order_seq_cst);
- a->val_dont_use = v;
- atomic_signal_fence(memory_order_seq_cst);
- }
- if (mo == memory_order_seq_cst)
- atomic_thread_fence(memory_order_seq_cst);
-}
-
-template<typename T>
-INLINE typename T::Type atomic_fetch_add(volatile T *a,
- typename T::Type v, memory_order mo) {
- (void)mo;
- DCHECK(!((uptr)a % sizeof(*a)));
- return __sync_fetch_and_add(&a->val_dont_use, v);
-}
-
-template<typename T>
-INLINE typename T::Type atomic_fetch_sub(volatile T *a,
- typename T::Type v, memory_order mo) {
- (void)mo;
- DCHECK(!((uptr)a % sizeof(*a)));
- return __sync_fetch_and_add(&a->val_dont_use, -v);
-}
-
-INLINE uptr atomic_exchange(volatile atomic_uintptr_t *a, uptr v,
- memory_order mo) {
- __asm__ __volatile__("xchg %1, %0" : "+r"(v), "+m"(*a) : : "memory", "cc");
- return v;
-}
-
-template<typename T>
-INLINE bool atomic_compare_exchange_strong(volatile T *a,
- typename T::Type *cmp,
- typename T::Type xchg,
- memory_order mo) {
- typedef typename T::Type Type;
- Type cmpv = *cmp;
- Type prev = __sync_val_compare_and_swap(&a->val_dont_use, cmpv, xchg);
- if (prev == cmpv)
- return true;
- *cmp = prev;
- return false;
-}
-
-INLINE bool atomic_compare_exchange_weak(volatile atomic_uintptr_t *a,
- uptr *cmp, uptr xchg,
- memory_order mo) {
- return atomic_compare_exchange_strong(a, cmp, xchg, mo);
-}
-
-} // namespace __tsan
-
-#endif // TSAN_ATOMIC_H
diff --git a/compiler-rt/lib/tsan/rtl/tsan_defs.h b/compiler-rt/lib/tsan/rtl/tsan_defs.h
index c2450312fbf..3d9cd54b5ea 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_defs.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_defs.h
@@ -54,24 +54,6 @@ const bool kCollectStats = true;
const bool kCollectStats = false;
#endif
-#if TSAN_DEBUG
-#define DCHECK(a) CHECK(a)
-#define DCHECK_EQ(a, b) CHECK_EQ(a, b)
-#define DCHECK_NE(a, b) CHECK_NE(a, b)
-#define DCHECK_LT(a, b) CHECK_LT(a, b)
-#define DCHECK_LE(a, b) CHECK_LE(a, b)
-#define DCHECK_GT(a, b) CHECK_GT(a, b)
-#define DCHECK_GE(a, b) CHECK_GE(a, b)
-#else
-#define DCHECK(a)
-#define DCHECK_EQ(a, b)
-#define DCHECK_NE(a, b)
-#define DCHECK_LT(a, b)
-#define DCHECK_LE(a, b)
-#define DCHECK_GT(a, b)
-#define DCHECK_GE(a, b)
-#endif
-
// The following "build consistency" machinery ensures that all source files
// are built in the same configuration. Inconsistent builds lead to
// hard to debug crashes.
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
index 2e9426bc16f..5dbaf866bee 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
@@ -12,11 +12,11 @@
//===----------------------------------------------------------------------===//
#include "interception/interception.h"
+#include "sanitizer_common/sanitizer_atomic.h"
#include "sanitizer_common/sanitizer_libc.h"
#include "sanitizer_common/sanitizer_placement_new.h"
#include "tsan_rtl.h"
#include "tsan_interface.h"
-#include "tsan_atomic.h"
#include "tsan_platform.h"
#include "tsan_mman.h"
diff --git a/compiler-rt/lib/tsan/rtl/tsan_mutex.h b/compiler-rt/lib/tsan/rtl/tsan_mutex.h
index 2180978f92f..6fbf8220eab 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_mutex.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_mutex.h
@@ -13,7 +13,7 @@
#ifndef TSAN_MUTEX_H
#define TSAN_MUTEX_H
-#include "tsan_atomic.h"
+#include "sanitizer_common/sanitizer_atomic.h"
#include "tsan_defs.h"
namespace __tsan {
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
index a66f6726848..822dfa164df 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
@@ -12,6 +12,7 @@
// Main file (entry points) for the TSan run-time.
//===----------------------------------------------------------------------===//
+#include "sanitizer_common/sanitizer_atomic.h"
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_libc.h"
#include "sanitizer_common/sanitizer_placement_new.h"
@@ -19,7 +20,6 @@
#include "tsan_platform.h"
#include "tsan_rtl.h"
#include "tsan_interface.h"
-#include "tsan_atomic.h"
#include "tsan_mman.h"
#include "tsan_suppressions.h"
diff --git a/compiler-rt/lib/tsan/rtl/tsan_sync.h b/compiler-rt/lib/tsan/rtl/tsan_sync.h
index 51989d223aa..34d3e0b2132 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_sync.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_sync.h
@@ -13,7 +13,8 @@
#ifndef TSAN_SYNC_H
#define TSAN_SYNC_H
-#include "tsan_atomic.h"
+#include "sanitizer_common/sanitizer_atomic.h"
+#include "sanitizer_common/sanitizer_common.h"
#include "tsan_clock.h"
#include "tsan_defs.h"
#include "tsan_mutex.h"
OpenPOWER on IntegriCloud