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