blob: 1d6a4fb23d688b2fb1993278195350789283a5f5 [file] [log] [blame]
Howard Hinnant8f73c632010-09-27 21:17:38 +00001// -*- C++ -*-
2//===--------------------------- atomic -----------------------------------===//
3//
4// The LLVM Compiler Infrastructure
5//
6// This file is distributed under the University of Illinois Open Source
7// License. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_ATOMIC
12#define _LIBCPP_ATOMIC
13
14/*
15 atomic synopsis
16
17namespace std
18{
19
20// order and consistency
21
22typedef enum memory_order
23{
Howard Hinnantd1176e22010-09-28 17:13:38 +000024 memory_order_relaxed,
25 memory_order_consume, // load-consume
26 memory_order_acquire, // load-acquire
27 memory_order_release, // store-release
28 memory_order_acq_rel, // store-release load-acquire
29 memory_order_seq_cst // store-release load-acquire
Howard Hinnant8f73c632010-09-27 21:17:38 +000030} memory_order;
31
32template <class T> T kill_dependency(T y);
33
34// lock-free property
35
36#define ATOMIC_CHAR_LOCK_FREE unspecified
37#define ATOMIC_CHAR16_T_LOCK_FREE unspecified
38#define ATOMIC_CHAR32_T_LOCK_FREE unspecified
39#define ATOMIC_WCHAR_T_LOCK_FREE unspecified
40#define ATOMIC_SHORT_LOCK_FREE unspecified
41#define ATOMIC_INT_LOCK_FREE unspecified
42#define ATOMIC_LONG_LOCK_FREE unspecified
43#define ATOMIC_LLONG_LOCK_FREE unspecified
44#define ATOMIC_ADDRESS_LOCK_FREE unspecified
45
Howard Hinnant8f73c632010-09-27 21:17:38 +000046// flag type and operations
47
48typedef struct atomic_flag
49{
50 bool test_and_set(memory_order = memory_order_seq_cst) volatile;
51 bool test_and_set(memory_order = memory_order_seq_cst);
52 void clear(memory_order = memory_order_seq_cst) volatile;
53 void clear(memory_order = memory_order_seq_cst);
54 atomic_flag() = default;
55 atomic_flag(const atomic_flag&) = delete;
56 atomic_flag& operator=(const atomic_flag&) = delete;
57 atomic_flag& operator=(const atomic_flag&) volatile = delete;
58} atomic_flag;
59
60bool atomic_flag_test_and_set(volatile atomic_flag*);
61bool atomic_flag_test_and_set(atomic_flag*);
62bool atomic_flag_test_and_set_explicit(volatile atomic_flag*, memory_order);
63bool atomic_flag_test_and_set_explicit(atomic_flag*, memory_order);
64void atomic_flag_clear(volatile atomic_flag*);
65void atomic_flag_clear(atomic_flag*);
66void atomic_flag_clear_explicit(volatile atomic_flag*, memory_order);
67void atomic_flag_clear_explicit(atomic_flag*, memory_order);
68
69#define ATOMIC_FLAG_INIT see below
Howard Hinnante7385012010-10-19 16:51:18 +000070#define ATOMIC_VAR_INIT(value) see below
Howard Hinnant8f73c632010-09-27 21:17:38 +000071
72// atomic_bool
73
74typedef struct atomic_bool
75{
76 bool is_lock_free() const volatile;
77 bool is_lock_free() const;
78 void store(bool, memory_order = memory_order_seq_cst) volatile;
79 void store(bool, memory_order = memory_order_seq_cst);
80 bool load(memory_order = memory_order_seq_cst) const volatile;
81 bool load(memory_order = memory_order_seq_cst) const;
82 operator bool() const volatile;
83 operator bool() const;
84 bool exchange(bool, memory_order = memory_order_seq_cst) volatile;
85 bool exchange(bool, memory_order = memory_order_seq_cst);
86 bool compare_exchange_weak(bool&, bool, memory_order,
87 memory_order) volatile;
88 bool compare_exchange_weak(bool&, bool, memory_order, memory_order);
89 bool compare_exchange_strong(bool&, bool, memory_order,
90 memory_order) volatile;
91 bool compare_exchange_strong(bool&, bool, memory_order, memory_order);
92 bool compare_exchange_weak(bool&, bool,
93 memory_order = memory_order_seq_cst) volatile;
94 bool compare_exchange_weak(bool&, bool,
95 memory_order = memory_order_seq_cst);
96 bool compare_exchange_strong(bool&, bool,
97 memory_order = memory_order_seq_cst) volatile;
98 bool compare_exchange_strong(bool&, bool,
99 memory_order = memory_order_seq_cst);
100 atomic_bool() = default;
101 constexpr atomic_bool(bool);
102 atomic_bool(const atomic_bool&) = delete;
103 atomic_bool& operator=(const atomic_bool&) = delete;
104 atomic_bool& operator=(const atomic_bool&) volatile = delete;
105 bool operator=(bool) volatile;
Howard Hinnante7385012010-10-19 16:51:18 +0000106 bool operator=(bool);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000107} atomic_bool;
108
109bool atomic_is_lock_free(const volatile atomic_bool*);
110bool atomic_is_lock_free(const atomic_bool*);
111void atomic_init(volatile atomic_bool*, bool);
112void atomic_init(atomic_bool*, bool);
113void atomic_store(volatile atomic_bool*, bool);
114void atomic_store(atomic_bool*, bool);
115void atomic_store_explicit(volatile atomic_bool*, bool, memory_order);
116void atomic_store_explicit(atomic_bool*, bool, memory_order);
117bool atomic_load(const volatile atomic_bool*);
118bool atomic_load(const atomic_bool*);
119bool atomic_load_explicit(const volatile atomic_bool*, memory_order);
120bool atomic_load_explicit(const atomic_bool*, memory_order);
121bool atomic_exchange(volatile atomic_bool*, bool);
122bool atomic_exchange(atomic_bool*, bool);
123bool atomic_exchange_explicit(volatile atomic_bool*, bool, memory_order);
124bool atomic_exchange_explicit(atomic_bool*, bool, memory_order);
125bool atomic_compare_exchange_weak(volatile atomic_bool*, bool*, bool);
126bool atomic_compare_exchange_weak(atomic_bool*, bool*, bool);
127bool atomic_compare_exchange_strong(volatile atomic_bool*, bool*, bool);
128bool atomic_compare_exchange_strong(atomic_bool*, bool*, bool);
129bool atomic_compare_exchange_weak_explicit(volatile atomic_bool*, bool*, bool,
130 memory_order, memory_order);
131bool atomic_compare_exchange_weak_explicit(atomic_bool*, bool*, bool,
132 memory_order, memory_order);
133bool atomic_compare_exchange_strong_explicit(volatile atomic_bool*, bool*, bool,
134 memory_order, memory_order);
135bool atomic_compare_exchange_strong_explicit(atomic_bool*, bool*, bool,
136 memory_order, memory_order);
137
138// atomic_char
139
140typedef struct atomic_char
141{
142 bool is_lock_free() const volatile;
143 bool is_lock_free() const;
144 void store(char, memory_order = memory_order_seq_cst) volatile;
145 void store(char, memory_order = memory_order_seq_cst);
146 char load(memory_order = memory_order_seq_cst) const volatile;
147 char load(memory_order = memory_order_seq_cst) const;
148 operator char() const volatile;
149 operator char() const;
Howard Hinnante7385012010-10-19 16:51:18 +0000150 char exchange(char, memory_order = memory_order_seq_cst) volatile;
Howard Hinnant8f73c632010-09-27 21:17:38 +0000151 char exchange(char, memory_order = memory_order_seq_cst);
152 bool compare_exchange_weak(char&, char, memory_order,
153 memory_order) volatile;
154 bool compare_exchange_weak(char&, char, memory_order, memory_order);
155 bool compare_exchange_strong(char&, char, memory_order,
156 memory_order) volatile;
157 bool compare_exchange_strong(char&, char, memory_order, memory_order);
158 bool compare_exchange_weak(char&, char,
159 memory_order = memory_order_seq_cst) volatile;
160 bool compare_exchange_weak(char&, char,
161 memory_order = memory_order_seq_cst);
162 bool compare_exchange_strong(char&, char,
163 memory_order = memory_order_seq_cst) volatile;
164 bool compare_exchange_strong(char&, char,
165 memory_order = memory_order_seq_cst);
166 char fetch_add(char, memory_order = memory_order_seq_cst) volatile;
167 char fetch_add(char, memory_order = memory_order_seq_cst);
168 char fetch_sub(char, memory_order = memory_order_seq_cst) volatile;
169 char fetch_sub(char, memory_order = memory_order_seq_cst);
170 char fetch_and(char, memory_order = memory_order_seq_cst) volatile;
171 char fetch_and(char, memory_order = memory_order_seq_cst);
172 char fetch_or(char, memory_order = memory_order_seq_cst) volatile;
173 char fetch_or(char, memory_order = memory_order_seq_cst);
174 char fetch_xor(char, memory_order = memory_order_seq_cst) volatile;
175 char fetch_xor(char, memory_order = memory_order_seq_cst);
176 atomic_char() = default;
177 constexpr atomic_char(char);
178 atomic_char(const atomic_char&) = delete;
179 atomic_char& operator=(const atomic_char&) = delete;
180 atomic_char& operator=(const atomic_char&) volatile = delete;
181 char operator=(char) volatile;
182 char operator=(char);
183 char operator++(int) volatile;
184 char operator++(int);
185 char operator--(int) volatile;
186 char operator--(int);
187 char operator++() volatile;
188 char operator++();
189 char operator--() volatile;
190 char operator--();
191 char operator+=(char) volatile;
192 char operator+=(char);
193 char operator-=(char) volatile;
194 char operator-=(char);
195 char operator&=(char) volatile;
196 char operator&=(char);
197 char operator|=(char) volatile;
198 char operator|=(char);
199 char operator^=(char) volatile;
200 char operator^=(char);
201} atomic_char;
202
203bool atomic_is_lock_free(const volatile atomic_char*);
204bool atomic_is_lock_free(const atomic_char*);
Howard Hinnante7385012010-10-19 16:51:18 +0000205void atomic_init(volatile atomic_char*, char);
206void atomic_init(atomic_char*, char);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000207void atomic_store(volatile atomic_char*, char);
208void atomic_store(atomic_char*, char);
209void atomic_store_explicit(volatile atomic_char*, char, memory_order);
210void atomic_store_explicit(atomic_char*, char, memory_order);
211char atomic_load(const volatile atomic_char*);
212char atomic_load(const atomic_char*);
213char atomic_load_explicit(const volatile atomic_char*, memory_order);
214char atomic_load_explicit(const atomic_char*, memory_order);
215char atomic_exchange(volatile atomic_char*, char);
216char atomic_exchange(atomic_char*, char);
217char atomic_exchange_explicit(volatile atomic_char*, char, memory_order);
218char atomic_exchange_explicit(atomic_char*, char, memory_order);
219bool atomic_compare_exchange_weak(volatile atomic_char*, char*, char);
220bool atomic_compare_exchange_weak(atomic_char*, char*, char);
221bool atomic_compare_exchange_strong(volatile atomic_char*, char*, char);
222bool atomic_compare_exchange_strong(atomic_char*, char*, char);
223bool atomic_compare_exchange_weak_explicit(volatile atomic_char*, char*, char,
224 memory_order, memory_order);
225bool atomic_compare_exchange_weak_explicit(atomic_char*, char*, char,
226 memory_order, memory_order);
227bool atomic_compare_exchange_strong_explicit(volatile atomic_char*, char*, char,
228 memory_order, memory_order);
229bool atomic_compare_exchange_strong_explicit(atomic_char*, char*, char,
230 memory_order, memory_order);
231char atomic_fetch_add(volatile atomic_char*, char);
232char atomic_fetch_add(atomic_char*, char);
233char atomic_fetch_add_explicit(volatile atomic_char*, char, memory_order);
234char atomic_fetch_add_explicit(atomic_char*, char, memory_order);
235char atomic_fetch_sub(volatile atomic_char*, char);
236char atomic_fetch_sub(atomic_char*, char);
237char atomic_fetch_sub_explicit(volatile atomic_char*, char, memory_order);
238char atomic_fetch_sub_explicit(atomic_char*, char, memory_order);
239char atomic_fetch_and(volatile atomic_char*, char);
240char atomic_fetch_and(atomic_char*, char);
241char atomic_fetch_and_explicit(volatile atomic_char*, char, memory_order);
242char atomic_fetch_and_explicit(atomic_char*, char, memory_order);
243char atomic_fetch_or(volatile atomic_char*, char);
244char atomic_fetch_or(atomic_char*, char);
245char atomic_fetch_or_explicit(volatile atomic_char*, char, memory_order);
246char atomic_fetch_or_explicit(atomic_char*, char, memory_order);
247char atomic_fetch_xor(volatile atomic_char*, char);
248char atomic_fetch_xor(atomic_char*, char);
249char atomic_fetch_xor_explicit(volatile atomic_char*, char, memory_order);
250char atomic_fetch_xor_explicit(atomic_char*, char, memory_order);
251
252// atomic_schar
253
254typedef struct atomic_schar
255{
256 bool is_lock_free() const volatile;
257 bool is_lock_free() const;
258 void store(signed char, memory_order = memory_order_seq_cst) volatile;
259 void store(signed char, memory_order = memory_order_seq_cst);
260 signed char load(memory_order = memory_order_seq_cst) const volatile;
261 signed char load(memory_order = memory_order_seq_cst) const;
262 operator signed char() const volatile;
263 operator signed char() const;
264 signed char exchange(signed char,
Howard Hinnante7385012010-10-19 16:51:18 +0000265 memory_order = memory_order_seq_cst) volatile;
Howard Hinnant8f73c632010-09-27 21:17:38 +0000266 signed char exchange(signed char, memory_order = memory_order_seq_cst);
267 bool compare_exchange_weak(signed char&, signed char, memory_order,
268 memory_order) volatile;
269 bool compare_exchange_weak(signed char&, signed char, memory_order,
270 memory_order);
271 bool compare_exchange_strong(signed char&, signed char, memory_order,
272 memory_order) volatile;
273 bool compare_exchange_strong(signed char&, signed char, memory_order,
274 memory_order);
275 bool compare_exchange_weak(signed char&, signed char,
276 memory_order = memory_order_seq_cst) volatile;
277 bool compare_exchange_weak(signed char&, signed char,
278 memory_order = memory_order_seq_cst);
279 bool compare_exchange_strong(signed char&, signed char,
280 memory_order = memory_order_seq_cst) volatile;
281 bool compare_exchange_strong(signed char&, signed char,
282 memory_order = memory_order_seq_cst);
283 signed char fetch_add(signed char,
284 memory_order = memory_order_seq_cst) volatile;
285 signed char fetch_add(signed char, memory_order = memory_order_seq_cst);
286 signed char fetch_sub(signed char,
287 memory_order = memory_order_seq_cst) volatile;
288 signed char fetch_sub(signed char, memory_order = memory_order_seq_cst);
289 signed char fetch_and(signed char,
290 memory_order = memory_order_seq_cst) volatile;
291 signed char fetch_and(signed char, memory_order = memory_order_seq_cst);
292 signed char fetch_or(signed char,
293 memory_order = memory_order_seq_cst) volatile;
294 signed char fetch_or(signed char, memory_order = memory_order_seq_cst);
295 signed char fetch_xor(signed char,
296 memory_order = memory_order_seq_cst) volatile;
297 signed char fetch_xor(signed char, memory_order = memory_order_seq_cst);
298 atomic_schar() = default;
299 constexpr atomic_schar(signed char);
300 atomic_schar(const atomic_schar&) = delete;
301 atomic_schar& operator=(const atomic_schar&) = delete;
302 atomic_schar& operator=(const atomic_schar&) volatile = delete;
303 signed char operator=(signed char) volatile;
304 signed char operator=(signed char);
305 signed char operator++(int) volatile;
306 signed char operator++(int);
307 signed char operator--(int) volatile;
308 signed char operator--(int);
309 signed char operator++() volatile;
310 signed char operator++();
311 signed char operator--() volatile;
312 signed char operator--();
313 signed char operator+=(signed char) volatile;
314 signed char operator+=(signed char);
315 signed char operator-=(signed char) volatile;
316 signed char operator-=(signed char);
317 signed char operator&=(signed char) volatile;
318 signed char operator&=(signed char);
319 signed char operator|=(signed char) volatile;
320 signed char operator|=(signed char);
321 signed char operator^=(signed char) volatile;
322 signed char operator^=(signed char);
323} atomic_schar;
324
325bool atomic_is_lock_free(const volatile atomic_schar*);
326bool atomic_is_lock_free(const atomic_schar*);
Howard Hinnante7385012010-10-19 16:51:18 +0000327void atomic_init(volatile atomic_schar*, signed char);
328void atomic_init(atomic_schar*, signed char);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000329void atomic_store(volatile atomic_schar*, signed char);
330void atomic_store(atomic_schar*, signed char);
331void atomic_store_explicit(volatile atomic_schar*, signed char, memory_order);
332void atomic_store_explicit(atomic_schar*, signed char, memory_order);
333signed char atomic_load(const volatile atomic_schar*);
334signed char atomic_load(const atomic_schar*);
335signed char atomic_load_explicit(const volatile atomic_schar*, memory_order);
336signed char atomic_load_explicit(const atomic_schar*, memory_order);
337signed char atomic_exchange(volatile atomic_schar*, signed char);
338signed char atomic_exchange(atomic_schar*, signed char);
339signed char atomic_exchange_explicit(volatile atomic_schar*, signed char,
340 memory_order);
341signed char atomic_exchange_explicit(atomic_schar*, signed char, memory_order);
342bool atomic_compare_exchange_weak(volatile atomic_schar*, signed char*,
343 signed char);
344bool atomic_compare_exchange_weak(atomic_schar*, signed char*, signed char);
345bool atomic_compare_exchange_strong(volatile atomic_schar*, signed char*,
346 signed char);
347bool atomic_compare_exchange_strong(atomic_schar*, signed char*, signed char);
348bool atomic_compare_exchange_weak_explicit(volatile atomic_schar*, signed char*,
349 signed char, memory_order,
350 memory_order);
351bool atomic_compare_exchange_weak_explicit(atomic_schar*, signed char*,
352 signed char, memory_order,
353 memory_order);
354bool atomic_compare_exchange_strong_explicit(volatile atomic_schar*,
355 signed char*, signed char,
356 memory_order, memory_order);
357bool atomic_compare_exchange_strong_explicit(atomic_schar*, signed char*,
358 signed char, memory_order, memory_order);
359signed char atomic_fetch_add(volatile atomic_schar*, signed char);
360signed char atomic_fetch_add(atomic_schar*, signed char);
361signed char atomic_fetch_add_explicit(volatile atomic_schar*, signed char,
362 memory_order);
363signed char atomic_fetch_add_explicit(atomic_schar*, signed char, memory_order);
364signed char atomic_fetch_sub(volatile atomic_schar*, signed char);
365signed char atomic_fetch_sub(atomic_schar*, signed char);
366signed char atomic_fetch_sub_explicit(volatile atomic_schar*, signed char,
367 memory_order);
368signed char atomic_fetch_sub_explicit(atomic_schar*, signed char, memory_order);
369signed char atomic_fetch_and(volatile atomic_schar*, signed char);
370signed char atomic_fetch_and(atomic_schar*, signed char);
371signed char atomic_fetch_and_explicit(volatile atomic_schar*, signed char,
372 memory_order);
373signed char atomic_fetch_and_explicit(atomic_schar*, signed char, memory_order);
374signed char atomic_fetch_or(volatile atomic_schar*, signed char);
375signed char atomic_fetch_or(atomic_schar*, signed char);
376signed char atomic_fetch_or_explicit(volatile atomic_schar*, signed char,
377 memory_order);
378signed char atomic_fetch_or_explicit(atomic_schar*, signed char, memory_order);
379signed char atomic_fetch_xor(volatile atomic_schar*, signed char);
380signed char atomic_fetch_xor(atomic_schar*, signed char);
381signed char atomic_fetch_xor_explicit(volatile atomic_schar*, signed char,
382 memory_order);
383signed char atomic_fetch_xor_explicit(atomic_schar*, signed char, memory_order);
384
385// atomic_uchar
386
387typedef struct atomic_uchar
388{
389 bool is_lock_free() const volatile;
390 bool is_lock_free() const;
391 void store(unsigned char, memory_order = memory_order_seq_cst) volatile;
392 void store(unsigned char, memory_order = memory_order_seq_cst);
393 unsigned char load(memory_order = memory_order_seq_cst) const volatile;
394 unsigned char load(memory_order = memory_order_seq_cst) const;
395 operator unsigned char() const volatile;
396 operator unsigned char() const;
397 unsigned char exchange(unsigned char,
Howard Hinnante7385012010-10-19 16:51:18 +0000398 memory_order = memory_order_seq_cst) volatile;
Howard Hinnant8f73c632010-09-27 21:17:38 +0000399 unsigned char exchange(unsigned char, memory_order = memory_order_seq_cst);
400 bool compare_exchange_weak(unsigned char&, unsigned char, memory_order,
401 memory_order) volatile;
402 bool compare_exchange_weak(unsigned char&, unsigned char, memory_order,
403 memory_order);
404 bool compare_exchange_strong(unsigned char&, unsigned char, memory_order,
405 memory_order) volatile;
406 bool compare_exchange_strong(unsigned char&, unsigned char, memory_order,
407 memory_order);
408 bool compare_exchange_weak(unsigned char&, unsigned char,
409 memory_order = memory_order_seq_cst) volatile;
410 bool compare_exchange_weak(unsigned char&, unsigned char,
411 memory_order = memory_order_seq_cst);
412 bool compare_exchange_strong(unsigned char&, unsigned char,
413 memory_order = memory_order_seq_cst) volatile;
414 bool compare_exchange_strong(unsigned char&, unsigned char,
415 memory_order = memory_order_seq_cst);
416 unsigned char fetch_add(unsigned char,
417 memory_order = memory_order_seq_cst) volatile;
418 unsigned char fetch_add(unsigned char, memory_order = memory_order_seq_cst);
419 unsigned char fetch_sub(unsigned char,
420 memory_order = memory_order_seq_cst) volatile;
421 unsigned char fetch_sub(unsigned char, memory_order = memory_order_seq_cst);
422 unsigned char fetch_and(unsigned char,
423 memory_order = memory_order_seq_cst) volatile;
424 unsigned char fetch_and(unsigned char, memory_order = memory_order_seq_cst);
425 unsigned char fetch_or(unsigned char,
426 memory_order = memory_order_seq_cst) volatile;
427 unsigned char fetch_or(unsigned char, memory_order = memory_order_seq_cst);
428 unsigned char fetch_xor(unsigned char,
429 memory_order = memory_order_seq_cst) volatile;
430 unsigned char fetch_xor(unsigned char, memory_order = memory_order_seq_cst);
431 atomic_uchar() = default;
432 constexpr atomic_uchar(unsigned char);
433 atomic_uchar(const atomic_uchar&) = delete;
434 atomic_uchar& operator=(const atomic_uchar&) = delete;
435 atomic_uchar& operator=(const atomic_uchar&) volatile = delete;
436 unsigned char operator=(unsigned char) volatile;
437 unsigned char operator=(unsigned char);
438 unsigned char operator++(int) volatile;
439 unsigned char operator++(int);
440 unsigned char operator--(int) volatile;
441 unsigned char operator--(int);
442 unsigned char operator++() volatile;
443 unsigned char operator++();
444 unsigned char operator--() volatile;
445 unsigned char operator--();
446 unsigned char operator+=(unsigned char) volatile;
447 unsigned char operator+=(unsigned char);
448 unsigned char operator-=(unsigned char) volatile;
449 unsigned char operator-=(unsigned char);
450 unsigned char operator&=(unsigned char) volatile;
451 unsigned char operator&=(unsigned char);
452 unsigned char operator|=(unsigned char) volatile;
453 unsigned char operator|=(unsigned char);
454 unsigned char operator^=(unsigned char) volatile;
455 unsigned char operator^=(unsigned char);
456} atomic_uchar;
457
458bool atomic_is_lock_free(const volatile atomic_uchar*);
459bool atomic_is_lock_free(const atomic_uchar*);
Howard Hinnante7385012010-10-19 16:51:18 +0000460void atomic_init(volatile atomic_uchar*, unsigned char);
461void atomic_init(atomic_uchar*, unsigned char);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000462void atomic_store(volatile atomic_uchar*, unsigned char);
463void atomic_store(atomic_uchar*, unsigned char);
464void atomic_store_explicit(volatile atomic_uchar*, unsigned char, memory_order);
465void atomic_store_explicit(atomic_uchar*, unsigned char, memory_order);
466unsigned char atomic_load(const volatile atomic_uchar*);
467unsigned char atomic_load(const atomic_uchar*);
468unsigned char atomic_load_explicit(const volatile atomic_uchar*, memory_order);
469unsigned char atomic_load_explicit(const atomic_uchar*, memory_order);
470unsigned char atomic_exchange(volatile atomic_uchar*, unsigned char);
471unsigned char atomic_exchange(atomic_uchar*, unsigned char);
472unsigned char atomic_exchange_explicit(volatile atomic_uchar*, unsigned char,
473 memory_order);
474unsigned char atomic_exchange_explicit(atomic_uchar*, unsigned char,
475 memory_order);
476bool atomic_compare_exchange_weak(volatile atomic_uchar*, unsigned char*,
477 unsigned char);
478bool atomic_compare_exchange_weak(atomic_uchar*, unsigned char*, unsigned char);
479bool atomic_compare_exchange_strong(volatile atomic_uchar*, unsigned char*,
480 unsigned char);
481bool atomic_compare_exchange_strong(atomic_uchar*, unsigned char*,
482 unsigned char);
483bool atomic_compare_exchange_weak_explicit(volatile atomic_uchar*,
484 unsigned char*, unsigned char,
485 memory_order, memory_order);
486bool atomic_compare_exchange_weak_explicit(atomic_uchar*, unsigned char*,
487 unsigned char, memory_order,
488 memory_order);
489bool atomic_compare_exchange_strong_explicit(volatile atomic_uchar*,
490 unsigned char*, unsigned char,
491 memory_order, memory_order);
492bool atomic_compare_exchange_strong_explicit(atomic_uchar*, unsigned char*,
493 unsigned char, memory_order,
494 memory_order);
495unsigned char atomic_fetch_add(volatile atomic_uchar*, unsigned char);
496unsigned char atomic_fetch_add(atomic_uchar*, unsigned char);
497unsigned char atomic_fetch_add_explicit(volatile atomic_uchar*, unsigned char,
498 memory_order);
499unsigned char atomic_fetch_add_explicit(atomic_uchar*, unsigned char,
500 memory_order);
501unsigned char atomic_fetch_sub(volatile atomic_uchar*, unsigned char);
502unsigned char atomic_fetch_sub(atomic_uchar*, unsigned char);
503unsigned char atomic_fetch_sub_explicit(volatile atomic_uchar*, unsigned char,
504 memory_order);
505unsigned char atomic_fetch_sub_explicit(atomic_uchar*, unsigned char,
506 memory_order);
507unsigned char atomic_fetch_and(volatile atomic_uchar*, unsigned char);
508unsigned char atomic_fetch_and(atomic_uchar*, unsigned char);
509unsigned char atomic_fetch_and_explicit(volatile atomic_uchar*, unsigned char,
510 memory_order);
511unsigned char atomic_fetch_and_explicit(atomic_uchar*, unsigned char,
512 memory_order);
513unsigned char atomic_fetch_or(volatile atomic_uchar*, unsigned char);
514unsigned char atomic_fetch_or(atomic_uchar*, unsigned char);
515unsigned char atomic_fetch_or_explicit(volatile atomic_uchar*, unsigned char,
516 memory_order);
517unsigned char atomic_fetch_or_explicit(atomic_uchar*, unsigned char,
518 memory_order);
519unsigned char atomic_fetch_xor(volatile atomic_uchar*, unsigned char);
520unsigned char atomic_fetch_xor(atomic_uchar*, unsigned char);
521unsigned char atomic_fetch_xor_explicit(volatile atomic_uchar*, unsigned char,
522 memory_order);
523unsigned char atomic_fetch_xor_explicit(atomic_uchar*, unsigned char,
524 memory_order);
525
526// atomic_short
527
528typedef struct atomic_short
529{
530 bool is_lock_free() const volatile;
531 bool is_lock_free() const;
532 void store(short, memory_order = memory_order_seq_cst) volatile;
533 void store(short, memory_order = memory_order_seq_cst);
534 short load(memory_order = memory_order_seq_cst) const volatile;
535 short load(memory_order = memory_order_seq_cst) const;
536 operator short() const volatile;
537 operator short() const;
Howard Hinnante7385012010-10-19 16:51:18 +0000538 short exchange(short, memory_order = memory_order_seq_cst) volatile;
Howard Hinnant8f73c632010-09-27 21:17:38 +0000539 short exchange(short, memory_order = memory_order_seq_cst);
540 bool compare_exchange_weak(short&, short, memory_order,
541 memory_order) volatile;
542 bool compare_exchange_weak(short&, short, memory_order, memory_order);
543 bool compare_exchange_strong(short&, short, memory_order,
544 memory_order) volatile;
545 bool compare_exchange_strong(short&, short, memory_order, memory_order);
546 bool compare_exchange_weak(short&, short,
547 memory_order = memory_order_seq_cst) volatile;
548 bool compare_exchange_weak(short&, short,
549 memory_order = memory_order_seq_cst);
550 bool compare_exchange_strong(short&, short,
551 memory_order = memory_order_seq_cst) volatile;
552 bool compare_exchange_strong(short&, short,
553 memory_order = memory_order_seq_cst);
554 short fetch_add(short, memory_order = memory_order_seq_cst) volatile;
555 short fetch_add(short, memory_order = memory_order_seq_cst);
556 short fetch_sub(short, memory_order = memory_order_seq_cst) volatile;
557 short fetch_sub(short, memory_order = memory_order_seq_cst);
558 short fetch_and(short, memory_order = memory_order_seq_cst) volatile;
559 short fetch_and(short, memory_order = memory_order_seq_cst);
560 short fetch_or(short, memory_order = memory_order_seq_cst) volatile;
561 short fetch_or(short, memory_order = memory_order_seq_cst);
562 short fetch_xor(short, memory_order = memory_order_seq_cst) volatile;
563 short fetch_xor(short, memory_order = memory_order_seq_cst);
564 atomic_short() = default;
565 constexpr atomic_short(short);
566 atomic_short(const atomic_short&) = delete;
567 atomic_short& operator=(const atomic_short&) = delete;
568 atomic_short& operator=(const atomic_short&) volatile = delete;
569 short operator=(short) volatile;
570 short operator=(short);
571 short operator++(int) volatile;
572 short operator++(int);
573 short operator--(int) volatile;
574 short operator--(int);
575 short operator++() volatile;
576 short operator++();
577 short operator--() volatile;
578 short operator--();
579 short operator+=(short) volatile;
580 short operator+=(short);
581 short operator-=(short) volatile;
582 short operator-=(short);
583 short operator&=(short) volatile;
584 short operator&=(short);
585 short operator|=(short) volatile;
586 short operator|=(short);
587 short operator^=(short) volatile;
588 short operator^=(short);
589} atomic_short;
590
591bool atomic_is_lock_free(const volatile atomic_short*);
592bool atomic_is_lock_free(const atomic_short*);
Howard Hinnante7385012010-10-19 16:51:18 +0000593void atomic_init(volatile atomic_short*, short);
594void atomic_init(atomic_short*, short);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000595void atomic_store(volatile atomic_short*, short);
596void atomic_store(atomic_short*, short);
597void atomic_store_explicit(volatile atomic_short*, short, memory_order);
598void atomic_store_explicit(atomic_short*, short, memory_order);
599short atomic_load(const volatile atomic_short*);
600short atomic_load(const atomic_short*);
601short atomic_load_explicit(const volatile atomic_short*, memory_order);
602short atomic_load_explicit(const atomic_short*, memory_order);
603short atomic_exchange(volatile atomic_short*, short);
604short atomic_exchange(atomic_short*, short);
605short atomic_exchange_explicit(volatile atomic_short*, short, memory_order);
606short atomic_exchange_explicit(atomic_short*, short, memory_order);
607bool atomic_compare_exchange_weak(volatile atomic_short*, short*, short);
608bool atomic_compare_exchange_weak(atomic_short*, short*, short);
609bool atomic_compare_exchange_strong(volatile atomic_short*, short*, short);
610bool atomic_compare_exchange_strong(atomic_short*, short*, short);
611bool atomic_compare_exchange_weak_explicit(volatile atomic_short*, short*,
612 short, memory_order, memory_order);
613bool atomic_compare_exchange_weak_explicit(atomic_short*, short*, short,
614 memory_order, memory_order);
615bool atomic_compare_exchange_strong_explicit(volatile atomic_short*, short*,
616 short, memory_order, memory_order);
617bool atomic_compare_exchange_strong_explicit(atomic_short*, short*, short,
618 memory_order, memory_order);
619short atomic_fetch_add(volatile atomic_short*, short);
620short atomic_fetch_add(atomic_short*, short);
621short atomic_fetch_add_explicit(volatile atomic_short*, short, memory_order);
622short atomic_fetch_add_explicit(atomic_short*, short, memory_order);
623short atomic_fetch_sub(volatile atomic_short*, short);
624short atomic_fetch_sub(atomic_short*, short);
625short atomic_fetch_sub_explicit(volatile atomic_short*, short, memory_order);
626short atomic_fetch_sub_explicit(atomic_short*, short, memory_order);
627short atomic_fetch_and(volatile atomic_short*, short);
628short atomic_fetch_and(atomic_short*, short);
629short atomic_fetch_and_explicit(volatile atomic_short*, short, memory_order);
630short atomic_fetch_and_explicit(atomic_short*, short, memory_order);
631short atomic_fetch_or(volatile atomic_short*, short);
632short atomic_fetch_or(atomic_short*, short);
633short atomic_fetch_or_explicit(volatile atomic_short*, short, memory_order);
634short atomic_fetch_or_explicit(atomic_short*, short, memory_order);
635short atomic_fetch_xor(volatile atomic_short*, short);
636short atomic_fetch_xor(atomic_short*, short);
637short atomic_fetch_xor_explicit(volatile atomic_short*, short, memory_order);
638short atomic_fetch_xor_explicit(atomic_short*, short, memory_order);
639
640// atomic_ushort
641
642typedef struct atomic_ushort
643{
644 bool is_lock_free() const volatile;
645 bool is_lock_free() const;
646 void store(unsigned short, memory_order = memory_order_seq_cst) volatile;
647 void store(unsigned short, memory_order = memory_order_seq_cst);
648 unsigned short load(memory_order = memory_order_seq_cst) const volatile;
649 unsigned short load(memory_order = memory_order_seq_cst) const;
650 operator unsigned short() const volatile;
651 operator unsigned short() const;
652 unsigned short exchange(unsigned short,
Howard Hinnante7385012010-10-19 16:51:18 +0000653 memory_order = memory_order_seq_cst) volatile;
Howard Hinnant8f73c632010-09-27 21:17:38 +0000654 unsigned short exchange(unsigned short,
655 memory_order = memory_order_seq_cst);
656 bool compare_exchange_weak(unsigned short&, unsigned short, memory_order,
657 memory_order) volatile;
658 bool compare_exchange_weak(unsigned short&, unsigned short, memory_order,
659 memory_order);
660 bool compare_exchange_strong(unsigned short&, unsigned short, memory_order,
661 memory_order) volatile;
662 bool compare_exchange_strong(unsigned short&, unsigned short, memory_order,
663 memory_order);
664 bool compare_exchange_weak(unsigned short&, unsigned short,
665 memory_order = memory_order_seq_cst) volatile;
666 bool compare_exchange_weak(unsigned short&, unsigned short,
667 memory_order = memory_order_seq_cst);
668 bool compare_exchange_strong(unsigned short&, unsigned short,
669 memory_order = memory_order_seq_cst) volatile;
670 bool compare_exchange_strong(unsigned short&, unsigned short,
671 memory_order = memory_order_seq_cst);
672 unsigned short fetch_add(unsigned short,
673 memory_order = memory_order_seq_cst) volatile;
674 unsigned short fetch_add(unsigned short,
675 memory_order = memory_order_seq_cst);
676 unsigned short fetch_sub(unsigned short,
677 memory_order = memory_order_seq_cst) volatile;
678 unsigned short fetch_sub(unsigned short,
679 memory_order = memory_order_seq_cst);
680 unsigned short fetch_and(unsigned short,
681 memory_order = memory_order_seq_cst) volatile;
682 unsigned short fetch_and(unsigned short,
683 memory_order = memory_order_seq_cst);
684 unsigned short fetch_or(unsigned short,
685 memory_order = memory_order_seq_cst) volatile;
686 unsigned short fetch_or(unsigned short,
687 memory_order = memory_order_seq_cst);
688 unsigned short fetch_xor(unsigned short,
689 memory_order = memory_order_seq_cst) volatile;
690 unsigned short fetch_xor(unsigned short,
691 memory_order = memory_order_seq_cst);
692 atomic_ushort() = default;
693 constexpr atomic_ushort(unsigned short);
694 atomic_ushort(const atomic_ushort&) = delete;
695 atomic_ushort& operator=(const atomic_ushort&) = delete;
696 atomic_ushort& operator=(const atomic_ushort&) volatile = delete;
697 unsigned short operator=(unsigned short) volatile;
698 unsigned short operator=(unsigned short);
699 unsigned short operator++(int) volatile;
700 unsigned short operator++(int);
701 unsigned short operator--(int) volatile;
702 unsigned short operator--(int);
703 unsigned short operator++() volatile;
704 unsigned short operator++();
705 unsigned short operator--() volatile;
706 unsigned short operator--();
707 unsigned short operator+=(unsigned short) volatile;
708 unsigned short operator+=(unsigned short);
709 unsigned short operator-=(unsigned short) volatile;
710 unsigned short operator-=(unsigned short);
711 unsigned short operator&=(unsigned short) volatile;
712 unsigned short operator&=(unsigned short);
713 unsigned short operator|=(unsigned short) volatile;
714 unsigned short operator|=(unsigned short);
715 unsigned short operator^=(unsigned short) volatile;
716 unsigned short operator^=(unsigned short);
717} atomic_ushort;
718
719bool atomic_is_lock_free(const volatile atomic_ushort*);
720bool atomic_is_lock_free(const atomic_ushort*);
Howard Hinnante7385012010-10-19 16:51:18 +0000721void atomic_init(volatile atomic_ushort*, unsigned short);
722void atomic_init(atomic_ushort*, unsigned short);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000723void atomic_store(volatile atomic_ushort*, unsigned short);
724void atomic_store(atomic_ushort*, unsigned short);
725void atomic_store_explicit(volatile atomic_ushort*, unsigned short,
726 memory_order);
727void atomic_store_explicit(atomic_ushort*, unsigned short, memory_order);
728unsigned short atomic_load(const volatile atomic_ushort*);
729unsigned short atomic_load(const atomic_ushort*);
730unsigned short atomic_load_explicit(const volatile atomic_ushort*,
731 memory_order);
732unsigned short atomic_load_explicit(const atomic_ushort*, memory_order);
733unsigned short atomic_exchange(volatile atomic_ushort*, unsigned short);
734unsigned short atomic_exchange(atomic_ushort*, unsigned short);
735unsigned short atomic_exchange_explicit(volatile atomic_ushort*, unsigned short,
736 memory_order);
737unsigned short atomic_exchange_explicit(atomic_ushort*, unsigned short,
738 memory_order);
739bool atomic_compare_exchange_weak(volatile atomic_ushort*, unsigned short*,
740 unsigned short);
741bool atomic_compare_exchange_weak(atomic_ushort*, unsigned short*,
742 unsigned short);
743bool atomic_compare_exchange_strong(volatile atomic_ushort*, unsigned short*,
744 unsigned short);
745bool atomic_compare_exchange_strong(atomic_ushort*, unsigned short*,
746 unsigned short);
747bool atomic_compare_exchange_weak_explicit(volatile atomic_ushort*,
748 unsigned short*, unsigned short,
749 memory_order, memory_order);
750bool atomic_compare_exchange_weak_explicit(atomic_ushort*, unsigned short*,
751 unsigned short, memory_order,
752 memory_order);
753bool atomic_compare_exchange_strong_explicit(volatile atomic_ushort*,
754 unsigned short*, unsigned short,
755 memory_order, memory_order);
756bool atomic_compare_exchange_strong_explicit(atomic_ushort*, unsigned short*,
757 unsigned short, memory_order,
758 memory_order);
759unsigned short atomic_fetch_add(volatile atomic_ushort*, unsigned short);
760unsigned short atomic_fetch_add(atomic_ushort*, unsigned short);
761unsigned short atomic_fetch_add_explicit(volatile atomic_ushort*,
762 unsigned short, memory_order);
763unsigned short atomic_fetch_add_explicit(atomic_ushort*, unsigned short,
764 memory_order);
765unsigned short atomic_fetch_sub(volatile atomic_ushort*, unsigned short);
766unsigned short atomic_fetch_sub(atomic_ushort*, unsigned short);
767unsigned short atomic_fetch_sub_explicit(volatile atomic_ushort*,
768 unsigned short, memory_order);
769unsigned short atomic_fetch_sub_explicit(atomic_ushort*, unsigned short,
770 memory_order);
771unsigned short atomic_fetch_and(volatile atomic_ushort*, unsigned short);
772unsigned short atomic_fetch_and(atomic_ushort*, unsigned short);
773unsigned short atomic_fetch_and_explicit(volatile atomic_ushort*,
774 unsigned short, memory_order);
775unsigned short atomic_fetch_and_explicit(atomic_ushort*, unsigned short,
776 memory_order);
777unsigned short atomic_fetch_or(volatile atomic_ushort*, unsigned short);
778unsigned short atomic_fetch_or(atomic_ushort*, unsigned short);
779unsigned short atomic_fetch_or_explicit(volatile atomic_ushort*, unsigned short,
780 memory_order);
781unsigned short atomic_fetch_or_explicit(atomic_ushort*, unsigned short,
782 memory_order);
783unsigned short atomic_fetch_xor(volatile atomic_ushort*, unsigned short);
784unsigned short atomic_fetch_xor(atomic_ushort*, unsigned short);
785unsigned short atomic_fetch_xor_explicit(volatile atomic_ushort*,
786 unsigned short, memory_order);
787unsigned short atomic_fetch_xor_explicit(atomic_ushort*, unsigned short,
788 memory_order);
789
790// atomic_int
791
792typedef struct atomic_int
793{
794 bool is_lock_free() const volatile;
795 bool is_lock_free() const;
796 void store(int, memory_order = memory_order_seq_cst) volatile;
797 void store(int, memory_order = memory_order_seq_cst);
798 int load(memory_order = memory_order_seq_cst) const volatile;
799 int load(memory_order = memory_order_seq_cst) const;
800 operator int() const volatile;
801 operator int() const;
Howard Hinnante7385012010-10-19 16:51:18 +0000802 int exchange(int, memory_order = memory_order_seq_cst) volatile;
Howard Hinnant8f73c632010-09-27 21:17:38 +0000803 int exchange(int, memory_order = memory_order_seq_cst);
804 bool compare_exchange_weak(int&, int, memory_order, memory_order) volatile;
805 bool compare_exchange_weak(int&, int, memory_order, memory_order);
806 bool compare_exchange_strong(int&, int, memory_order,
807 memory_order) volatile;
808 bool compare_exchange_strong(int&, int, memory_order, memory_order);
809 bool compare_exchange_weak(int&, int,
810 memory_order = memory_order_seq_cst) volatile;
811 bool compare_exchange_weak(int&, int, memory_order = memory_order_seq_cst);
812 bool compare_exchange_strong(int&, int,
813 memory_order = memory_order_seq_cst) volatile;
814 bool compare_exchange_strong(int&, int,
815 memory_order = memory_order_seq_cst);
816 int fetch_add(int, memory_order = memory_order_seq_cst) volatile;
817 int fetch_add(int, memory_order = memory_order_seq_cst);
818 int fetch_sub(int, memory_order = memory_order_seq_cst) volatile;
819 int fetch_sub(int, memory_order = memory_order_seq_cst);
820 int fetch_and(int, memory_order = memory_order_seq_cst) volatile;
821 int fetch_and(int, memory_order = memory_order_seq_cst);
822 int fetch_or(int, memory_order = memory_order_seq_cst) volatile;
823 int fetch_or(int, memory_order = memory_order_seq_cst);
824 int fetch_xor(int, memory_order = memory_order_seq_cst) volatile;
825 int fetch_xor(int, memory_order = memory_order_seq_cst);
826 atomic_int() = default;
827 constexpr atomic_int(int);
828 atomic_int(const atomic_int&) = delete;
829 atomic_int& operator=(const atomic_int&) = delete;
830 atomic_int& operator=(const atomic_int&) volatile = delete;
831 int operator=(int) volatile;
832 int operator=(int);
833 int operator++(int) volatile;
834 int operator++(int);
835 int operator--(int) volatile;
836 int operator--(int);
837 int operator++() volatile;
838 int operator++();
839 int operator--() volatile;
840 int operator--();
841 int operator+=(int) volatile;
842 int operator+=(int);
843 int operator-=(int) volatile;
844 int operator-=(int);
845 int operator&=(int) volatile;
846 int operator&=(int);
847 int operator|=(int) volatile;
848 int operator|=(int);
849 int operator^=(int) volatile;
850 int operator^=(int);
851} atomic_int;
852
853bool atomic_is_lock_free(const volatile atomic_int*);
854bool atomic_is_lock_free(const atomic_int*);
Howard Hinnante7385012010-10-19 16:51:18 +0000855void atomic_init(volatile atomic_int*, int);
856void atomic_init(atomic_int*, int);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000857void atomic_store(volatile atomic_int*, int);
858void atomic_store(atomic_int*, int);
859void atomic_store_explicit(volatile atomic_int*, int, memory_order);
860void atomic_store_explicit(atomic_int*, int, memory_order);
861int atomic_load(const volatile atomic_int*);
862int atomic_load(const atomic_int*);
863int atomic_load_explicit(const volatile atomic_int*, memory_order);
864int atomic_load_explicit(const atomic_int*, memory_order);
865int atomic_exchange(volatile atomic_int*, int);
866int atomic_exchange(atomic_int*, int);
867int atomic_exchange_explicit(volatile atomic_int*, int, memory_order);
868int atomic_exchange_explicit(atomic_int*, int, memory_order);
869bool atomic_compare_exchange_weak(volatile atomic_int*, int*, int);
870bool atomic_compare_exchange_weak(atomic_int*, int*, int);
871bool atomic_compare_exchange_strong(volatile atomic_int*, int*, int);
872bool atomic_compare_exchange_strong(atomic_int*, int*, int);
873bool atomic_compare_exchange_weak_explicit(volatile atomic_int*, int*, int,
874 memory_order, memory_order);
875bool atomic_compare_exchange_weak_explicit(atomic_int*, int*, int, memory_order,
876 memory_order);
877bool atomic_compare_exchange_strong_explicit(volatile atomic_int*, int*, int,
878 memory_order, memory_order);
879bool atomic_compare_exchange_strong_explicit(atomic_int*, int*, int,
880 memory_order, memory_order);
881int atomic_fetch_add(volatile atomic_int*, int);
882int atomic_fetch_add(atomic_int*, int);
883int atomic_fetch_add_explicit(volatile atomic_int*, int, memory_order);
884int atomic_fetch_add_explicit(atomic_int*, int, memory_order);
885int atomic_fetch_sub(volatile atomic_int*, int);
886int atomic_fetch_sub(atomic_int*, int);
887int atomic_fetch_sub_explicit(volatile atomic_int*, int, memory_order);
888int atomic_fetch_sub_explicit(atomic_int*, int, memory_order);
889int atomic_fetch_and(volatile atomic_int*, int);
890int atomic_fetch_and(atomic_int*, int);
891int atomic_fetch_and_explicit(volatile atomic_int*, int, memory_order);
892int atomic_fetch_and_explicit(atomic_int*, int, memory_order);
893int atomic_fetch_or(volatile atomic_int*, int);
894int atomic_fetch_or(atomic_int*, int);
895int atomic_fetch_or_explicit(volatile atomic_int*, int, memory_order);
896int atomic_fetch_or_explicit(atomic_int*, int, memory_order);
897int atomic_fetch_xor(volatile atomic_int*, int);
898int atomic_fetch_xor(atomic_int*, int);
899int atomic_fetch_xor_explicit(volatile atomic_int*, int, memory_order);
900int atomic_fetch_xor_explicit(atomic_int*, int, memory_order);
901
902// atomic_uint
903
904typedef struct atomic_uint
905{
906 bool is_lock_free() const volatile;
907 bool is_lock_free() const;
908 void store(unsigned int, memory_order = memory_order_seq_cst) volatile;
909 void store(unsigned int, memory_order = memory_order_seq_cst);
910 unsigned int load(memory_order = memory_order_seq_cst) const volatile;
911 unsigned int load(memory_order = memory_order_seq_cst) const;
912 operator unsigned int() const volatile;
913 operator unsigned int() const;
914 unsigned int exchange(unsigned int,
Howard Hinnante7385012010-10-19 16:51:18 +0000915 memory_order = memory_order_seq_cst) volatile;
Howard Hinnant8f73c632010-09-27 21:17:38 +0000916 unsigned int exchange(unsigned int, memory_order = memory_order_seq_cst);
917 bool compare_exchange_weak(unsigned int&, unsigned int, memory_order,
918 memory_order) volatile;
919 bool compare_exchange_weak(unsigned int&, unsigned int, memory_order,
920 memory_order);
921 bool compare_exchange_strong(unsigned int&, unsigned int, memory_order,
922 memory_order) volatile;
923 bool compare_exchange_strong(unsigned int&, unsigned int, memory_order,
924 memory_order);
925 bool compare_exchange_weak(unsigned int&, unsigned int,
926 memory_order = memory_order_seq_cst) volatile;
927 bool compare_exchange_weak(unsigned int&, unsigned int,
928 memory_order = memory_order_seq_cst);
929 bool compare_exchange_strong(unsigned int&, unsigned int,
930 memory_order = memory_order_seq_cst) volatile;
931 bool compare_exchange_strong(unsigned int&, unsigned int,
932 memory_order = memory_order_seq_cst);
933 unsigned int fetch_add(unsigned int,
934 memory_order = memory_order_seq_cst) volatile;
935 unsigned int fetch_add(unsigned int, memory_order = memory_order_seq_cst);
936 unsigned int fetch_sub(unsigned int,
937 memory_order = memory_order_seq_cst) volatile;
938 unsigned int fetch_sub(unsigned int, memory_order = memory_order_seq_cst);
939 unsigned int fetch_and(unsigned int,
940 memory_order = memory_order_seq_cst) volatile;
941 unsigned int fetch_and(unsigned int, memory_order = memory_order_seq_cst);
942 unsigned int fetch_or(unsigned int,
943 memory_order = memory_order_seq_cst) volatile;
944 unsigned int fetch_or(unsigned int, memory_order = memory_order_seq_cst);
945 unsigned int fetch_xor(unsigned int,
946 memory_order = memory_order_seq_cst) volatile;
947 unsigned int fetch_xor(unsigned int, memory_order = memory_order_seq_cst);
948 atomic_uint() = default;
949 constexpr atomic_uint(unsigned int);
950 atomic_uint(const atomic_uint&) = delete;
951 atomic_uint& operator=(const atomic_uint&) = delete;
952 atomic_uint& operator=(const atomic_uint&) volatile = delete;
953 unsigned int operator=(unsigned int) volatile;
954 unsigned int operator=(unsigned int);
955 unsigned int operator++(int) volatile;
956 unsigned int operator++(int);
957 unsigned int operator--(int) volatile;
958 unsigned int operator--(int);
959 unsigned int operator++() volatile;
960 unsigned int operator++();
961 unsigned int operator--() volatile;
962 unsigned int operator--();
963 unsigned int operator+=(unsigned int) volatile;
964 unsigned int operator+=(unsigned int);
965 unsigned int operator-=(unsigned int) volatile;
966 unsigned int operator-=(unsigned int);
967 unsigned int operator&=(unsigned int) volatile;
968 unsigned int operator&=(unsigned int);
969 unsigned int operator|=(unsigned int) volatile;
970 unsigned int operator|=(unsigned int);
971 unsigned int operator^=(unsigned int) volatile;
972 unsigned int operator^=(unsigned int);
973} atomic_uint;
974
975bool atomic_is_lock_free(const volatile atomic_uint*);
976bool atomic_is_lock_free(const atomic_uint*);
Howard Hinnante7385012010-10-19 16:51:18 +0000977void atomic_init(volatile atomic_uint*, unsigned int);
978void atomic_init(atomic_uint*, unsigned int);
Howard Hinnant8f73c632010-09-27 21:17:38 +0000979void atomic_store(volatile atomic_uint*, unsigned int);
980void atomic_store(atomic_uint*, unsigned int);
981void atomic_store_explicit(volatile atomic_uint*, unsigned int, memory_order);
982void atomic_store_explicit(atomic_uint*, unsigned int, memory_order);
983unsigned int atomic_load(const volatile atomic_uint*);
984unsigned int atomic_load(const atomic_uint*);
985unsigned int atomic_load_explicit(const volatile atomic_uint*, memory_order);
986unsigned int atomic_load_explicit(const atomic_uint*, memory_order);
987unsigned int atomic_exchange(volatile atomic_uint*, unsigned int);
988unsigned int atomic_exchange(atomic_uint*, unsigned int);
989unsigned int atomic_exchange_explicit(volatile atomic_uint*, unsigned int,
990 memory_order);
991unsigned int atomic_exchange_explicit(atomic_uint*, unsigned int, memory_order);
992bool atomic_compare_exchange_weak(volatile atomic_uint*, unsigned int*,
993 unsigned int);
994bool atomic_compare_exchange_weak(atomic_uint*, unsigned int*, unsigned int);
995bool atomic_compare_exchange_strong(volatile atomic_uint*, unsigned int*,
996 unsigned int);
997bool atomic_compare_exchange_strong(atomic_uint*, unsigned int*, unsigned int);
998bool atomic_compare_exchange_weak_explicit(volatile atomic_uint*, unsigned int*,
999 unsigned int, memory_order,
1000 memory_order);
1001bool atomic_compare_exchange_weak_explicit(atomic_uint*, unsigned int*,
1002 unsigned int, memory_order,
1003 memory_order);
1004bool atomic_compare_exchange_strong_explicit(volatile atomic_uint*,
1005 unsigned int*, unsigned int,
1006 memory_order, memory_order);
1007bool atomic_compare_exchange_strong_explicit(atomic_uint*, unsigned int*,
1008 unsigned int, memory_order,
1009 memory_order);
1010unsigned int atomic_fetch_add(volatile atomic_uint*, unsigned int);
1011unsigned int atomic_fetch_add(atomic_uint*, unsigned int);
1012unsigned int atomic_fetch_add_explicit(volatile atomic_uint*, unsigned int,
1013 memory_order);
1014unsigned int atomic_fetch_add_explicit(atomic_uint*, unsigned int,
1015 memory_order);
1016unsigned int atomic_fetch_sub(volatile atomic_uint*, unsigned int);
1017unsigned int atomic_fetch_sub(atomic_uint*, unsigned int);
1018unsigned int atomic_fetch_sub_explicit(volatile atomic_uint*, unsigned int,
1019 memory_order);
1020unsigned int atomic_fetch_sub_explicit(atomic_uint*, unsigned int,
1021 memory_order);
1022unsigned int atomic_fetch_and(volatile atomic_uint*, unsigned int);
1023unsigned int atomic_fetch_and(atomic_uint*, unsigned int);
1024unsigned int atomic_fetch_and_explicit(volatile atomic_uint*, unsigned int,
1025 memory_order);
1026unsigned int atomic_fetch_and_explicit(atomic_uint*, unsigned int,
1027 memory_order);
1028unsigned int atomic_fetch_or(volatile atomic_uint*, unsigned int);
1029unsigned int atomic_fetch_or(atomic_uint*, unsigned int);
1030unsigned int atomic_fetch_or_explicit(volatile atomic_uint*, unsigned int,
1031 memory_order);
1032unsigned int atomic_fetch_or_explicit(atomic_uint*, unsigned int, memory_order);
1033unsigned int atomic_fetch_xor(volatile atomic_uint*, unsigned int);
1034unsigned int atomic_fetch_xor(atomic_uint*, unsigned int);
1035unsigned int atomic_fetch_xor_explicit(volatile atomic_uint*, unsigned int,
1036 memory_order);
1037unsigned int atomic_fetch_xor_explicit(atomic_uint*, unsigned int,
1038 memory_order);
1039
1040// atomic_long
1041
1042typedef struct atomic_long
1043{
1044 bool is_lock_free() const volatile;
1045 bool is_lock_free() const;
1046 void store(long, memory_order = memory_order_seq_cst) volatile;
1047 void store(long, memory_order = memory_order_seq_cst);
1048 long load(memory_order = memory_order_seq_cst) const volatile;
1049 long load(memory_order = memory_order_seq_cst) const;
1050 operator long() const volatile;
1051 operator long() const;
Howard Hinnante7385012010-10-19 16:51:18 +00001052 long exchange(long, memory_order = memory_order_seq_cst) volatile;
Howard Hinnant8f73c632010-09-27 21:17:38 +00001053 long exchange(long, memory_order = memory_order_seq_cst);
1054 bool compare_exchange_weak(long&, long, memory_order,
1055 memory_order) volatile;
1056 bool compare_exchange_weak(long&, long, memory_order, memory_order);
1057 bool compare_exchange_strong(long&, long, memory_order,
1058 memory_order) volatile;
1059 bool compare_exchange_strong(long&, long, memory_order, memory_order);
1060 bool compare_exchange_weak(long&, long,
1061 memory_order = memory_order_seq_cst) volatile;
1062 bool compare_exchange_weak(long&, long,
1063 memory_order = memory_order_seq_cst);
1064 bool compare_exchange_strong(long&, long,
1065 memory_order = memory_order_seq_cst) volatile;
1066 bool compare_exchange_strong(long&, long,
1067 memory_order = memory_order_seq_cst);
1068 long fetch_add(long, memory_order = memory_order_seq_cst) volatile;
1069 long fetch_add(long, memory_order = memory_order_seq_cst);
1070 long fetch_sub(long, memory_order = memory_order_seq_cst) volatile;
1071 long fetch_sub(long, memory_order = memory_order_seq_cst);
1072 long fetch_and(long, memory_order = memory_order_seq_cst) volatile;
1073 long fetch_and(long, memory_order = memory_order_seq_cst);
1074 long fetch_or(long, memory_order = memory_order_seq_cst) volatile;
1075 long fetch_or(long, memory_order = memory_order_seq_cst);
1076 long fetch_xor(long, memory_order = memory_order_seq_cst) volatile;
1077 long fetch_xor(long, memory_order = memory_order_seq_cst);
1078 atomic_long() = default;
1079 constexpr atomic_long(long);
1080 atomic_long(const atomic_long&) = delete;
1081 atomic_long& operator=(const atomic_long&) = delete;
1082 atomic_long& operator=(const atomic_long&) volatile = delete;
1083 long operator=(long) volatile;
1084 long operator=(long);
1085 long operator++(int) volatile;
1086 long operator++(int);
1087 long operator--(int) volatile;
1088 long operator--(int);
1089 long operator++() volatile;
1090 long operator++();
1091 long operator--() volatile;
1092 long operator--();
1093 long operator+=(long) volatile;
1094 long operator+=(long);
1095 long operator-=(long) volatile;
1096 long operator-=(long);
1097 long operator&=(long) volatile;
1098 long operator&=(long);
1099 long operator|=(long) volatile;
1100 long operator|=(long);
1101 long operator^=(long) volatile;
1102 long operator^=(long);
1103} atomic_long;
1104
1105bool atomic_is_lock_free(const volatile atomic_long*);
1106bool atomic_is_lock_free(const atomic_long*);
Howard Hinnante7385012010-10-19 16:51:18 +00001107void atomic_init(volatile atomic_long*, long);
1108void atomic_init(atomic_long*, long);
Howard Hinnant8f73c632010-09-27 21:17:38 +00001109void atomic_store(volatile atomic_long*, long);
1110void atomic_store(atomic_long*, long);
1111void atomic_store_explicit(volatile atomic_long*, long, memory_order);
1112void atomic_store_explicit(atomic_long*, long, memory_order);
1113long atomic_load(const volatile atomic_long*);
1114long atomic_load(const atomic_long*);
1115long atomic_load_explicit(const volatile atomic_long*, memory_order);
1116long atomic_load_explicit(const atomic_long*, memory_order);
1117long atomic_exchange(volatile atomic_long*, long);
1118long atomic_exchange(atomic_long*, long);
1119long atomic_exchange_explicit(volatile atomic_long*, long, memory_order);
1120long atomic_exchange_explicit(atomic_long*, long, memory_order);
1121bool atomic_compare_exchange_weak(volatile atomic_long*, long*, long);
1122bool atomic_compare_exchange_weak(atomic_long*, long*, long);
1123bool atomic_compare_exchange_strong(volatile atomic_long*, long*, long);
1124bool atomic_compare_exchange_strong(atomic_long*, long*, long);
1125bool atomic_compare_exchange_weak_explicit(volatile atomic_long*, long*, long,
1126 memory_order, memory_order);
1127bool atomic_compare_exchange_weak_explicit(atomic_long*, long*, long,
1128 memory_order, memory_order);
1129bool atomic_compare_exchange_strong_explicit(volatile atomic_long*, long*, long,
1130 memory_order, memory_order);
1131bool atomic_compare_exchange_strong_explicit(atomic_long*, long*, long,
1132 memory_order, memory_order);
1133long atomic_fetch_add(volatile atomic_long*, long);
1134long atomic_fetch_add(atomic_long*, long);
1135long atomic_fetch_add_explicit(volatile atomic_long*, long, memory_order);
1136long atomic_fetch_add_explicit(atomic_long*, long, memory_order);
1137long atomic_fetch_sub(volatile atomic_long*, long);
1138long atomic_fetch_sub(atomic_long*, long);
1139long atomic_fetch_sub_explicit(volatile atomic_long*, long, memory_order);
1140long atomic_fetch_sub_explicit(atomic_long*, long, memory_order);
1141long atomic_fetch_and(volatile atomic_long*, long);
1142long atomic_fetch_and(atomic_long*, long);
1143long atomic_fetch_and_explicit(volatile atomic_long*, long, memory_order);
1144long atomic_fetch_and_explicit(atomic_long*, long, memory_order);
1145long atomic_fetch_or(volatile atomic_long*, long);
1146long atomic_fetch_or(atomic_long*, long);
1147long atomic_fetch_or_explicit(volatile atomic_long*, long, memory_order);
1148long atomic_fetch_or_explicit(atomic_long*, long, memory_order);
1149long atomic_fetch_xor(volatile atomic_long*, long);
1150long atomic_fetch_xor(atomic_long*, long);
1151long atomic_fetch_xor_explicit(volatile atomic_long*, long, memory_order);
1152long atomic_fetch_xor_explicit(atomic_long*, long, memory_order);
1153
1154// atomic_ulong
1155
1156typedef struct atomic_ulong
1157{
1158 bool is_lock_free() const volatile;
1159 bool is_lock_free() const;
1160 void store(unsigned long, memory_order = memory_order_seq_cst) volatile;
1161 void store(unsigned long, memory_order = memory_order_seq_cst);
1162 unsigned long load(memory_order = memory_order_seq_cst) const volatile;
1163 unsigned long load(memory_order = memory_order_seq_cst) const;
1164 operator unsigned long() const volatile;
1165 operator unsigned long() const;
1166 unsigned long exchange(unsigned long,
Howard Hinnante7385012010-10-19 16:51:18 +00001167 memory_order = memory_order_seq_cst) volatile;
Howard Hinnant8f73c632010-09-27 21:17:38 +00001168 unsigned long exchange(unsigned long, memory_order = memory_order_seq_cst);
1169 bool compare_exchange_weak(unsigned long&, unsigned long, memory_order,
1170 memory_order) volatile;
1171 bool compare_exchange_weak(unsigned long&, unsigned long, memory_order,
1172 memory_order);
1173 bool compare_exchange_strong(unsigned long&, unsigned long, memory_order,
1174 memory_order) volatile;
1175 bool compare_exchange_strong(unsigned long&, unsigned long, memory_order,
1176 memory_order);
1177 bool compare_exchange_weak(unsigned long&, unsigned long,
1178 memory_order = memory_order_seq_cst) volatile;
1179 bool compare_exchange_weak(unsigned long&, unsigned long,
1180 memory_order = memory_order_seq_cst);
1181 bool compare_exchange_strong(unsigned long&, unsigned long,
1182 memory_order = memory_order_seq_cst) volatile;
1183 bool compare_exchange_strong(unsigned long&, unsigned long,
1184 memory_order = memory_order_seq_cst);
1185 unsigned long fetch_add(unsigned long,
1186 memory_order = memory_order_seq_cst) volatile;
1187 unsigned long fetch_add(unsigned long, memory_order = memory_order_seq_cst);
1188 unsigned long fetch_sub(unsigned long,
1189 memory_order = memory_order_seq_cst) volatile;
1190 unsigned long fetch_sub(unsigned long, memory_order = memory_order_seq_cst);
1191 unsigned long fetch_and(unsigned long,
1192 memory_order = memory_order_seq_cst) volatile;
1193 unsigned long fetch_and(unsigned long, memory_order = memory_order_seq_cst);
1194 unsigned long fetch_or(unsigned long,
1195 memory_order = memory_order_seq_cst) volatile;
1196 unsigned long fetch_or(unsigned long, memory_order = memory_order_seq_cst);
1197 unsigned long fetch_xor(unsigned long,
1198 memory_order = memory_order_seq_cst) volatile;
1199 unsigned long fetch_xor(unsigned long, memory_order = memory_order_seq_cst);
1200 atomic_ulong() = default;
1201 constexpr atomic_ulong(unsigned long);
1202 atomic_ulong(const atomic_ulong&) = delete;
1203 atomic_ulong& operator=(const atomic_ulong&) = delete;
1204 atomic_ulong& operator=(const atomic_ulong&) volatile = delete;
1205 unsigned long operator=(unsigned long) volatile;
1206 unsigned long operator=(unsigned long);
1207 unsigned long operator++(int) volatile;
1208 unsigned long operator++(int);
1209 unsigned long operator--(int) volatile;
1210 unsigned long operator--(int);
1211 unsigned long operator++() volatile;
1212 unsigned long operator++();
1213 unsigned long operator--() volatile;
1214 unsigned long operator--();
1215 unsigned long operator+=(unsigned long) volatile;
1216 unsigned long operator+=(unsigned long);
1217 unsigned long operator-=(unsigned long) volatile;
1218 unsigned long operator-=(unsigned long);
1219 unsigned long operator&=(unsigned long) volatile;
1220 unsigned long operator&=(unsigned long);
1221 unsigned long operator|=(unsigned long) volatile;
1222 unsigned long operator|=(unsigned long);
1223 unsigned long operator^=(unsigned long) volatile;
1224 unsigned long operator^=(unsigned long);
1225} atomic_ulong;
1226
1227bool atomic_is_lock_free(const volatile atomic_ulong*);
1228bool atomic_is_lock_free(const atomic_ulong*);
Howard Hinnante7385012010-10-19 16:51:18 +00001229void atomic_init(volatile atomic_ulong*, unsigned long);
1230void atomic_init(atomic_ulong*, unsigned long);
Howard Hinnant8f73c632010-09-27 21:17:38 +00001231void atomic_store(volatile atomic_ulong*, unsigned long);
1232void atomic_store(atomic_ulong*, unsigned long);
1233void atomic_store_explicit(volatile atomic_ulong*, unsigned long, memory_order);
1234void atomic_store_explicit(atomic_ulong*, unsigned long, memory_order);
1235unsigned long atomic_load(const volatile atomic_ulong*);
1236unsigned long atomic_load(const atomic_ulong*);
1237unsigned long atomic_load_explicit(const volatile atomic_ulong*, memory_order);
1238unsigned long atomic_load_explicit(const atomic_ulong*, memory_order);
1239unsigned long atomic_exchange(volatile atomic_ulong*, unsigned long);
1240unsigned long atomic_exchange(atomic_ulong*, unsigned long);
1241unsigned long atomic_exchange_explicit(volatile atomic_ulong*, unsigned long,
1242 memory_order);
1243unsigned long atomic_exchange_explicit(atomic_ulong*, unsigned long,
1244 memory_order);
1245bool atomic_compare_exchange_weak(volatile atomic_ulong*, unsigned long*,
1246 unsigned long);
1247bool atomic_compare_exchange_weak(atomic_ulong*, unsigned long*, unsigned long);
1248bool atomic_compare_exchange_strong(volatile atomic_ulong*, unsigned long*,
1249 unsigned long);
1250bool atomic_compare_exchange_strong(atomic_ulong*, unsigned long*,
1251 unsigned long);
1252bool atomic_compare_exchange_weak_explicit(volatile atomic_ulong*,
1253 unsigned long*, unsigned long,
1254 memory_order, memory_order);
1255bool atomic_compare_exchange_weak_explicit(atomic_ulong*, unsigned long*,
1256 unsigned long, memory_order,
1257 memory_order);
1258bool atomic_compare_exchange_strong_explicit(volatile atomic_ulong*,
1259 unsigned long*, unsigned long,
1260 memory_order, memory_order);
1261bool atomic_compare_exchange_strong_explicit(atomic_ulong*, unsigned long*,
1262 unsigned long, memory_order,
1263 memory_order);
1264unsigned long atomic_fetch_add(volatile atomic_ulong*, unsigned long);
1265unsigned long atomic_fetch_add(atomic_ulong*, unsigned long);
1266unsigned long atomic_fetch_add_explicit(volatile atomic_ulong*, unsigned long,
1267 memory_order);
1268unsigned long atomic_fetch_add_explicit(atomic_ulong*, unsigned long,
1269 memory_order);
1270unsigned long atomic_fetch_sub(volatile atomic_ulong*, unsigned long);
1271unsigned long atomic_fetch_sub(atomic_ulong*, unsigned long);
1272unsigned long atomic_fetch_sub_explicit(volatile atomic_ulong*, unsigned long,
1273 memory_order);
1274unsigned long atomic_fetch_sub_explicit(atomic_ulong*, unsigned long,
1275 memory_order);
1276unsigned long atomic_fetch_and(volatile atomic_ulong*, unsigned long);
1277unsigned long atomic_fetch_and(atomic_ulong*, unsigned long);
1278unsigned long atomic_fetch_and_explicit(volatile atomic_ulong*, unsigned long,
1279 memory_order);
1280unsigned long atomic_fetch_and_explicit(atomic_ulong*, unsigned long,
1281 memory_order);
1282unsigned long atomic_fetch_or(volatile atomic_ulong*, unsigned long);
1283unsigned long atomic_fetch_or(atomic_ulong*, unsigned long);
1284unsigned long atomic_fetch_or_explicit(volatile atomic_ulong*, unsigned long,
1285 memory_order);
1286unsigned long atomic_fetch_or_explicit(atomic_ulong*, unsigned long,
1287 memory_order);
1288unsigned long atomic_fetch_xor(volatile atomic_ulong*, unsigned long);
1289unsigned long atomic_fetch_xor(atomic_ulong*, unsigned long);
1290unsigned long atomic_fetch_xor_explicit(volatile atomic_ulong*, unsigned long,
1291 memory_order);
1292unsigned long atomic_fetch_xor_explicit(atomic_ulong*, unsigned long,
1293 memory_order);
1294
1295// atomic_llong
1296
1297typedef struct atomic_llong
1298{
1299 bool is_lock_free() const volatile;
1300 bool is_lock_free() const;
1301 void store(long long, memory_order = memory_order_seq_cst) volatile;
1302 void store(long long, memory_order = memory_order_seq_cst);
1303 long long load(memory_order = memory_order_seq_cst) const volatile;
1304 long long load(memory_order = memory_order_seq_cst) const;
1305 operator long long() const volatile;
1306 operator long long() const;
Howard Hinnante7385012010-10-19 16:51:18 +00001307 long long exchange(long long, memory_order = memory_order_seq_cst) volatile;
Howard Hinnant8f73c632010-09-27 21:17:38 +00001308 long long exchange(long long, memory_order = memory_order_seq_cst);
1309 bool compare_exchange_weak(long long&, long long, memory_order,
1310 memory_order) volatile;
1311 bool compare_exchange_weak(long long&, long long, memory_order,
1312 memory_order);
1313 bool compare_exchange_strong(long long&, long long, memory_order,
1314 memory_order) volatile;
1315 bool compare_exchange_strong(long long&, long long, memory_order,
1316 memory_order);
1317 bool compare_exchange_weak(long long&, long long,
1318 memory_order = memory_order_seq_cst) volatile;
1319 bool compare_exchange_weak(long long&, long long,
1320 memory_order = memory_order_seq_cst);
1321 bool compare_exchange_strong(long long&, long long,
1322 memory_order = memory_order_seq_cst) volatile;
1323 bool compare_exchange_strong(long long&, long long,
1324 memory_order = memory_order_seq_cst);
1325 long long fetch_add(long long,
1326 memory_order = memory_order_seq_cst) volatile;
1327 long long fetch_add(long long, memory_order = memory_order_seq_cst);
1328 long long fetch_sub(long long,
1329 memory_order = memory_order_seq_cst) volatile;
1330 long long fetch_sub(long long, memory_order = memory_order_seq_cst);
1331 long long fetch_and(long long,
1332 memory_order = memory_order_seq_cst) volatile;
1333 long long fetch_and(long long, memory_order = memory_order_seq_cst);
1334 long long fetch_or(long long, memory_order = memory_order_seq_cst) volatile;
1335 long long fetch_or(long long, memory_order = memory_order_seq_cst);
1336 long long fetch_xor(long long,
1337 memory_order = memory_order_seq_cst) volatile;
1338 long long fetch_xor(long long, memory_order = memory_order_seq_cst);
1339 atomic_llong() = default;
1340 constexpr atomic_llong(long long);
1341 atomic_llong(const atomic_llong&) = delete;
1342 atomic_llong& operator=(const atomic_llong&) = delete;
1343 atomic_llong& operator=(const atomic_llong&) volatile = delete;
1344 long long operator=(long long) volatile;
1345 long long operator=(long long);
1346 long long operator++(int) volatile;
1347 long long operator++(int);
1348 long long operator--(int) volatile;
1349 long long operator--(int);
1350 long long operator++() volatile;
1351 long long operator++();
1352 long long operator--() volatile;
1353 long long operator--();
1354 long long operator+=(long long) volatile;
1355 long long operator+=(long long);
1356 long long operator-=(long long) volatile;
1357 long long operator-=(long long);
1358 long long operator&=(long long) volatile;
1359 long long operator&=(long long);
1360 long long operator|=(long long) volatile;
1361 long long operator|=(long long);
1362 long long operator^=(long long) volatile;
1363 long long operator^=(long long);
1364} atomic_llong;
1365
1366bool atomic_is_lock_free(const volatile atomic_llong*);
1367bool atomic_is_lock_free(const atomic_llong*);
Howard Hinnante7385012010-10-19 16:51:18 +00001368void atomic_init(volatile atomic_llong*, long long);
1369void atomic_init(atomic_llong*, long long);
Howard Hinnant8f73c632010-09-27 21:17:38 +00001370void atomic_store(volatile atomic_llong*, long long);
1371void atomic_store(atomic_llong*, long long);
1372void atomic_store_explicit(volatile atomic_llong*, long long, memory_order);
1373void atomic_store_explicit(atomic_llong*, long long, memory_order);
1374long long atomic_load(const volatile atomic_llong*);
1375long long atomic_load(const atomic_llong*);
1376long long atomic_load_explicit(const volatile atomic_llong*, memory_order);
1377long long atomic_load_explicit(const atomic_llong*, memory_order);
1378long long atomic_exchange(volatile atomic_llong*, long long);
1379long long atomic_exchange(atomic_llong*, long long);
1380long long atomic_exchange_explicit(volatile atomic_llong*, long long,
1381 memory_order);
1382long long atomic_exchange_explicit(atomic_llong*, long long, memory_order);
1383bool atomic_compare_exchange_weak(volatile atomic_llong*, long long*,
1384 long long);
1385bool atomic_compare_exchange_weak(atomic_llong*, long long*, long long);
1386bool atomic_compare_exchange_strong(volatile atomic_llong*, long long*,
1387 long long);
1388bool atomic_compare_exchange_strong(atomic_llong*, long long*, long long);
1389bool atomic_compare_exchange_weak_explicit(volatile atomic_llong*, long long*,
1390 long long, memory_order,
1391 memory_order);
1392bool atomic_compare_exchange_weak_explicit(atomic_llong*, long long*, long long,
1393 memory_order, memory_order);
1394bool atomic_compare_exchange_strong_explicit(volatile atomic_llong*, long long*,
1395 long long, memory_order,
1396 memory_order);
1397bool atomic_compare_exchange_strong_explicit(atomic_llong*, long long*,
1398 long long, memory_order,
1399 memory_order);
1400long long atomic_fetch_add(volatile atomic_llong*, long long);
1401long long atomic_fetch_add(atomic_llong*, long long);
1402long long atomic_fetch_add_explicit(volatile atomic_llong*, long long,
1403 memory_order);
1404long long atomic_fetch_add_explicit(atomic_llong*, long long, memory_order);
1405long long atomic_fetch_sub(volatile atomic_llong*, long long);
1406long long atomic_fetch_sub(atomic_llong*, long long);
1407long long atomic_fetch_sub_explicit(volatile atomic_llong*, long long,
1408 memory_order);
1409long long atomic_fetch_sub_explicit(atomic_llong*, long long, memory_order);
1410long long atomic_fetch_and(volatile atomic_llong*, long long);
1411long long atomic_fetch_and(atomic_llong*, long long);
1412long long atomic_fetch_and_explicit(volatile atomic_llong*, long long,
1413 memory_order);
1414long long atomic_fetch_and_explicit(atomic_llong*, long long, memory_order);
1415long long atomic_fetch_or(volatile atomic_llong*, long long);
1416long long atomic_fetch_or(atomic_llong*, long long);
1417long long atomic_fetch_or_explicit(volatile atomic_llong*, long long,
1418 memory_order);
1419long long atomic_fetch_or_explicit(atomic_llong*, long long, memory_order);
1420long long atomic_fetch_xor(volatile atomic_llong*, long long);
1421long long atomic_fetch_xor(atomic_llong*, long long);
1422long long atomic_fetch_xor_explicit(volatile atomic_llong*, long long,
1423 memory_order);
1424long long atomic_fetch_xor_explicit(atomic_llong*, long long, memory_order);
1425
1426// atomic_ullong
1427
1428typedef struct atomic_ullong
1429{
1430 bool is_lock_free() const volatile;
1431 bool is_lock_free() const;
1432 void store(unsigned long long,
1433 memory_order = memory_order_seq_cst) volatile;
1434 void store(unsigned long long, memory_order = memory_order_seq_cst);
1435 unsigned long long load(memory_order = memory_order_seq_cst) const volatile;
1436 unsigned long long load(memory_order = memory_order_seq_cst) const;
1437 operator unsigned long long() const volatile;
1438 operator unsigned long long() const;
1439 unsigned long long exchange(unsigned long long,
Howard Hinnante7385012010-10-19 16:51:18 +00001440 memory_order = memory_order_seq_cst) volatile;
Howard Hinnant8f73c632010-09-27 21:17:38 +00001441 unsigned long long exchange(unsigned long long,
1442 memory_order = memory_order_seq_cst);
1443 bool compare_exchange_weak(unsigned long long&, unsigned long long,
1444 memory_order, memory_order) volatile;
1445 bool compare_exchange_weak(unsigned long long&, unsigned long long,
1446 memory_order, memory_order);
1447 bool compare_exchange_strong(unsigned long long&, unsigned long long,
1448 memory_order, memory_order) volatile;
1449 bool compare_exchange_strong(unsigned long long&, unsigned long long,
1450 memory_order, memory_order);
1451 bool compare_exchange_weak(unsigned long long&, unsigned long long,
1452 memory_order = memory_order_seq_cst) volatile;
1453 bool compare_exchange_weak(unsigned long long&, unsigned long long,
1454 memory_order = memory_order_seq_cst);
1455 bool compare_exchange_strong(unsigned long long&, unsigned long long,
1456 memory_order = memory_order_seq_cst) volatile;
1457 bool compare_exchange_strong(unsigned long long&, unsigned long long,
1458 memory_order = memory_order_seq_cst);
1459 unsigned long long fetch_add(unsigned long long,
1460 memory_order = memory_order_seq_cst) volatile;
1461 unsigned long long fetch_add(unsigned long long,
1462 memory_order = memory_order_seq_cst);
1463 unsigned long long fetch_sub(unsigned long long,
1464 memory_order = memory_order_seq_cst) volatile;
1465 unsigned long long fetch_sub(unsigned long long,
1466 memory_order = memory_order_seq_cst);
1467 unsigned long long fetch_and(unsigned long long,
1468 memory_order = memory_order_seq_cst) volatile;
1469 unsigned long long fetch_and(unsigned long long,
1470 memory_order = memory_order_seq_cst);
1471 unsigned long long fetch_or(unsigned long long,
1472 memory_order = memory_order_seq_cst) volatile;
1473 unsigned long long fetch_or(unsigned long long,
1474 memory_order = memory_order_seq_cst);
1475 unsigned long long fetch_xor(unsigned long long,
1476 memory_order = memory_order_seq_cst) volatile;
1477 unsigned long long fetch_xor(unsigned long long,
1478 memory_order = memory_order_seq_cst);
1479 atomic_ullong() = default;
1480 constexpr atomic_ullong(unsigned long long);
1481 atomic_ullong(const atomic_ullong&) = delete;
1482 atomic_ullong& operator=(const atomic_ullong&) = delete;
1483 atomic_ullong& operator=(const atomic_ullong&) volatile = delete;
1484 unsigned long long operator=(unsigned long long) volatile;
1485 unsigned long long operator=(unsigned long long);
1486 unsigned long long operator++(int) volatile;
1487 unsigned long long operator++(int);
1488 unsigned long long operator--(int) volatile;
1489 unsigned long long operator--(int);
1490 unsigned long long operator++() volatile;
1491 unsigned long long operator++();
1492 unsigned long long operator--() volatile;
1493 unsigned long long operator--();
1494 unsigned long long operator+=(unsigned long long) volatile;
1495 unsigned long long operator+=(unsigned long long);
1496 unsigned long long operator-=(unsigned long long) volatile;
1497 unsigned long long operator-=(unsigned long long);
1498 unsigned long long operator&=(unsigned long long) volatile;
1499 unsigned long long operator&=(unsigned long long);
1500 unsigned long long operator|=(unsigned long long) volatile;
1501 unsigned long long operator|=(unsigned long long);
1502 unsigned long long operator^=(unsigned long long) volatile;
1503 unsigned long long operator^=(unsigned long long);
1504} atomic_ullong;
1505
1506bool atomic_is_lock_free(const volatile atomic_ullong*);
1507bool atomic_is_lock_free(const atomic_ullong*);
Howard Hinnante7385012010-10-19 16:51:18 +00001508void atomic_init(volatile atomic_ullong*, unsigned long long);
1509void atomic_init(atomic_ullong*, unsigned long long);
Howard Hinnant8f73c632010-09-27 21:17:38 +00001510void atomic_store(volatile atomic_ullong*, unsigned long long);
1511void atomic_store(atomic_ullong*, unsigned long long);
1512void atomic_store_explicit(volatile atomic_ullong*, unsigned long long,
1513 memory_order);
1514void atomic_store_explicit(atomic_ullong*, unsigned long long, memory_order);
1515unsigned long long atomic_load(const volatile atomic_ullong*);
1516unsigned long long atomic_load(const atomic_ullong*);
1517unsigned long long atomic_load_explicit(const volatile atomic_ullong*,
1518 memory_order);
1519unsigned long long atomic_load_explicit(const atomic_ullong*, memory_order);
1520unsigned long long atomic_exchange(volatile atomic_ullong*, unsigned long long);
1521unsigned long long atomic_exchange(atomic_ullong*, unsigned long long);
1522unsigned long long atomic_exchange_explicit(volatile atomic_ullong*,
1523 unsigned long long, memory_order);
1524unsigned long long atomic_exchange_explicit(atomic_ullong*, unsigned long long,
1525 memory_order);
1526bool atomic_compare_exchange_weak(volatile atomic_ullong*, unsigned long long*,
1527 unsigned long long);
1528bool atomic_compare_exchange_weak(atomic_ullong*, unsigned long long*,
1529 unsigned long long);
1530bool atomic_compare_exchange_strong(volatile atomic_ullong*,
1531 unsigned long long*, unsigned long long);
1532bool atomic_compare_exchange_strong(atomic_ullong*, unsigned long long*,
1533 unsigned long long);
1534bool atomic_compare_exchange_weak_explicit(volatile atomic_ullong*,
1535 unsigned long long*,
1536 unsigned long long, memory_order,
1537 memory_order);
1538bool atomic_compare_exchange_weak_explicit(atomic_ullong*, unsigned long long*,
1539 unsigned long long, memory_order,
1540 memory_order);
1541bool atomic_compare_exchange_strong_explicit(volatile atomic_ullong*,
1542 unsigned long long*,
1543 unsigned long long, memory_order,
1544 memory_order);
1545bool atomic_compare_exchange_strong_explicit(atomic_ullong*,
1546 unsigned long long*,
1547 unsigned long long, memory_order,
1548 memory_order);
1549unsigned long long atomic_fetch_add(volatile atomic_ullong*,
1550 unsigned long long);
1551unsigned long long atomic_fetch_add(atomic_ullong*, unsigned long long);
1552unsigned long long atomic_fetch_add_explicit(volatile atomic_ullong*,
1553 unsigned long long, memory_order);
1554unsigned long long atomic_fetch_add_explicit(atomic_ullong*, unsigned long long,
1555 memory_order);
1556unsigned long long atomic_fetch_sub(volatile atomic_ullong*,
1557 unsigned long long);
1558unsigned long long atomic_fetch_sub(atomic_ullong*, unsigned long long);
1559unsigned long long atomic_fetch_sub_explicit(volatile atomic_ullong*,
1560 unsigned long long, memory_order);
1561unsigned long long atomic_fetch_sub_explicit(atomic_ullong*, unsigned long long,
1562 memory_order);
1563unsigned long long atomic_fetch_and(volatile atomic_ullong*,
1564 unsigned long long);
1565unsigned long long atomic_fetch_and(atomic_ullong*, unsigned long long);
1566unsigned long long atomic_fetch_and_explicit(volatile atomic_ullong*,
1567 unsigned long long, memory_order);
1568unsigned long long atomic_fetch_and_explicit(atomic_ullong*, unsigned long long,
1569 memory_order);
1570unsigned long long atomic_fetch_or(volatile atomic_ullong*, unsigned long long);
1571unsigned long long atomic_fetch_or(atomic_ullong*, unsigned long long);
1572unsigned long long atomic_fetch_or_explicit(volatile atomic_ullong*,
1573 unsigned long long, memory_order);
1574unsigned long long atomic_fetch_or_explicit(atomic_ullong*, unsigned long long,
1575 memory_order);
1576unsigned long long atomic_fetch_xor(volatile atomic_ullong*,
1577 unsigned long long);
1578unsigned long long atomic_fetch_xor(atomic_ullong*, unsigned long long);
1579unsigned long long atomic_fetch_xor_explicit(volatile atomic_ullong*,
1580 unsigned long long, memory_order);
1581unsigned long long atomic_fetch_xor_explicit(atomic_ullong*, unsigned long long,
1582 memory_order);
1583
1584// atomic_char16_t
1585
1586typedef struct atomic_char16_t
1587{
1588 bool is_lock_free() const volatile;
1589 bool is_lock_free() const;
1590 void store(char16_t, memory_order = memory_order_seq_cst) volatile;
1591 void store(char16_t, memory_order = memory_order_seq_cst);
1592 char16_t load(memory_order = memory_order_seq_cst) const volatile;
1593 char16_t load(memory_order = memory_order_seq_cst) const;
1594 operator char16_t() const volatile;
1595 operator char16_t() const;
Howard Hinnante7385012010-10-19 16:51:18 +00001596 char16_t exchange(char16_t, memory_order = memory_order_seq_cst) volatile;
Howard Hinnant8f73c632010-09-27 21:17:38 +00001597 char16_t exchange(char16_t, memory_order = memory_order_seq_cst);
1598 bool compare_exchange_weak(char16_t&, char16_t, memory_order,
1599 memory_order) volatile;
1600 bool compare_exchange_weak(char16_t&, char16_t, memory_order, memory_order);
1601 bool compare_exchange_strong(char16_t&, char16_t, memory_order,
1602 memory_order) volatile;
1603 bool compare_exchange_strong(char16_t&, char16_t,
1604 memory_order, memory_order);
1605 bool compare_exchange_weak(char16_t&, char16_t,
1606 memory_order = memory_order_seq_cst) volatile;
1607 bool compare_exchange_weak(char16_t&, char16_t,
1608 memory_order = memory_order_seq_cst);
1609 bool compare_exchange_strong(char16_t&, char16_t,
1610 memory_order = memory_order_seq_cst) volatile;
1611 bool compare_exchange_strong(char16_t&, char16_t,
1612 memory_order = memory_order_seq_cst);
1613 char16_t fetch_add(char16_t, memory_order = memory_order_seq_cst) volatile;
1614 char16_t fetch_add(char16_t, memory_order = memory_order_seq_cst);
1615 char16_t fetch_sub(char16_t, memory_order = memory_order_seq_cst) volatile;
1616 char16_t fetch_sub(char16_t, memory_order = memory_order_seq_cst);
1617 char16_t fetch_and(char16_t, memory_order = memory_order_seq_cst) volatile;
1618 char16_t fetch_and(char16_t, memory_order = memory_order_seq_cst);
1619 char16_t fetch_or(char16_t, memory_order = memory_order_seq_cst) volatile;
1620 char16_t fetch_or(char16_t, memory_order = memory_order_seq_cst);
1621 char16_t fetch_xor(char16_t, memory_order = memory_order_seq_cst) volatile;
1622 char16_t fetch_xor(char16_t, memory_order = memory_order_seq_cst);
1623 atomic_char16_t() = default;
1624 constexpr atomic_char16_t(char16_t);
1625 atomic_char16_t(const atomic_char16_t&) = delete;
1626 atomic_char16_t& operator=(const atomic_char16_t&) = delete;
1627 atomic_char16_t& operator=(const atomic_char16_t&) volatile = delete;
1628 char16_t operator=(char16_t) volatile;
1629 char16_t operator=(char16_t);
1630 char16_t operator++(int) volatile;
1631 char16_t operator++(int);
1632 char16_t operator--(int) volatile;
1633 char16_t operator--(int);
1634 char16_t operator++() volatile;
1635 char16_t operator++();
1636 char16_t operator--() volatile;
1637 char16_t operator--();
1638 char16_t operator+=(char16_t) volatile;
1639 char16_t operator+=(char16_t);
1640 char16_t operator-=(char16_t) volatile;
1641 char16_t operator-=(char16_t);
1642 char16_t operator&=(char16_t) volatile;
1643 char16_t operator&=(char16_t);
1644 char16_t operator|=(char16_t) volatile;
1645 char16_t operator|=(char16_t);
1646 char16_t operator^=(char16_t) volatile;
1647 char16_t operator^=(char16_t);
1648} atomic_char16_t;
1649
1650bool atomic_is_lock_free(const volatile atomic_char16_t*);
1651bool atomic_is_lock_free(const atomic_char16_t*);
Howard Hinnante7385012010-10-19 16:51:18 +00001652void atomic_init(volatile atomic_char16_t*, char16_t);
1653void atomic_init(atomic_char16_t*, char16_t);
Howard Hinnant8f73c632010-09-27 21:17:38 +00001654void atomic_store(volatile atomic_char16_t*, char16_t);
1655void atomic_store(atomic_char16_t*, char16_t);
1656void atomic_store_explicit(volatile atomic_char16_t*, char16_t, memory_order);
1657void atomic_store_explicit(atomic_char16_t*, char16_t, memory_order);
1658char16_t atomic_load(const volatile atomic_char16_t*);
1659char16_t atomic_load(const atomic_char16_t*);
1660char16_t atomic_load_explicit(const volatile atomic_char16_t*, memory_order);
1661char16_t atomic_load_explicit(const atomic_char16_t*, memory_order);
1662char16_t atomic_exchange(volatile atomic_char16_t*, char16_t);
1663char16_t atomic_exchange(atomic_char16_t*, char16_t);
1664char16_t atomic_exchange_explicit(volatile atomic_char16_t*, char16_t,
1665 memory_order);
1666char16_t atomic_exchange_explicit(atomic_char16_t*, char16_t, memory_order);
1667bool atomic_compare_exchange_weak(volatile atomic_char16_t*, char16_t*,
1668 char16_t);
1669bool atomic_compare_exchange_weak(atomic_char16_t*, char16_t*, char16_t);
1670bool atomic_compare_exchange_strong(volatile atomic_char16_t*, char16_t*,
1671 char16_t);
1672bool atomic_compare_exchange_strong(atomic_char16_t*, char16_t*, char16_t);
1673bool atomic_compare_exchange_weak_explicit(volatile atomic_char16_t*, char16_t*,
1674 char16_t, memory_order,
1675 memory_order);
1676bool atomic_compare_exchange_weak_explicit(atomic_char16_t*, char16_t*,
1677 char16_t, memory_order,
1678 memory_order);
1679bool atomic_compare_exchange_strong_explicit(volatile atomic_char16_t*,
1680 char16_t*, char16_t, memory_order,
1681 memory_order);
1682bool atomic_compare_exchange_strong_explicit(atomic_char16_t*, char16_t*,
1683 char16_t, memory_order,
1684 memory_order);
1685char16_t atomic_fetch_add(volatile atomic_char16_t*, char16_t);
1686char16_t atomic_fetch_add(atomic_char16_t*, char16_t);
1687char16_t atomic_fetch_add_explicit(volatile atomic_char16_t*, char16_t,
1688 memory_order);
1689char16_t atomic_fetch_add_explicit(atomic_char16_t*, char16_t, memory_order);
1690char16_t atomic_fetch_sub(volatile atomic_char16_t*, char16_t);
1691char16_t atomic_fetch_sub(atomic_char16_t*, char16_t);
1692char16_t atomic_fetch_sub_explicit(volatile atomic_char16_t*, char16_t,
1693 memory_order);
1694char16_t atomic_fetch_sub_explicit(atomic_char16_t*, char16_t, memory_order);
1695char16_t atomic_fetch_and(volatile atomic_char16_t*, char16_t);
1696char16_t atomic_fetch_and(atomic_char16_t*, char16_t);
1697char16_t atomic_fetch_and_explicit(volatile atomic_char16_t*, char16_t,
1698 memory_order);
1699char16_t atomic_fetch_and_explicit(atomic_char16_t*, char16_t, memory_order);
1700char16_t atomic_fetch_or(volatile atomic_char16_t*, char16_t);
1701char16_t atomic_fetch_or(atomic_char16_t*, char16_t);
1702char16_t atomic_fetch_or_explicit(volatile atomic_char16_t*, char16_t,
1703 memory_order);
1704char16_t atomic_fetch_or_explicit(atomic_char16_t*, char16_t, memory_order);
1705char16_t atomic_fetch_xor(volatile atomic_char16_t*, char16_t);
1706char16_t atomic_fetch_xor(atomic_char16_t*, char16_t);
1707char16_t atomic_fetch_xor_explicit(volatile atomic_char16_t*, char16_t,
1708 memory_order);
1709char16_t atomic_fetch_xor_explicit(atomic_char16_t*, char16_t, memory_order);
1710
1711// atomic_char32_t
1712
1713typedef struct atomic_char32_t
1714{
1715 bool is_lock_free() const volatile;
1716 bool is_lock_free() const;
1717 void store(char32_t, memory_order = memory_order_seq_cst) volatile;
1718 void store(char32_t, memory_order = memory_order_seq_cst);
1719 char32_t load(memory_order = memory_order_seq_cst) const volatile;
1720 char32_t load(memory_order = memory_order_seq_cst) const;
1721 operator char32_t() const volatile;
1722 operator char32_t() const;
Howard Hinnante7385012010-10-19 16:51:18 +00001723 char32_t exchange(char32_t, memory_order = memory_order_seq_cst) volatile;
Howard Hinnant8f73c632010-09-27 21:17:38 +00001724 char32_t exchange(char32_t, memory_order = memory_order_seq_cst);
1725 bool compare_exchange_weak(char32_t&, char32_t, memory_order,
1726 memory_order) volatile;
1727 bool compare_exchange_weak(char32_t&, char32_t, memory_order, memory_order);
1728 bool compare_exchange_strong(char32_t&, char32_t, memory_order,
1729 memory_order) volatile;
1730 bool compare_exchange_strong(char32_t&, char32_t,
1731 memory_order, memory_order);
1732 bool compare_exchange_weak(char32_t&, char32_t,
1733 memory_order = memory_order_seq_cst) volatile;
1734 bool compare_exchange_weak(char32_t&, char32_t,
1735 memory_order = memory_order_seq_cst);
1736 bool compare_exchange_strong(char32_t&, char32_t,
1737 memory_order = memory_order_seq_cst) volatile;
1738 bool compare_exchange_strong(char32_t&, char32_t,
1739 memory_order = memory_order_seq_cst);
1740 char32_t fetch_add(char32_t, memory_order = memory_order_seq_cst) volatile;
1741 char32_t fetch_add(char32_t, memory_order = memory_order_seq_cst);
1742 char32_t fetch_sub(char32_t, memory_order = memory_order_seq_cst) volatile;
1743 char32_t fetch_sub(char32_t, memory_order = memory_order_seq_cst);
1744 char32_t fetch_and(char32_t, memory_order = memory_order_seq_cst) volatile;
1745 char32_t fetch_and(char32_t, memory_order = memory_order_seq_cst);
1746 char32_t fetch_or(char32_t, memory_order = memory_order_seq_cst) volatile;
1747 char32_t fetch_or(char32_t, memory_order = memory_order_seq_cst);
1748 char32_t fetch_xor(char32_t, memory_order = memory_order_seq_cst) volatile;
1749 char32_t fetch_xor(char32_t, memory_order = memory_order_seq_cst);
1750 atomic_char32_t() = default;
1751 constexpr atomic_char32_t(char32_t);
1752 atomic_char32_t(const atomic_char32_t&) = delete;
1753 atomic_char32_t& operator=(const atomic_char32_t&) = delete;
1754 atomic_char32_t& operator=(const atomic_char32_t&) volatile = delete;
1755 char32_t operator=(char32_t) volatile;
1756 char32_t operator=(char32_t);
1757 char32_t operator++(int) volatile;
1758 char32_t operator++(int);
1759 char32_t operator--(int) volatile;
1760 char32_t operator--(int);
1761 char32_t operator++() volatile;
1762 char32_t operator++();
1763 char32_t operator--() volatile;
1764 char32_t operator--();
1765 char32_t operator+=(char32_t) volatile;
1766 char32_t operator+=(char32_t);
1767 char32_t operator-=(char32_t) volatile;
1768 char32_t operator-=(char32_t);
1769 char32_t operator&=(char32_t) volatile;
1770 char32_t operator&=(char32_t);
1771 char32_t operator|=(char32_t) volatile;
1772 char32_t operator|=(char32_t);
1773 char32_t operator^=(char32_t) volatile;
1774 char32_t operator^=(char32_t);
1775} atomic_char32_t;
1776
1777bool atomic_is_lock_free(const volatile atomic_char32_t*);
1778bool atomic_is_lock_free(const atomic_char32_t*);
Howard Hinnante7385012010-10-19 16:51:18 +00001779void atomic_init(volatile atomic_char32_t*, char32_t);
1780void atomic_init(atomic_char32_t*, char32_t);
Howard Hinnant8f73c632010-09-27 21:17:38 +00001781void atomic_store(volatile atomic_char32_t*, char32_t);
1782void atomic_store(atomic_char32_t*, char32_t);
1783void atomic_store_explicit(volatile atomic_char32_t*, char32_t, memory_order);
1784void atomic_store_explicit(atomic_char32_t*, char32_t, memory_order);
1785char32_t atomic_load(const volatile atomic_char32_t*);
1786char32_t atomic_load(const atomic_char32_t*);
1787char32_t atomic_load_explicit(const volatile atomic_char32_t*, memory_order);
1788char32_t atomic_load_explicit(const atomic_char32_t*, memory_order);
1789char32_t atomic_exchange(volatile atomic_char32_t*, char32_t);
1790char32_t atomic_exchange(atomic_char32_t*, char32_t);
1791char32_t atomic_exchange_explicit(volatile atomic_char32_t*, char32_t,
1792 memory_order);
1793char32_t atomic_exchange_explicit(atomic_char32_t*, char32_t, memory_order);
1794bool atomic_compare_exchange_weak(volatile atomic_char32_t*, char32_t*,
1795 char32_t);
1796bool atomic_compare_exchange_weak(atomic_char32_t*, char32_t*, char32_t);
1797bool atomic_compare_exchange_strong(volatile atomic_char32_t*, char32_t*,
1798 char32_t);
1799bool atomic_compare_exchange_strong(atomic_char32_t*, char32_t*, char32_t);
1800bool atomic_compare_exchange_weak_explicit(volatile atomic_char32_t*, char32_t*,
1801 char32_t, memory_order,
1802 memory_order);
1803bool atomic_compare_exchange_weak_explicit(atomic_char32_t*, char32_t*,
1804 char32_t, memory_order,
1805 memory_order);
1806bool atomic_compare_exchange_strong_explicit(volatile atomic_char32_t*,
1807 char32_t*, char32_t, memory_order,
1808 memory_order);
1809bool atomic_compare_exchange_strong_explicit(atomic_char32_t*, char32_t*,
1810 char32_t, memory_order,
1811 memory_order);
1812char32_t atomic_fetch_add(volatile atomic_char32_t*, char32_t);
1813char32_t atomic_fetch_add(atomic_char32_t*, char32_t);
1814char32_t atomic_fetch_add_explicit(volatile atomic_char32_t*, char32_t,
1815 memory_order);
1816char32_t atomic_fetch_add_explicit(atomic_char32_t*, char32_t, memory_order);
1817char32_t atomic_fetch_sub(volatile atomic_char32_t*, char32_t);
1818char32_t atomic_fetch_sub(atomic_char32_t*, char32_t);
1819char32_t atomic_fetch_sub_explicit(volatile atomic_char32_t*, char32_t,
1820 memory_order);
1821char32_t atomic_fetch_sub_explicit(atomic_char32_t*, char32_t, memory_order);
1822char32_t atomic_fetch_and(volatile atomic_char32_t*, char32_t);
1823char32_t atomic_fetch_and(atomic_char32_t*, char32_t);
1824char32_t atomic_fetch_and_explicit(volatile atomic_char32_t*, char32_t,
1825 memory_order);
1826char32_t atomic_fetch_and_explicit(atomic_char32_t*, char32_t, memory_order);
1827char32_t atomic_fetch_or(volatile atomic_char32_t*, char32_t);
1828char32_t atomic_fetch_or(atomic_char32_t*, char32_t);
1829char32_t atomic_fetch_or_explicit(volatile atomic_char32_t*, char32_t,
1830 memory_order);
1831char32_t atomic_fetch_or_explicit(atomic_char32_t*, char32_t, memory_order);
1832char32_t atomic_fetch_xor(volatile atomic_char32_t*, char32_t);
1833char32_t atomic_fetch_xor(atomic_char32_t*, char32_t);
1834char32_t atomic_fetch_xor_explicit(volatile atomic_char32_t*, char32_t,
1835 memory_order);
1836char32_t atomic_fetch_xor_explicit(atomic_char32_t*, char32_t, memory_order);
1837
1838// atomic_wchar_t
1839
1840typedef struct atomic_wchar_t
1841{
1842 bool is_lock_free() const volatile;
1843 bool is_lock_free() const;
1844 void store(wchar_t, memory_order = memory_order_seq_cst) volatile;
1845 void store(wchar_t, memory_order = memory_order_seq_cst);
1846 wchar_t load(memory_order = memory_order_seq_cst) const volatile;
1847 wchar_t load(memory_order = memory_order_seq_cst) const;
1848 operator wchar_t() const volatile;
1849 operator wchar_t() const;
Howard Hinnante7385012010-10-19 16:51:18 +00001850 wchar_t exchange(wchar_t, memory_order = memory_order_seq_cst) volatile;
Howard Hinnant8f73c632010-09-27 21:17:38 +00001851 wchar_t exchange(wchar_t, memory_order = memory_order_seq_cst);
1852 bool compare_exchange_weak(wchar_t&, wchar_t, memory_order,
1853 memory_order) volatile;
1854 bool compare_exchange_weak(wchar_t&, wchar_t, memory_order, memory_order);
1855 bool compare_exchange_strong(wchar_t&, wchar_t, memory_order,
1856 memory_order) volatile;
1857 bool compare_exchange_strong(wchar_t&, wchar_t, memory_order, memory_order);
1858 bool compare_exchange_weak(wchar_t&, wchar_t,
1859 memory_order = memory_order_seq_cst) volatile;
1860 bool compare_exchange_weak(wchar_t&, wchar_t,
1861 memory_order = memory_order_seq_cst);
1862 bool compare_exchange_strong(wchar_t&, wchar_t,
1863 memory_order = memory_order_seq_cst) volatile;
1864 bool compare_exchange_strong(wchar_t&, wchar_t,
1865 memory_order = memory_order_seq_cst);
1866 wchar_t fetch_add(wchar_t, memory_order = memory_order_seq_cst) volatile;
1867 wchar_t fetch_add(wchar_t, memory_order = memory_order_seq_cst);
1868 wchar_t fetch_sub(wchar_t, memory_order = memory_order_seq_cst) volatile;
1869 wchar_t fetch_sub(wchar_t, memory_order = memory_order_seq_cst);
1870 wchar_t fetch_and(wchar_t, memory_order = memory_order_seq_cst) volatile;
1871 wchar_t fetch_and(wchar_t, memory_order = memory_order_seq_cst);
1872 wchar_t fetch_or(wchar_t, memory_order = memory_order_seq_cst) volatile;
1873 wchar_t fetch_or(wchar_t, memory_order = memory_order_seq_cst);
1874 wchar_t fetch_xor(wchar_t, memory_order = memory_order_seq_cst) volatile;
1875 wchar_t fetch_xor(wchar_t, memory_order = memory_order_seq_cst);
1876 atomic_wchar_t() = default;
1877 constexpr atomic_wchar_t(wchar_t);
1878 atomic_wchar_t(const atomic_wchar_t&) = delete;
1879 atomic_wchar_t& operator=(const atomic_wchar_t&) = delete;
1880 atomic_wchar_t& operator=(const atomic_wchar_t&) volatile = delete;
1881 wchar_t operator=(wchar_t) volatile;
1882 wchar_t operator=(wchar_t);
1883 wchar_t operator++(int) volatile;
1884 wchar_t operator++(int);
1885 wchar_t operator--(int) volatile;
1886 wchar_t operator--(int);
1887 wchar_t operator++() volatile;
1888 wchar_t operator++();
1889 wchar_t operator--() volatile;
1890 wchar_t operator--();
1891 wchar_t operator+=(wchar_t) volatile;
1892 wchar_t operator+=(wchar_t);
1893 wchar_t operator-=(wchar_t) volatile;
1894 wchar_t operator-=(wchar_t);
1895 wchar_t operator&=(wchar_t) volatile;
1896 wchar_t operator&=(wchar_t);
1897 wchar_t operator|=(wchar_t) volatile;
1898 wchar_t operator|=(wchar_t);
1899 wchar_t operator^=(wchar_t) volatile;
1900 wchar_t operator^=(wchar_t);
1901} atomic_wchar_t;
1902
1903bool atomic_is_lock_free(const volatile atomic_wchar_t*);
1904bool atomic_is_lock_free(const atomic_wchar_t*);
Howard Hinnante7385012010-10-19 16:51:18 +00001905void atomic_init(volatile atomic_wchar_t*, wchar_t);
1906void atomic_init(atomic_wchar_t*, wchar_t);
Howard Hinnant8f73c632010-09-27 21:17:38 +00001907void atomic_store(volatile atomic_wchar_t*, wchar_t);
1908void atomic_store(atomic_wchar_t*, wchar_t);
1909void atomic_store_explicit(volatile atomic_wchar_t*, wchar_t, memory_order);
1910void atomic_store_explicit(atomic_wchar_t*, wchar_t, memory_order);
1911wchar_t atomic_load(const volatile atomic_wchar_t*);
1912wchar_t atomic_load(const atomic_wchar_t*);
1913wchar_t atomic_load_explicit(const volatile atomic_wchar_t*, memory_order);
1914wchar_t atomic_load_explicit(const atomic_wchar_t*, memory_order);
1915wchar_t atomic_exchange(volatile atomic_wchar_t*, wchar_t);
1916wchar_t atomic_exchange(atomic_wchar_t*, wchar_t);
1917wchar_t atomic_exchange_explicit(volatile atomic_wchar_t*,
1918 wchar_t, memory_order);
1919wchar_t atomic_exchange_explicit(atomic_wchar_t*, wchar_t, memory_order);
1920bool atomic_compare_exchange_weak(volatile atomic_wchar_t*, wchar_t*, wchar_t);
1921bool atomic_compare_exchange_weak(atomic_wchar_t*, wchar_t*, wchar_t);
1922bool atomic_compare_exchange_strong(volatile atomic_wchar_t*, wchar_t*,
1923 wchar_t);
1924bool atomic_compare_exchange_strong(atomic_wchar_t*, wchar_t*, wchar_t);
1925bool atomic_compare_exchange_weak_explicit(volatile atomic_wchar_t*, wchar_t*,
1926 wchar_t, memory_order, memory_order);
1927bool atomic_compare_exchange_weak_explicit(atomic_wchar_t*, wchar_t*, wchar_t,
1928 memory_order, memory_order);
1929bool atomic_compare_exchange_strong_explicit(volatile atomic_wchar_t*, wchar_t*,
1930 wchar_t, memory_order,
1931 memory_order);
1932bool atomic_compare_exchange_strong_explicit(atomic_wchar_t*, wchar_t*, wchar_t,
1933 memory_order, memory_order);
1934wchar_t atomic_fetch_add(volatile atomic_wchar_t*, wchar_t);
1935wchar_t atomic_fetch_add(atomic_wchar_t*, wchar_t);
1936wchar_t atomic_fetch_add_explicit(volatile atomic_wchar_t*, wchar_t,
1937 memory_order);
1938wchar_t atomic_fetch_add_explicit(atomic_wchar_t*, wchar_t, memory_order);
1939wchar_t atomic_fetch_sub(volatile atomic_wchar_t*, wchar_t);
1940wchar_t atomic_fetch_sub(atomic_wchar_t*, wchar_t);
1941wchar_t atomic_fetch_sub_explicit(volatile atomic_wchar_t*, wchar_t,
1942 memory_order);
1943wchar_t atomic_fetch_sub_explicit(atomic_wchar_t*, wchar_t, memory_order);
1944wchar_t atomic_fetch_and(volatile atomic_wchar_t*, wchar_t);
1945wchar_t atomic_fetch_and(atomic_wchar_t*, wchar_t);
1946wchar_t atomic_fetch_and_explicit(volatile atomic_wchar_t*, wchar_t,
1947 memory_order);
1948wchar_t atomic_fetch_and_explicit(atomic_wchar_t*, wchar_t, memory_order);
1949wchar_t atomic_fetch_or(volatile atomic_wchar_t*, wchar_t);
1950wchar_t atomic_fetch_or(atomic_wchar_t*, wchar_t);
1951wchar_t atomic_fetch_or_explicit(volatile atomic_wchar_t*, wchar_t,
1952 memory_order);
1953wchar_t atomic_fetch_or_explicit(atomic_wchar_t*, wchar_t, memory_order);
1954wchar_t atomic_fetch_xor(volatile atomic_wchar_t*, wchar_t);
1955wchar_t atomic_fetch_xor(atomic_wchar_t*, wchar_t);
1956wchar_t atomic_fetch_xor_explicit(volatile atomic_wchar_t*, wchar_t,
1957 memory_order);
1958wchar_t atomic_fetch_xor_explicit(atomic_wchar_t*, wchar_t, memory_order);
1959
1960// Atomics for standard typedef types
1961
1962typedef atomic_schar atomic_int_least8_t;
1963typedef atomic_uchar atomic_uint_least8_t;
1964typedef atomic_short atomic_int_least16_t;
1965typedef atomic_ushort atomic_uint_least16_t;
1966typedef atomic_int atomic_int_least32_t;
1967typedef atomic_uint atomic_uint_least32_t;
1968typedef atomic_llong atomic_int_least64_t;
1969typedef atomic_ullong atomic_uint_least64_t;
1970
1971typedef atomic_schar atomic_int_fast8_t;
1972typedef atomic_uchar atomic_uint_fast8_t;
1973typedef atomic_short atomic_int_fast16_t;
1974typedef atomic_ushort atomic_uint_fast16_t;
1975typedef atomic_int atomic_int_fast32_t;
1976typedef atomic_uint atomic_uint_fast32_t;
1977typedef atomic_llong atomic_int_fast64_t;
1978typedef atomic_ullong atomic_uint_fast64_t;
1979
1980typedef atomic_long atomic_intptr_t;
1981typedef atomic_ulong atomic_uintptr_t;
1982typedef atomic_ulong atomic_size_t;
1983typedef atomic_long atomic_ptrdiff_t;
1984typedef atomic_llong atomic_intmax_t;
1985typedef atomic_ullong atomic_uintmax_t;
1986
1987// address types
1988
1989typedef struct atomic_address
1990{
1991 bool is_lock_free() const volatile;
1992 bool is_lock_free() const;
1993 void store(void*, memory_order = memory_order_seq_cst) volatile;
1994 void store(void*, memory_order = memory_order_seq_cst);
1995 void* load(memory_order = memory_order_seq_cst) const volatile;
1996 void* load(memory_order = memory_order_seq_cst) const;
1997 operator void*() const volatile;
1998 operator void*() const;
1999 void* exchange(void*, memory_order = memory_order_seq_cst) volatile;
2000 void* exchange(void*, memory_order = memory_order_seq_cst);
2001 bool compare_exchange_weak(void*&, void*, memory_order,
2002 memory_order) volatile;
2003 bool compare_exchange_weak(void*&, void*, memory_order, memory_order);
2004 bool compare_exchange_strong(void*&, void*, memory_order,
2005 memory_order) volatile;
2006 bool compare_exchange_strong(void*&, void*, memory_order, memory_order);
2007 bool compare_exchange_weak(void*&, void*,
2008 memory_order = memory_order_seq_cst) volatile;
2009 bool compare_exchange_weak(void*&, void*,
2010 memory_order = memory_order_seq_cst);
2011 bool compare_exchange_strong(void*&, void*,
2012 memory_order = memory_order_seq_cst) volatile;
2013 bool compare_exchange_strong(void*&, void*,
2014 memory_order = memory_order_seq_cst);
2015 bool compare_exchange_weak(const void*&, const void*,
2016 memory_order, memory_order) volatile;
2017 bool compare_exchange_weak(const void*&, const void*, memory_order,
2018 memory_order);
2019 bool compare_exchange_strong(const void*&, const void*, memory_order,
2020 memory_order) volatile;
2021 bool compare_exchange_strong(const void*&, const void*, memory_order,
2022 memory_order);
2023 bool compare_exchange_weak(const void*&, const void*,
2024 memory_order = memory_order_seq_cst) volatile;
2025 bool compare_exchange_weak(const void*&, const void*,
2026 memory_order = memory_order_seq_cst);
2027 bool compare_exchange_strong(const void*&, const void*,
2028 memory_order = memory_order_seq_cst) volatile;
2029 bool compare_exchange_strong(const void*&, const void*,
2030 memory_order = memory_order_seq_cst);
2031 void* fetch_add(ptrdiff_t, memory_order = memory_order_seq_cst) volatile;
2032 void* fetch_add(ptrdiff_t, memory_order = memory_order_seq_cst);
2033 void* fetch_sub(ptrdiff_t, memory_order = memory_order_seq_cst) volatile;
2034 void* fetch_sub(ptrdiff_t, memory_order = memory_order_seq_cst);
2035 atomic_address() = default;
2036 constexpr atomic_address(void*);
2037 atomic_address(const atomic_address&) = delete;
2038 atomic_address& operator=(const atomic_address&) = delete;
2039 atomic_address& operator=(const atomic_address&) volatile = delete;
2040 void* operator=(const void*) volatile;
2041 void* operator=(const void*);
2042 void* operator+=(ptrdiff_t) volatile;
2043 void* operator+=(ptrdiff_t);
2044 void* operator-=(ptrdiff_t) volatile;
2045 void* operator-=(ptrdiff_t);
2046} atomic_address;
2047
2048bool atomic_is_lock_free(const volatile atomic_address*);
2049bool atomic_is_lock_free(const atomic_address*);
2050void atomic_init(volatile atomic_address*, void*);
2051void atomic_init(atomic_address*, void*);
2052void atomic_store(volatile atomic_address*, void*);
2053void atomic_store(atomic_address*, void*);
2054void atomic_store_explicit(volatile atomic_address*, void*, memory_order);
2055void atomic_store_explicit(atomic_address*, void*, memory_order);
2056void* atomic_load(const volatile atomic_address*);
2057void* atomic_load(const atomic_address*);
2058void* atomic_load_explicit(const volatile atomic_address*, memory_order);
2059void* atomic_load_explicit(const atomic_address*, memory_order);
2060void* atomic_exchange(volatile atomic_address*, void*);
2061void* atomic_exchange(atomic_address*, void*);
2062void* atomic_exchange_explicit(volatile atomic_address*, void*, memory_order);
2063void* atomic_exchange_explicit(atomic_address*, void*, memory_order);
2064bool atomic_compare_exchange_weak(volatile atomic_address*, void**, void*);
2065bool atomic_compare_exchange_weak(atomic_address*, void**, void*);
2066bool atomic_compare_exchange_strong(volatile atomic_address*, void**, void*);
2067bool atomic_compare_exchange_strong(atomic_address*, void**, void*);
2068bool atomic_compare_exchange_weak_explicit(volatile atomic_address*, void**,
2069 void*, memory_order, memory_order);
2070bool atomic_compare_exchange_weak_explicit(atomic_address*, void**, void*,
2071 memory_order, memory_order);
2072bool atomic_compare_exchange_strong_explicit(volatile atomic_address*, void**,
2073 void*, memory_order, memory_order);
2074bool atomic_compare_exchange_strong_explicit(atomic_address*, void**, void*,
2075 memory_order, memory_order);
2076void* atomic_fetch_add(volatile atomic_address*, ptrdiff_t);
2077void* atomic_fetch_add(atomic_address*, ptrdiff_t);
2078void* atomic_fetch_add_explicit(volatile atomic_address*, ptrdiff_t,
2079 memory_order);
2080void* atomic_fetch_add_explicit(atomic_address*, ptrdiff_t, memory_order);
2081void* atomic_fetch_sub(volatile atomic_address*, ptrdiff_t);
2082void* atomic_fetch_sub(atomic_address*, ptrdiff_t);
2083void* atomic_fetch_sub_explicit(volatile atomic_address*, ptrdiff_t,
2084 memory_order);
2085void* atomic_fetch_sub_explicit(atomic_address*, ptrdiff_t, memory_order);
2086
2087// generic types
2088
2089template <class T>
2090struct atomic
2091{
2092 bool is_lock_free() const volatile;
2093 bool is_lock_free() const;
2094 void store(T, memory_order = memory_order_seq_cst) volatile;
2095 void store(T, memory_order = memory_order_seq_cst);
2096 T load(memory_order = memory_order_seq_cst) const volatile;
2097 T load(memory_order = memory_order_seq_cst) const;
2098 operator T() const volatile;
2099 operator T() const;
2100 T exchange(T, memory_order = memory_order_seq_cst) volatile;
2101 T exchange(T, memory_order = memory_order_seq_cst);
2102 bool compare_exchange_weak(T&, T, memory_order, memory_order) volatile;
2103 bool compare_exchange_weak(T&, T, memory_order, memory_order);
2104 bool compare_exchange_strong(T&, T, memory_order, memory_order) volatile;
2105 bool compare_exchange_strong(T&, T, memory_order, memory_order);
2106 bool compare_exchange_weak(T&, T,
2107 memory_order = memory_order_seq_cst) volatile;
2108 bool compare_exchange_weak(T&, T, memory_order = memory_order_seq_cst);
2109 bool compare_exchange_strong(T&, T,
2110 memory_order = memory_order_seq_cst) volatile;
2111 bool compare_exchange_strong(T&, T, memory_order = memory_order_seq_cst);
2112
2113 atomic() = default;
2114 constexpr atomic(T);
2115 atomic(const atomic&) = delete;
2116 atomic& operator=(const atomic&) = delete;
2117 atomic& operator=(const atomic&) volatile = delete;
2118 T operator=(T) volatile;
2119 T operator=(T);
2120};
2121
2122template <>
2123struct atomic<bool>
2124 : public atomic_bool
2125{
2126 atomic() = default;
2127 constexpr atomic(bool);
2128 atomic(const atomic&) = delete;
2129 atomic& operator=(const atomic&) = delete;
2130 atomic& operator=(const atomic&) volatile = delete;
2131 bool operator=(bool) volatile;
2132 bool operator=(bool);
2133 operator bool() const volatile;
2134 operator bool() const;
2135};
2136
2137template <>
2138struct atomic<char>
2139 : public atomic_char
2140{
2141 atomic() = default;
2142 constexpr atomic(char);
2143 atomic(const atomic&) = delete;
2144 atomic& operator=(const atomic&) = delete;
2145 atomic& operator=(const atomic&) volatile = delete;
2146 char operator=(char) volatile;
2147 char operator=(char);
2148 operator char() const volatile;
2149 operator char() const;
2150};
2151
2152template <>
2153struct atomic<signed char>
2154 : public atomic_schar
2155{
2156 atomic() = default;
2157 constexpr atomic(signed char);
2158 atomic(const atomic&) = delete;
2159 atomic& operator=(const atomic&) = delete;
2160 atomic& operator=(const atomic&) volatile = delete;
2161 signed char operator=(signed char) volatile;
2162 signed char operator=(signed char);
2163 operator signed char() const volatile;
2164 operator signed char() const;
2165};
2166
2167template <>
2168struct atomic<unsigned char>
2169 : public atomic_uchar
2170{
2171 atomic() = default;
2172 constexpr atomic(unsigned char);
2173 atomic(const atomic&) = delete;
2174 atomic& operator=(const atomic&) = delete;
2175 atomic& operator=(const atomic&) volatile = delete;
2176 unsigned char operator=(unsigned char) volatile;
2177 unsigned char operator=(unsigned char);
2178 operator unsigned char() const volatile;
2179 operator unsigned char() const;
2180};
2181
2182template <>
2183struct atomic<short>
2184 : public atomic_short
2185{
2186 atomic() = default;
2187 constexpr atomic(short);
2188 atomic(const atomic&) = delete;
2189 atomic& operator=(const atomic&) = delete;
2190 atomic& operator=(const atomic&) volatile = delete;
2191 short operator=(short) volatile;
2192 short operator=(short);
2193 operator short() const volatile;
2194 operator short() const;
2195};
2196
2197template <>
2198struct atomic<unsigned short>
2199 : public atomic_ushort
2200{
2201 atomic() = default;
2202 constexpr atomic(unsigned short);
2203 atomic(const atomic&) = delete;
2204 atomic& operator=(const atomic&) = delete;
2205 atomic& operator=(const atomic&) volatile = delete;
2206 unsigned short operator=(unsigned short) volatile;
2207 unsigned short operator=(unsigned short);
2208 operator unsigned short() const volatile;
2209 operator unsigned short() const;
2210};
2211
2212template <>
2213struct atomic<int>
2214 : public atomic_int
2215{
2216 atomic() = default;
2217 constexpr atomic(int);
2218 atomic(const atomic&) = delete;
2219 atomic& operator=(const atomic&) = delete;
2220 atomic& operator=(const atomic&) volatile = delete;
2221 int operator=(int) volatile;
2222 int operator=(int);
2223 operator int() const volatile;
2224 operator int() const;
2225};
2226
2227template <>
2228struct atomic<unsigned int>
2229 : public atomic_uint
2230{
2231 atomic() = default;
2232 constexpr atomic(unsigned int);
2233 atomic(const atomic&) = delete;
2234 atomic& operator=(const atomic&) = delete;
2235 atomic& operator=(const atomic&) volatile = delete;
2236 unsigned int operator=(unsigned int) volatile;
2237 unsigned int operator=(unsigned int);
2238 operator unsigned int() const volatile;
2239 operator unsigned int() const;
2240};
2241
2242template <>
2243struct atomic<long>
2244 : public atomic_long
2245{
2246 atomic() = default;
2247 constexpr atomic(long);
2248 atomic(const atomic&) = delete;
2249 atomic& operator=(const atomic&) = delete;
2250 atomic& operator=(const atomic&) volatile = delete;
2251 long operator=(long) volatile;
2252 long operator=(long);
2253 operator long() const volatile;
2254 operator long() const;
2255};
2256
2257template <>
2258struct atomic<unsigned long>
2259 : public atomic_ulong
2260{
2261 atomic() = default;
2262 constexpr atomic(unsigned long);
2263 atomic(const atomic&) = delete;
2264 atomic& operator=(const atomic&) = delete;
2265 atomic& operator=(const atomic&) volatile = delete;
2266 unsigned long operator=(unsigned long) volatile;
2267 unsigned long operator=(unsigned long);
2268 operator unsigned long() const volatile;
2269 operator unsigned long() const;
2270};
2271
2272template <>
2273struct atomic<long long>
2274 : public atomic_llong
2275{
2276 atomic() = default;
2277 constexpr atomic(long long);
2278 atomic(const atomic&) = delete;
2279 atomic& operator=(const atomic&) = delete;
2280 atomic& operator=(const atomic&) volatile = delete;
2281 long long operator=(long long) volatile;
2282 long long operator=(long long);
2283 operator long long() const volatile;
2284 operator long long() const;
2285};
2286
2287template <>
2288struct atomic<unsigned long long>
2289 : public atomic_ullong
2290{
2291 atomic() = default;
2292 constexpr atomic(unsigned long long);
2293 atomic(const atomic&) = delete;
2294 atomic& operator=(const atomic&) = delete;
2295 atomic& operator=(const atomic&) volatile = delete;
2296 unsigned long long operator=(unsigned long long) volatile;
2297 unsigned long long operator=(unsigned long long);
2298 operator unsigned long long() const volatile;
2299 operator unsigned long long() const;
2300};
2301
2302template <>
2303struct atomic<char16_t>
2304 : public atomic_char16_t
2305{
2306 atomic() = default;
2307 constexpr atomic(char16_t);
2308 atomic(const atomic&) = delete;
2309 atomic& operator=(const atomic&) = delete;
2310 atomic& operator=(const atomic&) volatile = delete;
2311 char16_t operator=(char16_t) volatile;
2312 char16_t operator=(char16_t);
2313 operator char16_t() const volatile;
2314 operator char16_t() const;
2315};
2316
2317template <>
2318struct atomic<char32_t>
2319 : public atomic_char32_t
2320{
2321 atomic() = default;
2322 constexpr atomic(char32_t);
2323 atomic(const atomic&) = delete;
2324 atomic& operator=(const atomic&) = delete;
2325 atomic& operator=(const atomic&) volatile = delete;
2326 char32_t operator=(char32_t) volatile;
2327 char32_t operator=(char32_t);
2328 operator char32_t() const volatile;
2329 operator char32_t() const;
2330};
2331
2332template <>
2333struct atomic<wchar_t>
2334 : public atomic_wchar_t
2335{
2336 atomic() = default;
2337 constexpr atomic(wchar_t);
2338 atomic(const atomic&) = delete;
2339 atomic& operator=(const atomic&) = delete;
2340 atomic& operator=(const atomic&) volatile = delete;
2341 wchar_t operator=(wchar_t) volatile;
2342 wchar_t operator=(wchar_t);
2343 operator wchar_t() const volatile;
2344 operator wchar_t() const;
2345};
2346
2347template <class T>
2348struct atomic<T*>
2349 : public atomic_address
2350{
2351 void store(T*, memory_order = memory_order_seq_cst) volatile;
2352 void store(T*, memory_order = memory_order_seq_cst);
2353 T* load(memory_order = memory_order_seq_cst) const volatile;
2354 T* load(memory_order = memory_order_seq_cst) const;
2355 operator T*() const volatile;
2356 operator T*() const;
2357 T* exchange(T*, memory_order = memory_order_seq_cst) volatile;
2358 T* exchange(T*, memory_order = memory_order_seq_cst);
2359 bool compare_exchange_weak(T*&, T*, memory_order, memory_order) volatile;
2360 bool compare_exchange_weak(T*&, T*, memory_order, memory_order);
2361 bool compare_exchange_strong(T*&, T*, memory_order, memory_order) volatile;
2362 bool compare_exchange_strong(T*&, T*, memory_order, memory_order);
2363 bool compare_exchange_weak(T*&, T*,
2364 memory_order = memory_order_seq_cst) volatile;
2365 bool compare_exchange_weak(T*&, T*, memory_order = memory_order_seq_cst);
2366 bool compare_exchange_strong(T*&, T*,
2367 memory_order = memory_order_seq_cst) volatile;
2368 bool compare_exchange_strong(T*&, T*, memory_order = memory_order_seq_cst);
2369 T* fetch_add(ptrdiff_t, memory_order = memory_order_seq_cst) volatile;
2370 T* fetch_add(ptrdiff_t, memory_order = memory_order_seq_cst);
2371 T* fetch_sub(ptrdiff_t, memory_order = memory_order_seq_cst) volatile;
2372 T* fetch_sub(ptrdiff_t, memory_order = memory_order_seq_cst);
2373 atomic() = default;
2374 constexpr atomic(T*);
2375 atomic(const atomic&) = delete;
2376 atomic& operator=(const atomic&) = delete;
2377 atomic& operator=(const atomic&) volatile = delete;
2378 T* operator=(T*) volatile;
2379 T* operator=(T*);
2380 T* operator++(int) volatile;
2381 T* operator++(int);
2382 T* operator--(int) volatile;
2383 T* operator--(int);
2384 T* operator++() volatile;
2385 T* operator++();
2386 T* operator--() volatile;
2387 T* operator--();
2388 T* operator+=(ptrdiff_t) volatile;
2389 T* operator+=(ptrdiff_t);
2390 T* operator-=(ptrdiff_t) volatile;
2391 T* operator-=(ptrdiff_t);
2392};
2393
2394// fences
2395
2396void atomic_thread_fence(memory_order);
2397void atomic_signal_fence(memory_order);
2398
2399} // std
2400
2401*/
2402
2403#include <__config>
2404
2405#pragma GCC system_header
2406
2407_LIBCPP_BEGIN_NAMESPACE_STD
2408
Howard Hinnantd1176e22010-09-28 17:13:38 +00002409typedef enum memory_order
2410{
2411 memory_order_relaxed, memory_order_consume, memory_order_acquire,
2412 memory_order_release, memory_order_acq_rel, memory_order_seq_cst
2413} memory_order;
2414
2415template <class _Tp>
2416inline _LIBCPP_INLINE_VISIBILITY
2417_Tp
2418kill_dependency(_Tp __y)
2419{
2420 return __y;
2421}
Howard Hinnant8f73c632010-09-27 21:17:38 +00002422
Howard Hinnanted760f42010-09-29 18:13:54 +00002423// flag type and operations
2424
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002425typedef bool __atomic_flag__;
Howard Hinnant6cac2c22010-10-05 14:02:23 +00002426
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002427struct atomic_flag;
Howard Hinnanted760f42010-09-29 18:13:54 +00002428
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002429bool atomic_flag_test_and_set(volatile atomic_flag*);
2430bool atomic_flag_test_and_set(atomic_flag*);
2431bool atomic_flag_test_and_set_explicit(volatile atomic_flag*, memory_order);
2432bool atomic_flag_test_and_set_explicit(atomic_flag*, memory_order);
2433void atomic_flag_clear(volatile atomic_flag*);
2434void atomic_flag_clear(atomic_flag*);
2435void atomic_flag_clear_explicit(volatile atomic_flag*, memory_order);
2436void atomic_flag_clear_explicit(atomic_flag*, memory_order);
2437
2438typedef struct _LIBCPP_VISIBLE atomic_flag
Howard Hinnanted760f42010-09-29 18:13:54 +00002439{
Howard Hinnant6cac2c22010-10-05 14:02:23 +00002440 __atomic_flag__ __flg_;
Howard Hinnanted760f42010-09-29 18:13:54 +00002441
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002442 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002443 bool test_and_set(memory_order __o = memory_order_seq_cst) volatile
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002444 {return atomic_flag_test_and_set_explicit(this, __o);}
2445 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002446 bool test_and_set(memory_order __o = memory_order_seq_cst)
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002447 {return atomic_flag_test_and_set_explicit(this, __o);}
Howard Hinnanted760f42010-09-29 18:13:54 +00002448
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002449 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002450 void clear(memory_order __o = memory_order_seq_cst) volatile
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002451 {atomic_flag_clear_explicit(this, __o);}
2452 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002453 void clear(memory_order __o = memory_order_seq_cst)
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002454 {atomic_flag_clear_explicit(this, __o);}
Howard Hinnanted760f42010-09-29 18:13:54 +00002455
2456#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2457 atomic_flag() = default;
2458#else
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002459 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant79101ae2010-09-30 21:05:29 +00002460 atomic_flag() {};
Howard Hinnanted760f42010-09-29 18:13:54 +00002461#endif
2462
Howard Hinnanted760f42010-09-29 18:13:54 +00002463#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
2464 atomic_flag(const atomic_flag&) = delete;
2465 atomic_flag& operator=(const atomic_flag&) = delete;
2466 atomic_flag& operator=(const atomic_flag&) volatile = delete;
2467#else
2468private:
2469 atomic_flag(const atomic_flag&);
2470 atomic_flag& operator=(const atomic_flag&);
2471 atomic_flag& operator=(const atomic_flag&) volatile;
2472public:
2473#endif
Howard Hinnanted760f42010-09-29 18:13:54 +00002474} atomic_flag;
2475
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002476inline _LIBCPP_INLINE_VISIBILITY
2477bool
2478atomic_flag_test_and_set(volatile atomic_flag* __f)
2479{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002480 return __atomic_exchange(&__f->__flg_, __atomic_flag__(true),
2481 memory_order_seq_cst)
Howard Hinnant6cac2c22010-10-05 14:02:23 +00002482 == __atomic_flag__(true);
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002483}
Howard Hinnanted760f42010-09-29 18:13:54 +00002484
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002485inline _LIBCPP_INLINE_VISIBILITY
2486bool
2487atomic_flag_test_and_set(atomic_flag* __f)
2488{
2489 return atomic_flag_test_and_set(const_cast<volatile atomic_flag*>(__f));
2490}
2491
2492inline _LIBCPP_INLINE_VISIBILITY
2493bool
2494atomic_flag_test_and_set_explicit(volatile atomic_flag* __f, memory_order __o)
2495{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002496 return __atomic_exchange(&__f->__flg_, __atomic_flag__(true), __o)
Howard Hinnant6cac2c22010-10-05 14:02:23 +00002497 == __atomic_flag__(true);
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002498}
2499
2500inline _LIBCPP_INLINE_VISIBILITY
2501bool
2502atomic_flag_test_and_set_explicit(atomic_flag* __f, memory_order __o)
2503{
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002504 return atomic_flag_test_and_set_explicit(const_cast<volatile atomic_flag*>
2505 (__f), __o);
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002506}
2507
2508inline _LIBCPP_INLINE_VISIBILITY
2509void
2510atomic_flag_clear(volatile atomic_flag* __f)
2511{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002512 __atomic_store(&__f->__flg_, __atomic_flag__(false), memory_order_seq_cst);
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002513}
2514
2515inline _LIBCPP_INLINE_VISIBILITY
2516void
2517atomic_flag_clear(atomic_flag* __f)
2518{
2519 atomic_flag_clear(const_cast<volatile atomic_flag*>(__f));
2520}
2521
2522inline _LIBCPP_INLINE_VISIBILITY
2523void
2524atomic_flag_clear_explicit(volatile atomic_flag* __f, memory_order __o)
2525{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002526 __atomic_store(&__f->__flg_, __atomic_flag__(false), __o);
Howard Hinnant767ae2b2010-09-29 21:20:03 +00002527}
2528
2529inline _LIBCPP_INLINE_VISIBILITY
2530void
2531atomic_flag_clear_explicit(atomic_flag* __f, memory_order __o)
2532{
2533 atomic_flag_clear_explicit(const_cast<volatile atomic_flag*>(__f), __o);
2534}
2535
2536#define ATOMIC_FLAG_INIT {false}
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002537#define ATOMIC_VAR_INIT(__v) {__v}
2538
2539inline _LIBCPP_INLINE_VISIBILITY
2540memory_order
2541__translate_memory_order(memory_order __o)
2542{
2543 switch (__o)
2544 {
2545 case memory_order_acq_rel:
2546 return memory_order_acquire;
2547 case memory_order_release:
2548 return memory_order_relaxed;
2549 }
2550 return __o;
2551}
2552
2553// atomic_bool
2554
2555struct atomic_bool;
2556
2557bool atomic_is_lock_free(const volatile atomic_bool*);
2558bool atomic_is_lock_free(const atomic_bool*);
2559void atomic_init(volatile atomic_bool*, bool);
2560void atomic_init(atomic_bool*, bool);
2561void atomic_store(volatile atomic_bool*, bool);
2562void atomic_store(atomic_bool*, bool);
2563void atomic_store_explicit(volatile atomic_bool*, bool, memory_order);
2564void atomic_store_explicit(atomic_bool*, bool, memory_order);
2565bool atomic_load(const volatile atomic_bool*);
2566bool atomic_load(const atomic_bool*);
2567bool atomic_load_explicit(const volatile atomic_bool*, memory_order);
2568bool atomic_load_explicit(const atomic_bool*, memory_order);
2569bool atomic_exchange(volatile atomic_bool*, bool);
2570bool atomic_exchange(atomic_bool*, bool);
2571bool atomic_exchange_explicit(volatile atomic_bool*, bool, memory_order);
2572bool atomic_exchange_explicit(atomic_bool*, bool, memory_order);
2573bool atomic_compare_exchange_weak(volatile atomic_bool*, bool*, bool);
2574bool atomic_compare_exchange_weak(atomic_bool*, bool*, bool);
2575bool atomic_compare_exchange_strong(volatile atomic_bool*, bool*, bool);
2576bool atomic_compare_exchange_strong(atomic_bool*, bool*, bool);
2577bool atomic_compare_exchange_weak_explicit(volatile atomic_bool*, bool*, bool,
2578 memory_order, memory_order);
2579bool atomic_compare_exchange_weak_explicit(atomic_bool*, bool*, bool,
2580 memory_order, memory_order);
2581bool atomic_compare_exchange_strong_explicit(volatile atomic_bool*, bool*, bool,
2582 memory_order, memory_order);
2583bool atomic_compare_exchange_strong_explicit(atomic_bool*, bool*, bool,
2584 memory_order, memory_order);
2585
2586typedef struct atomic_bool
2587{
2588 bool __v_;
2589
2590 _LIBCPP_INLINE_VISIBILITY
2591 bool is_lock_free() const volatile
2592 {return atomic_is_lock_free(this);}
2593 _LIBCPP_INLINE_VISIBILITY
2594 bool is_lock_free() const
2595 {return atomic_is_lock_free(this);}
2596 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002597 void store(bool __v, memory_order __o = memory_order_seq_cst) volatile
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002598 {atomic_store_explicit(this, __v, __o);}
2599 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002600 void store(bool __v, memory_order __o = memory_order_seq_cst)
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002601 {atomic_store_explicit(this, __v, __o);}
2602 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002603 bool load(memory_order __o = memory_order_seq_cst) const volatile
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002604 {return atomic_load_explicit(this, __o);}
2605 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002606 bool load(memory_order __o = memory_order_seq_cst) const
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002607 {return atomic_load_explicit(this, __o);}
2608 _LIBCPP_INLINE_VISIBILITY
2609 operator bool() const volatile
2610 {return load();}
2611 _LIBCPP_INLINE_VISIBILITY
2612 operator bool() const
2613 {return load();}
2614 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002615 bool exchange(bool __v, memory_order __o = memory_order_seq_cst) volatile
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002616 {return atomic_exchange_explicit(this, __v, __o);}
2617 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002618 bool exchange(bool __v, memory_order __o = memory_order_seq_cst)
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002619 {return atomic_exchange_explicit(this, __v, __o);}
2620 _LIBCPP_INLINE_VISIBILITY
2621 bool compare_exchange_weak(bool& __v, bool __e, memory_order __s,
2622 memory_order __f) volatile
2623 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
2624 __f);}
2625 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002626 bool compare_exchange_weak(bool& __v, bool __e,
2627 memory_order __s = memory_order_seq_cst) volatile
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002628 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002629 __translate_memory_order(__s));}
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002630 _LIBCPP_INLINE_VISIBILITY
2631 bool compare_exchange_weak(bool& __v, bool __e, memory_order __s,
2632 memory_order __f)
2633 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
2634 __f);}
2635 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002636 bool compare_exchange_weak(bool& __v, bool __e,
2637 memory_order __s = memory_order_seq_cst)
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002638 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002639 __translate_memory_order(__s));}
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002640 _LIBCPP_INLINE_VISIBILITY
2641 bool compare_exchange_strong(bool& __v, bool __e, memory_order __s,
2642 memory_order __f) volatile
2643 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
2644 __f);}
2645 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002646 bool compare_exchange_strong(bool& __v, bool __e,
2647 memory_order __s = memory_order_seq_cst) volatile
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002648 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002649 __translate_memory_order(__s));}
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002650 _LIBCPP_INLINE_VISIBILITY
2651 bool compare_exchange_strong(bool& __v, bool __e, memory_order __s,
2652 memory_order __f)
2653 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
2654 __f);}
2655 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002656 bool compare_exchange_strong(bool& __v, bool __e,
2657 memory_order __s = memory_order_seq_cst)
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002658 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002659 __translate_memory_order(__s));}
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002660#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2661 atomic_bool() = default;
2662#else
2663 _LIBCPP_INLINE_VISIBILITY
2664 atomic_bool() {}
2665#endif
2666 _LIBCPP_INLINE_VISIBILITY
2667 /*constexpr*/ atomic_bool(bool __v)
2668 : __v_(__v) {}
2669#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
2670 atomic_bool(const atomic_bool&) = delete;
2671 atomic_bool& operator=(const atomic_bool&) = delete;
2672 atomic_bool& operator=(const atomic_bool&) volatile = delete;
2673#else
2674private:
2675 atomic_bool(const atomic_bool&);
2676 atomic_bool& operator=(const atomic_bool&);
2677 atomic_bool& operator=(const atomic_bool&) volatile;
2678public:
2679#endif
2680 _LIBCPP_INLINE_VISIBILITY
2681 bool operator=(bool __v) volatile
2682 {store(__v); return __v;}
Howard Hinnante7385012010-10-19 16:51:18 +00002683 _LIBCPP_INLINE_VISIBILITY
2684 bool operator=(bool __v)
2685 {store(__v); return __v;}
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002686} atomic_bool;
2687
2688inline _LIBCPP_INLINE_VISIBILITY
2689bool atomic_is_lock_free(const volatile atomic_bool*)
2690{
Howard Hinnante7385012010-10-19 16:51:18 +00002691 typedef bool type;
2692 return __atomic_is_lock_free(type);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002693}
2694
2695inline _LIBCPP_INLINE_VISIBILITY
2696bool atomic_is_lock_free(const atomic_bool* __obj)
2697{
2698 return atomic_is_lock_free(const_cast<const volatile atomic_bool*>(__obj));
2699}
2700
2701inline _LIBCPP_INLINE_VISIBILITY
2702void atomic_init(volatile atomic_bool* __obj, bool __desr)
2703{
2704 __obj->__v_ = __desr;
2705}
2706
2707inline _LIBCPP_INLINE_VISIBILITY
2708void atomic_init(atomic_bool* __obj, bool __desr)
2709{
2710 __obj->__v_ = __desr;
2711}
2712
2713inline _LIBCPP_INLINE_VISIBILITY
2714void atomic_store(volatile atomic_bool* __obj, bool __desr)
2715{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002716 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002717}
2718
2719inline _LIBCPP_INLINE_VISIBILITY
2720void atomic_store(atomic_bool* __obj, bool __desr)
2721{
2722 atomic_store(const_cast<volatile atomic_bool*>(__obj), __desr);
2723}
2724
2725inline _LIBCPP_INLINE_VISIBILITY
2726void atomic_store_explicit(volatile atomic_bool* __obj, bool __desr,
2727 memory_order __o)
2728{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002729 __atomic_store(&__obj->__v_, __desr, __o);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002730}
2731
2732inline _LIBCPP_INLINE_VISIBILITY
2733void atomic_store_explicit(atomic_bool* __obj, bool __desr, memory_order __o)
2734{
2735 atomic_store_explicit(const_cast<volatile atomic_bool*>(__obj), __desr,
2736 __o);
2737}
2738
2739inline _LIBCPP_INLINE_VISIBILITY
2740bool atomic_load(const volatile atomic_bool* __obj)
2741{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002742 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002743}
2744
2745inline _LIBCPP_INLINE_VISIBILITY
2746bool atomic_load(const atomic_bool* __obj)
2747{
2748 return atomic_load(const_cast<const volatile atomic_bool*>(__obj));
2749}
2750
2751inline _LIBCPP_INLINE_VISIBILITY
2752bool atomic_load_explicit(const volatile atomic_bool* __obj, memory_order __o)
2753{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002754 return __atomic_load(&__obj->__v_, __o);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002755}
2756
2757inline _LIBCPP_INLINE_VISIBILITY
2758bool atomic_load_explicit(const atomic_bool* __obj, memory_order __o)
2759{
2760 return atomic_load_explicit(const_cast<const volatile atomic_bool*>
2761 (__obj), __o);
2762}
2763
2764inline _LIBCPP_INLINE_VISIBILITY
2765bool atomic_exchange(volatile atomic_bool* __obj, bool __desr)
2766{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002767 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002768}
2769
2770inline _LIBCPP_INLINE_VISIBILITY
2771bool atomic_exchange(atomic_bool* __obj, bool __desr)
2772{
2773 return atomic_exchange(const_cast<volatile atomic_bool*>(__obj), __desr);
2774}
2775
2776inline _LIBCPP_INLINE_VISIBILITY
2777bool atomic_exchange_explicit(volatile atomic_bool* __obj, bool __desr,
2778 memory_order __o)
2779{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002780 return __atomic_exchange(&__obj->__v_, __desr, __o);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002781}
2782
2783inline _LIBCPP_INLINE_VISIBILITY
2784bool atomic_exchange_explicit(atomic_bool* __obj, bool __desr, memory_order __o)
2785{
2786 return atomic_exchange_explicit(const_cast<volatile atomic_bool*>
2787 (__obj), __desr, __o);
2788}
2789
2790inline _LIBCPP_INLINE_VISIBILITY
2791bool atomic_compare_exchange_weak(volatile atomic_bool* __obj, bool* __exp,
2792 bool __desr)
2793{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002794 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
2795 memory_order_seq_cst, memory_order_seq_cst);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002796}
2797
2798inline _LIBCPP_INLINE_VISIBILITY
2799bool atomic_compare_exchange_weak(atomic_bool* __obj, bool* __exp, bool __desr)
2800{
2801 return atomic_compare_exchange_weak(const_cast<volatile atomic_bool*>
2802 (__obj), __exp, __desr);
2803}
2804
2805inline _LIBCPP_INLINE_VISIBILITY
2806bool atomic_compare_exchange_weak_explicit(volatile atomic_bool* __obj,
2807 bool* __exp, bool __desr,
2808 memory_order __s, memory_order __f)
2809{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002810 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
2811 __f);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002812}
2813
2814inline _LIBCPP_INLINE_VISIBILITY
2815bool atomic_compare_exchange_weak_explicit(atomic_bool* __obj, bool* __exp,
2816 bool __desr,
2817 memory_order __s, memory_order __f)
2818{
2819 return atomic_compare_exchange_weak_explicit(
2820 const_cast<volatile atomic_bool*>(__obj), __exp, __desr, __s, __f);
2821}
2822
2823inline _LIBCPP_INLINE_VISIBILITY
2824bool atomic_compare_exchange_strong(volatile atomic_bool* __obj, bool* __exp,
2825 bool __desr)
2826{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002827 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
2828 memory_order_seq_cst, memory_order_seq_cst);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002829}
2830
2831inline _LIBCPP_INLINE_VISIBILITY
2832bool atomic_compare_exchange_strong(atomic_bool* __obj, bool* __exp,
2833 bool __desr)
2834{
2835 return atomic_compare_exchange_strong(const_cast<volatile atomic_bool*>
2836 (__obj), __exp, __desr);
2837}
2838
2839inline _LIBCPP_INLINE_VISIBILITY
2840bool atomic_compare_exchange_strong_explicit(volatile atomic_bool* __obj,
2841 bool* __exp, bool __desr,
2842 memory_order __s, memory_order __f)
2843{
Howard Hinnant21ef47f2010-10-18 20:39:07 +00002844 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
2845 __f);
Howard Hinnant611fdaf2010-10-04 18:52:54 +00002846}
2847
2848inline _LIBCPP_INLINE_VISIBILITY
2849bool atomic_compare_exchange_strong_explicit(atomic_bool* __obj, bool* __exp,
2850 bool __desr,
2851 memory_order __s, memory_order __f)
2852{
2853 return atomic_compare_exchange_strong_explicit(
2854 const_cast<volatile atomic_bool*>(__obj), __exp, __desr, __s, __f);
2855}
Howard Hinnanted760f42010-09-29 18:13:54 +00002856
Howard Hinnante7385012010-10-19 16:51:18 +00002857// atomic_char
2858
2859struct atomic_char;
2860
2861bool atomic_is_lock_free(const volatile atomic_char*);
2862bool atomic_is_lock_free(const atomic_char*);
2863void atomic_init(volatile atomic_char*, char);
2864void atomic_init(atomic_char*, char);
2865void atomic_store(volatile atomic_char*, char);
2866void atomic_store(atomic_char*, char);
2867void atomic_store_explicit(volatile atomic_char*, char, memory_order);
2868void atomic_store_explicit(atomic_char*, char, memory_order);
2869char atomic_load(const volatile atomic_char*);
2870char atomic_load(const atomic_char*);
2871char atomic_load_explicit(const volatile atomic_char*, memory_order);
2872char atomic_load_explicit(const atomic_char*, memory_order);
2873char atomic_exchange(volatile atomic_char*, char);
2874char atomic_exchange(atomic_char*, char);
2875char atomic_exchange_explicit(volatile atomic_char*, char, memory_order);
2876char atomic_exchange_explicit(atomic_char*, char, memory_order);
2877bool atomic_compare_exchange_weak(volatile atomic_char*, char*, char);
2878bool atomic_compare_exchange_weak(atomic_char*, char*, char);
2879bool atomic_compare_exchange_strong(volatile atomic_char*, char*, char);
2880bool atomic_compare_exchange_strong(atomic_char*, char*, char);
2881bool atomic_compare_exchange_weak_explicit(volatile atomic_char*, char*, char,
2882 memory_order, memory_order);
2883bool atomic_compare_exchange_weak_explicit(atomic_char*, char*, char,
2884 memory_order, memory_order);
2885bool atomic_compare_exchange_strong_explicit(volatile atomic_char*, char*, char,
2886 memory_order, memory_order);
2887bool atomic_compare_exchange_strong_explicit(atomic_char*, char*, char,
2888 memory_order, memory_order);
2889char atomic_fetch_add(volatile atomic_char*, char);
2890char atomic_fetch_add(atomic_char*, char);
2891char atomic_fetch_add_explicit(volatile atomic_char*, char, memory_order);
2892char atomic_fetch_add_explicit(atomic_char*, char, memory_order);
2893char atomic_fetch_sub(volatile atomic_char*, char);
2894char atomic_fetch_sub(atomic_char*, char);
2895char atomic_fetch_sub_explicit(volatile atomic_char*, char, memory_order);
2896char atomic_fetch_sub_explicit(atomic_char*, char, memory_order);
2897char atomic_fetch_and(volatile atomic_char*, char);
2898char atomic_fetch_and(atomic_char*, char);
2899char atomic_fetch_and_explicit(volatile atomic_char*, char, memory_order);
2900char atomic_fetch_and_explicit(atomic_char*, char, memory_order);
2901char atomic_fetch_or(volatile atomic_char*, char);
2902char atomic_fetch_or(atomic_char*, char);
2903char atomic_fetch_or_explicit(volatile atomic_char*, char, memory_order);
2904char atomic_fetch_or_explicit(atomic_char*, char, memory_order);
2905char atomic_fetch_xor(volatile atomic_char*, char);
2906char atomic_fetch_xor(atomic_char*, char);
2907char atomic_fetch_xor_explicit(volatile atomic_char*, char, memory_order);
2908char atomic_fetch_xor_explicit(atomic_char*, char, memory_order);
2909
2910typedef struct atomic_char
2911{
2912 char __v_;
2913
2914 _LIBCPP_INLINE_VISIBILITY
2915 bool is_lock_free() const volatile
2916 {return atomic_is_lock_free(this);}
2917 _LIBCPP_INLINE_VISIBILITY
2918 bool is_lock_free() const
2919 {return atomic_is_lock_free(this);}
2920 _LIBCPP_INLINE_VISIBILITY
2921 void store(char __v, memory_order __o = memory_order_seq_cst) volatile
2922 {atomic_store_explicit(this, __v, __o);}
2923 _LIBCPP_INLINE_VISIBILITY
2924 void store(char __v, memory_order __o = memory_order_seq_cst)
2925 {atomic_store_explicit(this, __v, __o);}
2926 _LIBCPP_INLINE_VISIBILITY
2927 char load(memory_order __o = memory_order_seq_cst) const volatile
2928 {return atomic_load_explicit(this, __o);}
2929 _LIBCPP_INLINE_VISIBILITY
2930 char load(memory_order __o = memory_order_seq_cst) const
2931 {return atomic_load_explicit(this, __o);}
2932 _LIBCPP_INLINE_VISIBILITY
2933 operator char() const volatile
2934 {return load();}
2935 _LIBCPP_INLINE_VISIBILITY
2936 operator char() const
2937 {return load();}
2938 _LIBCPP_INLINE_VISIBILITY
2939 char exchange(char __v, memory_order __o = memory_order_seq_cst) volatile
2940 {return atomic_exchange_explicit(this, __v, __o);}
2941 _LIBCPP_INLINE_VISIBILITY
2942 char exchange(char __v, memory_order __o = memory_order_seq_cst)
2943 {return atomic_exchange_explicit(this, __v, __o);}
2944 _LIBCPP_INLINE_VISIBILITY
2945 bool compare_exchange_weak(char& __v, char __e, memory_order __s,
2946 memory_order __f) volatile
2947 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
2948 __f);}
2949 _LIBCPP_INLINE_VISIBILITY
2950 bool compare_exchange_weak(char& __v, char __e, memory_order __s,
2951 memory_order __f)
2952 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
2953 __f);}
2954 _LIBCPP_INLINE_VISIBILITY
2955 bool compare_exchange_strong(char& __v, char __e, memory_order __s,
2956 memory_order __f) volatile
2957 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
2958 __f);}
2959 _LIBCPP_INLINE_VISIBILITY
2960 bool compare_exchange_strong(char& __v, char __e, memory_order __s,
2961 memory_order __f)
2962 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
2963 __f);}
2964 _LIBCPP_INLINE_VISIBILITY
2965 bool compare_exchange_weak(char& __v, char __e,
2966 memory_order __s = memory_order_seq_cst) volatile
2967 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
2968 __translate_memory_order(__s));}
2969 _LIBCPP_INLINE_VISIBILITY
2970 bool compare_exchange_weak(char& __v, char __e,
2971 memory_order __s = memory_order_seq_cst)
2972 {return atomic_compare_exchange_weak_explicit(this, &__v, __e, __s,
2973 __translate_memory_order(__s));}
2974 _LIBCPP_INLINE_VISIBILITY
2975 bool compare_exchange_strong(char& __v, char __e,
2976 memory_order __s = memory_order_seq_cst) volatile
2977 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
2978 __translate_memory_order(__s));}
2979 _LIBCPP_INLINE_VISIBILITY
2980 bool compare_exchange_strong(char& __v, char __e,
2981 memory_order __s = memory_order_seq_cst)
2982 {return atomic_compare_exchange_strong_explicit(this, &__v, __e, __s,
2983 __translate_memory_order(__s));}
2984 _LIBCPP_INLINE_VISIBILITY
2985 char fetch_add(char __v, memory_order __o = memory_order_seq_cst) volatile
2986 {return atomic_fetch_add_explicit(this, __v, __o);}
2987 _LIBCPP_INLINE_VISIBILITY
2988 char fetch_add(char __v, memory_order __o = memory_order_seq_cst)
2989 {return atomic_fetch_add_explicit(this, __v, __o);}
2990 _LIBCPP_INLINE_VISIBILITY
2991 char fetch_sub(char __v, memory_order __o = memory_order_seq_cst) volatile
2992 {return atomic_fetch_sub_explicit(this, __v, __o);}
2993 _LIBCPP_INLINE_VISIBILITY
2994 char fetch_sub(char __v, memory_order __o = memory_order_seq_cst)
2995 {return atomic_fetch_sub_explicit(this, __v, __o);}
2996 _LIBCPP_INLINE_VISIBILITY
2997 char fetch_and(char __v, memory_order __o = memory_order_seq_cst) volatile
2998 {return atomic_fetch_and_explicit(this, __v, __o);}
2999 _LIBCPP_INLINE_VISIBILITY
3000 char fetch_and(char __v, memory_order __o = memory_order_seq_cst)
3001 {return atomic_fetch_and_explicit(this, __v, __o);}
3002 _LIBCPP_INLINE_VISIBILITY
3003 char fetch_or(char __v, memory_order __o = memory_order_seq_cst) volatile
3004 {return atomic_fetch_or_explicit(this, __v, __o);}
3005 _LIBCPP_INLINE_VISIBILITY
3006 char fetch_or(char __v, memory_order __o = memory_order_seq_cst)
3007 {return atomic_fetch_or_explicit(this, __v, __o);}
3008 _LIBCPP_INLINE_VISIBILITY
3009 char fetch_xor(char __v, memory_order __o = memory_order_seq_cst) volatile
3010 {return atomic_fetch_xor_explicit(this, __v, __o);}
3011 _LIBCPP_INLINE_VISIBILITY
3012 char fetch_xor(char __v, memory_order __o = memory_order_seq_cst)
3013 {return atomic_fetch_xor_explicit(this, __v, __o);}
3014#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
3015 atomic_char() = default;
3016#else
3017 _LIBCPP_INLINE_VISIBILITY
3018 atomic_char() {}
3019#endif
3020 _LIBCPP_INLINE_VISIBILITY
3021 /*constexpr*/ atomic_char(char __v)
3022 : __v_(__v) {}
3023#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
3024 atomic_char(const atomic_char&) = delete;
3025 atomic_char& operator=(const atomic_char&) = delete;
3026 atomic_char& operator=(const atomic_char&) volatile = delete;
3027#else
3028private:
3029 atomic_char(const atomic_char&);
3030 atomic_char& operator=(const atomic_char&);
3031 atomic_char& operator=(const atomic_char&) volatile;
3032public:
3033#endif
3034 _LIBCPP_INLINE_VISIBILITY
3035 char operator=(char __v) volatile
3036 {store(__v); return __v;}
3037 _LIBCPP_INLINE_VISIBILITY
3038 char operator=(char __v)
3039 {store(__v); return __v;}
3040 _LIBCPP_INLINE_VISIBILITY
3041 char operator++(int) volatile
3042 {return fetch_add(char(1));}
3043 _LIBCPP_INLINE_VISIBILITY
3044 char operator++(int)
3045 {return fetch_add(char(1));}
3046 _LIBCPP_INLINE_VISIBILITY
3047 char operator--(int) volatile
3048 {return fetch_sub(char(1));}
3049 _LIBCPP_INLINE_VISIBILITY
3050 char operator--(int)
3051 {return fetch_sub(char(1));}
3052 _LIBCPP_INLINE_VISIBILITY
3053 char operator++() volatile
3054 {return char(fetch_add(char(1)) + 1);}
3055 _LIBCPP_INLINE_VISIBILITY
3056 char operator++()
3057 {return char(fetch_add(char(1)) + 1);}
3058 _LIBCPP_INLINE_VISIBILITY
3059 char operator--() volatile
3060 {return char(fetch_sub(char(1)) - 1);}
3061 _LIBCPP_INLINE_VISIBILITY
3062 char operator--()
3063 {return char(fetch_sub(char(1)) - 1);}
3064 _LIBCPP_INLINE_VISIBILITY
3065 char operator+=(char __v) volatile
3066 {return char(fetch_add(__v) + __v);}
3067 _LIBCPP_INLINE_VISIBILITY
3068 char operator+=(char __v)
3069 {return char(fetch_add(__v) + __v);}
3070 _LIBCPP_INLINE_VISIBILITY
3071 char operator-=(char __v) volatile
3072 {return char(fetch_sub(__v) - __v);}
3073 _LIBCPP_INLINE_VISIBILITY
3074 char operator-=(char __v)
3075 {return char(fetch_sub(__v) - __v);}
3076 _LIBCPP_INLINE_VISIBILITY
3077 char operator&=(char __v) volatile
3078 {return char(fetch_and(__v) & __v);}
3079 _LIBCPP_INLINE_VISIBILITY
3080 char operator&=(char __v)
3081 {return char(fetch_and(__v) & __v);}
3082 _LIBCPP_INLINE_VISIBILITY
3083 char operator|=(char __v) volatile
3084 {return char(fetch_or(__v) | __v);}
3085 _LIBCPP_INLINE_VISIBILITY
3086 char operator|=(char __v)
3087 {return char(fetch_or(__v) | __v);}
3088 _LIBCPP_INLINE_VISIBILITY
3089 char operator^=(char __v) volatile
3090 {return char(fetch_xor(__v) ^ __v);}
3091 _LIBCPP_INLINE_VISIBILITY
3092 char operator^=(char __v)
3093 {return char(fetch_xor(__v) ^ __v);}
3094} atomic_char;
3095
3096inline _LIBCPP_INLINE_VISIBILITY
3097bool
3098atomic_is_lock_free(const volatile atomic_char*)
3099{
3100 typedef char type;
3101 return __atomic_is_lock_free(type);
3102}
3103
3104inline _LIBCPP_INLINE_VISIBILITY
3105bool
3106atomic_is_lock_free(const atomic_char* __obj)
3107{
3108 return atomic_is_lock_free(const_cast<volatile atomic_char*>(__obj));
3109}
3110
3111inline _LIBCPP_INLINE_VISIBILITY
3112void
3113atomic_init(volatile atomic_char* __obj, char __desr)
3114{
3115 __obj->__v_ = __desr;
3116}
3117
3118inline _LIBCPP_INLINE_VISIBILITY
3119void
3120atomic_init(atomic_char* __obj, char __desr)
3121{
3122 __obj->__v_ = __desr;
3123}
3124
3125inline _LIBCPP_INLINE_VISIBILITY
3126void
3127atomic_store(volatile atomic_char* __obj, char __desr)
3128{
3129 __atomic_store(&__obj->__v_, __desr, memory_order_seq_cst);
3130}
3131
3132inline _LIBCPP_INLINE_VISIBILITY
3133void
3134atomic_store(atomic_char* __obj, char __desr)
3135{
3136 atomic_store(const_cast<volatile atomic_char*>(__obj), __desr);
3137}
3138
3139inline _LIBCPP_INLINE_VISIBILITY
3140void
3141atomic_store_explicit(volatile atomic_char* __obj, char __desr,
3142 memory_order __o)
3143{
3144 __atomic_store(&__obj->__v_, __desr, __o);
3145}
3146
3147inline _LIBCPP_INLINE_VISIBILITY
3148void
3149atomic_store_explicit(atomic_char* __obj, char __desr, memory_order __o)
3150{
3151 atomic_store_explicit(const_cast<volatile atomic_char*>(__obj), __desr,
3152 __o);
3153}
3154
3155inline _LIBCPP_INLINE_VISIBILITY
3156char
3157atomic_load(const volatile atomic_char* __obj)
3158{
3159 return __atomic_load(&__obj->__v_, memory_order_seq_cst);
3160}
3161
3162inline _LIBCPP_INLINE_VISIBILITY
3163char
3164atomic_load(const atomic_char* __obj)
3165{
3166 return atomic_load(const_cast<const volatile atomic_char*>(__obj));
3167}
3168
3169inline _LIBCPP_INLINE_VISIBILITY
3170char
3171atomic_load_explicit(const volatile atomic_char* __obj, memory_order __o)
3172{
3173 return __atomic_load(&__obj->__v_, __o);
3174}
3175
3176inline _LIBCPP_INLINE_VISIBILITY
3177char
3178atomic_load_explicit(const atomic_char* __obj, memory_order __o)
3179{
3180 return atomic_load_explicit(const_cast<const volatile atomic_char*>
3181 (__obj), __o);
3182}
3183
3184inline _LIBCPP_INLINE_VISIBILITY
3185char
3186atomic_exchange(volatile atomic_char* __obj, char __desr)
3187{
3188 return __atomic_exchange(&__obj->__v_, __desr, memory_order_seq_cst);
3189}
3190
3191inline _LIBCPP_INLINE_VISIBILITY
3192char
3193atomic_exchange(atomic_char* __obj, char __desr)
3194{
3195 return atomic_exchange(const_cast<volatile atomic_char*>(__obj), __desr);
3196}
3197
3198inline _LIBCPP_INLINE_VISIBILITY
3199char
3200atomic_exchange_explicit(volatile atomic_char* __obj, char __desr,
3201 memory_order __o)
3202{
3203 return __atomic_exchange(&__obj->__v_, __desr, __o);
3204}
3205
3206inline _LIBCPP_INLINE_VISIBILITY
3207char
3208atomic_exchange_explicit(atomic_char* __obj, char __desr, memory_order __o)
3209{
3210 return atomic_exchange_explicit(const_cast<volatile atomic_char*>
3211 (__obj), __desr, __o);
3212}
3213
3214inline _LIBCPP_INLINE_VISIBILITY
3215bool
3216atomic_compare_exchange_weak(volatile atomic_char* __obj, char* __exp,
3217 char __desr)
3218{
3219 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr,
3220 memory_order_seq_cst, memory_order_seq_cst);
3221}
3222
3223inline _LIBCPP_INLINE_VISIBILITY
3224bool
3225atomic_compare_exchange_weak(atomic_char* __obj, char* __exp, char __desr)
3226{
3227 return atomic_compare_exchange_weak(const_cast<volatile atomic_char*>
3228 (__obj), __exp, __desr);
3229}
3230
3231inline _LIBCPP_INLINE_VISIBILITY
3232bool
3233atomic_compare_exchange_strong(volatile atomic_char* __obj, char* __exp,
3234 char __desr)
3235{
3236 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr,
3237 memory_order_seq_cst, memory_order_seq_cst);
3238}
3239
3240inline _LIBCPP_INLINE_VISIBILITY
3241bool
3242atomic_compare_exchange_strong(atomic_char* __obj, char* __exp, char __desr)
3243{
3244 return atomic_compare_exchange_strong(const_cast<volatile atomic_char*>
3245 (__obj), __exp, __desr);
3246}
3247
3248inline _LIBCPP_INLINE_VISIBILITY
3249bool
3250atomic_compare_exchange_weak_explicit(volatile atomic_char* __obj, char* __exp,
3251 char __desr, memory_order __s,
3252 memory_order __f)
3253{
3254 return __atomic_compare_exchange_weak(&__obj->__v_, __exp, __desr, __s,
3255 __f);
3256}
3257
3258inline _LIBCPP_INLINE_VISIBILITY
3259bool
3260atomic_compare_exchange_weak_explicit(atomic_char* __obj, char* __exp,
3261 char __desr, memory_order __s,
3262 memory_order __f)
3263{
3264 return atomic_compare_exchange_weak_explicit(
3265 const_cast<volatile atomic_char*>(__obj), __exp, __desr, __s, __f);
3266}
3267
3268inline _LIBCPP_INLINE_VISIBILITY
3269bool
3270atomic_compare_exchange_strong_explicit(volatile atomic_char* __obj,
3271 char* __exp, char __desr,
3272 memory_order __s, memory_order __f)
3273{
3274 return __atomic_compare_exchange_strong(&__obj->__v_, __exp, __desr, __s,
3275 __f);
3276}
3277
3278inline _LIBCPP_INLINE_VISIBILITY
3279bool
3280atomic_compare_exchange_strong_explicit(atomic_char* __obj, char* __exp,
3281 char __desr, memory_order __s,
3282 memory_order __f)
3283{
3284 return atomic_compare_exchange_strong_explicit(
3285 const_cast<volatile atomic_char*>(__obj), __exp, __desr, __s, __f);
3286}
3287
3288inline _LIBCPP_INLINE_VISIBILITY
3289char
3290atomic_fetch_add(volatile atomic_char* __obj, char __v)
3291{
3292 return __atomic_fetch_add(&__obj->__v_, __v, memory_order_seq_cst);
3293}
3294
3295inline _LIBCPP_INLINE_VISIBILITY
3296char
3297atomic_fetch_add(atomic_char* __obj, char __v)
3298{
3299 return atomic_fetch_add(const_cast<volatile atomic_char*>(__obj), __v);
3300}
3301
3302inline _LIBCPP_INLINE_VISIBILITY
3303char
3304atomic_fetch_add_explicit(volatile atomic_char* __obj, char __v,
3305 memory_order __o)
3306{
3307 return __atomic_fetch_add(&__obj->__v_, __v, __o);
3308}
3309
3310inline _LIBCPP_INLINE_VISIBILITY
3311char
3312atomic_fetch_add_explicit(atomic_char* __obj, char __v, memory_order __o)
3313{
3314 return atomic_fetch_add_explicit(const_cast<volatile atomic_char*>(__obj),
3315 __v, __o);
3316}
3317
3318inline _LIBCPP_INLINE_VISIBILITY
3319char
3320atomic_fetch_sub(volatile atomic_char* __obj, char __v)
3321{
3322 return __atomic_fetch_sub(&__obj->__v_, __v, memory_order_seq_cst);
3323}
3324
3325inline _LIBCPP_INLINE_VISIBILITY
3326char
3327atomic_fetch_sub(atomic_char* __obj, char __v)
3328{
3329 return atomic_fetch_sub(const_cast<volatile atomic_char*>(__obj), __v);
3330}
3331
3332inline _LIBCPP_INLINE_VISIBILITY
3333char
3334atomic_fetch_sub_explicit(volatile atomic_char* __obj, char __v,
3335 memory_order __o)
3336{
3337 return __atomic_fetch_sub(&__obj->__v_, __v, __o);
3338}
3339
3340inline _LIBCPP_INLINE_VISIBILITY
3341char
3342atomic_fetch_sub_explicit(atomic_char* __obj, char __v, memory_order __o)
3343{
3344 return atomic_fetch_sub_explicit(const_cast<volatile atomic_char*>(__obj),
3345 __v, __o);
3346}
3347
3348inline _LIBCPP_INLINE_VISIBILITY
3349char
3350atomic_fetch_and(volatile atomic_char* __obj, char __v)
3351{
3352 return __atomic_fetch_and(&__obj->__v_, __v, memory_order_seq_cst);
3353}
3354
3355inline _LIBCPP_INLINE_VISIBILITY
3356char
3357atomic_fetch_and(atomic_char* __obj, char __v)
3358{
3359 return atomic_fetch_and(const_cast<volatile atomic_char*>(__obj), __v);
3360}
3361
3362inline _LIBCPP_INLINE_VISIBILITY
3363char
3364atomic_fetch_and_explicit(volatile atomic_char* __obj, char __v,
3365 memory_order __o)
3366{
3367 return __atomic_fetch_and(&__obj->__v_, __v, __o);
3368}
3369
3370inline _LIBCPP_INLINE_VISIBILITY
3371char
3372atomic_fetch_and_explicit(atomic_char* __obj, char __v, memory_order __o)
3373{
3374 return atomic_fetch_and_explicit(const_cast<volatile atomic_char*>(__obj),
3375 __v, __o);
3376}
3377
3378inline _LIBCPP_INLINE_VISIBILITY
3379char
3380atomic_fetch_or(volatile atomic_char* __obj, char __v)
3381{
3382 return __atomic_fetch_or(&__obj->__v_, __v, memory_order_seq_cst);
3383}
3384
3385inline _LIBCPP_INLINE_VISIBILITY
3386char
3387atomic_fetch_or(atomic_char* __obj, char __v)
3388{
3389 return atomic_fetch_or(const_cast<volatile atomic_char*>(__obj), __v);
3390}
3391
3392inline _LIBCPP_INLINE_VISIBILITY
3393char
3394atomic_fetch_or_explicit(volatile atomic_char* __obj, char __v,
3395 memory_order __o)
3396{
3397 return __atomic_fetch_or(&__obj->__v_, __v, __o);
3398}
3399
3400inline _LIBCPP_INLINE_VISIBILITY
3401char
3402atomic_fetch_or_explicit(atomic_char* __obj, char __v, memory_order __o)
3403{
3404 return atomic_fetch_or_explicit(const_cast<volatile atomic_char*>(__obj),
3405 __v, __o);
3406}
3407
3408inline _LIBCPP_INLINE_VISIBILITY
3409char
3410atomic_fetch_xor(volatile atomic_char* __obj, char __v)
3411{
3412 return __atomic_fetch_xor(&__obj->__v_, __v, memory_order_seq_cst);
3413}
3414
3415inline _LIBCPP_INLINE_VISIBILITY
3416char
3417atomic_fetch_xor(atomic_char* __obj, char __v)
3418{
3419 return atomic_fetch_xor(const_cast<volatile atomic_char*>(__obj), __v);
3420}
3421
3422inline _LIBCPP_INLINE_VISIBILITY
3423char
3424atomic_fetch_xor_explicit(volatile atomic_char* __obj, char __v,
3425 memory_order __o)
3426{
3427 return __atomic_fetch_xor(&__obj->__v_, __v, __o);
3428}
3429
3430inline _LIBCPP_INLINE_VISIBILITY
3431char
3432atomic_fetch_xor_explicit(atomic_char* __obj, char __v, memory_order __o)
3433{
3434 return atomic_fetch_xor_explicit(const_cast<volatile atomic_char*>(__obj),
3435 __v, __o);
3436}
3437
Howard Hinnant8f73c632010-09-27 21:17:38 +00003438_LIBCPP_END_NAMESPACE_STD
3439
3440#endif // _LIBCPP_ATOMIC