blob: dc16568dc12273c974065d0d0b76ebacb0bfdf01 [file] [log] [blame]
Howard Hinnant086b7182010-10-06 16:15:10 +00001<!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 more of a synopsis than a true description. The compiler supplies all
40of the intrinsics as described below. This list of intrinsics roughly parallels
41the requirements of the C and C++ atomics proposals. The C and C++ library
42imlpementations simply drop through to these intrinsics. Anything the platform
43does not support in hardware, the compiler arranges for a (compiler-rt) library
44call to be made which will do the job with a mutex, and in this case ignoring
45the memory ordering parameter.
46</p>
47
48<blockquote><pre>
49<font color="#C80000">// type can be any pod</font>
50<font color="#C80000">// Behavior is defined for mem_ord = 0, 1, 2, 5</font>
51type __atomic_load(const volatile type* atomic_obj, int mem_ord);
52
53<font color="#C80000">// type can be any pod</font>
54<font color="#C80000">// Behavior is defined for mem_ord = 0, 3, 5</font>
55type __atomic_store(volatile type* atomic_obj, type desired, int mem_ord);
56
57<font color="#C80000">// type can be any pod</font>
58<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
59type __atomic_exchange(volatile type* atomic_obj, type desired, int mem_ord);
60
61<font color="#C80000">// type can be any pod</font>
62<font color="#C80000">// Behavior is defined for mem_success = [0 ... 5],</font>
63<font color="#C80000">// mem_falure &lt;= mem_success &amp;&amp; mem_failure != [3, 4]</font>
64bool __atomic_compare_exchange_strong(volatile type* atomic_obj,
65 type* expected, type desired,
66 int mem_success, int mem_failure);
67
68<font color="#C80000">// type can be any pod</font>
69<font color="#C80000">// Behavior is defined for mem_success = [0 ... 5],</font>
70<font color="#C80000">// mem_falure &lt;= mem_success &amp;&amp; mem_failure != [3, 4]</font>
71bool __atomic_compare_exchange_weak(volatile type* atomic_obj,
72 type* expected, type desired,
73 int mem_success, int mem_failure);
74
75<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
76<font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
77<font color="#C80000">// char16_t, char32_t, wchar_t</font>
78<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
79type __atomic_fetch_add(volatile type* atomic_obj, type operand, int mem_ord);
80
81<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
82<font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
83<font color="#C80000">// char16_t, char32_t, wchar_t</font>
84<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
85type __atomic_fetch_sub(volatile type* atomic_obj, type operand, int mem_ord);
86
87<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
88<font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
89<font color="#C80000">// char16_t, char32_t, wchar_t</font>
90<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
91type __atomic_fetch_and(volatile type* atomic_obj, type operand, int mem_ord);
92
93<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
94<font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
95<font color="#C80000">// char16_t, char32_t, wchar_t</font>
96<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
97type __atomic_fetch_or(volatile type* atomic_obj, type operand, int mem_ord);
98
99<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
100<font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
101<font color="#C80000">// char16_t, char32_t, wchar_t</font>
102<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
103type __atomic_fetch_xor(volatile type* atomic_obj, type operand, int mem_ord);
104
105<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
106void* __atomic_fetch_add(void* volatile* atomic_obj, ptrdiff_t operand, int mem_ord);
107void* __atomic_fetch_sub(void* volatile* atomic_obj, ptrdiff_t operand, int mem_ord);
108
109<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
110void __atomic_thread_fence(int mem_ord);
111void __atomic_signal_fence(int mem_ord);
112</pre></blockquote>
113
114<p>
115If desired the intrinsics taking a single <tt>mem_ord</tt> parameter can default
116this argument to 5.
117</p>
118
119<p>
120If desired the intrinsics taking two ordering parameters can default
121<tt>mem_success</tt> to 5, and <tt>mem_failure</tt> to <tt>mem_success</tt>.
122</p>
123
124</div>
125</body>
126</html>