Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / atomic / detail / gcc-atomic.hpp @ 2486

History | View | Annotate | Download (40 kB)

1
#ifndef BOOST_ATOMIC_DETAIL_GCC_ATOMIC_HPP
2
#define BOOST_ATOMIC_DETAIL_GCC_ATOMIC_HPP
3

    
4
//  Copyright (c) 2013 Andrey Semashev
5
//
6
//  Distributed under the Boost Software License, Version 1.0.
7
//  See accompanying file LICENSE_1_0.txt or copy at
8
//  http://www.boost.org/LICENSE_1_0.txt)
9

    
10
#include <string.h>
11
#include <cstddef>
12
#include <boost/cstdint.hpp>
13
#include <boost/atomic/detail/config.hpp>
14

    
15
#ifdef BOOST_HAS_PRAGMA_ONCE
16
#pragma once
17
#endif
18

    
19
namespace boost {
20
namespace atomics {
21
namespace detail {
22

    
23
#if (defined(__i386__) && defined(__SSE2__)) || defined(__x86_64__)
24
#define BOOST_ATOMIC_X86_PAUSE() __asm__ __volatile__ ("pause\n")
25
#endif
26

    
27
#if defined(__i386__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)
28
#define BOOST_ATOMIC_X86_HAS_CMPXCHG8B 1
29
#endif
30

    
31
#if defined(__x86_64__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16)
32
#define BOOST_ATOMIC_X86_HAS_CMPXCHG16B 1
33
#endif
34

    
35
BOOST_FORCEINLINE BOOST_CONSTEXPR int convert_memory_order_to_gcc(memory_order order) BOOST_NOEXCEPT
36
{
37
    return (order == memory_order_relaxed ? __ATOMIC_RELAXED : (order == memory_order_consume ? __ATOMIC_CONSUME :
38
        (order == memory_order_acquire ? __ATOMIC_ACQUIRE : (order == memory_order_release ? __ATOMIC_RELEASE :
39
        (order == memory_order_acq_rel ? __ATOMIC_ACQ_REL : __ATOMIC_SEQ_CST)))));
40
}
41

    
42
} // namespace detail
43
} // namespace atomics
44

    
45
#if __GCC_ATOMIC_BOOL_LOCK_FREE == 2
46

    
47
class atomic_flag
48
{
49
private:
50
    atomic_flag(const atomic_flag &) /* = delete */ ;
51
    atomic_flag & operator=(const atomic_flag &) /* = delete */ ;
52
    bool v_;
53

    
54
public:
55
    BOOST_CONSTEXPR atomic_flag(void) BOOST_NOEXCEPT : v_(false) {}
56

    
57
    bool test_and_set(memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
58
    {
59
        return __atomic_test_and_set(&v_, atomics::detail::convert_memory_order_to_gcc(order));
60
    }
61

    
62
    void clear(memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
63
    {
64
        __atomic_clear((bool*)&v_, atomics::detail::convert_memory_order_to_gcc(order));
65
    }
66
};
67

    
68
#define BOOST_ATOMIC_FLAG_LOCK_FREE 2
69

    
70
#endif // __GCC_ATOMIC_BOOL_LOCK_FREE == 2
71

    
72
} // namespace boost
73

    
74
#include <boost/atomic/detail/base.hpp>
75

    
76
#if !defined(BOOST_ATOMIC_FORCE_FALLBACK)
77

    
78
#if __GCC_ATOMIC_CHAR_LOCK_FREE == 2
79
#define BOOST_ATOMIC_CHAR_LOCK_FREE 2
80
#endif
81
#if __GCC_ATOMIC_CHAR16_T_LOCK_FREE == 2
82
#define BOOST_ATOMIC_CHAR16_T_LOCK_FREE 2
83
#endif
84
#if __GCC_ATOMIC_CHAR32_T_LOCK_FREE == 2
85
#define BOOST_ATOMIC_CHAR32_T_LOCK_FREE 2
86
#endif
87
#if __GCC_ATOMIC_WCHAR_T_LOCK_FREE == 2
88
#define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 2
89
#endif
90
#if __GCC_ATOMIC_SHORT_LOCK_FREE == 2
91
#define BOOST_ATOMIC_SHORT_LOCK_FREE 2
92
#endif
93
#if __GCC_ATOMIC_INT_LOCK_FREE == 2
94
#define BOOST_ATOMIC_INT_LOCK_FREE 2
95
#endif
96
#if __GCC_ATOMIC_LONG_LOCK_FREE == 2
97
#define BOOST_ATOMIC_LONG_LOCK_FREE 2
98
#endif
99
#if __GCC_ATOMIC_LLONG_LOCK_FREE == 2
100
#define BOOST_ATOMIC_LLONG_LOCK_FREE 2
101
#endif
102
#if defined(BOOST_ATOMIC_X86_HAS_CMPXCHG16B) && (defined(BOOST_HAS_INT128) || !defined(BOOST_NO_ALIGNMENT))
103
#define BOOST_ATOMIC_INT128_LOCK_FREE 2
104
#endif
105
#if __GCC_ATOMIC_POINTER_LOCK_FREE == 2
106
#define BOOST_ATOMIC_POINTER_LOCK_FREE 2
107
#endif
108
#if __GCC_ATOMIC_BOOL_LOCK_FREE == 2
109
#define BOOST_ATOMIC_BOOL_LOCK_FREE 2
110
#endif
111

    
112
namespace boost {
113

    
114
#define BOOST_ATOMIC_THREAD_FENCE 2
115
BOOST_FORCEINLINE void atomic_thread_fence(memory_order order)
116
{
117
    __atomic_thread_fence(atomics::detail::convert_memory_order_to_gcc(order));
118
}
119

    
120
#define BOOST_ATOMIC_SIGNAL_FENCE 2
121
BOOST_FORCEINLINE void atomic_signal_fence(memory_order order)
122
{
123
    __atomic_signal_fence(atomics::detail::convert_memory_order_to_gcc(order));
124
}
125

    
126
namespace atomics {
127
namespace detail {
128

    
129
#if defined(BOOST_ATOMIC_CHAR_LOCK_FREE) && BOOST_ATOMIC_CHAR_LOCK_FREE > 0
130

    
131
template<typename T, bool Sign>
132
class base_atomic<T, int, 1, Sign>
133
{
134
private:
135
    typedef base_atomic this_type;
136
    typedef T value_type;
137
    typedef T difference_type;
138

    
139
protected:
140
    typedef value_type value_arg_type;
141

    
142
public:
143
    BOOST_DEFAULTED_FUNCTION(base_atomic(void), {})
144
    BOOST_CONSTEXPR explicit base_atomic(value_type v) BOOST_NOEXCEPT : v_(v) {}
145

    
146
    void store(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
147
    {
148
        __atomic_store_n(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
149
    }
150

    
151
    value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT
152
    {
153
        return __atomic_load_n(&v_, atomics::detail::convert_memory_order_to_gcc(order));
154
    }
155

    
156
    value_type fetch_add(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
157
    {
158
        return __atomic_fetch_add(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
159
    }
160

    
161
    value_type fetch_sub(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
162
    {
163
        return __atomic_fetch_sub(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
164
    }
165

    
166
    value_type exchange(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
167
    {
168
        return __atomic_exchange_n(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
169
    }
170

    
171
    bool compare_exchange_strong(
172
        value_type& expected,
173
        value_type desired,
174
        memory_order success_order,
175
        memory_order failure_order) volatile BOOST_NOEXCEPT
176
    {
177
        return __atomic_compare_exchange_n(&v_, &expected, desired, false,
178
            atomics::detail::convert_memory_order_to_gcc(success_order),
179
            atomics::detail::convert_memory_order_to_gcc(failure_order));
180
    }
181

    
182
    bool compare_exchange_weak(
183
        value_type& expected,
184
        value_type desired,
185
        memory_order success_order,
186
        memory_order failure_order) volatile BOOST_NOEXCEPT
187
    {
188
        return __atomic_compare_exchange_n(&v_, &expected, desired, true,
189
            atomics::detail::convert_memory_order_to_gcc(success_order),
190
            atomics::detail::convert_memory_order_to_gcc(failure_order));
191
    }
192

    
193
    value_type fetch_and(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
194
    {
195
        return __atomic_fetch_and(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
196
    }
197

    
198
    value_type fetch_or(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
199
    {
200
        return __atomic_fetch_or(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
201
    }
202

    
203
    value_type fetch_xor(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
204
    {
205
        return __atomic_fetch_xor(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
206
    }
207

    
208
    bool is_lock_free(void) const volatile BOOST_NOEXCEPT
209
    {
210
        return __atomic_is_lock_free(sizeof(v_), &v_);
211
    }
212

    
213
    BOOST_ATOMIC_DECLARE_INTEGRAL_OPERATORS
214

    
215
    BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&))
216
    BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&))
217

    
218
private:
219
    value_type v_;
220
};
221

    
222
template<typename T, bool Sign>
223
class base_atomic<T, void, 1, Sign>
224
{
225
private:
226
    typedef base_atomic this_type;
227
    typedef T value_type;
228
    typedef uint8_t storage_type;
229

    
230
protected:
231
    typedef value_type const& value_arg_type;
232

    
233
public:
234
    BOOST_DEFAULTED_FUNCTION(base_atomic(void), {})
235
    BOOST_CONSTEXPR explicit base_atomic(value_type const& v) BOOST_NOEXCEPT :
236
        v_(reinterpret_cast<storage_type const&>(v))
237
    {
238
    }
239

    
240
    void store(value_type const& v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
241
    {
242
        __atomic_store(&v_, (storage_type*)&v, atomics::detail::convert_memory_order_to_gcc(order));
243
    }
244

    
245
    value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT
246
    {
247
        value_type v;
248
        __atomic_load(&v_, (storage_type*)&v, atomics::detail::convert_memory_order_to_gcc(order));
249
        return v;
250
    }
251

    
252
    value_type exchange(value_type const& v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
253
    {
254
        value_type r;
255
        __atomic_exchange(&v_, (storage_type*)&v, (storage_type*)&r, atomics::detail::convert_memory_order_to_gcc(order));
256
        return r;
257
    }
258

    
259
    bool compare_exchange_strong(
260
        value_type& expected,
261
        value_type const& desired,
262
        memory_order success_order,
263
        memory_order failure_order) volatile BOOST_NOEXCEPT
264
    {
265
        return __atomic_compare_exchange(&v_, (storage_type*)&expected, (storage_type*)&desired, false,
266
            atomics::detail::convert_memory_order_to_gcc(success_order),
267
            atomics::detail::convert_memory_order_to_gcc(failure_order));
268
    }
269

    
270
    bool compare_exchange_weak(
271
        value_type & expected,
272
        value_type const& desired,
273
        memory_order success_order,
274
        memory_order failure_order) volatile BOOST_NOEXCEPT
275
    {
276
        return __atomic_compare_exchange(&v_, (storage_type*)&expected, (storage_type*)&desired, true,
277
            atomics::detail::convert_memory_order_to_gcc(success_order),
278
            atomics::detail::convert_memory_order_to_gcc(failure_order));
279
    }
280

    
281
    bool is_lock_free(void) const volatile BOOST_NOEXCEPT
282
    {
283
        return __atomic_is_lock_free(sizeof(v_), &v_);
284
    }
285

    
286
    BOOST_ATOMIC_DECLARE_BASE_OPERATORS
287

    
288
    BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&))
289
    BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&))
290

    
291
private:
292
    storage_type v_;
293
};
294

    
295
#endif // defined(BOOST_ATOMIC_CHAR_LOCK_FREE) && BOOST_ATOMIC_CHAR_LOCK_FREE > 0
296

    
297
#if defined(BOOST_ATOMIC_SHORT_LOCK_FREE) && BOOST_ATOMIC_SHORT_LOCK_FREE > 0
298

    
299
template<typename T, bool Sign>
300
class base_atomic<T, int, 2, Sign>
301
{
302
private:
303
    typedef base_atomic this_type;
304
    typedef T value_type;
305
    typedef T difference_type;
306

    
307
protected:
308
    typedef value_type value_arg_type;
309

    
310
public:
311
    BOOST_DEFAULTED_FUNCTION(base_atomic(void), {})
312
    BOOST_CONSTEXPR explicit base_atomic(value_type v) BOOST_NOEXCEPT : v_(v) {}
313

    
314
    void store(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
315
    {
316
        __atomic_store_n(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
317
    }
318

    
319
    value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT
320
    {
321
        return __atomic_load_n(&v_, atomics::detail::convert_memory_order_to_gcc(order));
322
    }
323

    
324
    value_type fetch_add(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
325
    {
326
        return __atomic_fetch_add(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
327
    }
328

    
329
    value_type fetch_sub(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
330
    {
331
        return __atomic_fetch_sub(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
332
    }
333

    
334
    value_type exchange(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
335
    {
336
        return __atomic_exchange_n(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
337
    }
338

    
339
    bool compare_exchange_strong(
340
        value_type& expected,
341
        value_type desired,
342
        memory_order success_order,
343
        memory_order failure_order) volatile BOOST_NOEXCEPT
344
    {
345
        return __atomic_compare_exchange_n(&v_, &expected, desired, false,
346
            atomics::detail::convert_memory_order_to_gcc(success_order),
347
            atomics::detail::convert_memory_order_to_gcc(failure_order));
348
    }
349

    
350
    bool compare_exchange_weak(
351
        value_type& expected,
352
        value_type desired,
353
        memory_order success_order,
354
        memory_order failure_order) volatile BOOST_NOEXCEPT
355
    {
356
        return __atomic_compare_exchange_n(&v_, &expected, desired, true,
357
            atomics::detail::convert_memory_order_to_gcc(success_order),
358
            atomics::detail::convert_memory_order_to_gcc(failure_order));
359
    }
360

    
361
    value_type fetch_and(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
362
    {
363
        return __atomic_fetch_and(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
364
    }
365

    
366
    value_type fetch_or(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
367
    {
368
        return __atomic_fetch_or(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
369
    }
370

    
371
    value_type fetch_xor(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
372
    {
373
        return __atomic_fetch_xor(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
374
    }
375

    
376
    bool is_lock_free(void) const volatile BOOST_NOEXCEPT
377
    {
378
        return __atomic_is_lock_free(sizeof(v_), &v_);
379
    }
380

    
381
    BOOST_ATOMIC_DECLARE_INTEGRAL_OPERATORS
382

    
383
    BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&))
384
    BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&))
385

    
386
private:
387
    value_type v_;
388
};
389

    
390
template<typename T, bool Sign>
391
class base_atomic<T, void, 2, Sign>
392
{
393
private:
394
    typedef base_atomic this_type;
395
    typedef T value_type;
396
    typedef uint16_t storage_type;
397

    
398
protected:
399
    typedef value_type const& value_arg_type;
400

    
401
public:
402
    BOOST_DEFAULTED_FUNCTION(base_atomic(void), {})
403
    BOOST_CONSTEXPR explicit base_atomic(value_type const& v) BOOST_NOEXCEPT :
404
        v_(reinterpret_cast<storage_type const&>(v))
405
    {
406
    }
407

    
408
    void store(value_type const& v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
409
    {
410
        __atomic_store(&v_, (storage_type*)&v, atomics::detail::convert_memory_order_to_gcc(order));
411
    }
412

    
413
    value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT
414
    {
415
        value_type v;
416
        __atomic_load(&v_, (storage_type*)&v, atomics::detail::convert_memory_order_to_gcc(order));
417
        return v;
418
    }
419

    
420
    value_type exchange(value_type const& v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
421
    {
422
        value_type r;
423
        __atomic_exchange(&v_, (storage_type*)&v, (storage_type*)&r, atomics::detail::convert_memory_order_to_gcc(order));
424
        return r;
425
    }
426

    
427
    bool compare_exchange_strong(
428
        value_type& expected,
429
        value_type const& desired,
430
        memory_order success_order,
431
        memory_order failure_order) volatile BOOST_NOEXCEPT
432
    {
433
        return __atomic_compare_exchange(&v_, (storage_type*)&expected, (storage_type*)&desired, false,
434
            atomics::detail::convert_memory_order_to_gcc(success_order),
435
            atomics::detail::convert_memory_order_to_gcc(failure_order));
436
    }
437

    
438
    bool compare_exchange_weak(
439
        value_type & expected,
440
        value_type const& desired,
441
        memory_order success_order,
442
        memory_order failure_order) volatile BOOST_NOEXCEPT
443
    {
444
        return __atomic_compare_exchange(&v_, (storage_type*)&expected, (storage_type*)&desired, true,
445
            atomics::detail::convert_memory_order_to_gcc(success_order),
446
            atomics::detail::convert_memory_order_to_gcc(failure_order));
447
    }
448

    
449
    bool is_lock_free(void) const volatile BOOST_NOEXCEPT
450
    {
451
        return __atomic_is_lock_free(sizeof(v_), &v_);
452
    }
453

    
454
    BOOST_ATOMIC_DECLARE_BASE_OPERATORS
455

    
456
    BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&))
457
    BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&))
458

    
459
private:
460
    storage_type v_;
461
};
462

    
463
#endif // defined(BOOST_ATOMIC_SHORT_LOCK_FREE) && BOOST_ATOMIC_SHORT_LOCK_FREE > 0
464

    
465
#if defined(BOOST_ATOMIC_INT_LOCK_FREE) && BOOST_ATOMIC_INT_LOCK_FREE > 0
466

    
467
template<typename T, bool Sign>
468
class base_atomic<T, int, 4, Sign>
469
{
470
private:
471
    typedef base_atomic this_type;
472
    typedef T value_type;
473
    typedef T difference_type;
474

    
475
protected:
476
    typedef value_type value_arg_type;
477

    
478
public:
479
    BOOST_DEFAULTED_FUNCTION(base_atomic(void), {})
480
    BOOST_CONSTEXPR explicit base_atomic(value_type v) BOOST_NOEXCEPT : v_(v) {}
481

    
482
    void store(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
483
    {
484
        __atomic_store_n(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
485
    }
486

    
487
    value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT
488
    {
489
        return __atomic_load_n(&v_, atomics::detail::convert_memory_order_to_gcc(order));
490
    }
491

    
492
    value_type fetch_add(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
493
    {
494
        return __atomic_fetch_add(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
495
    }
496

    
497
    value_type fetch_sub(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
498
    {
499
        return __atomic_fetch_sub(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
500
    }
501

    
502
    value_type exchange(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
503
    {
504
        return __atomic_exchange_n(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
505
    }
506

    
507
    bool compare_exchange_strong(
508
        value_type& expected,
509
        value_type desired,
510
        memory_order success_order,
511
        memory_order failure_order) volatile BOOST_NOEXCEPT
512
    {
513
        return __atomic_compare_exchange_n(&v_, &expected, desired, false,
514
            atomics::detail::convert_memory_order_to_gcc(success_order),
515
            atomics::detail::convert_memory_order_to_gcc(failure_order));
516
    }
517

    
518
    bool compare_exchange_weak(
519
        value_type& expected,
520
        value_type desired,
521
        memory_order success_order,
522
        memory_order failure_order) volatile BOOST_NOEXCEPT
523
    {
524
        return __atomic_compare_exchange_n(&v_, &expected, desired, true,
525
            atomics::detail::convert_memory_order_to_gcc(success_order),
526
            atomics::detail::convert_memory_order_to_gcc(failure_order));
527
    }
528

    
529
    value_type fetch_and(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
530
    {
531
        return __atomic_fetch_and(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
532
    }
533

    
534
    value_type fetch_or(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
535
    {
536
        return __atomic_fetch_or(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
537
    }
538

    
539
    value_type fetch_xor(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
540
    {
541
        return __atomic_fetch_xor(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
542
    }
543

    
544
    bool is_lock_free(void) const volatile BOOST_NOEXCEPT
545
    {
546
        return __atomic_is_lock_free(sizeof(v_), &v_);
547
    }
548

    
549
    BOOST_ATOMIC_DECLARE_INTEGRAL_OPERATORS
550

    
551
    BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&))
552
    BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&))
553

    
554
private:
555
    value_type v_;
556
};
557

    
558
template<typename T, bool Sign>
559
class base_atomic<T, void, 4, Sign>
560
{
561
private:
562
    typedef base_atomic this_type;
563
    typedef T value_type;
564
    typedef uint32_t storage_type;
565

    
566
protected:
567
    typedef value_type const& value_arg_type;
568

    
569
public:
570
    BOOST_DEFAULTED_FUNCTION(base_atomic(void), {})
571
    explicit base_atomic(value_type const& v) BOOST_NOEXCEPT : v_(0)
572
    {
573
        memcpy(&v_, &v, sizeof(value_type));
574
    }
575

    
576
    void store(value_type const& v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
577
    {
578
        storage_type tmp = 0;
579
        memcpy(&tmp, &v, sizeof(value_type));
580
        __atomic_store_n(&v_, tmp, atomics::detail::convert_memory_order_to_gcc(order));
581
    }
582

    
583
    value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT
584
    {
585
        storage_type tmp = __atomic_load_n(&v_, atomics::detail::convert_memory_order_to_gcc(order));
586
        value_type v;
587
        memcpy(&v, &tmp, sizeof(value_type));
588
        return v;
589
    }
590

    
591
    value_type exchange(value_type const& v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
592
    {
593
        storage_type tmp = 0;
594
        memcpy(&tmp, &v, sizeof(value_type));
595
        tmp = __atomic_exchange_n(&v_, tmp, atomics::detail::convert_memory_order_to_gcc(order));
596
        value_type res;
597
        memcpy(&res, &tmp, sizeof(value_type));
598
        return res;
599
    }
600

    
601
    bool compare_exchange_strong(
602
        value_type& expected,
603
        value_type const& desired,
604
        memory_order success_order,
605
        memory_order failure_order) volatile BOOST_NOEXCEPT
606
    {
607
        storage_type expected_s = 0, desired_s = 0;
608
        memcpy(&expected_s, &expected, sizeof(value_type));
609
        memcpy(&desired_s, &desired, sizeof(value_type));
610
        const bool success = __atomic_compare_exchange_n(&v_, &expected_s, desired_s, false,
611
            atomics::detail::convert_memory_order_to_gcc(success_order),
612
            atomics::detail::convert_memory_order_to_gcc(failure_order));
613
        memcpy(&expected, &expected_s, sizeof(value_type));
614
        return success;
615
    }
616

    
617
    bool compare_exchange_weak(
618
        value_type& expected,
619
        value_type const& desired,
620
        memory_order success_order,
621
        memory_order failure_order) volatile BOOST_NOEXCEPT
622
    {
623
        storage_type expected_s = 0, desired_s = 0;
624
        memcpy(&expected_s, &expected, sizeof(value_type));
625
        memcpy(&desired_s, &desired, sizeof(value_type));
626
        const bool success = __atomic_compare_exchange_n(&v_, &expected_s, desired_s, true,
627
            atomics::detail::convert_memory_order_to_gcc(success_order),
628
            atomics::detail::convert_memory_order_to_gcc(failure_order));
629
        memcpy(&expected, &expected_s, sizeof(value_type));
630
        return success;
631
    }
632

    
633
    bool is_lock_free(void) const volatile BOOST_NOEXCEPT
634
    {
635
        return __atomic_is_lock_free(sizeof(v_), &v_);
636
    }
637

    
638
    BOOST_ATOMIC_DECLARE_BASE_OPERATORS
639

    
640
    BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&))
641
    BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&))
642

    
643
private:
644
    storage_type v_;
645
};
646

    
647
#endif // defined(BOOST_ATOMIC_INT_LOCK_FREE) && BOOST_ATOMIC_INT_LOCK_FREE > 0
648

    
649
#if defined(BOOST_ATOMIC_LLONG_LOCK_FREE) && BOOST_ATOMIC_LLONG_LOCK_FREE > 0
650

    
651
template<typename T, bool Sign>
652
class base_atomic<T, int, 8, Sign>
653
{
654
private:
655
    typedef base_atomic this_type;
656
    typedef T value_type;
657
    typedef T difference_type;
658

    
659
protected:
660
    typedef value_type value_arg_type;
661

    
662
public:
663
    BOOST_DEFAULTED_FUNCTION(base_atomic(void), {})
664
    BOOST_CONSTEXPR explicit base_atomic(value_type v) BOOST_NOEXCEPT : v_(v) {}
665

    
666
    void store(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
667
    {
668
        __atomic_store_n(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
669
    }
670

    
671
    value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT
672
    {
673
        return __atomic_load_n(&v_, atomics::detail::convert_memory_order_to_gcc(order));
674
    }
675

    
676
    value_type fetch_add(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
677
    {
678
        return __atomic_fetch_add(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
679
    }
680

    
681
    value_type fetch_sub(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
682
    {
683
        return __atomic_fetch_sub(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
684
    }
685

    
686
    value_type exchange(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
687
    {
688
        return __atomic_exchange_n(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
689
    }
690

    
691
    bool compare_exchange_strong(
692
        value_type& expected,
693
        value_type desired,
694
        memory_order success_order,
695
        memory_order failure_order) volatile BOOST_NOEXCEPT
696
    {
697
        return __atomic_compare_exchange_n(&v_, &expected, desired, false,
698
            atomics::detail::convert_memory_order_to_gcc(success_order),
699
            atomics::detail::convert_memory_order_to_gcc(failure_order));
700
    }
701

    
702
    bool compare_exchange_weak(
703
        value_type& expected,
704
        value_type desired,
705
        memory_order success_order,
706
        memory_order failure_order) volatile BOOST_NOEXCEPT
707
    {
708
        return __atomic_compare_exchange_n(&v_, &expected, desired, true,
709
            atomics::detail::convert_memory_order_to_gcc(success_order),
710
            atomics::detail::convert_memory_order_to_gcc(failure_order));
711
    }
712

    
713
    value_type fetch_and(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
714
    {
715
        return __atomic_fetch_and(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
716
    }
717

    
718
    value_type fetch_or(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
719
    {
720
        return __atomic_fetch_or(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
721
    }
722

    
723
    value_type fetch_xor(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
724
    {
725
        return __atomic_fetch_xor(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
726
    }
727

    
728
    bool is_lock_free(void) const volatile BOOST_NOEXCEPT
729
    {
730
        return __atomic_is_lock_free(sizeof(v_), &v_);
731
    }
732

    
733
    BOOST_ATOMIC_DECLARE_INTEGRAL_OPERATORS
734

    
735
    BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&))
736
    BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&))
737

    
738
private:
739
    value_type v_;
740
};
741

    
742
template<typename T, bool Sign>
743
class base_atomic<T, void, 8, Sign>
744
{
745
private:
746
    typedef base_atomic this_type;
747
    typedef T value_type;
748
    typedef uint64_t storage_type;
749

    
750
protected:
751
    typedef value_type const& value_arg_type;
752

    
753
public:
754
    BOOST_DEFAULTED_FUNCTION(base_atomic(void), {})
755
    explicit base_atomic(value_type const& v) BOOST_NOEXCEPT : v_(0)
756
    {
757
        memcpy(&v_, &v, sizeof(value_type));
758
    }
759

    
760
    void store(value_type const& v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
761
    {
762
        storage_type tmp = 0;
763
        memcpy(&tmp, &v, sizeof(value_type));
764
        __atomic_store_n(&v_, tmp, atomics::detail::convert_memory_order_to_gcc(order));
765
    }
766

    
767
    value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT
768
    {
769
        storage_type tmp = __atomic_load_n(&v_, atomics::detail::convert_memory_order_to_gcc(order));
770
        value_type v;
771
        memcpy(&v, &tmp, sizeof(value_type));
772
        return v;
773
    }
774

    
775
    value_type exchange(value_type const& v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
776
    {
777
        storage_type tmp = 0;
778
        memcpy(&tmp, &v, sizeof(value_type));
779
        tmp = __atomic_exchange_n(&v_, tmp, atomics::detail::convert_memory_order_to_gcc(order));
780
        value_type res;
781
        memcpy(&res, &tmp, sizeof(value_type));
782
        return res;
783
    }
784

    
785
    bool compare_exchange_strong(
786
        value_type& expected,
787
        value_type const& desired,
788
        memory_order success_order,
789
        memory_order failure_order) volatile BOOST_NOEXCEPT
790
    {
791
        storage_type expected_s = 0, desired_s = 0;
792
        memcpy(&expected_s, &expected, sizeof(value_type));
793
        memcpy(&desired_s, &desired, sizeof(value_type));
794
        const bool success = __atomic_compare_exchange_n(&v_, &expected_s, desired_s, false,
795
            atomics::detail::convert_memory_order_to_gcc(success_order),
796
            atomics::detail::convert_memory_order_to_gcc(failure_order));
797
        memcpy(&expected, &expected_s, sizeof(value_type));
798
        return success;
799
    }
800

    
801
    bool compare_exchange_weak(
802
        value_type& expected,
803
        value_type const& desired,
804
        memory_order success_order,
805
        memory_order failure_order) volatile BOOST_NOEXCEPT
806
    {
807
        storage_type expected_s = 0, desired_s = 0;
808
        memcpy(&expected_s, &expected, sizeof(value_type));
809
        memcpy(&desired_s, &desired, sizeof(value_type));
810
        const bool success = __atomic_compare_exchange_n(&v_, &expected_s, desired_s, true,
811
            atomics::detail::convert_memory_order_to_gcc(success_order),
812
            atomics::detail::convert_memory_order_to_gcc(failure_order));
813
        memcpy(&expected, &expected_s, sizeof(value_type));
814
        return success;
815
    }
816

    
817
    bool is_lock_free(void) const volatile BOOST_NOEXCEPT
818
    {
819
        return __atomic_is_lock_free(sizeof(v_), &v_);
820
    }
821

    
822
    BOOST_ATOMIC_DECLARE_BASE_OPERATORS
823

    
824
    BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&))
825
    BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&))
826

    
827
private:
828
    storage_type v_;
829
};
830

    
831
#endif // defined(BOOST_ATOMIC_LLONG_LOCK_FREE) && BOOST_ATOMIC_LLONG_LOCK_FREE > 0
832

    
833
#if defined(BOOST_ATOMIC_INT128_LOCK_FREE) && BOOST_ATOMIC_INT128_LOCK_FREE > 0
834

    
835
template<typename T, bool Sign>
836
class base_atomic<T, int, 16, Sign>
837
{
838
private:
839
    typedef base_atomic this_type;
840
    typedef T value_type;
841
    typedef T difference_type;
842

    
843
protected:
844
    typedef value_type value_arg_type;
845

    
846
public:
847
    BOOST_DEFAULTED_FUNCTION(base_atomic(void), {})
848
    BOOST_CONSTEXPR explicit base_atomic(value_type v) BOOST_NOEXCEPT : v_(v) {}
849

    
850
    void store(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
851
    {
852
        __atomic_store_n(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
853
    }
854

    
855
    value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT
856
    {
857
        return __atomic_load_n(&v_, atomics::detail::convert_memory_order_to_gcc(order));
858
    }
859

    
860
    value_type fetch_add(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
861
    {
862
        return __atomic_fetch_add(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
863
    }
864

    
865
    value_type fetch_sub(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
866
    {
867
        return __atomic_fetch_sub(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
868
    }
869

    
870
    value_type exchange(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
871
    {
872
        return __atomic_exchange_n(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
873
    }
874

    
875
    bool compare_exchange_strong(
876
        value_type& expected,
877
        value_type desired,
878
        memory_order success_order,
879
        memory_order failure_order) volatile BOOST_NOEXCEPT
880
    {
881
        return __atomic_compare_exchange_n(&v_, &expected, desired, false,
882
            atomics::detail::convert_memory_order_to_gcc(success_order),
883
            atomics::detail::convert_memory_order_to_gcc(failure_order));
884
    }
885

    
886
    bool compare_exchange_weak(
887
        value_type& expected,
888
        value_type desired,
889
        memory_order success_order,
890
        memory_order failure_order) volatile BOOST_NOEXCEPT
891
    {
892
        return __atomic_compare_exchange_n(&v_, &expected, desired, true,
893
            atomics::detail::convert_memory_order_to_gcc(success_order),
894
            atomics::detail::convert_memory_order_to_gcc(failure_order));
895
    }
896

    
897
    value_type fetch_and(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
898
    {
899
        return __atomic_fetch_and(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
900
    }
901

    
902
    value_type fetch_or(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
903
    {
904
        return __atomic_fetch_or(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
905
    }
906

    
907
    value_type fetch_xor(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
908
    {
909
        return __atomic_fetch_xor(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
910
    }
911

    
912
    bool is_lock_free(void) const volatile BOOST_NOEXCEPT
913
    {
914
        return __atomic_is_lock_free(sizeof(v_), &v_);
915
    }
916

    
917
    BOOST_ATOMIC_DECLARE_INTEGRAL_OPERATORS
918

    
919
    BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&))
920
    BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&))
921

    
922
private:
923
    value_type v_;
924
};
925

    
926
#if defined(BOOST_HAS_INT128)
927

    
928
typedef boost::uint128_type storage128_type;
929

    
930
#else // defined(BOOST_HAS_INT128)
931

    
932
struct BOOST_ALIGNMENT(16) storage128_type
933
{
934
    uint64_t data[2];
935
};
936

    
937
inline bool operator== (storage128_type const& left, storage128_type const& right)
938
{
939
    return left.data[0] == right.data[0] && left.data[1] == right.data[1];
940
}
941
inline bool operator!= (storage128_type const& left, storage128_type const& right)
942
{
943
    return !(left == right);
944
}
945

    
946
#endif // defined(BOOST_HAS_INT128)
947

    
948
template<typename T, bool Sign>
949
class base_atomic<T, void, 16, Sign>
950
{
951
private:
952
    typedef base_atomic this_type;
953
    typedef T value_type;
954
    typedef storage128_type storage_type;
955

    
956
protected:
957
    typedef value_type const& value_arg_type;
958

    
959
public:
960
    BOOST_DEFAULTED_FUNCTION(base_atomic(void), {})
961
    explicit base_atomic(value_type const& v) BOOST_NOEXCEPT : v_(0)
962
    {
963
        memcpy(&v_, &v, sizeof(value_type));
964
    }
965

    
966
    void store(value_type const& v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
967
    {
968
        storage_type tmp = 0;
969
        memcpy(&tmp, &v, sizeof(value_type));
970
        __atomic_store_n(&v_, tmp, atomics::detail::convert_memory_order_to_gcc(order));
971
    }
972

    
973
    value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT
974
    {
975
        storage_type tmp = __atomic_load_n(&v_, atomics::detail::convert_memory_order_to_gcc(order));
976
        value_type v;
977
        memcpy(&v, &tmp, sizeof(value_type));
978
        return v;
979
    }
980

    
981
    value_type exchange(value_type const& v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
982
    {
983
        storage_type tmp = 0;
984
        memcpy(&tmp, &v, sizeof(value_type));
985
        tmp = __atomic_exchange_n(&v_, tmp, atomics::detail::convert_memory_order_to_gcc(order));
986
        value_type res;
987
        memcpy(&res, &tmp, sizeof(value_type));
988
        return res;
989
    }
990

    
991
    bool compare_exchange_strong(
992
        value_type& expected,
993
        value_type const& desired,
994
        memory_order success_order,
995
        memory_order failure_order) volatile BOOST_NOEXCEPT
996
    {
997
        storage_type expected_s = 0, desired_s = 0;
998
        memcpy(&expected_s, &expected, sizeof(value_type));
999
        memcpy(&desired_s, &desired, sizeof(value_type));
1000
        const bool success = __atomic_compare_exchange_n(&v_, &expected_s, desired_s, false,
1001
            atomics::detail::convert_memory_order_to_gcc(success_order),
1002
            atomics::detail::convert_memory_order_to_gcc(failure_order));
1003
        memcpy(&expected, &expected_s, sizeof(value_type));
1004
        return success;
1005
    }
1006

    
1007
    bool compare_exchange_weak(
1008
        value_type& expected,
1009
        value_type const& desired,
1010
        memory_order success_order,
1011
        memory_order failure_order) volatile BOOST_NOEXCEPT
1012
    {
1013
        storage_type expected_s = 0, desired_s = 0;
1014
        memcpy(&expected_s, &expected, sizeof(value_type));
1015
        memcpy(&desired_s, &desired, sizeof(value_type));
1016
        const bool success = __atomic_compare_exchange_n(&v_, &expected_s, desired_s, true,
1017
            atomics::detail::convert_memory_order_to_gcc(success_order),
1018
            atomics::detail::convert_memory_order_to_gcc(failure_order));
1019
        memcpy(&expected, &expected_s, sizeof(value_type));
1020
        return success;
1021
    }
1022

    
1023
    bool is_lock_free(void) const volatile BOOST_NOEXCEPT
1024
    {
1025
        return __atomic_is_lock_free(sizeof(v_), &v_);
1026
    }
1027

    
1028
    BOOST_ATOMIC_DECLARE_BASE_OPERATORS
1029

    
1030
    BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&))
1031
    BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&))
1032

    
1033
private:
1034
    storage_type v_;
1035
};
1036

    
1037
#endif // defined(BOOST_ATOMIC_INT128_LOCK_FREE) && BOOST_ATOMIC_INT128_LOCK_FREE > 0
1038

    
1039

    
1040
/* pointers */
1041

    
1042
#if defined(BOOST_ATOMIC_POINTER_LOCK_FREE) && BOOST_ATOMIC_POINTER_LOCK_FREE > 0
1043

    
1044
template<typename T, bool Sign>
1045
class base_atomic<T*, void*, sizeof(void*), Sign>
1046
{
1047
private:
1048
    typedef base_atomic this_type;
1049
    typedef T* value_type;
1050
    typedef std::ptrdiff_t difference_type;
1051

    
1052
protected:
1053
    typedef value_type value_arg_type;
1054

    
1055
public:
1056
    BOOST_DEFAULTED_FUNCTION(base_atomic(void), {})
1057
    BOOST_CONSTEXPR explicit base_atomic(value_type v) BOOST_NOEXCEPT : v_(v) {}
1058

    
1059
    void store(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
1060
    {
1061
        __atomic_store_n(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
1062
    }
1063

    
1064
    value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT
1065
    {
1066
        return __atomic_load_n(&v_, atomics::detail::convert_memory_order_to_gcc(order));
1067
    }
1068

    
1069
    value_type fetch_add(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
1070
    {
1071
        return __atomic_fetch_add(&v_, v * sizeof(T), atomics::detail::convert_memory_order_to_gcc(order));
1072
    }
1073

    
1074
    value_type fetch_sub(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
1075
    {
1076
        return __atomic_fetch_sub(&v_, v * sizeof(T), atomics::detail::convert_memory_order_to_gcc(order));
1077
    }
1078

    
1079
    value_type exchange(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
1080
    {
1081
        return __atomic_exchange_n(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
1082
    }
1083

    
1084
    bool compare_exchange_strong(
1085
        value_type& expected,
1086
        value_type desired,
1087
        memory_order success_order,
1088
        memory_order failure_order) volatile BOOST_NOEXCEPT
1089
    {
1090
        return __atomic_compare_exchange_n(&v_, &expected, desired, false,
1091
            atomics::detail::convert_memory_order_to_gcc(success_order),
1092
            atomics::detail::convert_memory_order_to_gcc(failure_order));
1093
    }
1094

    
1095
    bool compare_exchange_weak(
1096
        value_type& expected,
1097
        value_type desired,
1098
        memory_order success_order,
1099
        memory_order failure_order) volatile BOOST_NOEXCEPT
1100
    {
1101
        return __atomic_compare_exchange_n(&v_, &expected, desired, true,
1102
            atomics::detail::convert_memory_order_to_gcc(success_order),
1103
            atomics::detail::convert_memory_order_to_gcc(failure_order));
1104
    }
1105

    
1106
    bool is_lock_free(void) const volatile BOOST_NOEXCEPT
1107
    {
1108
        return __atomic_is_lock_free(sizeof(v_), &v_);
1109
    }
1110

    
1111
    BOOST_ATOMIC_DECLARE_POINTER_OPERATORS
1112

    
1113
    BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&))
1114
    BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&))
1115

    
1116
private:
1117
    value_type v_;
1118
};
1119

    
1120
template<bool Sign>
1121
class base_atomic<void*, void*, sizeof(void*), Sign>
1122
{
1123
private:
1124
    typedef base_atomic this_type;
1125
    typedef void* value_type;
1126
    typedef std::ptrdiff_t difference_type;
1127

    
1128
protected:
1129
    typedef value_type value_arg_type;
1130

    
1131
public:
1132
    BOOST_DEFAULTED_FUNCTION(base_atomic(void), {})
1133
    BOOST_CONSTEXPR explicit base_atomic(value_type v) BOOST_NOEXCEPT : v_(v) {}
1134

    
1135
    void store(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
1136
    {
1137
        __atomic_store_n(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
1138
    }
1139

    
1140
    value_type load(memory_order order = memory_order_seq_cst) const volatile BOOST_NOEXCEPT
1141
    {
1142
        return __atomic_load_n(&v_, atomics::detail::convert_memory_order_to_gcc(order));
1143
    }
1144

    
1145
    value_type fetch_add(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
1146
    {
1147
        return __atomic_fetch_add(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
1148
    }
1149

    
1150
    value_type fetch_sub(difference_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
1151
    {
1152
        return __atomic_fetch_sub(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
1153
    }
1154

    
1155
    value_type exchange(value_type v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
1156
    {
1157
        return __atomic_exchange_n(&v_, v, atomics::detail::convert_memory_order_to_gcc(order));
1158
    }
1159

    
1160
    bool compare_exchange_strong(
1161
        value_type& expected,
1162
        value_type desired,
1163
        memory_order success_order,
1164
        memory_order failure_order) volatile BOOST_NOEXCEPT
1165
    {
1166
        return __atomic_compare_exchange_n(&v_, &expected, desired, false,
1167
            atomics::detail::convert_memory_order_to_gcc(success_order),
1168
            atomics::detail::convert_memory_order_to_gcc(failure_order));
1169
    }
1170

    
1171
    bool compare_exchange_weak(
1172
        value_type& expected,
1173
        value_type desired,
1174
        memory_order success_order,
1175
        memory_order failure_order) volatile BOOST_NOEXCEPT
1176
    {
1177
        return __atomic_compare_exchange_n(&v_, &expected, desired, true,
1178
            atomics::detail::convert_memory_order_to_gcc(success_order),
1179
            atomics::detail::convert_memory_order_to_gcc(failure_order));
1180
    }
1181

    
1182
    bool is_lock_free(void) const volatile BOOST_NOEXCEPT
1183
    {
1184
        return __atomic_is_lock_free(sizeof(v_), &v_);
1185
    }
1186

    
1187
    BOOST_ATOMIC_DECLARE_VOID_POINTER_OPERATORS
1188

    
1189
    BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&))
1190
    BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&))
1191

    
1192
private:
1193
    value_type v_;
1194
};
1195

    
1196
#endif // defined(BOOST_ATOMIC_POINTER_LOCK_FREE) && BOOST_ATOMIC_POINTER_LOCK_FREE > 0
1197

    
1198
} // namespace detail
1199
} // namespace atomics
1200
} // namespace boost
1201

    
1202
#endif // !defined(BOOST_ATOMIC_FORCE_FALLBACK)
1203

    
1204
#endif // BOOST_ATOMIC_DETAIL_GCC_ATOMIC_HPP