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