| 102 | Atomic<int32_t>::Atomic(int32_t value) : value(value) {} |
| 103 | |
| 104 | int32_t Atomic<int32_t>::fetch_add(int32_t val, memory_order mem) |
| 105 | { |
| 106 | #if _MSC_VER |
| 107 | #if defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) |
| 108 | switch (mem) |
| 109 | { |
| 110 | case memory_order_relaxed: return _InterlockedExchangeAdd_nf(reinterpret_cast<volatile long*>(&value), val); |
| 111 | case memory_order_acquire: return _InterlockedExchangeAdd_acq(reinterpret_cast<volatile long*>(&value), val); |
| 112 | case memory_order_release: return _InterlockedExchangeAdd_rel(reinterpret_cast<volatile long*>(&value), val); |
| 113 | case memory_order_acq_rel: |
| 114 | case memory_order_seq_cst: |
| 115 | default: // consume is treated as acquire |
| 116 | return _InterlockedExchangeAdd(reinterpret_cast<volatile long*>(&value), val); |
| 117 | } |
| 118 | #else |
| 119 | (void)mem; |
| 120 | return _InterlockedExchangeAdd(reinterpret_cast<volatile long*>(&value), val); |
| 121 | #endif |
| 122 | #else |
| 123 | return __atomic_fetch_add(&value, val, mem); |
| 124 | #endif |
| 125 | } |
| 126 | |
| 127 | int32_t Atomic<int32_t>::fetch_sub(int32_t val, memory_order mem) |
| 128 | { |
no outgoing calls