1 //===-- tsan_interface_atomic.h ---------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file is a part of ThreadSanitizer (TSan), a race detector. 11 // 12 //===----------------------------------------------------------------------===// 13 #ifndef TSAN_INTERFACE_ATOMIC_H 14 #define TSAN_INTERFACE_ATOMIC_H 15 16 #ifndef INTERFACE_ATTRIBUTE 17 # define INTERFACE_ATTRIBUTE __attribute__((visibility("default"))) 18 #endif 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 typedef char __tsan_atomic8; 25 typedef short __tsan_atomic16; // NOLINT 26 typedef int __tsan_atomic32; 27 typedef long __tsan_atomic64; // NOLINT 28 29 #if defined(__SIZEOF_INT128__) \ 30 || (__clang_major__ * 100 + __clang_minor__ >= 302) 31 __extension__ typedef __int128 __tsan_atomic128; 32 #define __TSAN_HAS_INT128 1 33 #else 34 typedef char __tsan_atomic128; 35 #define __TSAN_HAS_INT128 0 36 #endif 37 38 // Part of ABI, do not change. 39 // http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/atomic?view=markup 40 typedef enum { 41 __tsan_memory_order_relaxed, 42 __tsan_memory_order_consume, 43 __tsan_memory_order_acquire, 44 __tsan_memory_order_release, 45 __tsan_memory_order_acq_rel, 46 __tsan_memory_order_seq_cst 47 } __tsan_memory_order; 48 49 __tsan_atomic8 __tsan_atomic8_load(const volatile __tsan_atomic8 *a, 50 __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 51 __tsan_atomic16 __tsan_atomic16_load(const volatile __tsan_atomic16 *a, 52 __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 53 __tsan_atomic32 __tsan_atomic32_load(const volatile __tsan_atomic32 *a, 54 __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 55 __tsan_atomic64 __tsan_atomic64_load(const volatile __tsan_atomic64 *a, 56 __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 57 __tsan_atomic128 __tsan_atomic128_load(const volatile __tsan_atomic128 *a, 58 __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 59 60 void __tsan_atomic8_store(volatile __tsan_atomic8 *a, __tsan_atomic8 v, 61 __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 62 void __tsan_atomic16_store(volatile __tsan_atomic16 *a, __tsan_atomic16 v, 63 __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 64 void __tsan_atomic32_store(volatile __tsan_atomic32 *a, __tsan_atomic32 v, 65 __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 66 void __tsan_atomic64_store(volatile __tsan_atomic64 *a, __tsan_atomic64 v, 67 __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 68 void __tsan_atomic128_store(volatile __tsan_atomic128 *a, __tsan_atomic128 v, 69 __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 70 71 __tsan_atomic8 __tsan_atomic8_exchange(volatile __tsan_atomic8 *a, 72 __tsan_atomic8 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 73 __tsan_atomic16 __tsan_atomic16_exchange(volatile __tsan_atomic16 *a, 74 __tsan_atomic16 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 75 __tsan_atomic32 __tsan_atomic32_exchange(volatile __tsan_atomic32 *a, 76 __tsan_atomic32 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 77 __tsan_atomic64 __tsan_atomic64_exchange(volatile __tsan_atomic64 *a, 78 __tsan_atomic64 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 79 __tsan_atomic128 __tsan_atomic128_exchange(volatile __tsan_atomic128 *a, 80 __tsan_atomic128 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 81 82 __tsan_atomic8 __tsan_atomic8_fetch_add(volatile __tsan_atomic8 *a, 83 __tsan_atomic8 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 84 __tsan_atomic16 __tsan_atomic16_fetch_add(volatile __tsan_atomic16 *a, 85 __tsan_atomic16 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 86 __tsan_atomic32 __tsan_atomic32_fetch_add(volatile __tsan_atomic32 *a, 87 __tsan_atomic32 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 88 __tsan_atomic64 __tsan_atomic64_fetch_add(volatile __tsan_atomic64 *a, 89 __tsan_atomic64 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 90 __tsan_atomic128 __tsan_atomic128_fetch_add(volatile __tsan_atomic128 *a, 91 __tsan_atomic128 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 92 93 __tsan_atomic8 __tsan_atomic8_fetch_sub(volatile __tsan_atomic8 *a, 94 __tsan_atomic8 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 95 __tsan_atomic16 __tsan_atomic16_fetch_sub(volatile __tsan_atomic16 *a, 96 __tsan_atomic16 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 97 __tsan_atomic32 __tsan_atomic32_fetch_sub(volatile __tsan_atomic32 *a, 98 __tsan_atomic32 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 99 __tsan_atomic64 __tsan_atomic64_fetch_sub(volatile __tsan_atomic64 *a, 100 __tsan_atomic64 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 101 __tsan_atomic128 __tsan_atomic128_fetch_sub(volatile __tsan_atomic128 *a, 102 __tsan_atomic128 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 103 104 __tsan_atomic8 __tsan_atomic8_fetch_and(volatile __tsan_atomic8 *a, 105 __tsan_atomic8 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 106 __tsan_atomic16 __tsan_atomic16_fetch_and(volatile __tsan_atomic16 *a, 107 __tsan_atomic16 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 108 __tsan_atomic32 __tsan_atomic32_fetch_and(volatile __tsan_atomic32 *a, 109 __tsan_atomic32 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 110 __tsan_atomic64 __tsan_atomic64_fetch_and(volatile __tsan_atomic64 *a, 111 __tsan_atomic64 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 112 __tsan_atomic128 __tsan_atomic128_fetch_and(volatile __tsan_atomic128 *a, 113 __tsan_atomic128 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 114 115 __tsan_atomic8 __tsan_atomic8_fetch_or(volatile __tsan_atomic8 *a, 116 __tsan_atomic8 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 117 __tsan_atomic16 __tsan_atomic16_fetch_or(volatile __tsan_atomic16 *a, 118 __tsan_atomic16 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 119 __tsan_atomic32 __tsan_atomic32_fetch_or(volatile __tsan_atomic32 *a, 120 __tsan_atomic32 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 121 __tsan_atomic64 __tsan_atomic64_fetch_or(volatile __tsan_atomic64 *a, 122 __tsan_atomic64 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 123 __tsan_atomic128 __tsan_atomic128_fetch_or(volatile __tsan_atomic128 *a, 124 __tsan_atomic128 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 125 126 __tsan_atomic8 __tsan_atomic8_fetch_xor(volatile __tsan_atomic8 *a, 127 __tsan_atomic8 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 128 __tsan_atomic16 __tsan_atomic16_fetch_xor(volatile __tsan_atomic16 *a, 129 __tsan_atomic16 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 130 __tsan_atomic32 __tsan_atomic32_fetch_xor(volatile __tsan_atomic32 *a, 131 __tsan_atomic32 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 132 __tsan_atomic64 __tsan_atomic64_fetch_xor(volatile __tsan_atomic64 *a, 133 __tsan_atomic64 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 134 __tsan_atomic128 __tsan_atomic128_fetch_xor(volatile __tsan_atomic128 *a, 135 __tsan_atomic128 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 136 137 __tsan_atomic8 __tsan_atomic8_fetch_nand(volatile __tsan_atomic8 *a, 138 __tsan_atomic8 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 139 __tsan_atomic16 __tsan_atomic16_fetch_nand(volatile __tsan_atomic16 *a, 140 __tsan_atomic16 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 141 __tsan_atomic32 __tsan_atomic32_fetch_nand(volatile __tsan_atomic32 *a, 142 __tsan_atomic32 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 143 __tsan_atomic64 __tsan_atomic64_fetch_nand(volatile __tsan_atomic64 *a, 144 __tsan_atomic64 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 145 __tsan_atomic128 __tsan_atomic128_fetch_nand(volatile __tsan_atomic128 *a, 146 __tsan_atomic128 v, __tsan_memory_order mo) INTERFACE_ATTRIBUTE; 147 148 int __tsan_atomic8_compare_exchange_weak(volatile __tsan_atomic8 *a, 149 __tsan_atomic8 *c, __tsan_atomic8 v, __tsan_memory_order mo, 150 __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE; 151 int __tsan_atomic16_compare_exchange_weak(volatile __tsan_atomic16 *a, 152 __tsan_atomic16 *c, __tsan_atomic16 v, __tsan_memory_order mo, 153 __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE; 154 int __tsan_atomic32_compare_exchange_weak(volatile __tsan_atomic32 *a, 155 __tsan_atomic32 *c, __tsan_atomic32 v, __tsan_memory_order mo, 156 __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE; 157 int __tsan_atomic64_compare_exchange_weak(volatile __tsan_atomic64 *a, 158 __tsan_atomic64 *c, __tsan_atomic64 v, __tsan_memory_order mo, 159 __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE; 160 int __tsan_atomic128_compare_exchange_weak(volatile __tsan_atomic128 *a, 161 __tsan_atomic128 *c, __tsan_atomic128 v, __tsan_memory_order mo, 162 __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE; 163 164 int __tsan_atomic8_compare_exchange_strong(volatile __tsan_atomic8 *a, 165 __tsan_atomic8 *c, __tsan_atomic8 v, __tsan_memory_order mo, 166 __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE; 167 int __tsan_atomic16_compare_exchange_strong(volatile __tsan_atomic16 *a, 168 __tsan_atomic16 *c, __tsan_atomic16 v, __tsan_memory_order mo, 169 __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE; 170 int __tsan_atomic32_compare_exchange_strong(volatile __tsan_atomic32 *a, 171 __tsan_atomic32 *c, __tsan_atomic32 v, __tsan_memory_order mo, 172 __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE; 173 int __tsan_atomic64_compare_exchange_strong(volatile __tsan_atomic64 *a, 174 __tsan_atomic64 *c, __tsan_atomic64 v, __tsan_memory_order mo, 175 __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE; 176 int __tsan_atomic128_compare_exchange_strong(volatile __tsan_atomic128 *a, 177 __tsan_atomic128 *c, __tsan_atomic128 v, __tsan_memory_order mo, 178 __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE; 179 180 __tsan_atomic8 __tsan_atomic8_compare_exchange_val( 181 volatile __tsan_atomic8 *a, __tsan_atomic8 c, __tsan_atomic8 v, 182 __tsan_memory_order mo, __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE; 183 __tsan_atomic16 __tsan_atomic16_compare_exchange_val( 184 volatile __tsan_atomic16 *a, __tsan_atomic16 c, __tsan_atomic16 v, 185 __tsan_memory_order mo, __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE; 186 __tsan_atomic32 __tsan_atomic32_compare_exchange_val( 187 volatile __tsan_atomic32 *a, __tsan_atomic32 c, __tsan_atomic32 v, 188 __tsan_memory_order mo, __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE; 189 __tsan_atomic64 __tsan_atomic64_compare_exchange_val( 190 volatile __tsan_atomic64 *a, __tsan_atomic64 c, __tsan_atomic64 v, 191 __tsan_memory_order mo, __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE; 192 __tsan_atomic128 __tsan_atomic128_compare_exchange_val( 193 volatile __tsan_atomic128 *a, __tsan_atomic128 c, __tsan_atomic128 v, 194 __tsan_memory_order mo, __tsan_memory_order fail_mo) INTERFACE_ATTRIBUTE; 195 196 void __tsan_atomic_thread_fence(__tsan_memory_order mo) INTERFACE_ATTRIBUTE; 197 void __tsan_atomic_signal_fence(__tsan_memory_order mo) INTERFACE_ATTRIBUTE; 198 199 #ifdef __cplusplus 200 } // extern "C" 201 #endif 202 203 #undef INTERFACE_ATTRIBUTE 204 205 #endif // #ifndef TSAN_INTERFACE_ATOMIC_H 206