blob: bcb262712792180c82d34fd603022a00f1dd074f [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>
Howard Hinnant77868b92010-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 Hinnant08f29692010-10-08 17:36:50 +000053bool __atomic_is_lock_free(const type* atomic_obj);
54
55<font color="#C80000">// type must be trivially copyable</font>
Howard Hinnant086b7182010-10-06 16:15:10 +000056<font color="#C80000">// Behavior is defined for mem_ord = 0, 1, 2, 5</font>
Howard Hinnant77868b92010-10-07 14:18:37 +000057type __atomic_load(const type* atomic_obj, int mem_ord);
Howard Hinnant086b7182010-10-06 16:15:10 +000058
Howard Hinnant77868b92010-10-07 14:18:37 +000059<font color="#C80000">// type must be trivially copyable</font>
Howard Hinnant086b7182010-10-06 16:15:10 +000060<font color="#C80000">// Behavior is defined for mem_ord = 0, 3, 5</font>
Howard Hinnant77868b92010-10-07 14:18:37 +000061type __atomic_store(type* atomic_obj, type desired, int mem_ord);
Howard Hinnant086b7182010-10-06 16:15:10 +000062
Howard Hinnant77868b92010-10-07 14:18:37 +000063<font color="#C80000">// type must be trivially copyable</font>
Howard Hinnant086b7182010-10-06 16:15:10 +000064<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
Howard Hinnant77868b92010-10-07 14:18:37 +000065type __atomic_exchange(type* atomic_obj, type desired, int mem_ord);
Howard Hinnant086b7182010-10-06 16:15:10 +000066
Howard Hinnant77868b92010-10-07 14:18:37 +000067<font color="#C80000">// type must be trivially copyable</font>
Howard Hinnant086b7182010-10-06 16:15:10 +000068<font color="#C80000">// Behavior is defined for mem_success = [0 ... 5],</font>
Howard Hinnant77868b92010-10-07 14:18:37 +000069<font color="#C80000">// mem_falure &lt;= mem_success</font>
70bool __atomic_compare_exchange_strong(type* atomic_obj,
Howard Hinnant086b7182010-10-06 16:15:10 +000071 type* expected, type desired,
72 int mem_success, int mem_failure);
73
Howard Hinnant77868b92010-10-07 14:18:37 +000074<font color="#C80000">// type must be trivially copyable</font>
Howard Hinnant086b7182010-10-06 16:15:10 +000075<font color="#C80000">// Behavior is defined for mem_success = [0 ... 5],</font>
Howard Hinnant77868b92010-10-07 14:18:37 +000076<font color="#C80000">// mem_falure &lt;= mem_success</font>
77bool __atomic_compare_exchange_weak(type* atomic_obj,
Howard Hinnant086b7182010-10-06 16:15:10 +000078 type* expected, type desired,
79 int mem_success, int mem_failure);
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>
Howard Hinnant77868b92010-10-07 14:18:37 +000085type __atomic_fetch_add(type* atomic_obj, type operand, int mem_ord);
Howard Hinnant086b7182010-10-06 16:15:10 +000086
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>
Howard Hinnant77868b92010-10-07 14:18:37 +000091type __atomic_fetch_sub(type* atomic_obj, type operand, int mem_ord);
Howard Hinnant086b7182010-10-06 16:15:10 +000092
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>
Howard Hinnant77868b92010-10-07 14:18:37 +000097type __atomic_fetch_and(type* atomic_obj, type operand, int mem_ord);
Howard Hinnant086b7182010-10-06 16:15:10 +000098
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>
Howard Hinnant77868b92010-10-07 14:18:37 +0000103type __atomic_fetch_or(type* atomic_obj, type operand, int mem_ord);
Howard Hinnant086b7182010-10-06 16:15:10 +0000104
105<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
106<font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font>
107<font color="#C80000">// char16_t, char32_t, wchar_t</font>
108<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
Howard Hinnant77868b92010-10-07 14:18:37 +0000109type __atomic_fetch_xor(type* atomic_obj, type operand, int mem_ord);
Howard Hinnant086b7182010-10-06 16:15:10 +0000110
111<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
Howard Hinnant77868b92010-10-07 14:18:37 +0000112void* __atomic_fetch_add(void** atomic_obj, ptrdiff_t operand, int mem_ord);
113void* __atomic_fetch_sub(void** atomic_obj, ptrdiff_t operand, int mem_ord);
Howard Hinnant086b7182010-10-06 16:15:10 +0000114
115<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
116void __atomic_thread_fence(int mem_ord);
117void __atomic_signal_fence(int mem_ord);
118</pre></blockquote>
119
120<p>
121If desired the intrinsics taking a single <tt>mem_ord</tt> parameter can default
122this argument to 5.
123</p>
124
125<p>
126If desired the intrinsics taking two ordering parameters can default
127<tt>mem_success</tt> to 5, and <tt>mem_failure</tt> to <tt>mem_success</tt>.
128</p>
129
130</div>
131</body>
132</html>