tsan_interface_atomic.h 9.5 KB

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