Skip to content

Commit 71dee18

Browse files
author
Howard Hinnant
committed
Updated atomic design docs
llvm-svn: 116065
1 parent 00351b7 commit 71dee18

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

libcxx/www/atomic_design.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,40 @@ <h1>&lt;atomic&gt; design</h1>
5353
</li>
5454
</ol>
5555

56+
<p>
57+
With any design, the (back end) compiler writer should note:
58+
</p>
59+
60+
<blockquote>
61+
<p>
62+
The decision to implement lock-free operations on any given type (or not) is an
63+
ABI-binding decision. One can not change from treating a type as not lock free,
64+
to lock free (or vice-versa) without breaking your ABI.
65+
</p>
66+
67+
<p>
68+
Example:
69+
</p>
70+
71+
<blockquote><pre>
72+
TU1.cc
73+
-----------
74+
extern atomic&lt;long long&gt; A;
75+
int foo() { return A.compare_exchange_strong(w, x); }
76+
77+
TU2.cc
78+
-----------
79+
extern atomic&lt;long long&gt; A;
80+
void bar() { return A.compare_exchange_strong(y, z); }
81+
</pre></blockquote>
82+
</blockquote>
83+
84+
<p>
85+
If only <em>one</em> of these calls to <tt>compare_exchange_strong</tt> is
86+
implemented with mutex-locked code, then that mutex-locked code will not be
87+
executed mutually exclusively of the one implemented in a lock-free manner.
88+
</p>
89+
5690
</div>
5791
</body>
5892
</html>

libcxx/www/atomic_design_a.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ <h1>&lt;atomic&gt; design</h1>
4949
<font color="#C80000">// In every intrinsic signature below, type* atomic_obj may be a pointer to a</font>
5050
<font color="#C80000">// volatile-qualifed type.</font>
5151

52+
<font color="#C80000">// type must be trivially copyable</font>
53+
bool __atomic_is_lock_free(const type* atomic_obj);
54+
5255
<font color="#C80000">// type must be trivially copyable</font>
5356
<font color="#C80000">// Behavior is defined for mem_ord = 0, 1, 2, 5</font>
5457
type __atomic_load(const type* atomic_obj, int mem_ord);

libcxx/www/atomic_design_b.html

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,29 @@ <h1>&lt;atomic&gt; design</h1>
4444
</p>
4545

4646
<blockquote><pre>
47-
<font color="#C80000">// type can be any pod</font>
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>
4851
type __atomic_load_relaxed(const volatile type* atomic_obj);
4952
type __atomic_load_consume(const volatile type* atomic_obj);
5053
type __atomic_load_acquire(const volatile type* atomic_obj);
5154
type __atomic_load_seq_cst(const volatile type* atomic_obj);
5255

53-
<font color="#C80000">// type can be any pod</font>
56+
<font color="#C80000">// type must be trivially copyable</font>
5457
type __atomic_store_relaxed(volatile type* atomic_obj, type desired);
5558
type __atomic_store_release(volatile type* atomic_obj, type desired);
5659
type __atomic_store_seq_cst(volatile type* atomic_obj, type desired);
5760

58-
<font color="#C80000">// type can be any pod</font>
61+
<font color="#C80000">// type must be trivially copyable</font>
5962
type __atomic_exchange_relaxed(volatile type* atomic_obj, type desired);
6063
type __atomic_exchange_consume(volatile type* atomic_obj, type desired);
6164
type __atomic_exchange_acquire(volatile type* atomic_obj, type desired);
6265
type __atomic_exchange_release(volatile type* atomic_obj, type desired);
6366
type __atomic_exchange_acq_rel(volatile type* atomic_obj, type desired);
6467
type __atomic_exchange_seq_cst(volatile type* atomic_obj, type desired);
6568

66-
<font color="#C80000">// type can be any pod</font>
69+
<font color="#C80000">// type must be trivially copyable</font>
6770
bool __atomic_compare_exchange_strong_relaxed_relaxed(volatile type* atomic_obj,
6871
type* expected,
6972
type desired);
@@ -113,7 +116,7 @@ <h1>&lt;atomic&gt; design</h1>
113116
type* expected,
114117
type desired);
115118

116-
<font color="#C80000">// type can be any pod</font>
119+
<font color="#C80000">// type must be trivially copyable</font>
117120
bool __atomic_compare_exchange_weak_relaxed_relaxed(volatile type* atomic_obj,
118121
type* expected,
119122
type desired);

0 commit comments

Comments
 (0)