]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/std/atomic
Remove unwanted svn:executable properties that svn add had decided to add.
[thirdparty/gcc.git] / libstdc++-v3 / include / std / atomic
CommitLineData
d466a7e2
BK
1// -*- C++ -*- header.
2
036e0d4f 3// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
d466a7e2
BK
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
748086b7 8// Free Software Foundation; either version 3, or (at your option)
d466a7e2
BK
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
748086b7
JJ
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
d466a7e2 24
f910786b 25/** @file include/atomic
afd88205 26 * This is a Standard C++ Library header.
d466a7e2
BK
27 */
28
29// Based on "C++ Atomic Types and Operations" by Hans Boehm and Lawrence Crowl.
30// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html
31
afd88205
BK
32#ifndef _GLIBCXX_ATOMIC
33#define _GLIBCXX_ATOMIC 1
d466a7e2
BK
34
35#pragma GCC system_header
36
37#ifndef __GXX_EXPERIMENTAL_CXX0X__
ab65a4c7 38# include <bits/c++0x_warning.h>
d466a7e2
BK
39#endif
40
afd88205 41#include <bits/atomic_base.h>
94a86be0
BK
42#include <bits/atomic_0.h>
43#include <bits/atomic_2.h>
d466a7e2 44
12ffa228
BK
45namespace std _GLIBCXX_VISIBILITY(default)
46{
47_GLIBCXX_BEGIN_NAMESPACE_VERSION
d466a7e2 48
5b9daa7e
BK
49 /**
50 * @addtogroup atomics
51 * @{
52 */
53
94a86be0
BK
54 /// atomic_bool
55 // NB: No operators or fetch-operations for this type.
56 struct atomic_bool
d466a7e2 57 {
94a86be0
BK
58 private:
59 __atomic_base<bool> _M_base;
60
61 public:
bdc05efb
PC
62 atomic_bool() noexcept = default;
63 ~atomic_bool() noexcept = default;
94a86be0
BK
64 atomic_bool(const atomic_bool&) = delete;
65 atomic_bool& operator=(const atomic_bool&) = delete;
66 atomic_bool& operator=(const atomic_bool&) volatile = delete;
67
bdc05efb 68 constexpr atomic_bool(bool __i) noexcept : _M_base(__i) { }
94a86be0
BK
69
70 bool
bdc05efb 71 operator=(bool __i) noexcept
94a86be0
BK
72 { return _M_base.operator=(__i); }
73
bdc05efb 74 operator bool() const noexcept
94a86be0
BK
75 { return _M_base.load(); }
76
bdc05efb 77 operator bool() const volatile noexcept
94a86be0
BK
78 { return _M_base.load(); }
79
80 bool
bdc05efb 81 is_lock_free() const noexcept { return _M_base.is_lock_free(); }
94a86be0
BK
82
83 bool
bdc05efb 84 is_lock_free() const volatile noexcept { return _M_base.is_lock_free(); }
94a86be0
BK
85
86 void
bdc05efb 87 store(bool __i, memory_order __m = memory_order_seq_cst) noexcept
94a86be0
BK
88 { _M_base.store(__i, __m); }
89
90 void
bdc05efb 91 store(bool __i, memory_order __m = memory_order_seq_cst) volatile noexcept
94a86be0
BK
92 { _M_base.store(__i, __m); }
93
94 bool
bdc05efb 95 load(memory_order __m = memory_order_seq_cst) const noexcept
94a86be0
BK
96 { return _M_base.load(__m); }
97
98 bool
bdc05efb 99 load(memory_order __m = memory_order_seq_cst) const volatile noexcept
94a86be0
BK
100 { return _M_base.load(__m); }
101
102 bool
bdc05efb 103 exchange(bool __i, memory_order __m = memory_order_seq_cst) noexcept
94a86be0
BK
104 { return _M_base.exchange(__i, __m); }
105
106 bool
bdc05efb
PC
107 exchange(bool __i,
108 memory_order __m = memory_order_seq_cst) volatile noexcept
94a86be0
BK
109 { return _M_base.exchange(__i, __m); }
110
111 bool
112 compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1,
bdc05efb 113 memory_order __m2) noexcept
94a86be0
BK
114 { return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); }
115
116 bool
117 compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1,
bdc05efb 118 memory_order __m2) volatile noexcept
94a86be0
BK
119 { return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); }
120
121 bool
122 compare_exchange_weak(bool& __i1, bool __i2,
bdc05efb 123 memory_order __m = memory_order_seq_cst) noexcept
94a86be0
BK
124 { return _M_base.compare_exchange_weak(__i1, __i2, __m); }
125
126 bool
127 compare_exchange_weak(bool& __i1, bool __i2,
bdc05efb 128 memory_order __m = memory_order_seq_cst) volatile noexcept
94a86be0
BK
129 { return _M_base.compare_exchange_weak(__i1, __i2, __m); }
130
131 bool
132 compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1,
bdc05efb 133 memory_order __m2) noexcept
94a86be0
BK
134 { return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); }
135
136 bool
137 compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1,
bdc05efb 138 memory_order __m2) volatile noexcept
94a86be0
BK
139 { return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); }
140
141 bool
142 compare_exchange_strong(bool& __i1, bool __i2,
bdc05efb 143 memory_order __m = memory_order_seq_cst) noexcept
94a86be0
BK
144 { return _M_base.compare_exchange_strong(__i1, __i2, __m); }
145
146 bool
147 compare_exchange_strong(bool& __i1, bool __i2,
bdc05efb 148 memory_order __m = memory_order_seq_cst) volatile noexcept
94a86be0
BK
149 { return _M_base.compare_exchange_strong(__i1, __i2, __m); }
150 };
d466a7e2 151
d466a7e2 152
50ce8d3d
BK
153 /// atomic
154 /// 29.4.3, Generic atomic type, primary class template.
155 template<typename _Tp>
156 struct atomic
157 {
158 private:
159 _Tp _M_i;
d466a7e2 160
50ce8d3d 161 public:
bdc05efb
PC
162 atomic() noexcept = default;
163 ~atomic() noexcept = default;
50ce8d3d 164 atomic(const atomic&) = delete;
94a86be0 165 atomic& operator=(const atomic&) = delete;
afd88205 166 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 167
bdc05efb 168 constexpr atomic(_Tp __i) noexcept : _M_i(__i) { }
d466a7e2 169
bdc05efb 170 operator _Tp() const noexcept;
d466a7e2 171
bdc05efb 172 operator _Tp() const volatile noexcept;
94a86be0 173
afd88205 174 _Tp
bdc05efb 175 operator=(_Tp __i) noexcept { store(__i); return __i; }
d466a7e2 176
94a86be0 177 _Tp
bdc05efb 178 operator=(_Tp __i) volatile noexcept { store(__i); return __i; }
94a86be0
BK
179
180 bool
bdc05efb 181 is_lock_free() const noexcept;
94a86be0 182
afd88205 183 bool
bdc05efb 184 is_lock_free() const volatile noexcept;
d466a7e2 185
94a86be0 186 void
bdc05efb 187 store(_Tp, memory_order = memory_order_seq_cst) noexcept;
94a86be0 188
afd88205 189 void
bdc05efb 190 store(_Tp, memory_order = memory_order_seq_cst) volatile noexcept;
d466a7e2 191
94a86be0 192 _Tp
bdc05efb 193 load(memory_order = memory_order_seq_cst) const noexcept;
94a86be0 194
afd88205 195 _Tp
bdc05efb 196 load(memory_order = memory_order_seq_cst) const volatile noexcept;
d466a7e2 197
94a86be0 198 _Tp
bdc05efb 199 exchange(_Tp __i, memory_order = memory_order_seq_cst) noexcept;
94a86be0 200
afd88205 201 _Tp
bdc05efb 202 exchange(_Tp __i, memory_order = memory_order_seq_cst) volatile noexcept;
d466a7e2 203
94a86be0 204 bool
bdc05efb 205 compare_exchange_weak(_Tp&, _Tp, memory_order, memory_order) noexcept;
94a86be0 206
afd88205 207 bool
bdc05efb
PC
208 compare_exchange_weak(_Tp&, _Tp, memory_order,
209 memory_order) volatile noexcept;
d466a7e2 210
afd88205 211 bool
bdc05efb
PC
212 compare_exchange_weak(_Tp&, _Tp,
213 memory_order = memory_order_seq_cst) noexcept;
d466a7e2 214
afd88205
BK
215 bool
216 compare_exchange_weak(_Tp&, _Tp,
bdc05efb 217 memory_order = memory_order_seq_cst) volatile noexcept;
d466a7e2 218
94a86be0 219 bool
bdc05efb 220 compare_exchange_strong(_Tp&, _Tp, memory_order, memory_order) noexcept;
94a86be0
BK
221
222 bool
bdc05efb
PC
223 compare_exchange_strong(_Tp&, _Tp, memory_order,
224 memory_order) volatile noexcept;
94a86be0
BK
225
226 bool
bdc05efb
PC
227 compare_exchange_strong(_Tp&, _Tp,
228 memory_order = memory_order_seq_cst) noexcept;
94a86be0 229
afd88205
BK
230 bool
231 compare_exchange_strong(_Tp&, _Tp,
bdc05efb 232 memory_order = memory_order_seq_cst) volatile noexcept;
50ce8d3d 233 };
d466a7e2 234
d466a7e2 235
50ce8d3d 236 /// Partial specialization for pointer types.
afd88205 237 template<typename _Tp>
036e0d4f 238 struct atomic<_Tp*>
50ce8d3d 239 {
036e0d4f
BK
240 typedef _Tp* __pointer_type;
241 typedef __atomic_base<_Tp*> __base_type;
242 __base_type _M_b;
243
bdc05efb
PC
244 atomic() noexcept = default;
245 ~atomic() noexcept = default;
50ce8d3d 246 atomic(const atomic&) = delete;
036e0d4f 247 atomic& operator=(const atomic&) = delete;
afd88205 248 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 249
bdc05efb 250 constexpr atomic(__pointer_type __p) noexcept : _M_b(__p) { }
94a86be0 251
bdc05efb 252 operator __pointer_type() const noexcept
036e0d4f 253 { return __pointer_type(_M_b); }
d466a7e2 254
bdc05efb 255 operator __pointer_type() const volatile noexcept
036e0d4f 256 { return __pointer_type(_M_b); }
d466a7e2 257
036e0d4f 258 __pointer_type
bdc05efb 259 operator=(__pointer_type __p) noexcept
036e0d4f 260 { return _M_b.operator=(__p); }
d466a7e2 261
036e0d4f 262 __pointer_type
bdc05efb 263 operator=(__pointer_type __p) volatile noexcept
036e0d4f 264 { return _M_b.operator=(__p); }
94a86be0 265
036e0d4f 266 __pointer_type
bdc05efb 267 operator++(int) noexcept
036e0d4f 268 { return _M_b++; }
94a86be0 269
036e0d4f 270 __pointer_type
bdc05efb 271 operator++(int) volatile noexcept
036e0d4f 272 { return _M_b++; }
d466a7e2 273
036e0d4f 274 __pointer_type
bdc05efb 275 operator--(int) noexcept
036e0d4f 276 { return _M_b--; }
d466a7e2 277
036e0d4f 278 __pointer_type
bdc05efb 279 operator--(int) volatile noexcept
036e0d4f 280 { return _M_b--; }
d466a7e2 281
036e0d4f 282 __pointer_type
bdc05efb 283 operator++() noexcept
036e0d4f 284 { return ++_M_b; }
d466a7e2 285
036e0d4f 286 __pointer_type
bdc05efb 287 operator++() volatile noexcept
036e0d4f 288 { return ++_M_b; }
94a86be0 289
036e0d4f 290 __pointer_type
bdc05efb 291 operator--() noexcept
036e0d4f 292 { return --_M_b; }
94a86be0 293
036e0d4f 294 __pointer_type
bdc05efb 295 operator--() volatile noexcept
036e0d4f
BK
296 { return --_M_b; }
297
298 __pointer_type
bdc05efb 299 operator+=(ptrdiff_t __d) noexcept
036e0d4f
BK
300 { return _M_b.operator+=(__d); }
301
302 __pointer_type
bdc05efb 303 operator+=(ptrdiff_t __d) volatile noexcept
036e0d4f
BK
304 { return _M_b.operator+=(__d); }
305
306 __pointer_type
bdc05efb 307 operator-=(ptrdiff_t __d) noexcept
036e0d4f
BK
308 { return _M_b.operator-=(__d); }
309
310 __pointer_type
bdc05efb 311 operator-=(ptrdiff_t __d) volatile noexcept
036e0d4f 312 { return _M_b.operator-=(__d); }
94a86be0 313
afd88205 314 bool
bdc05efb 315 is_lock_free() const noexcept
036e0d4f 316 { return _M_b.is_lock_free(); }
d466a7e2 317
94a86be0 318 bool
bdc05efb 319 is_lock_free() const volatile noexcept
036e0d4f
BK
320 { return _M_b.is_lock_free(); }
321
322 void
bdc05efb
PC
323 store(__pointer_type __p,
324 memory_order __m = memory_order_seq_cst) noexcept
036e0d4f
BK
325 { return _M_b.store(__p, __m); }
326
327 void
328 store(__pointer_type __p,
bdc05efb 329 memory_order __m = memory_order_seq_cst) volatile noexcept
036e0d4f 330 { return _M_b.store(__p, __m); }
94a86be0 331
036e0d4f 332 __pointer_type
bdc05efb 333 load(memory_order __m = memory_order_seq_cst) const noexcept
036e0d4f 334 { return _M_b.load(__m); }
d466a7e2 335
036e0d4f 336 __pointer_type
bdc05efb 337 load(memory_order __m = memory_order_seq_cst) const volatile noexcept
036e0d4f 338 { return _M_b.load(__m); }
94a86be0 339
036e0d4f 340 __pointer_type
bdc05efb
PC
341 exchange(__pointer_type __p,
342 memory_order __m = memory_order_seq_cst) noexcept
036e0d4f 343 { return _M_b.exchange(__p, __m); }
d466a7e2 344
036e0d4f
BK
345 __pointer_type
346 exchange(__pointer_type __p,
bdc05efb 347 memory_order __m = memory_order_seq_cst) volatile noexcept
036e0d4f 348 { return _M_b.exchange(__p, __m); }
94a86be0 349
036e0d4f
BK
350 bool
351 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
bdc05efb 352 memory_order __m1, memory_order __m2) noexcept
036e0d4f 353 { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
d466a7e2 354
036e0d4f
BK
355 bool
356 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
bdc05efb
PC
357 memory_order __m1,
358 memory_order __m2) volatile noexcept
036e0d4f 359 { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
94a86be0 360
036e0d4f
BK
361 bool
362 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
bdc05efb 363 memory_order __m = memory_order_seq_cst) noexcept
afd88205 364 {
036e0d4f
BK
365 return compare_exchange_weak(__p1, __p2, __m,
366 __calculate_memory_order(__m));
50ce8d3d 367 }
d466a7e2 368
036e0d4f
BK
369 bool
370 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
bdc05efb 371 memory_order __m = memory_order_seq_cst) volatile noexcept
94a86be0 372 {
036e0d4f
BK
373 return compare_exchange_weak(__p1, __p2, __m,
374 __calculate_memory_order(__m));
94a86be0
BK
375 }
376
036e0d4f
BK
377 bool
378 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
bdc05efb 379 memory_order __m1, memory_order __m2) noexcept
036e0d4f 380 { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
d466a7e2 381
036e0d4f
BK
382 bool
383 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
bdc05efb
PC
384 memory_order __m1,
385 memory_order __m2) volatile noexcept
036e0d4f 386 { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
94a86be0 387
036e0d4f
BK
388 bool
389 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
bdc05efb 390 memory_order __m = memory_order_seq_cst) noexcept
036e0d4f
BK
391 {
392 return _M_b.compare_exchange_strong(__p1, __p2, __m,
393 __calculate_memory_order(__m));
394 }
d466a7e2 395
036e0d4f
BK
396 bool
397 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
bdc05efb 398 memory_order __m = memory_order_seq_cst) volatile noexcept
036e0d4f
BK
399 {
400 return _M_b.compare_exchange_strong(__p1, __p2, __m,
401 __calculate_memory_order(__m));
402 }
94a86be0 403
036e0d4f 404 __pointer_type
bdc05efb
PC
405 fetch_add(ptrdiff_t __d,
406 memory_order __m = memory_order_seq_cst) noexcept
036e0d4f 407 { return _M_b.fetch_add(__d, __m); }
d466a7e2 408
036e0d4f
BK
409 __pointer_type
410 fetch_add(ptrdiff_t __d,
bdc05efb 411 memory_order __m = memory_order_seq_cst) volatile noexcept
036e0d4f 412 { return _M_b.fetch_add(__d, __m); }
94a86be0 413
036e0d4f 414 __pointer_type
bdc05efb
PC
415 fetch_sub(ptrdiff_t __d,
416 memory_order __m = memory_order_seq_cst) noexcept
036e0d4f 417 { return _M_b.fetch_sub(__d, __m); }
d466a7e2 418
036e0d4f
BK
419 __pointer_type
420 fetch_sub(ptrdiff_t __d,
bdc05efb 421 memory_order __m = memory_order_seq_cst) volatile noexcept
036e0d4f 422 { return _M_b.fetch_sub(__d, __m); }
50ce8d3d 423 };
d466a7e2 424
036e0d4f 425
50ce8d3d 426 /// Explicit specialization for bool.
afd88205 427 template<>
50ce8d3d
BK
428 struct atomic<bool> : public atomic_bool
429 {
430 typedef bool __integral_type;
431 typedef atomic_bool __base_type;
d466a7e2 432
bdc05efb
PC
433 atomic() noexcept = default;
434 ~atomic() noexcept = default;
50ce8d3d 435 atomic(const atomic&) = delete;
94a86be0 436 atomic& operator=(const atomic&) = delete;
afd88205 437 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 438
bdc05efb 439 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
d466a7e2 440
50ce8d3d
BK
441 using __base_type::operator __integral_type;
442 using __base_type::operator=;
443 };
d466a7e2 444
50ce8d3d 445 /// Explicit specialization for char.
afd88205 446 template<>
50ce8d3d
BK
447 struct atomic<char> : public atomic_char
448 {
449 typedef char __integral_type;
450 typedef atomic_char __base_type;
d466a7e2 451
bdc05efb
PC
452 atomic() noexcept = default;
453 ~atomic() noexcept = default;
50ce8d3d 454 atomic(const atomic&) = delete;
94a86be0 455 atomic& operator=(const atomic&) = delete;
afd88205 456 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 457
bdc05efb 458 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
d466a7e2 459
50ce8d3d
BK
460 using __base_type::operator __integral_type;
461 using __base_type::operator=;
462 };
d466a7e2 463
50ce8d3d 464 /// Explicit specialization for signed char.
afd88205 465 template<>
50ce8d3d 466 struct atomic<signed char> : public atomic_schar
afd88205 467 {
50ce8d3d
BK
468 typedef signed char __integral_type;
469 typedef atomic_schar __base_type;
d466a7e2 470
bdc05efb
PC
471 atomic() noexcept= default;
472 ~atomic() noexcept = default;
50ce8d3d 473 atomic(const atomic&) = delete;
94a86be0 474 atomic& operator=(const atomic&) = delete;
afd88205 475 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 476
bdc05efb 477 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
d466a7e2 478
50ce8d3d
BK
479 using __base_type::operator __integral_type;
480 using __base_type::operator=;
481 };
d466a7e2 482
50ce8d3d 483 /// Explicit specialization for unsigned char.
afd88205 484 template<>
50ce8d3d
BK
485 struct atomic<unsigned char> : public atomic_uchar
486 {
487 typedef unsigned char __integral_type;
488 typedef atomic_uchar __base_type;
d466a7e2 489
bdc05efb
PC
490 atomic() noexcept= default;
491 ~atomic() noexcept = default;
50ce8d3d 492 atomic(const atomic&) = delete;
94a86be0 493 atomic& operator=(const atomic&) = delete;
afd88205 494 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 495
bdc05efb 496 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
d466a7e2 497
50ce8d3d
BK
498 using __base_type::operator __integral_type;
499 using __base_type::operator=;
500 };
d466a7e2 501
50ce8d3d 502 /// Explicit specialization for short.
afd88205 503 template<>
50ce8d3d
BK
504 struct atomic<short> : public atomic_short
505 {
506 typedef short __integral_type;
507 typedef atomic_short __base_type;
d466a7e2 508
bdc05efb
PC
509 atomic() noexcept = default;
510 ~atomic() noexcept = default;
50ce8d3d 511 atomic(const atomic&) = delete;
94a86be0 512 atomic& operator=(const atomic&) = delete;
afd88205 513 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 514
bdc05efb 515 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
d466a7e2 516
50ce8d3d
BK
517 using __base_type::operator __integral_type;
518 using __base_type::operator=;
519 };
d466a7e2 520
50ce8d3d 521 /// Explicit specialization for unsigned short.
afd88205 522 template<>
50ce8d3d
BK
523 struct atomic<unsigned short> : public atomic_ushort
524 {
525 typedef unsigned short __integral_type;
526 typedef atomic_ushort __base_type;
d466a7e2 527
bdc05efb
PC
528 atomic() noexcept = default;
529 ~atomic() noexcept = default;
50ce8d3d 530 atomic(const atomic&) = delete;
94a86be0 531 atomic& operator=(const atomic&) = delete;
afd88205 532 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 533
bdc05efb 534 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
d466a7e2 535
50ce8d3d
BK
536 using __base_type::operator __integral_type;
537 using __base_type::operator=;
538 };
d466a7e2 539
50ce8d3d 540 /// Explicit specialization for int.
afd88205 541 template<>
50ce8d3d
BK
542 struct atomic<int> : atomic_int
543 {
544 typedef int __integral_type;
545 typedef atomic_int __base_type;
d466a7e2 546
bdc05efb
PC
547 atomic() noexcept = default;
548 ~atomic() noexcept = default;
50ce8d3d 549 atomic(const atomic&) = delete;
94a86be0 550 atomic& operator=(const atomic&) = delete;
afd88205 551 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 552
bdc05efb 553 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
d466a7e2 554
50ce8d3d
BK
555 using __base_type::operator __integral_type;
556 using __base_type::operator=;
557 };
d466a7e2 558
50ce8d3d 559 /// Explicit specialization for unsigned int.
afd88205 560 template<>
50ce8d3d
BK
561 struct atomic<unsigned int> : public atomic_uint
562 {
563 typedef unsigned int __integral_type;
564 typedef atomic_uint __base_type;
d466a7e2 565
bdc05efb
PC
566 atomic() noexcept = default;
567 ~atomic() noexcept = default;
50ce8d3d 568 atomic(const atomic&) = delete;
94a86be0 569 atomic& operator=(const atomic&) = delete;
afd88205 570 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 571
bdc05efb 572 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
d466a7e2 573
50ce8d3d
BK
574 using __base_type::operator __integral_type;
575 using __base_type::operator=;
576 };
d466a7e2 577
50ce8d3d 578 /// Explicit specialization for long.
afd88205 579 template<>
50ce8d3d
BK
580 struct atomic<long> : public atomic_long
581 {
582 typedef long __integral_type;
583 typedef atomic_long __base_type;
d466a7e2 584
bdc05efb
PC
585 atomic() noexcept = default;
586 ~atomic() noexcept = default;
50ce8d3d 587 atomic(const atomic&) = delete;
94a86be0 588 atomic& operator=(const atomic&) = delete;
afd88205 589 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 590
bdc05efb 591 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
d466a7e2 592
50ce8d3d
BK
593 using __base_type::operator __integral_type;
594 using __base_type::operator=;
595 };
d466a7e2 596
50ce8d3d 597 /// Explicit specialization for unsigned long.
afd88205 598 template<>
50ce8d3d
BK
599 struct atomic<unsigned long> : public atomic_ulong
600 {
601 typedef unsigned long __integral_type;
602 typedef atomic_ulong __base_type;
d466a7e2 603
bdc05efb
PC
604 atomic() noexcept = default;
605 ~atomic() noexcept = default;
50ce8d3d 606 atomic(const atomic&) = delete;
94a86be0 607 atomic& operator=(const atomic&) = delete;
afd88205 608 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 609
bdc05efb 610 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
d466a7e2 611
50ce8d3d
BK
612 using __base_type::operator __integral_type;
613 using __base_type::operator=;
614 };
d466a7e2 615
50ce8d3d 616 /// Explicit specialization for long long.
afd88205 617 template<>
50ce8d3d
BK
618 struct atomic<long long> : public atomic_llong
619 {
620 typedef long long __integral_type;
621 typedef atomic_llong __base_type;
d466a7e2 622
bdc05efb
PC
623 atomic() noexcept = default;
624 ~atomic() noexcept = default;
50ce8d3d 625 atomic(const atomic&) = delete;
94a86be0 626 atomic& operator=(const atomic&) = delete;
afd88205 627 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 628
bdc05efb 629 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
d466a7e2 630
50ce8d3d
BK
631 using __base_type::operator __integral_type;
632 using __base_type::operator=;
633 };
d466a7e2 634
50ce8d3d 635 /// Explicit specialization for unsigned long long.
afd88205 636 template<>
50ce8d3d
BK
637 struct atomic<unsigned long long> : public atomic_ullong
638 {
639 typedef unsigned long long __integral_type;
640 typedef atomic_ullong __base_type;
d466a7e2 641
bdc05efb
PC
642 atomic() noexcept = default;
643 ~atomic() noexcept = default;
50ce8d3d 644 atomic(const atomic&) = delete;
94a86be0 645 atomic& operator=(const atomic&) = delete;
afd88205 646 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 647
bdc05efb 648 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
d466a7e2 649
50ce8d3d
BK
650 using __base_type::operator __integral_type;
651 using __base_type::operator=;
652 };
d466a7e2 653
50ce8d3d 654 /// Explicit specialization for wchar_t.
afd88205 655 template<>
50ce8d3d
BK
656 struct atomic<wchar_t> : public atomic_wchar_t
657 {
658 typedef wchar_t __integral_type;
659 typedef atomic_wchar_t __base_type;
d466a7e2 660
bdc05efb
PC
661 atomic() noexcept = default;
662 ~atomic() noexcept = default;
50ce8d3d 663 atomic(const atomic&) = delete;
94a86be0 664 atomic& operator=(const atomic&) = delete;
afd88205 665 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 666
bdc05efb 667 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
d466a7e2 668
50ce8d3d
BK
669 using __base_type::operator __integral_type;
670 using __base_type::operator=;
671 };
d466a7e2 672
50ce8d3d 673 /// Explicit specialization for char16_t.
afd88205 674 template<>
50ce8d3d
BK
675 struct atomic<char16_t> : public atomic_char16_t
676 {
677 typedef char16_t __integral_type;
678 typedef atomic_char16_t __base_type;
d466a7e2 679
bdc05efb
PC
680 atomic() noexcept = default;
681 ~atomic() noexcept = default;
50ce8d3d 682 atomic(const atomic&) = delete;
94a86be0 683 atomic& operator=(const atomic&) = delete;
afd88205 684 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 685
bdc05efb 686 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
d466a7e2 687
50ce8d3d
BK
688 using __base_type::operator __integral_type;
689 using __base_type::operator=;
690 };
d466a7e2 691
50ce8d3d 692 /// Explicit specialization for char32_t.
afd88205 693 template<>
50ce8d3d
BK
694 struct atomic<char32_t> : public atomic_char32_t
695 {
696 typedef char32_t __integral_type;
697 typedef atomic_char32_t __base_type;
d466a7e2 698
bdc05efb
PC
699 atomic() noexcept = default;
700 ~atomic() noexcept = default;
50ce8d3d 701 atomic(const atomic&) = delete;
94a86be0 702 atomic& operator=(const atomic&) = delete;
afd88205 703 atomic& operator=(const atomic&) volatile = delete;
d466a7e2 704
bdc05efb 705 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
d466a7e2 706
50ce8d3d
BK
707 using __base_type::operator __integral_type;
708 using __base_type::operator=;
709 };
d466a7e2 710
94a86be0 711
94a86be0 712 // Function definitions, atomic_flag operations.
afd88205 713 inline bool
bdc05efb
PC
714 atomic_flag_test_and_set_explicit(atomic_flag* __a,
715 memory_order __m) noexcept
50ce8d3d 716 { return __a->test_and_set(__m); }
d466a7e2 717
94a86be0 718 inline bool
036e0d4f 719 atomic_flag_test_and_set_explicit(volatile atomic_flag* __a,
bdc05efb 720 memory_order __m) noexcept
94a86be0
BK
721 { return __a->test_and_set(__m); }
722
afd88205 723 inline void
bdc05efb 724 atomic_flag_clear_explicit(atomic_flag* __a, memory_order __m) noexcept
94a86be0
BK
725 { __a->clear(__m); }
726
727 inline void
bdc05efb
PC
728 atomic_flag_clear_explicit(volatile atomic_flag* __a,
729 memory_order __m) noexcept
94a86be0 730 { __a->clear(__m); }
d466a7e2 731
94a86be0 732 inline bool
bdc05efb 733 atomic_flag_test_and_set(atomic_flag* __a) noexcept
94a86be0 734 { return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
d466a7e2 735
94a86be0 736 inline bool
bdc05efb 737 atomic_flag_test_and_set(volatile atomic_flag* __a) noexcept
94a86be0
BK
738 { return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
739
740 inline void
bdc05efb 741 atomic_flag_clear(atomic_flag* __a) noexcept
94a86be0
BK
742 { atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
743
744 inline void
bdc05efb 745 atomic_flag_clear(volatile atomic_flag* __a) noexcept
94a86be0 746 { atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
94a86be0 747
d466a7e2 748
036e0d4f 749 // Function templates generally applicable to atomic types.
94a86be0
BK
750 template<typename _ITp>
751 inline bool
bdc05efb 752 atomic_is_lock_free(const atomic<_ITp>* __a) noexcept
94a86be0
BK
753 { return __a->is_lock_free(); }
754
755 template<typename _ITp>
756 inline bool
bdc05efb 757 atomic_is_lock_free(const volatile atomic<_ITp>* __a) noexcept
94a86be0
BK
758 { return __a->is_lock_free(); }
759
760 template<typename _ITp>
036e0d4f 761 inline void
bdc05efb 762 atomic_init(atomic<_ITp>* __a, _ITp __i) noexcept;
94a86be0
BK
763
764 template<typename _ITp>
036e0d4f 765 inline void
bdc05efb 766 atomic_init(volatile atomic<_ITp>* __a, _ITp __i) noexcept;
d466a7e2 767
50ce8d3d 768 template<typename _ITp>
afd88205 769 inline void
bdc05efb
PC
770 atomic_store_explicit(atomic<_ITp>* __a, _ITp __i,
771 memory_order __m) noexcept
50ce8d3d
BK
772 { __a->store(__i, __m); }
773
94a86be0
BK
774 template<typename _ITp>
775 inline void
036e0d4f 776 atomic_store_explicit(volatile atomic<_ITp>* __a, _ITp __i,
bdc05efb 777 memory_order __m) noexcept
94a86be0
BK
778 { __a->store(__i, __m); }
779
50ce8d3d
BK
780 template<typename _ITp>
781 inline _ITp
bdc05efb 782 atomic_load_explicit(const atomic<_ITp>* __a, memory_order __m) noexcept
afd88205 783 { return __a->load(__m); }
50ce8d3d 784
94a86be0
BK
785 template<typename _ITp>
786 inline _ITp
036e0d4f 787 atomic_load_explicit(const volatile atomic<_ITp>* __a,
bdc05efb 788 memory_order __m) noexcept
94a86be0
BK
789 { return __a->load(__m); }
790
50ce8d3d 791 template<typename _ITp>
afd88205 792 inline _ITp
036e0d4f 793 atomic_exchange_explicit(atomic<_ITp>* __a, _ITp __i,
bdc05efb 794 memory_order __m) noexcept
afd88205 795 { return __a->exchange(__i, __m); }
50ce8d3d 796
94a86be0
BK
797 template<typename _ITp>
798 inline _ITp
036e0d4f 799 atomic_exchange_explicit(volatile atomic<_ITp>* __a, _ITp __i,
bdc05efb 800 memory_order __m) noexcept
94a86be0
BK
801 { return __a->exchange(__i, __m); }
802
50ce8d3d 803 template<typename _ITp>
afd88205 804 inline bool
036e0d4f 805 atomic_compare_exchange_weak_explicit(atomic<_ITp>* __a,
afd88205 806 _ITp* __i1, _ITp __i2,
bdc05efb
PC
807 memory_order __m1,
808 memory_order __m2) noexcept
50ce8d3d 809 { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); }
d466a7e2 810
94a86be0
BK
811 template<typename _ITp>
812 inline bool
036e0d4f 813 atomic_compare_exchange_weak_explicit(volatile atomic<_ITp>* __a,
94a86be0 814 _ITp* __i1, _ITp __i2,
bdc05efb
PC
815 memory_order __m1,
816 memory_order __m2) noexcept
94a86be0
BK
817 { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); }
818
50ce8d3d 819 template<typename _ITp>
afd88205 820 inline bool
036e0d4f 821 atomic_compare_exchange_strong_explicit(atomic<_ITp>* __a,
afd88205
BK
822 _ITp* __i1, _ITp __i2,
823 memory_order __m1,
bdc05efb 824 memory_order __m2) noexcept
50ce8d3d
BK
825 { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); }
826
94a86be0
BK
827 template<typename _ITp>
828 inline bool
036e0d4f 829 atomic_compare_exchange_strong_explicit(volatile atomic<_ITp>* __a,
94a86be0
BK
830 _ITp* __i1, _ITp __i2,
831 memory_order __m1,
bdc05efb 832 memory_order __m2) noexcept
94a86be0
BK
833 { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); }
834
d466a7e2 835
50ce8d3d 836 template<typename _ITp>
afd88205 837 inline void
bdc05efb 838 atomic_store(atomic<_ITp>* __a, _ITp __i) noexcept
50ce8d3d 839 { atomic_store_explicit(__a, __i, memory_order_seq_cst); }
d466a7e2 840
94a86be0
BK
841 template<typename _ITp>
842 inline void
bdc05efb 843 atomic_store(volatile atomic<_ITp>* __a, _ITp __i) noexcept
94a86be0
BK
844 { atomic_store_explicit(__a, __i, memory_order_seq_cst); }
845
50ce8d3d 846 template<typename _ITp>
afd88205 847 inline _ITp
bdc05efb 848 atomic_load(const atomic<_ITp>* __a) noexcept
50ce8d3d 849 { return atomic_load_explicit(__a, memory_order_seq_cst); }
d466a7e2 850
94a86be0
BK
851 template<typename _ITp>
852 inline _ITp
bdc05efb 853 atomic_load(const volatile atomic<_ITp>* __a) noexcept
94a86be0
BK
854 { return atomic_load_explicit(__a, memory_order_seq_cst); }
855
50ce8d3d 856 template<typename _ITp>
afd88205 857 inline _ITp
bdc05efb 858 atomic_exchange(atomic<_ITp>* __a, _ITp __i) noexcept
50ce8d3d 859 { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); }
d466a7e2 860
94a86be0
BK
861 template<typename _ITp>
862 inline _ITp
bdc05efb 863 atomic_exchange(volatile atomic<_ITp>* __a, _ITp __i) noexcept
94a86be0
BK
864 { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); }
865
50ce8d3d 866 template<typename _ITp>
afd88205 867 inline bool
036e0d4f 868 atomic_compare_exchange_weak(atomic<_ITp>* __a,
bdc05efb 869 _ITp* __i1, _ITp __i2) noexcept
afd88205
BK
870 {
871 return atomic_compare_exchange_weak_explicit(__a, __i1, __i2,
50ce8d3d 872 memory_order_seq_cst,
afd88205 873 memory_order_seq_cst);
d466a7e2
BK
874 }
875
94a86be0
BK
876 template<typename _ITp>
877 inline bool
036e0d4f 878 atomic_compare_exchange_weak(volatile atomic<_ITp>* __a,
bdc05efb 879 _ITp* __i1, _ITp __i2) noexcept
94a86be0
BK
880 {
881 return atomic_compare_exchange_weak_explicit(__a, __i1, __i2,
882 memory_order_seq_cst,
883 memory_order_seq_cst);
884 }
885
50ce8d3d 886 template<typename _ITp>
afd88205 887 inline bool
036e0d4f 888 atomic_compare_exchange_strong(atomic<_ITp>* __a,
bdc05efb 889 _ITp* __i1, _ITp __i2) noexcept
afd88205
BK
890 {
891 return atomic_compare_exchange_strong_explicit(__a, __i1, __i2,
50ce8d3d 892 memory_order_seq_cst,
afd88205 893 memory_order_seq_cst);
d466a7e2
BK
894 }
895
94a86be0
BK
896 template<typename _ITp>
897 inline bool
036e0d4f 898 atomic_compare_exchange_strong(volatile atomic<_ITp>* __a,
bdc05efb 899 _ITp* __i1, _ITp __i2) noexcept
94a86be0
BK
900 {
901 return atomic_compare_exchange_strong_explicit(__a, __i1, __i2,
902 memory_order_seq_cst,
903 memory_order_seq_cst);
904 }
905
036e0d4f
BK
906 // Function templates for atomic_integral operations only, using
907 // __atomic_base. Template argument should be constricted to
908 // intergral types as specified in the standard, excluding address
909 // types.
910 template<typename _ITp>
911 inline _ITp
912 atomic_fetch_add_explicit(__atomic_base<_ITp>* __a, _ITp __i,
bdc05efb 913 memory_order __m) noexcept
036e0d4f
BK
914 { return __a->fetch_add(__i, __m); }
915
916 template<typename _ITp>
917 inline _ITp
918 atomic_fetch_add_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
bdc05efb 919 memory_order __m) noexcept
036e0d4f
BK
920 { return __a->fetch_add(__i, __m); }
921
922 template<typename _ITp>
923 inline _ITp
924 atomic_fetch_sub_explicit(__atomic_base<_ITp>* __a, _ITp __i,
bdc05efb 925 memory_order __m) noexcept
036e0d4f
BK
926 { return __a->fetch_sub(__i, __m); }
927
928 template<typename _ITp>
929 inline _ITp
930 atomic_fetch_sub_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
bdc05efb 931 memory_order __m) noexcept
036e0d4f
BK
932 { return __a->fetch_sub(__i, __m); }
933
934 template<typename _ITp>
935 inline _ITp
936 atomic_fetch_and_explicit(__atomic_base<_ITp>* __a, _ITp __i,
bdc05efb 937 memory_order __m) noexcept
036e0d4f
BK
938 { return __a->fetch_and(__i, __m); }
939
940 template<typename _ITp>
941 inline _ITp
942 atomic_fetch_and_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
bdc05efb 943 memory_order __m) noexcept
036e0d4f
BK
944 { return __a->fetch_and(__i, __m); }
945
946 template<typename _ITp>
947 inline _ITp
948 atomic_fetch_or_explicit(__atomic_base<_ITp>* __a, _ITp __i,
bdc05efb 949 memory_order __m) noexcept
036e0d4f
BK
950 { return __a->fetch_or(__i, __m); }
951
952 template<typename _ITp>
953 inline _ITp
954 atomic_fetch_or_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
bdc05efb 955 memory_order __m) noexcept
036e0d4f
BK
956 { return __a->fetch_or(__i, __m); }
957
958 template<typename _ITp>
959 inline _ITp
960 atomic_fetch_xor_explicit(__atomic_base<_ITp>* __a, _ITp __i,
bdc05efb 961 memory_order __m) noexcept
036e0d4f
BK
962 { return __a->fetch_xor(__i, __m); }
963
964 template<typename _ITp>
965 inline _ITp
966 atomic_fetch_xor_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
bdc05efb 967 memory_order __m) noexcept
036e0d4f
BK
968 { return __a->fetch_xor(__i, __m); }
969
50ce8d3d 970 template<typename _ITp>
afd88205 971 inline _ITp
bdc05efb 972 atomic_fetch_add(__atomic_base<_ITp>* __a, _ITp __i) noexcept
50ce8d3d
BK
973 { return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); }
974
94a86be0
BK
975 template<typename _ITp>
976 inline _ITp
bdc05efb 977 atomic_fetch_add(volatile __atomic_base<_ITp>* __a, _ITp __i) noexcept
94a86be0
BK
978 { return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); }
979
50ce8d3d 980 template<typename _ITp>
afd88205 981 inline _ITp
bdc05efb 982 atomic_fetch_sub(__atomic_base<_ITp>* __a, _ITp __i) noexcept
50ce8d3d
BK
983 { return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); }
984
94a86be0
BK
985 template<typename _ITp>
986 inline _ITp
bdc05efb 987 atomic_fetch_sub(volatile __atomic_base<_ITp>* __a, _ITp __i) noexcept
94a86be0
BK
988 { return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); }
989
50ce8d3d 990 template<typename _ITp>
afd88205 991 inline _ITp
bdc05efb 992 atomic_fetch_and(__atomic_base<_ITp>* __a, _ITp __i) noexcept
50ce8d3d
BK
993 { return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); }
994
94a86be0
BK
995 template<typename _ITp>
996 inline _ITp
bdc05efb 997 atomic_fetch_and(volatile __atomic_base<_ITp>* __a, _ITp __i) noexcept
94a86be0
BK
998 { return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); }
999
50ce8d3d 1000 template<typename _ITp>
afd88205 1001 inline _ITp
bdc05efb 1002 atomic_fetch_or(__atomic_base<_ITp>* __a, _ITp __i) noexcept
50ce8d3d
BK
1003 { return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); }
1004
94a86be0
BK
1005 template<typename _ITp>
1006 inline _ITp
bdc05efb 1007 atomic_fetch_or(volatile __atomic_base<_ITp>* __a, _ITp __i) noexcept
94a86be0
BK
1008 { return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); }
1009
50ce8d3d 1010 template<typename _ITp>
afd88205 1011 inline _ITp
bdc05efb 1012 atomic_fetch_xor(__atomic_base<_ITp>* __a, _ITp __i) noexcept
50ce8d3d 1013 { return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); }
d466a7e2 1014
94a86be0
BK
1015 template<typename _ITp>
1016 inline _ITp
bdc05efb 1017 atomic_fetch_xor(volatile __atomic_base<_ITp>* __a, _ITp __i) noexcept
94a86be0
BK
1018 { return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); }
1019
036e0d4f
BK
1020
1021 // Partial specializations for pointers.
1022 template<typename _ITp>
1023 inline _ITp*
1024 atomic_fetch_add_explicit(atomic<_ITp*>* __a, ptrdiff_t __d,
bdc05efb 1025 memory_order __m) noexcept
036e0d4f
BK
1026 { return __a->fetch_add(__d, __m); }
1027
1028 template<typename _ITp>
1029 inline _ITp*
1030 atomic_fetch_add_explicit(volatile atomic<_ITp*>* __a, ptrdiff_t __d,
bdc05efb 1031 memory_order __m) noexcept
036e0d4f
BK
1032 { return __a->fetch_add(__d, __m); }
1033
1034 template<typename _ITp>
1035 inline _ITp*
bdc05efb 1036 atomic_fetch_add(volatile atomic<_ITp*>* __a, ptrdiff_t __d) noexcept
036e0d4f
BK
1037 { return __a->fetch_add(__d); }
1038
1039 template<typename _ITp>
1040 inline _ITp*
bdc05efb 1041 atomic_fetch_add(atomic<_ITp*>* __a, ptrdiff_t __d) noexcept
036e0d4f
BK
1042 { return __a->fetch_add(__d); }
1043
1044 template<typename _ITp>
1045 inline _ITp*
1046 atomic_fetch_sub_explicit(volatile atomic<_ITp*>* __a,
bdc05efb 1047 ptrdiff_t __d, memory_order __m) noexcept
036e0d4f
BK
1048 { return __a->fetch_sub(__d, __m); }
1049
1050 template<typename _ITp>
1051 inline _ITp*
1052 atomic_fetch_sub_explicit(atomic<_ITp*>* __a, ptrdiff_t __d,
bdc05efb 1053 memory_order __m) noexcept
036e0d4f
BK
1054 { return __a->fetch_sub(__d, __m); }
1055
1056 template<typename _ITp>
1057 inline _ITp*
bdc05efb 1058 atomic_fetch_sub(volatile atomic<_ITp*>* __a, ptrdiff_t __d) noexcept
036e0d4f
BK
1059 { return __a->fetch_sub(__d); }
1060
1061 template<typename _ITp>
1062 inline _ITp*
bdc05efb 1063 atomic_fetch_sub(atomic<_ITp*>* __a, ptrdiff_t __d) noexcept
036e0d4f 1064 { return __a->fetch_sub(__d); }
5b9daa7e
BK
1065 // @} group atomics
1066
12ffa228
BK
1067_GLIBCXX_END_NAMESPACE_VERSION
1068} // namespace
d466a7e2
BK
1069
1070#endif