tsan_interface_atomic.h 9.5 KB

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