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