mirror of
https://github.com/darlinghq/darling-compiler-rt.git
synced 2024-12-04 10:03:43 +00:00
[TSan] Move declarations of __tsan_atomic functions to a public header
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197015 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
493d0cf934
commit
b0f72ff7ba
@ -4,7 +4,8 @@ set(SANITIZER_HEADERS
|
||||
sanitizer/dfsan_interface.h
|
||||
sanitizer/linux_syscall_hooks.h
|
||||
sanitizer/lsan_interface.h
|
||||
sanitizer/msan_interface.h)
|
||||
sanitizer/msan_interface.h
|
||||
sanitizer/tsan_interface_atomic.h)
|
||||
|
||||
set(output_dir ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION}/include)
|
||||
|
||||
|
@ -9,14 +9,11 @@
|
||||
//
|
||||
// This file is a part of ThreadSanitizer (TSan), a race detector.
|
||||
//
|
||||
// Public interface header for TSan atomics.
|
||||
//===----------------------------------------------------------------------===//
|
||||
#ifndef TSAN_INTERFACE_ATOMIC_H
|
||||
#define TSAN_INTERFACE_ATOMIC_H
|
||||
|
||||
#ifndef INTERFACE_ATTRIBUTE
|
||||
# define INTERFACE_ATTRIBUTE __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -25,14 +22,12 @@ typedef char __tsan_atomic8;
|
||||
typedef short __tsan_atomic16; // NOLINT
|
||||
typedef int __tsan_atomic32;
|
||||
typedef long __tsan_atomic64; // NOLINT
|
||||
|
||||
#if defined(__SIZEOF_INT128__) \
|
||||
|| (__clang_major__ * 100 + __clang_minor__ >= 302)
|
||||
__extension__ typedef __int128 __tsan_atomic128;
|
||||
#define __TSAN_HAS_INT128 1
|
||||
# define __TSAN_HAS_INT128 1
|
||||
#else
|
||||
typedef char __tsan_atomic128;
|
||||
#define __TSAN_HAS_INT128 0
|
||||
# define __TSAN_HAS_INT128 0
|
||||
#endif
|
||||
|
||||
// Part of ABI, do not change.
|
||||
@ -47,159 +42,181 @@ typedef enum {
|
||||
} __tsan_memory_order;
|
||||
|
||||
__tsan_atomic8 __tsan_atomic8_load(const volatile __tsan_atomic8 *a,
|
||||
__tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order mo);
|
||||
__tsan_atomic16 __tsan_atomic16_load(const volatile __tsan_atomic16 *a,
|
||||
__tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order mo);
|
||||
__tsan_atomic32 __tsan_atomic32_load(const volatile __tsan_atomic32 *a,
|
||||
__tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order mo);
|
||||
__tsan_atomic64 __tsan_atomic64_load(const volatile __tsan_atomic64 *a,
|
||||
__tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order mo);
|
||||
#if __TSAN_HAS_INT128
|
||||
__tsan_atomic128 __tsan_atomic128_load(const volatile __tsan_atomic128 *a,
|
||||
__tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order mo);
|
||||
#endif
|
||||
|
||||
void __tsan_atomic8_store(volatile __tsan_atomic8 *a, __tsan_atomic8 v,
|
||||
__tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order mo);
|
||||
void __tsan_atomic16_store(volatile __tsan_atomic16 *a, __tsan_atomic16 v,
|
||||
__tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order mo);
|
||||
void __tsan_atomic32_store(volatile __tsan_atomic32 *a, __tsan_atomic32 v,
|
||||
__tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order mo);
|
||||
void __tsan_atomic64_store(volatile __tsan_atomic64 *a, __tsan_atomic64 v,
|
||||
__tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order mo);
|
||||
#if __TSAN_HAS_INT128
|
||||
void __tsan_atomic128_store(volatile __tsan_atomic128 *a, __tsan_atomic128 v,
|
||||
__tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order mo);
|
||||
#endif
|
||||
|
||||
__tsan_atomic8 __tsan_atomic8_exchange(volatile __tsan_atomic8 *a,
|
||||
__tsan_atomic8 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic8 v, __tsan_memory_order mo);
|
||||
__tsan_atomic16 __tsan_atomic16_exchange(volatile __tsan_atomic16 *a,
|
||||
__tsan_atomic16 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic16 v, __tsan_memory_order mo);
|
||||
__tsan_atomic32 __tsan_atomic32_exchange(volatile __tsan_atomic32 *a,
|
||||
__tsan_atomic32 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic32 v, __tsan_memory_order mo);
|
||||
__tsan_atomic64 __tsan_atomic64_exchange(volatile __tsan_atomic64 *a,
|
||||
__tsan_atomic64 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic64 v, __tsan_memory_order mo);
|
||||
#if __TSAN_HAS_INT128
|
||||
__tsan_atomic128 __tsan_atomic128_exchange(volatile __tsan_atomic128 *a,
|
||||
__tsan_atomic128 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic128 v, __tsan_memory_order mo);
|
||||
#endif
|
||||
|
||||
__tsan_atomic8 __tsan_atomic8_fetch_add(volatile __tsan_atomic8 *a,
|
||||
__tsan_atomic8 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic8 v, __tsan_memory_order mo);
|
||||
__tsan_atomic16 __tsan_atomic16_fetch_add(volatile __tsan_atomic16 *a,
|
||||
__tsan_atomic16 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic16 v, __tsan_memory_order mo);
|
||||
__tsan_atomic32 __tsan_atomic32_fetch_add(volatile __tsan_atomic32 *a,
|
||||
__tsan_atomic32 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic32 v, __tsan_memory_order mo);
|
||||
__tsan_atomic64 __tsan_atomic64_fetch_add(volatile __tsan_atomic64 *a,
|
||||
__tsan_atomic64 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic64 v, __tsan_memory_order mo);
|
||||
#if __TSAN_HAS_INT128
|
||||
__tsan_atomic128 __tsan_atomic128_fetch_add(volatile __tsan_atomic128 *a,
|
||||
__tsan_atomic128 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic128 v, __tsan_memory_order mo);
|
||||
#endif
|
||||
|
||||
__tsan_atomic8 __tsan_atomic8_fetch_sub(volatile __tsan_atomic8 *a,
|
||||
__tsan_atomic8 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic8 v, __tsan_memory_order mo);
|
||||
__tsan_atomic16 __tsan_atomic16_fetch_sub(volatile __tsan_atomic16 *a,
|
||||
__tsan_atomic16 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic16 v, __tsan_memory_order mo);
|
||||
__tsan_atomic32 __tsan_atomic32_fetch_sub(volatile __tsan_atomic32 *a,
|
||||
__tsan_atomic32 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic32 v, __tsan_memory_order mo);
|
||||
__tsan_atomic64 __tsan_atomic64_fetch_sub(volatile __tsan_atomic64 *a,
|
||||
__tsan_atomic64 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic64 v, __tsan_memory_order mo);
|
||||
#if __TSAN_HAS_INT128
|
||||
__tsan_atomic128 __tsan_atomic128_fetch_sub(volatile __tsan_atomic128 *a,
|
||||
__tsan_atomic128 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic128 v, __tsan_memory_order mo);
|
||||
#endif
|
||||
|
||||
__tsan_atomic8 __tsan_atomic8_fetch_and(volatile __tsan_atomic8 *a,
|
||||
__tsan_atomic8 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic8 v, __tsan_memory_order mo);
|
||||
__tsan_atomic16 __tsan_atomic16_fetch_and(volatile __tsan_atomic16 *a,
|
||||
__tsan_atomic16 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic16 v, __tsan_memory_order mo);
|
||||
__tsan_atomic32 __tsan_atomic32_fetch_and(volatile __tsan_atomic32 *a,
|
||||
__tsan_atomic32 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic32 v, __tsan_memory_order mo);
|
||||
__tsan_atomic64 __tsan_atomic64_fetch_and(volatile __tsan_atomic64 *a,
|
||||
__tsan_atomic64 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic64 v, __tsan_memory_order mo);
|
||||
#if __TSAN_HAS_INT128
|
||||
__tsan_atomic128 __tsan_atomic128_fetch_and(volatile __tsan_atomic128 *a,
|
||||
__tsan_atomic128 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic128 v, __tsan_memory_order mo);
|
||||
#endif
|
||||
|
||||
__tsan_atomic8 __tsan_atomic8_fetch_or(volatile __tsan_atomic8 *a,
|
||||
__tsan_atomic8 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic8 v, __tsan_memory_order mo);
|
||||
__tsan_atomic16 __tsan_atomic16_fetch_or(volatile __tsan_atomic16 *a,
|
||||
__tsan_atomic16 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic16 v, __tsan_memory_order mo);
|
||||
__tsan_atomic32 __tsan_atomic32_fetch_or(volatile __tsan_atomic32 *a,
|
||||
__tsan_atomic32 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic32 v, __tsan_memory_order mo);
|
||||
__tsan_atomic64 __tsan_atomic64_fetch_or(volatile __tsan_atomic64 *a,
|
||||
__tsan_atomic64 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic64 v, __tsan_memory_order mo);
|
||||
#if __TSAN_HAS_INT128
|
||||
__tsan_atomic128 __tsan_atomic128_fetch_or(volatile __tsan_atomic128 *a,
|
||||
__tsan_atomic128 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic128 v, __tsan_memory_order mo);
|
||||
#endif
|
||||
|
||||
__tsan_atomic8 __tsan_atomic8_fetch_xor(volatile __tsan_atomic8 *a,
|
||||
__tsan_atomic8 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic8 v, __tsan_memory_order mo);
|
||||
__tsan_atomic16 __tsan_atomic16_fetch_xor(volatile __tsan_atomic16 *a,
|
||||
__tsan_atomic16 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic16 v, __tsan_memory_order mo);
|
||||
__tsan_atomic32 __tsan_atomic32_fetch_xor(volatile __tsan_atomic32 *a,
|
||||
__tsan_atomic32 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic32 v, __tsan_memory_order mo);
|
||||
__tsan_atomic64 __tsan_atomic64_fetch_xor(volatile __tsan_atomic64 *a,
|
||||
__tsan_atomic64 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic64 v, __tsan_memory_order mo);
|
||||
#if __TSAN_HAS_INT128
|
||||
__tsan_atomic128 __tsan_atomic128_fetch_xor(volatile __tsan_atomic128 *a,
|
||||
__tsan_atomic128 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic128 v, __tsan_memory_order mo);
|
||||
#endif
|
||||
|
||||
__tsan_atomic8 __tsan_atomic8_fetch_nand(volatile __tsan_atomic8 *a,
|
||||
__tsan_atomic8 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic8 v, __tsan_memory_order mo);
|
||||
__tsan_atomic16 __tsan_atomic16_fetch_nand(volatile __tsan_atomic16 *a,
|
||||
__tsan_atomic16 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic16 v, __tsan_memory_order mo);
|
||||
__tsan_atomic32 __tsan_atomic32_fetch_nand(volatile __tsan_atomic32 *a,
|
||||
__tsan_atomic32 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic32 v, __tsan_memory_order mo);
|
||||
__tsan_atomic64 __tsan_atomic64_fetch_nand(volatile __tsan_atomic64 *a,
|
||||
__tsan_atomic64 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic64 v, __tsan_memory_order mo);
|
||||
#if __TSAN_HAS_INT128
|
||||
__tsan_atomic128 __tsan_atomic128_fetch_nand(volatile __tsan_atomic128 *a,
|
||||
__tsan_atomic128 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_atomic128 v, __tsan_memory_order mo);
|
||||
#endif
|
||||
|
||||
int __tsan_atomic8_compare_exchange_weak(volatile __tsan_atomic8 *a,
|
||||
__tsan_atomic8 *c, __tsan_atomic8 v, __tsan_memory_order mo,
|
||||
__tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order fail_mo);
|
||||
int __tsan_atomic16_compare_exchange_weak(volatile __tsan_atomic16 *a,
|
||||
__tsan_atomic16 *c, __tsan_atomic16 v, __tsan_memory_order mo,
|
||||
__tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order fail_mo);
|
||||
int __tsan_atomic32_compare_exchange_weak(volatile __tsan_atomic32 *a,
|
||||
__tsan_atomic32 *c, __tsan_atomic32 v, __tsan_memory_order mo,
|
||||
__tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order fail_mo);
|
||||
int __tsan_atomic64_compare_exchange_weak(volatile __tsan_atomic64 *a,
|
||||
__tsan_atomic64 *c, __tsan_atomic64 v, __tsan_memory_order mo,
|
||||
__tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order fail_mo);
|
||||
#if __TSAN_HAS_INT128
|
||||
int __tsan_atomic128_compare_exchange_weak(volatile __tsan_atomic128 *a,
|
||||
__tsan_atomic128 *c, __tsan_atomic128 v, __tsan_memory_order mo,
|
||||
__tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order fail_mo);
|
||||
#endif
|
||||
|
||||
int __tsan_atomic8_compare_exchange_strong(volatile __tsan_atomic8 *a,
|
||||
__tsan_atomic8 *c, __tsan_atomic8 v, __tsan_memory_order mo,
|
||||
__tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order fail_mo);
|
||||
int __tsan_atomic16_compare_exchange_strong(volatile __tsan_atomic16 *a,
|
||||
__tsan_atomic16 *c, __tsan_atomic16 v, __tsan_memory_order mo,
|
||||
__tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order fail_mo);
|
||||
int __tsan_atomic32_compare_exchange_strong(volatile __tsan_atomic32 *a,
|
||||
__tsan_atomic32 *c, __tsan_atomic32 v, __tsan_memory_order mo,
|
||||
__tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order fail_mo);
|
||||
int __tsan_atomic64_compare_exchange_strong(volatile __tsan_atomic64 *a,
|
||||
__tsan_atomic64 *c, __tsan_atomic64 v, __tsan_memory_order mo,
|
||||
__tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order fail_mo);
|
||||
#if __TSAN_HAS_INT128
|
||||
int __tsan_atomic128_compare_exchange_strong(volatile __tsan_atomic128 *a,
|
||||
__tsan_atomic128 *c, __tsan_atomic128 v, __tsan_memory_order mo,
|
||||
__tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order fail_mo);
|
||||
#endif
|
||||
|
||||
__tsan_atomic8 __tsan_atomic8_compare_exchange_val(
|
||||
volatile __tsan_atomic8 *a, __tsan_atomic8 c, __tsan_atomic8 v,
|
||||
__tsan_memory_order mo, __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order mo, __tsan_memory_order fail_mo);
|
||||
__tsan_atomic16 __tsan_atomic16_compare_exchange_val(
|
||||
volatile __tsan_atomic16 *a, __tsan_atomic16 c, __tsan_atomic16 v,
|
||||
__tsan_memory_order mo, __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order mo, __tsan_memory_order fail_mo);
|
||||
__tsan_atomic32 __tsan_atomic32_compare_exchange_val(
|
||||
volatile __tsan_atomic32 *a, __tsan_atomic32 c, __tsan_atomic32 v,
|
||||
__tsan_memory_order mo, __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order mo, __tsan_memory_order fail_mo);
|
||||
__tsan_atomic64 __tsan_atomic64_compare_exchange_val(
|
||||
volatile __tsan_atomic64 *a, __tsan_atomic64 c, __tsan_atomic64 v,
|
||||
__tsan_memory_order mo, __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order mo, __tsan_memory_order fail_mo);
|
||||
#if __TSAN_HAS_INT128
|
||||
__tsan_atomic128 __tsan_atomic128_compare_exchange_val(
|
||||
volatile __tsan_atomic128 *a, __tsan_atomic128 c, __tsan_atomic128 v,
|
||||
__tsan_memory_order mo, __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE;
|
||||
__tsan_memory_order mo, __tsan_memory_order fail_mo);
|
||||
#endif
|
||||
|
||||
void __tsan_atomic_thread_fence(__tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
void __tsan_atomic_signal_fence(__tsan_memory_order mo) INTERFACE_ATTRIBUTE;
|
||||
void __tsan_atomic_thread_fence(__tsan_memory_order mo);
|
||||
void __tsan_atomic_signal_fence(__tsan_memory_order mo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#undef INTERFACE_ATTRIBUTE
|
||||
|
||||
#endif // #ifndef TSAN_INTERFACE_ATOMIC_H
|
||||
#endif // TSAN_INTERFACE_ATOMIC_H
|
16
lib/tsan/lit_tests/interface_atomic_test.c
Normal file
16
lib/tsan/lit_tests/interface_atomic_test.c
Normal file
@ -0,0 +1,16 @@
|
||||
// Test that we can include header with TSan atomic interface.
|
||||
// RUN: %clang_tsan %s -o %t && %t | FileCheck %s
|
||||
#include <sanitizer/tsan_interface_atomic.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
__tsan_atomic32 a;
|
||||
__tsan_atomic32_store(&a, 100, __tsan_memory_order_release);
|
||||
int res = __tsan_atomic32_load(&a, __tsan_memory_order_acquire);
|
||||
if (res == 100) {
|
||||
// CHECK: PASS
|
||||
printf("PASS\n");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include "sanitizer_common/sanitizer_placement_new.h"
|
||||
#include "sanitizer_common/sanitizer_stacktrace.h"
|
||||
#include "tsan_interface_atomic.h"
|
||||
#include "tsan_flags.h"
|
||||
#include "tsan_rtl.h"
|
||||
|
||||
@ -38,19 +37,29 @@ using namespace __tsan; // NOLINT
|
||||
return Atomic##func(thr, pc, __VA_ARGS__); \
|
||||
/**/
|
||||
|
||||
// Some shortcuts.
|
||||
typedef __tsan_memory_order morder;
|
||||
typedef __tsan_atomic8 a8;
|
||||
typedef __tsan_atomic16 a16;
|
||||
typedef __tsan_atomic32 a32;
|
||||
typedef __tsan_atomic64 a64;
|
||||
typedef __tsan_atomic128 a128;
|
||||
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;
|
||||
// These should match declarations from public tsan_interface_atomic.h header.
|
||||
typedef char a8;
|
||||
typedef short a16; // NOLINT
|
||||
typedef int a32;
|
||||
typedef long a64; // NOLINT
|
||||
#if defined(__SIZEOF_INT128__) \
|
||||
|| (__clang_major__ * 100 + __clang_minor__ >= 302)
|
||||
__extension__ typedef __int128 a128;
|
||||
# define __TSAN_HAS_INT128 1
|
||||
#else
|
||||
# define __TSAN_HAS_INT128 0
|
||||
#endif
|
||||
|
||||
// Part of ABI, do not change.
|
||||
// http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/atomic?view=markup
|
||||
typedef enum {
|
||||
mo_relaxed,
|
||||
mo_consume,
|
||||
mo_acquire,
|
||||
mo_release,
|
||||
mo_acq_rel,
|
||||
mo_seq_cst
|
||||
} morder;
|
||||
|
||||
class ScopedAtomic {
|
||||
public:
|
||||
@ -392,288 +401,353 @@ static void AtomicFence(ThreadState *thr, uptr pc, morder mo) {
|
||||
__sync_synchronize();
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a8 __tsan_atomic8_load(const volatile a8 *a, morder mo) {
|
||||
SCOPED_ATOMIC(Load, a, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a16 __tsan_atomic16_load(const volatile a16 *a, morder mo) {
|
||||
SCOPED_ATOMIC(Load, a, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a32 __tsan_atomic32_load(const volatile a32 *a, morder mo) {
|
||||
SCOPED_ATOMIC(Load, a, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a64 __tsan_atomic64_load(const volatile a64 *a, morder mo) {
|
||||
SCOPED_ATOMIC(Load, a, mo);
|
||||
}
|
||||
|
||||
#if __TSAN_HAS_INT128
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a128 __tsan_atomic128_load(const volatile a128 *a, morder mo) {
|
||||
SCOPED_ATOMIC(Load, a, mo);
|
||||
}
|
||||
#endif
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
void __tsan_atomic8_store(volatile a8 *a, a8 v, morder mo) {
|
||||
SCOPED_ATOMIC(Store, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
void __tsan_atomic16_store(volatile a16 *a, a16 v, morder mo) {
|
||||
SCOPED_ATOMIC(Store, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
void __tsan_atomic32_store(volatile a32 *a, a32 v, morder mo) {
|
||||
SCOPED_ATOMIC(Store, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
void __tsan_atomic64_store(volatile a64 *a, a64 v, morder mo) {
|
||||
SCOPED_ATOMIC(Store, a, v, mo);
|
||||
}
|
||||
|
||||
#if __TSAN_HAS_INT128
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
void __tsan_atomic128_store(volatile a128 *a, a128 v, morder mo) {
|
||||
SCOPED_ATOMIC(Store, a, v, mo);
|
||||
}
|
||||
#endif
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a8 __tsan_atomic8_exchange(volatile a8 *a, a8 v, morder mo) {
|
||||
SCOPED_ATOMIC(Exchange, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a16 __tsan_atomic16_exchange(volatile a16 *a, a16 v, morder mo) {
|
||||
SCOPED_ATOMIC(Exchange, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a32 __tsan_atomic32_exchange(volatile a32 *a, a32 v, morder mo) {
|
||||
SCOPED_ATOMIC(Exchange, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a64 __tsan_atomic64_exchange(volatile a64 *a, a64 v, morder mo) {
|
||||
SCOPED_ATOMIC(Exchange, a, v, mo);
|
||||
}
|
||||
|
||||
#if __TSAN_HAS_INT128
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a128 __tsan_atomic128_exchange(volatile a128 *a, a128 v, morder mo) {
|
||||
SCOPED_ATOMIC(Exchange, a, v, mo);
|
||||
}
|
||||
#endif
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a8 __tsan_atomic8_fetch_add(volatile a8 *a, a8 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchAdd, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a16 __tsan_atomic16_fetch_add(volatile a16 *a, a16 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchAdd, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a32 __tsan_atomic32_fetch_add(volatile a32 *a, a32 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchAdd, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a64 __tsan_atomic64_fetch_add(volatile a64 *a, a64 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchAdd, a, v, mo);
|
||||
}
|
||||
|
||||
#if __TSAN_HAS_INT128
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a128 __tsan_atomic128_fetch_add(volatile a128 *a, a128 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchAdd, a, v, mo);
|
||||
}
|
||||
#endif
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a8 __tsan_atomic8_fetch_sub(volatile a8 *a, a8 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchSub, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a16 __tsan_atomic16_fetch_sub(volatile a16 *a, a16 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchSub, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a32 __tsan_atomic32_fetch_sub(volatile a32 *a, a32 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchSub, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a64 __tsan_atomic64_fetch_sub(volatile a64 *a, a64 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchSub, a, v, mo);
|
||||
}
|
||||
|
||||
#if __TSAN_HAS_INT128
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a128 __tsan_atomic128_fetch_sub(volatile a128 *a, a128 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchSub, a, v, mo);
|
||||
}
|
||||
#endif
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a8 __tsan_atomic8_fetch_and(volatile a8 *a, a8 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchAnd, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a16 __tsan_atomic16_fetch_and(volatile a16 *a, a16 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchAnd, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a32 __tsan_atomic32_fetch_and(volatile a32 *a, a32 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchAnd, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a64 __tsan_atomic64_fetch_and(volatile a64 *a, a64 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchAnd, a, v, mo);
|
||||
}
|
||||
|
||||
#if __TSAN_HAS_INT128
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a128 __tsan_atomic128_fetch_and(volatile a128 *a, a128 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchAnd, a, v, mo);
|
||||
}
|
||||
#endif
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a8 __tsan_atomic8_fetch_or(volatile a8 *a, a8 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchOr, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a16 __tsan_atomic16_fetch_or(volatile a16 *a, a16 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchOr, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a32 __tsan_atomic32_fetch_or(volatile a32 *a, a32 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchOr, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a64 __tsan_atomic64_fetch_or(volatile a64 *a, a64 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchOr, a, v, mo);
|
||||
}
|
||||
|
||||
#if __TSAN_HAS_INT128
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a128 __tsan_atomic128_fetch_or(volatile a128 *a, a128 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchOr, a, v, mo);
|
||||
}
|
||||
#endif
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a8 __tsan_atomic8_fetch_xor(volatile a8 *a, a8 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchXor, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a16 __tsan_atomic16_fetch_xor(volatile a16 *a, a16 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchXor, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a32 __tsan_atomic32_fetch_xor(volatile a32 *a, a32 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchXor, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a64 __tsan_atomic64_fetch_xor(volatile a64 *a, a64 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchXor, a, v, mo);
|
||||
}
|
||||
|
||||
#if __TSAN_HAS_INT128
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a128 __tsan_atomic128_fetch_xor(volatile a128 *a, a128 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchXor, a, v, mo);
|
||||
}
|
||||
#endif
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a8 __tsan_atomic8_fetch_nand(volatile a8 *a, a8 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchNand, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a16 __tsan_atomic16_fetch_nand(volatile a16 *a, a16 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchNand, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a32 __tsan_atomic32_fetch_nand(volatile a32 *a, a32 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchNand, a, v, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a64 __tsan_atomic64_fetch_nand(volatile a64 *a, a64 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchNand, a, v, mo);
|
||||
}
|
||||
|
||||
#if __TSAN_HAS_INT128
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a128 __tsan_atomic128_fetch_nand(volatile a128 *a, a128 v, morder mo) {
|
||||
SCOPED_ATOMIC(FetchNand, a, v, mo);
|
||||
}
|
||||
#endif
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
int __tsan_atomic8_compare_exchange_strong(volatile a8 *a, a8 *c, a8 v,
|
||||
morder mo, morder fmo) {
|
||||
SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
int __tsan_atomic16_compare_exchange_strong(volatile a16 *a, a16 *c, a16 v,
|
||||
morder mo, morder fmo) {
|
||||
SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
int __tsan_atomic32_compare_exchange_strong(volatile a32 *a, a32 *c, a32 v,
|
||||
morder mo, morder fmo) {
|
||||
SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
int __tsan_atomic64_compare_exchange_strong(volatile a64 *a, a64 *c, a64 v,
|
||||
morder mo, morder fmo) {
|
||||
SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
|
||||
}
|
||||
|
||||
#if __TSAN_HAS_INT128
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
int __tsan_atomic128_compare_exchange_strong(volatile a128 *a, a128 *c, a128 v,
|
||||
morder mo, morder fmo) {
|
||||
SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
|
||||
}
|
||||
#endif
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
int __tsan_atomic8_compare_exchange_weak(volatile a8 *a, a8 *c, a8 v,
|
||||
morder mo, morder fmo) {
|
||||
SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
int __tsan_atomic16_compare_exchange_weak(volatile a16 *a, a16 *c, a16 v,
|
||||
morder mo, morder fmo) {
|
||||
SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
int __tsan_atomic32_compare_exchange_weak(volatile a32 *a, a32 *c, a32 v,
|
||||
morder mo, morder fmo) {
|
||||
SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
int __tsan_atomic64_compare_exchange_weak(volatile a64 *a, a64 *c, a64 v,
|
||||
morder mo, morder fmo) {
|
||||
SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
|
||||
}
|
||||
|
||||
#if __TSAN_HAS_INT128
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
int __tsan_atomic128_compare_exchange_weak(volatile a128 *a, a128 *c, a128 v,
|
||||
morder mo, morder fmo) {
|
||||
SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
|
||||
}
|
||||
#endif
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a8 __tsan_atomic8_compare_exchange_val(volatile a8 *a, a8 c, a8 v,
|
||||
morder mo, morder fmo) {
|
||||
SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a16 __tsan_atomic16_compare_exchange_val(volatile a16 *a, a16 c, a16 v,
|
||||
morder mo, morder fmo) {
|
||||
SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a32 __tsan_atomic32_compare_exchange_val(volatile a32 *a, a32 c, a32 v,
|
||||
morder mo, morder fmo) {
|
||||
SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a64 __tsan_atomic64_compare_exchange_val(volatile a64 *a, a64 c, a64 v,
|
||||
morder mo, morder fmo) {
|
||||
SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
|
||||
}
|
||||
|
||||
#if __TSAN_HAS_INT128
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
a128 __tsan_atomic128_compare_exchange_val(volatile a128 *a, a128 c, a128 v,
|
||||
morder mo, morder fmo) {
|
||||
SCOPED_ATOMIC(CAS, a, c, v, mo, fmo);
|
||||
}
|
||||
#endif
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
void __tsan_atomic_thread_fence(morder mo) {
|
||||
char* a = 0;
|
||||
SCOPED_ATOMIC(Fence, mo);
|
||||
}
|
||||
|
||||
SANITIZER_INTERFACE_ATTRIBUTE
|
||||
void __tsan_atomic_signal_fence(morder mo) {
|
||||
}
|
||||
} // extern "C"
|
||||
|
Loading…
Reference in New Issue
Block a user