blob: f09d0b36a5321a73a0608be62e9a6de10de4072a [file] [log] [blame]
Howard Hinnanta35a35f2010-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>
Howard Hinnantdc2394f2010-10-07 14:18:37 +000049<font color="#C80000">// In every intrinsic signature below, type* atomic_obj may be a pointer to a</font>
50<font color="#C80000">// volatile-qualifed type.</font>
51
52<font color="#C80000">// type must be trivially copyable</font>
Howard Hinnanta35a35f2010-10-06 16:15:10 +000053<font color="#C80000">// Behavior is defined for mem_ord = 0, 1, 2, 5</font>
Howard Hinnantdc2394f2010-10-07 14:18:37 +000054type __atomic_load(const type* atomic_obj, int mem_ord);
Howard Hinnanta35a35f2010-10-06 16:15:10 +000055
Howard Hinnantdc2394f2010-10-07 14:18:37 +000056<font color="#C80000">// type must be trivially copyable</font>
Howard Hinnanta35a35f2010-10-06 16:15:10 +000057<font color="#C80000">// Behavior is defined for mem_ord = 0, 3, 5</font>
Howard Hinnantdc2394f2010-10-07 14:18:37 +000058type __atomic_store(type* atomic_obj, type desired, int mem_ord);
Howard Hinnanta35a35f2010-10-06 16:15:10 +000059
Howard Hinnantdc2394f2010-10-07 14:18:37 +000060<font color="#C80000">// type must be trivially copyable</font>
Howard Hinnanta35a35f2010-10-06 16:15:10 +000061<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
Howard Hinnantdc2394f2010-10-07 14:18:37 +000062type __atomic_exchange(type* atomic_obj, type desired, int mem_ord);
Howard Hinnanta35a35f2010-10-06 16:15:10 +000063
Howard Hinnantdc2394f2010-10-07 14:18:37 +000064<font color="#C80000">// type must be trivially copyable</font>
Howard Hinnanta35a35f2010-10-06 16:15:10 +000065<font color="#C80000">// Behavior is defined for mem_success = [0 ... 5],</font>
Howard Hinnantdc2394f2010-10-07 14:18:37 +000066<font color="#C80000">// mem_falure &lt;= mem_success</font>
67bool __atomic_compare_exchange_strong(type* atomic_obj,
Howard Hinnanta35a35f2010-10-06 16:15:10 +000068 type* expected, type desired,
69 int mem_success, int mem_failure);
70
Howard Hinnantdc2394f2010-10-07 14:18:37 +000071<font color="#C80000">// type must be trivially copyable</font>
Howard Hinnanta35a35f2010-10-06 16:15:10 +000072<font color="#C80000">// Behavior is defined for mem_success = [0 ... 5],</font>
Howard Hinnantdc2394f2010-10-07 14:18:37 +000073<font color="#C80000">// mem_falure &lt;= mem_success</font>
74bool __atomic_compare_exchange_weak(type* atomic_obj,
Howard Hinnanta35a35f2010-10-06 16:15:10 +000075 type* expected, type desired,
76 int mem_success, int mem_failure);
77
78<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
79<font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
80<font color="#C80000">// char16_t, char32_t, wchar_t</font>
81<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
Howard Hinnantdc2394f2010-10-07 14:18:37 +000082type __atomic_fetch_add(type* atomic_obj, type operand, int mem_ord);
Howard Hinnanta35a35f2010-10-06 16:15:10 +000083
84<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
85<font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
86<font color="#C80000">// char16_t, char32_t, wchar_t</font>
87<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
Howard Hinnantdc2394f2010-10-07 14:18:37 +000088type __atomic_fetch_sub(type* atomic_obj, type operand, int mem_ord);
Howard Hinnanta35a35f2010-10-06 16:15:10 +000089
90<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
91<font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
92<font color="#C80000">// char16_t, char32_t, wchar_t</font>
93<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
Howard Hinnantdc2394f2010-10-07 14:18:37 +000094type __atomic_fetch_and(type* atomic_obj, type operand, int mem_ord);
Howard Hinnanta35a35f2010-10-06 16:15:10 +000095
96<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
97<font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
98<font color="#C80000">// char16_t, char32_t, wchar_t</font>
99<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
Howard Hinnantdc2394f2010-10-07 14:18:37 +0000100type __atomic_fetch_or(type* atomic_obj, type operand, int mem_ord);
Howard Hinnanta35a35f2010-10-06 16:15:10 +0000101
102<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
103<font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
104<font color="#C80000">// char16_t, char32_t, wchar_t</font>
105<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
Howard Hinnantdc2394f2010-10-07 14:18:37 +0000106type __atomic_fetch_xor(type* atomic_obj, type operand, int mem_ord);
Howard Hinnanta35a35f2010-10-06 16:15:10 +0000107
108<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
Howard Hinnantdc2394f2010-10-07 14:18:37 +0000109void* __atomic_fetch_add(void** atomic_obj, ptrdiff_t operand, int mem_ord);
110void* __atomic_fetch_sub(void** atomic_obj, ptrdiff_t operand, int mem_ord);
Howard Hinnanta35a35f2010-10-06 16:15:10 +0000111
112<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
113void __atomic_thread_fence(int mem_ord);
114void __atomic_signal_fence(int mem_ord);
115</pre></blockquote>
116
117<p>
118If desired the intrinsics taking a single <tt>mem_ord</tt> parameter can default
119this argument to 5.
120</p>
121
122<p>
123If desired the intrinsics taking two ordering parameters can default
124<tt>mem_success</tt> to 5, and <tt>mem_failure</tt> to <tt>mem_success</tt>.
125</p>
126
127</div>
128</body>
129</html>