equal
deleted
inserted
replaced
29 #include "runtime/vm_version.hpp" |
29 #include "runtime/vm_version.hpp" |
30 |
30 |
31 // Implementation of class atomic |
31 // Implementation of class atomic |
32 // Note that memory_order_conservative requires a full barrier after atomic stores. |
32 // Note that memory_order_conservative requires a full barrier after atomic stores. |
33 // See https://patchwork.kernel.org/patch/3575821/ |
33 // See https://patchwork.kernel.org/patch/3575821/ |
34 |
|
35 #define FULL_MEM_BARRIER __sync_synchronize() |
|
36 #define READ_MEM_BARRIER __atomic_thread_fence(__ATOMIC_ACQUIRE); |
|
37 #define WRITE_MEM_BARRIER __atomic_thread_fence(__ATOMIC_RELEASE); |
|
38 |
34 |
39 template<size_t byte_size> |
35 template<size_t byte_size> |
40 struct Atomic::PlatformAdd |
36 struct Atomic::PlatformAdd |
41 : Atomic::AddAndFetch<Atomic::PlatformAdd<byte_size> > |
37 : Atomic::AddAndFetch<Atomic::PlatformAdd<byte_size> > |
42 { |
38 { |
79 FULL_MEM_BARRIER; |
75 FULL_MEM_BARRIER; |
80 return value; |
76 return value; |
81 } |
77 } |
82 } |
78 } |
83 |
79 |
|
80 template<size_t byte_size> |
|
81 struct Atomic::PlatformOrderedLoad<byte_size, X_ACQUIRE> |
|
82 { |
|
83 template <typename T> |
|
84 T operator()(const volatile T* p) const { T data; __atomic_load(const_cast<T*>(p), &data, __ATOMIC_ACQUIRE); return data; } |
|
85 }; |
|
86 |
|
87 template<size_t byte_size> |
|
88 struct Atomic::PlatformOrderedStore<byte_size, RELEASE_X> |
|
89 { |
|
90 template <typename T> |
|
91 void operator()(T v, volatile T* p) const { __atomic_store(const_cast<T*>(p), &v, __ATOMIC_RELEASE); } |
|
92 }; |
|
93 |
|
94 template<size_t byte_size> |
|
95 struct Atomic::PlatformOrderedStore<byte_size, RELEASE_X_FENCE> |
|
96 { |
|
97 template <typename T> |
|
98 void operator()(T v, volatile T* p) const { release_store(p, v); OrderAccess::fence(); } |
|
99 }; |
|
100 |
84 #endif // OS_CPU_LINUX_AARCH64_ATOMIC_LINUX_AARCH64_HPP |
101 #endif // OS_CPU_LINUX_AARCH64_ATOMIC_LINUX_AARCH64_HPP |