@@ -128,7 +128,9 @@ WINRT_EXPORT namespace winrt
128128#pragma clang diagnostic ignored "-Wdeprecated-declarations"
129129#endif
130130
131- #if defined _M_ARM
131+ #if defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))
132+ #define WINRT_IMPL_INTERLOCKED_READ_MEMORY_BARRIER __asm__ __volatile__ (" dmb ish" );
133+ #elif defined _M_ARM
132134#define WINRT_IMPL_INTERLOCKED_READ_MEMORY_BARRIER (__dmb(_ARM_BARRIER_ISH));
133135#elif defined _M_ARM64
134136#define WINRT_IMPL_INTERLOCKED_READ_MEMORY_BARRIER (__dmb(_ARM64_BARRIER_ISH));
@@ -143,7 +145,11 @@ namespace winrt::impl
143145 _ReadWriteBarrier ();
144146 return result;
145147#elif defined _M_ARM || defined _M_ARM64
148+ #if defined(__GNUC__)
149+ int32_t const result = *target;
150+ #else
146151 int32_t const result = __iso_volatile_load32 (reinterpret_cast <int32_t const volatile *>(target));
152+ #endif
147153 WINRT_IMPL_INTERLOCKED_READ_MEMORY_BARRIER
148154 return result;
149155#else
@@ -159,7 +165,11 @@ namespace winrt::impl
159165 _ReadWriteBarrier ();
160166 return result;
161167#elif defined _M_ARM64
168+ #if defined(__GNUC__)
169+ int64_t const result = *target;
170+ #else
162171 int64_t const result = __iso_volatile_load64 (target);
172+ #endif
163173 WINRT_IMPL_INTERLOCKED_READ_MEMORY_BARRIER
164174 return result;
165175#else
@@ -281,7 +291,12 @@ namespace winrt::impl
281291 object_and_count current_value{ pointer_value, 0 };
282292
283293#if defined _WIN64
284- if (1 == _InterlockedCompareExchange128 ((int64_t *)this , 0 , 0 , (int64_t *)¤t_value))
294+ #if defined(__GNUC__)
295+ bool exchanged = __sync_bool_compare_and_swap ((__int128*)this , *(__int128*)¤t_value, (__int128)0 );
296+ #else
297+ bool exchanged = 1 == _InterlockedCompareExchange128 ((int64_t *)this , 0 , 0 , (int64_t *)¤t_value);
298+ #endif
299+ if (exchanged)
285300 {
286301 pointer_value->Release ();
287302 }
0 commit comments