| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#ifndef _EH_ATOMICS_H |
| 32 |
#define _EH_ATOMICS_H 1 |
| 33 |
|
| 34 |
#include <bits/c++config.h> |
| 35 |
#include <bits/atomic_word.h> |
| 36 |
#include <bits/atomic_lockfree_defines.h> |
| 37 |
#if ATOMIC_INT_LOCK_FREE <= 1 |
| 38 |
# include <ext/atomicity.h> |
| 39 |
#endif |
| 40 |
|
| 41 |
#pragma GCC visibility push(default) |
| 42 |
extern "C++" { |
| 43 |
namespace __gnu_cxx |
| 44 |
{ |
| 45 |
void |
| 46 |
__eh_atomic_inc (_Atomic_word* __count) __attribute__((always_inline)); |
| 47 |
|
| 48 |
bool |
| 49 |
__eh_atomic_dec (_Atomic_word* __count) __attribute__((always_inline)); |
| 50 |
|
| 51 |
|
| 52 |
inline void |
| 53 |
__eh_atomic_inc (_Atomic_word* __count) |
| 54 |
{ |
| 55 |
#if ATOMIC_INT_LOCK_FREE > 1 |
| 56 |
__atomic_add_fetch (__count, 1, __ATOMIC_ACQ_REL); |
| 57 |
#else |
| 58 |
_GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE (__count); |
| 59 |
__gnu_cxx::__atomic_add_dispatch (__count, 1); |
| 60 |
_GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER (__count); |
| 61 |
#endif |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
inline bool |
| 66 |
__eh_atomic_dec (_Atomic_word* __count) |
| 67 |
{ |
| 68 |
#if ATOMIC_INT_LOCK_FREE > 1 |
| 69 |
return __atomic_sub_fetch (__count, 1, __ATOMIC_ACQ_REL) == 0; |
| 70 |
#else |
| 71 |
_GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE (__count); |
| 72 |
if (__gnu_cxx::__exchange_and_add_dispatch (__count, -1) == 1) |
| 73 |
{ |
| 74 |
_GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER (__count); |
| 75 |
return true; |
| 76 |
} |
| 77 |
return false; |
| 78 |
#endif |
| 79 |
} |
| 80 |
} |
| 81 |
} |
| 82 |
#pragma GCC visibility pop |
| 83 |
|
| 84 |
#endif |