tsan_interface_atomic.h revision 276789
1276789Sdim//===-- tsan_interface_atomic.h ---------------------------------*- C++ -*-===// 2276789Sdim// 3276789Sdim// The LLVM Compiler Infrastructure 4276789Sdim// 5276789Sdim// This file is distributed under the University of Illinois Open Source 6276789Sdim// License. See LICENSE.TXT for details. 7276789Sdim// 8276789Sdim//===----------------------------------------------------------------------===// 9276789Sdim// 10276789Sdim// This file is a part of ThreadSanitizer (TSan), a race detector. 11276789Sdim// 12276789Sdim// Public interface header for TSan atomics. 13276789Sdim//===----------------------------------------------------------------------===// 14276789Sdim#ifndef TSAN_INTERFACE_ATOMIC_H 15276789Sdim#define TSAN_INTERFACE_ATOMIC_H 16276789Sdim 17276789Sdim#ifdef __cplusplus 18276789Sdimextern "C" { 19276789Sdim#endif 20276789Sdim 21276789Sdimtypedef char __tsan_atomic8; 22276789Sdimtypedef short __tsan_atomic16; // NOLINT 23276789Sdimtypedef int __tsan_atomic32; 24276789Sdimtypedef long __tsan_atomic64; // NOLINT 25276789Sdim#if defined(__SIZEOF_INT128__) \ 26276789Sdim || (__clang_major__ * 100 + __clang_minor__ >= 302) 27276789Sdim__extension__ typedef __int128 __tsan_atomic128; 28276789Sdim# define __TSAN_HAS_INT128 1 29276789Sdim#else 30276789Sdim# define __TSAN_HAS_INT128 0 31276789Sdim#endif 32276789Sdim 33276789Sdim// Part of ABI, do not change. 34276789Sdim// http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/atomic?view=markup 35276789Sdimtypedef enum { 36276789Sdim __tsan_memory_order_relaxed, 37276789Sdim __tsan_memory_order_consume, 38276789Sdim __tsan_memory_order_acquire, 39276789Sdim __tsan_memory_order_release, 40276789Sdim __tsan_memory_order_acq_rel, 41276789Sdim __tsan_memory_order_seq_cst 42276789Sdim} __tsan_memory_order; 43276789Sdim 44276789Sdim__tsan_atomic8 __tsan_atomic8_load(const volatile __tsan_atomic8 *a, 45276789Sdim __tsan_memory_order mo); 46276789Sdim__tsan_atomic16 __tsan_atomic16_load(const volatile __tsan_atomic16 *a, 47276789Sdim __tsan_memory_order mo); 48276789Sdim__tsan_atomic32 __tsan_atomic32_load(const volatile __tsan_atomic32 *a, 49276789Sdim __tsan_memory_order mo); 50276789Sdim__tsan_atomic64 __tsan_atomic64_load(const volatile __tsan_atomic64 *a, 51276789Sdim __tsan_memory_order mo); 52276789Sdim#if __TSAN_HAS_INT128 53276789Sdim__tsan_atomic128 __tsan_atomic128_load(const volatile __tsan_atomic128 *a, 54276789Sdim __tsan_memory_order mo); 55276789Sdim#endif 56276789Sdim 57276789Sdimvoid __tsan_atomic8_store(volatile __tsan_atomic8 *a, __tsan_atomic8 v, 58276789Sdim __tsan_memory_order mo); 59276789Sdimvoid __tsan_atomic16_store(volatile __tsan_atomic16 *a, __tsan_atomic16 v, 60276789Sdim __tsan_memory_order mo); 61276789Sdimvoid __tsan_atomic32_store(volatile __tsan_atomic32 *a, __tsan_atomic32 v, 62276789Sdim __tsan_memory_order mo); 63276789Sdimvoid __tsan_atomic64_store(volatile __tsan_atomic64 *a, __tsan_atomic64 v, 64276789Sdim __tsan_memory_order mo); 65276789Sdim#if __TSAN_HAS_INT128 66276789Sdimvoid __tsan_atomic128_store(volatile __tsan_atomic128 *a, __tsan_atomic128 v, 67276789Sdim __tsan_memory_order mo); 68276789Sdim#endif 69276789Sdim 70276789Sdim__tsan_atomic8 __tsan_atomic8_exchange(volatile __tsan_atomic8 *a, 71276789Sdim __tsan_atomic8 v, __tsan_memory_order mo); 72276789Sdim__tsan_atomic16 __tsan_atomic16_exchange(volatile __tsan_atomic16 *a, 73276789Sdim __tsan_atomic16 v, __tsan_memory_order mo); 74276789Sdim__tsan_atomic32 __tsan_atomic32_exchange(volatile __tsan_atomic32 *a, 75276789Sdim __tsan_atomic32 v, __tsan_memory_order mo); 76276789Sdim__tsan_atomic64 __tsan_atomic64_exchange(volatile __tsan_atomic64 *a, 77276789Sdim __tsan_atomic64 v, __tsan_memory_order mo); 78276789Sdim#if __TSAN_HAS_INT128 79276789Sdim__tsan_atomic128 __tsan_atomic128_exchange(volatile __tsan_atomic128 *a, 80276789Sdim __tsan_atomic128 v, __tsan_memory_order mo); 81276789Sdim#endif 82276789Sdim 83276789Sdim__tsan_atomic8 __tsan_atomic8_fetch_add(volatile __tsan_atomic8 *a, 84276789Sdim __tsan_atomic8 v, __tsan_memory_order mo); 85276789Sdim__tsan_atomic16 __tsan_atomic16_fetch_add(volatile __tsan_atomic16 *a, 86276789Sdim __tsan_atomic16 v, __tsan_memory_order mo); 87276789Sdim__tsan_atomic32 __tsan_atomic32_fetch_add(volatile __tsan_atomic32 *a, 88276789Sdim __tsan_atomic32 v, __tsan_memory_order mo); 89276789Sdim__tsan_atomic64 __tsan_atomic64_fetch_add(volatile __tsan_atomic64 *a, 90276789Sdim __tsan_atomic64 v, __tsan_memory_order mo); 91276789Sdim#if __TSAN_HAS_INT128 92276789Sdim__tsan_atomic128 __tsan_atomic128_fetch_add(volatile __tsan_atomic128 *a, 93276789Sdim __tsan_atomic128 v, __tsan_memory_order mo); 94276789Sdim#endif 95276789Sdim 96276789Sdim__tsan_atomic8 __tsan_atomic8_fetch_sub(volatile __tsan_atomic8 *a, 97276789Sdim __tsan_atomic8 v, __tsan_memory_order mo); 98276789Sdim__tsan_atomic16 __tsan_atomic16_fetch_sub(volatile __tsan_atomic16 *a, 99276789Sdim __tsan_atomic16 v, __tsan_memory_order mo); 100276789Sdim__tsan_atomic32 __tsan_atomic32_fetch_sub(volatile __tsan_atomic32 *a, 101276789Sdim __tsan_atomic32 v, __tsan_memory_order mo); 102276789Sdim__tsan_atomic64 __tsan_atomic64_fetch_sub(volatile __tsan_atomic64 *a, 103276789Sdim __tsan_atomic64 v, __tsan_memory_order mo); 104276789Sdim#if __TSAN_HAS_INT128 105276789Sdim__tsan_atomic128 __tsan_atomic128_fetch_sub(volatile __tsan_atomic128 *a, 106276789Sdim __tsan_atomic128 v, __tsan_memory_order mo); 107276789Sdim#endif 108276789Sdim 109276789Sdim__tsan_atomic8 __tsan_atomic8_fetch_and(volatile __tsan_atomic8 *a, 110276789Sdim __tsan_atomic8 v, __tsan_memory_order mo); 111276789Sdim__tsan_atomic16 __tsan_atomic16_fetch_and(volatile __tsan_atomic16 *a, 112276789Sdim __tsan_atomic16 v, __tsan_memory_order mo); 113276789Sdim__tsan_atomic32 __tsan_atomic32_fetch_and(volatile __tsan_atomic32 *a, 114276789Sdim __tsan_atomic32 v, __tsan_memory_order mo); 115276789Sdim__tsan_atomic64 __tsan_atomic64_fetch_and(volatile __tsan_atomic64 *a, 116276789Sdim __tsan_atomic64 v, __tsan_memory_order mo); 117276789Sdim#if __TSAN_HAS_INT128 118276789Sdim__tsan_atomic128 __tsan_atomic128_fetch_and(volatile __tsan_atomic128 *a, 119276789Sdim __tsan_atomic128 v, __tsan_memory_order mo); 120276789Sdim#endif 121276789Sdim 122276789Sdim__tsan_atomic8 __tsan_atomic8_fetch_or(volatile __tsan_atomic8 *a, 123276789Sdim __tsan_atomic8 v, __tsan_memory_order mo); 124276789Sdim__tsan_atomic16 __tsan_atomic16_fetch_or(volatile __tsan_atomic16 *a, 125276789Sdim __tsan_atomic16 v, __tsan_memory_order mo); 126276789Sdim__tsan_atomic32 __tsan_atomic32_fetch_or(volatile __tsan_atomic32 *a, 127276789Sdim __tsan_atomic32 v, __tsan_memory_order mo); 128276789Sdim__tsan_atomic64 __tsan_atomic64_fetch_or(volatile __tsan_atomic64 *a, 129276789Sdim __tsan_atomic64 v, __tsan_memory_order mo); 130276789Sdim#if __TSAN_HAS_INT128 131276789Sdim__tsan_atomic128 __tsan_atomic128_fetch_or(volatile __tsan_atomic128 *a, 132276789Sdim __tsan_atomic128 v, __tsan_memory_order mo); 133276789Sdim#endif 134276789Sdim 135276789Sdim__tsan_atomic8 __tsan_atomic8_fetch_xor(volatile __tsan_atomic8 *a, 136276789Sdim __tsan_atomic8 v, __tsan_memory_order mo); 137276789Sdim__tsan_atomic16 __tsan_atomic16_fetch_xor(volatile __tsan_atomic16 *a, 138276789Sdim __tsan_atomic16 v, __tsan_memory_order mo); 139276789Sdim__tsan_atomic32 __tsan_atomic32_fetch_xor(volatile __tsan_atomic32 *a, 140276789Sdim __tsan_atomic32 v, __tsan_memory_order mo); 141276789Sdim__tsan_atomic64 __tsan_atomic64_fetch_xor(volatile __tsan_atomic64 *a, 142276789Sdim __tsan_atomic64 v, __tsan_memory_order mo); 143276789Sdim#if __TSAN_HAS_INT128 144276789Sdim__tsan_atomic128 __tsan_atomic128_fetch_xor(volatile __tsan_atomic128 *a, 145276789Sdim __tsan_atomic128 v, __tsan_memory_order mo); 146276789Sdim#endif 147276789Sdim 148276789Sdim__tsan_atomic8 __tsan_atomic8_fetch_nand(volatile __tsan_atomic8 *a, 149276789Sdim __tsan_atomic8 v, __tsan_memory_order mo); 150276789Sdim__tsan_atomic16 __tsan_atomic16_fetch_nand(volatile __tsan_atomic16 *a, 151276789Sdim __tsan_atomic16 v, __tsan_memory_order mo); 152276789Sdim__tsan_atomic32 __tsan_atomic32_fetch_nand(volatile __tsan_atomic32 *a, 153276789Sdim __tsan_atomic32 v, __tsan_memory_order mo); 154276789Sdim__tsan_atomic64 __tsan_atomic64_fetch_nand(volatile __tsan_atomic64 *a, 155276789Sdim __tsan_atomic64 v, __tsan_memory_order mo); 156276789Sdim#if __TSAN_HAS_INT128 157276789Sdim__tsan_atomic128 __tsan_atomic128_fetch_nand(volatile __tsan_atomic128 *a, 158276789Sdim __tsan_atomic128 v, __tsan_memory_order mo); 159276789Sdim#endif 160276789Sdim 161276789Sdimint __tsan_atomic8_compare_exchange_weak(volatile __tsan_atomic8 *a, 162276789Sdim __tsan_atomic8 *c, __tsan_atomic8 v, __tsan_memory_order mo, 163276789Sdim __tsan_memory_order fail_mo); 164276789Sdimint __tsan_atomic16_compare_exchange_weak(volatile __tsan_atomic16 *a, 165276789Sdim __tsan_atomic16 *c, __tsan_atomic16 v, __tsan_memory_order mo, 166276789Sdim __tsan_memory_order fail_mo); 167276789Sdimint __tsan_atomic32_compare_exchange_weak(volatile __tsan_atomic32 *a, 168276789Sdim __tsan_atomic32 *c, __tsan_atomic32 v, __tsan_memory_order mo, 169276789Sdim __tsan_memory_order fail_mo); 170276789Sdimint __tsan_atomic64_compare_exchange_weak(volatile __tsan_atomic64 *a, 171276789Sdim __tsan_atomic64 *c, __tsan_atomic64 v, __tsan_memory_order mo, 172276789Sdim __tsan_memory_order fail_mo); 173276789Sdim#if __TSAN_HAS_INT128 174276789Sdimint __tsan_atomic128_compare_exchange_weak(volatile __tsan_atomic128 *a, 175276789Sdim __tsan_atomic128 *c, __tsan_atomic128 v, __tsan_memory_order mo, 176276789Sdim __tsan_memory_order fail_mo); 177276789Sdim#endif 178276789Sdim 179276789Sdimint __tsan_atomic8_compare_exchange_strong(volatile __tsan_atomic8 *a, 180276789Sdim __tsan_atomic8 *c, __tsan_atomic8 v, __tsan_memory_order mo, 181276789Sdim __tsan_memory_order fail_mo); 182276789Sdimint __tsan_atomic16_compare_exchange_strong(volatile __tsan_atomic16 *a, 183276789Sdim __tsan_atomic16 *c, __tsan_atomic16 v, __tsan_memory_order mo, 184276789Sdim __tsan_memory_order fail_mo); 185276789Sdimint __tsan_atomic32_compare_exchange_strong(volatile __tsan_atomic32 *a, 186276789Sdim __tsan_atomic32 *c, __tsan_atomic32 v, __tsan_memory_order mo, 187276789Sdim __tsan_memory_order fail_mo); 188276789Sdimint __tsan_atomic64_compare_exchange_strong(volatile __tsan_atomic64 *a, 189276789Sdim __tsan_atomic64 *c, __tsan_atomic64 v, __tsan_memory_order mo, 190276789Sdim __tsan_memory_order fail_mo); 191276789Sdim#if __TSAN_HAS_INT128 192276789Sdimint __tsan_atomic128_compare_exchange_strong(volatile __tsan_atomic128 *a, 193276789Sdim __tsan_atomic128 *c, __tsan_atomic128 v, __tsan_memory_order mo, 194276789Sdim __tsan_memory_order fail_mo); 195276789Sdim#endif 196276789Sdim 197276789Sdim__tsan_atomic8 __tsan_atomic8_compare_exchange_val( 198276789Sdim volatile __tsan_atomic8 *a, __tsan_atomic8 c, __tsan_atomic8 v, 199276789Sdim __tsan_memory_order mo, __tsan_memory_order fail_mo); 200276789Sdim__tsan_atomic16 __tsan_atomic16_compare_exchange_val( 201276789Sdim volatile __tsan_atomic16 *a, __tsan_atomic16 c, __tsan_atomic16 v, 202276789Sdim __tsan_memory_order mo, __tsan_memory_order fail_mo); 203276789Sdim__tsan_atomic32 __tsan_atomic32_compare_exchange_val( 204276789Sdim volatile __tsan_atomic32 *a, __tsan_atomic32 c, __tsan_atomic32 v, 205276789Sdim __tsan_memory_order mo, __tsan_memory_order fail_mo); 206276789Sdim__tsan_atomic64 __tsan_atomic64_compare_exchange_val( 207276789Sdim volatile __tsan_atomic64 *a, __tsan_atomic64 c, __tsan_atomic64 v, 208276789Sdim __tsan_memory_order mo, __tsan_memory_order fail_mo); 209276789Sdim#if __TSAN_HAS_INT128 210276789Sdim__tsan_atomic128 __tsan_atomic128_compare_exchange_val( 211276789Sdim volatile __tsan_atomic128 *a, __tsan_atomic128 c, __tsan_atomic128 v, 212276789Sdim __tsan_memory_order mo, __tsan_memory_order fail_mo); 213276789Sdim#endif 214276789Sdim 215276789Sdimvoid __tsan_atomic_thread_fence(__tsan_memory_order mo); 216276789Sdimvoid __tsan_atomic_signal_fence(__tsan_memory_order mo); 217276789Sdim 218276789Sdim#ifdef __cplusplus 219276789Sdim} // extern "C" 220276789Sdim#endif 221276789Sdim 222276789Sdim#endif // TSAN_INTERFACE_ATOMIC_H 223