atomic_design_b.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
  4. <html>
  5. <head>
  6. <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  7. <title>&lt;atomic&gt; design</title>
  8. <link type="text/css" rel="stylesheet" href="menu.css">
  9. <link type="text/css" rel="stylesheet" href="content.css">
  10. </head>
  11. <body>
  12. <div id="menu">
  13. <div>
  14. <a href="https://llvm.org/">LLVM Home</a>
  15. </div>
  16. <div class="submenu">
  17. <label>libc++ Info</label>
  18. <a href="/index.html">About</a>
  19. </div>
  20. <div class="submenu">
  21. <label>Quick Links</label>
  22. <a href="https://lists.llvm.org/mailman/listinfo/cfe-dev">cfe-dev</a>
  23. <a href="https://lists.llvm.org/mailman/listinfo/cfe-commits">cfe-commits</a>
  24. <a href="https://bugs.llvm.org/">Bug Reports</a>
  25. <a href="https://github.com/llvm/llvm-project/tree/master/libcxx/">Browse Sources</a>
  26. </div>
  27. </div>
  28. <div id="content">
  29. <!--*********************************************************************-->
  30. <h1>&lt;atomic&gt; design</h1>
  31. <!--*********************************************************************-->
  32. <p>
  33. This is a variation of design A which puts the burden on the library to arrange
  34. for the correct manipulation of the run time memory ordering arguments, and only
  35. calls the compiler for well-defined memory orderings. I think of this design as
  36. the worst of A and C, instead of the best of A and C. But I offer it as an
  37. option in the spirit of completeness.
  38. </p>
  39. <blockquote><pre>
  40. <font color="#C80000">// type must be trivially copyable</font>
  41. bool __atomic_is_lock_free(const type* atomic_obj);
  42. <font color="#C80000">// type must be trivially copyable</font>
  43. type __atomic_load_relaxed(const volatile type* atomic_obj);
  44. type __atomic_load_consume(const volatile type* atomic_obj);
  45. type __atomic_load_acquire(const volatile type* atomic_obj);
  46. type __atomic_load_seq_cst(const volatile type* atomic_obj);
  47. <font color="#C80000">// type must be trivially copyable</font>
  48. type __atomic_store_relaxed(volatile type* atomic_obj, type desired);
  49. type __atomic_store_release(volatile type* atomic_obj, type desired);
  50. type __atomic_store_seq_cst(volatile type* atomic_obj, type desired);
  51. <font color="#C80000">// type must be trivially copyable</font>
  52. type __atomic_exchange_relaxed(volatile type* atomic_obj, type desired);
  53. type __atomic_exchange_consume(volatile type* atomic_obj, type desired);
  54. type __atomic_exchange_acquire(volatile type* atomic_obj, type desired);
  55. type __atomic_exchange_release(volatile type* atomic_obj, type desired);
  56. type __atomic_exchange_acq_rel(volatile type* atomic_obj, type desired);
  57. type __atomic_exchange_seq_cst(volatile type* atomic_obj, type desired);
  58. <font color="#C80000">// type must be trivially copyable</font>
  59. bool __atomic_compare_exchange_strong_relaxed_relaxed(volatile type* atomic_obj,
  60. type* expected,
  61. type desired);
  62. bool __atomic_compare_exchange_strong_consume_relaxed(volatile type* atomic_obj,
  63. type* expected,
  64. type desired);
  65. bool __atomic_compare_exchange_strong_consume_consume(volatile type* atomic_obj,
  66. type* expected,
  67. type desired);
  68. bool __atomic_compare_exchange_strong_acquire_relaxed(volatile type* atomic_obj,
  69. type* expected,
  70. type desired);
  71. bool __atomic_compare_exchange_strong_acquire_consume(volatile type* atomic_obj,
  72. type* expected,
  73. type desired);
  74. bool __atomic_compare_exchange_strong_acquire_acquire(volatile type* atomic_obj,
  75. type* expected,
  76. type desired);
  77. bool __atomic_compare_exchange_strong_release_relaxed(volatile type* atomic_obj,
  78. type* expected,
  79. type desired);
  80. bool __atomic_compare_exchange_strong_release_consume(volatile type* atomic_obj,
  81. type* expected,
  82. type desired);
  83. bool __atomic_compare_exchange_strong_release_acquire(volatile type* atomic_obj,
  84. type* expected,
  85. type desired);
  86. bool __atomic_compare_exchange_strong_acq_rel_relaxed(volatile type* atomic_obj,
  87. type* expected,
  88. type desired);
  89. bool __atomic_compare_exchange_strong_acq_rel_consume(volatile type* atomic_obj,
  90. type* expected,
  91. type desired);
  92. bool __atomic_compare_exchange_strong_acq_rel_acquire(volatile type* atomic_obj,
  93. type* expected,
  94. type desired);
  95. bool __atomic_compare_exchange_strong_seq_cst_relaxed(volatile type* atomic_obj,
  96. type* expected,
  97. type desired);
  98. bool __atomic_compare_exchange_strong_seq_cst_consume(volatile type* atomic_obj,
  99. type* expected,
  100. type desired);
  101. bool __atomic_compare_exchange_strong_seq_cst_acquire(volatile type* atomic_obj,
  102. type* expected,
  103. type desired);
  104. bool __atomic_compare_exchange_strong_seq_cst_seq_cst(volatile type* atomic_obj,
  105. type* expected,
  106. type desired);
  107. <font color="#C80000">// type must be trivially copyable</font>
  108. bool __atomic_compare_exchange_weak_relaxed_relaxed(volatile type* atomic_obj,
  109. type* expected,
  110. type desired);
  111. bool __atomic_compare_exchange_weak_consume_relaxed(volatile type* atomic_obj,
  112. type* expected,
  113. type desired);
  114. bool __atomic_compare_exchange_weak_consume_consume(volatile type* atomic_obj,
  115. type* expected,
  116. type desired);
  117. bool __atomic_compare_exchange_weak_acquire_relaxed(volatile type* atomic_obj,
  118. type* expected,
  119. type desired);
  120. bool __atomic_compare_exchange_weak_acquire_consume(volatile type* atomic_obj,
  121. type* expected,
  122. type desired);
  123. bool __atomic_compare_exchange_weak_acquire_acquire(volatile type* atomic_obj,
  124. type* expected,
  125. type desired);
  126. bool __atomic_compare_exchange_weak_release_relaxed(volatile type* atomic_obj,
  127. type* expected,
  128. type desired);
  129. bool __atomic_compare_exchange_weak_release_consume(volatile type* atomic_obj,
  130. type* expected,
  131. type desired);
  132. bool __atomic_compare_exchange_weak_release_acquire(volatile type* atomic_obj,
  133. type* expected,
  134. type desired);
  135. bool __atomic_compare_exchange_weak_acq_rel_relaxed(volatile type* atomic_obj,
  136. type* expected,
  137. type desired);
  138. bool __atomic_compare_exchange_weak_acq_rel_consume(volatile type* atomic_obj,
  139. type* expected,
  140. type desired);
  141. bool __atomic_compare_exchange_weak_acq_rel_acquire(volatile type* atomic_obj,
  142. type* expected,
  143. type desired);
  144. bool __atomic_compare_exchange_weak_seq_cst_relaxed(volatile type* atomic_obj,
  145. type* expected,
  146. type desired);
  147. bool __atomic_compare_exchange_weak_seq_cst_consume(volatile type* atomic_obj,
  148. type* expected,
  149. type desired);
  150. bool __atomic_compare_exchange_weak_seq_cst_acquire(volatile type* atomic_obj,
  151. type* expected,
  152. type desired);
  153. bool __atomic_compare_exchange_weak_seq_cst_seq_cst(volatile type* atomic_obj,
  154. type* expected,
  155. type desired);
  156. <font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
  157. <font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
  158. <font color="#C80000">// char16_t, char32_t, wchar_t</font>
  159. type __atomic_fetch_add_relaxed(volatile type* atomic_obj, type operand);
  160. type __atomic_fetch_add_consume(volatile type* atomic_obj, type operand);
  161. type __atomic_fetch_add_acquire(volatile type* atomic_obj, type operand);
  162. type __atomic_fetch_add_release(volatile type* atomic_obj, type operand);
  163. type __atomic_fetch_add_acq_rel(volatile type* atomic_obj, type operand);
  164. type __atomic_fetch_add_seq_cst(volatile type* atomic_obj, type operand);
  165. <font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
  166. <font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
  167. <font color="#C80000">// char16_t, char32_t, wchar_t</font>
  168. type __atomic_fetch_sub_relaxed(volatile type* atomic_obj, type operand);
  169. type __atomic_fetch_sub_consume(volatile type* atomic_obj, type operand);
  170. type __atomic_fetch_sub_acquire(volatile type* atomic_obj, type operand);
  171. type __atomic_fetch_sub_release(volatile type* atomic_obj, type operand);
  172. type __atomic_fetch_sub_acq_rel(volatile type* atomic_obj, type operand);
  173. type __atomic_fetch_sub_seq_cst(volatile type* atomic_obj, type operand);
  174. <font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
  175. <font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
  176. <font color="#C80000">// char16_t, char32_t, wchar_t</font>
  177. type __atomic_fetch_and_relaxed(volatile type* atomic_obj, type operand);
  178. type __atomic_fetch_and_consume(volatile type* atomic_obj, type operand);
  179. type __atomic_fetch_and_acquire(volatile type* atomic_obj, type operand);
  180. type __atomic_fetch_and_release(volatile type* atomic_obj, type operand);
  181. type __atomic_fetch_and_acq_rel(volatile type* atomic_obj, type operand);
  182. type __atomic_fetch_and_seq_cst(volatile type* atomic_obj, type operand);
  183. <font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
  184. <font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
  185. <font color="#C80000">// char16_t, char32_t, wchar_t</font>
  186. type __atomic_fetch_or_relaxed(volatile type* atomic_obj, type operand);
  187. type __atomic_fetch_or_consume(volatile type* atomic_obj, type operand);
  188. type __atomic_fetch_or_acquire(volatile type* atomic_obj, type operand);
  189. type __atomic_fetch_or_release(volatile type* atomic_obj, type operand);
  190. type __atomic_fetch_or_acq_rel(volatile type* atomic_obj, type operand);
  191. type __atomic_fetch_or_seq_cst(volatile type* atomic_obj, type operand);
  192. <font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
  193. <font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
  194. <font color="#C80000">// char16_t, char32_t, wchar_t</font>
  195. type __atomic_fetch_xor_relaxed(volatile type* atomic_obj, type operand);
  196. type __atomic_fetch_xor_consume(volatile type* atomic_obj, type operand);
  197. type __atomic_fetch_xor_acquire(volatile type* atomic_obj, type operand);
  198. type __atomic_fetch_xor_release(volatile type* atomic_obj, type operand);
  199. type __atomic_fetch_xor_acq_rel(volatile type* atomic_obj, type operand);
  200. type __atomic_fetch_xor_seq_cst(volatile type* atomic_obj, type operand);
  201. void* __atomic_fetch_add_relaxed(void* volatile* atomic_obj, ptrdiff_t operand);
  202. void* __atomic_fetch_add_consume(void* volatile* atomic_obj, ptrdiff_t operand);
  203. void* __atomic_fetch_add_acquire(void* volatile* atomic_obj, ptrdiff_t operand);
  204. void* __atomic_fetch_add_release(void* volatile* atomic_obj, ptrdiff_t operand);
  205. void* __atomic_fetch_add_acq_rel(void* volatile* atomic_obj, ptrdiff_t operand);
  206. void* __atomic_fetch_add_seq_cst(void* volatile* atomic_obj, ptrdiff_t operand);
  207. void* __atomic_fetch_sub_relaxed(void* volatile* atomic_obj, ptrdiff_t operand);
  208. void* __atomic_fetch_sub_consume(void* volatile* atomic_obj, ptrdiff_t operand);
  209. void* __atomic_fetch_sub_acquire(void* volatile* atomic_obj, ptrdiff_t operand);
  210. void* __atomic_fetch_sub_release(void* volatile* atomic_obj, ptrdiff_t operand);
  211. void* __atomic_fetch_sub_acq_rel(void* volatile* atomic_obj, ptrdiff_t operand);
  212. void* __atomic_fetch_sub_seq_cst(void* volatile* atomic_obj, ptrdiff_t operand);
  213. void __atomic_thread_fence_relaxed();
  214. void __atomic_thread_fence_consume();
  215. void __atomic_thread_fence_acquire();
  216. void __atomic_thread_fence_release();
  217. void __atomic_thread_fence_acq_rel();
  218. void __atomic_thread_fence_seq_cst();
  219. void __atomic_signal_fence_relaxed();
  220. void __atomic_signal_fence_consume();
  221. void __atomic_signal_fence_acquire();
  222. void __atomic_signal_fence_release();
  223. void __atomic_signal_fence_acq_rel();
  224. void __atomic_signal_fence_seq_cst();
  225. </pre></blockquote>
  226. </div>
  227. </body>
  228. </html>