32 #ifndef V8_ATOMICOPS_INTERNALS_ARM_GCC_H_
33 #define V8_ATOMICOPS_INTERNALS_ARM_GCC_H_
35 #if defined(__QNXNTO__)
36 #include <sys/cpuinline.h>
70 #if defined(__linux__) || defined(__ANDROID__)
72 typedef void (*KernelMemoryBarrierFunc)();
73 ((KernelMemoryBarrierFunc)0xffff0fa0)();
74 #elif defined(__QNXNTO__)
77 #error MemoryBarrier() is not implemented on this platform.
85 #if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
86 defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || \
87 defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
88 defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || \
89 defined(__ARM_ARCH_6KZ__) || defined(__ARM_ARCH_6T2__)
103 __asm__ __volatile__(
" ldrex %0, [%3]\n"
109 " strexeq %1, %5, [%3]\n"
110 :
"=&r"(prev_value),
"=&r"(reloop),
"+m"(*ptr)
111 :
"r"(ptr),
"r"(old_value),
"r"(new_value)
113 }
while (reloop != 0);
143 __asm__ __volatile__(
" ldrex %0, [%3]\n"
145 " strex %1, %0, [%3]\n"
146 :
"=&r"(value),
"=&r"(reloop),
"+m"(*ptr)
147 :
"r"(ptr),
"r"(increment)
171 __asm__ __volatile__(
" ldrex %0, [%3]\n"
172 " strex %1, %4, [%3]\n"
173 :
"=&r"(old_value),
"=&r"(reloop),
"+m"(*ptr)
174 :
"r"(ptr),
"r"(new_value)
176 }
while (reloop != 0);
181 #elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \
182 defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__)
198 inline int LinuxKernelCmpxchg(
Atomic32 old_value,
202 return ((KernelCmpxchgFunc)0xffff0fc0)(old_value, new_value, ptr);
209 Atomic32 new_value) {
213 if (prev_value != old_value)
215 if (!LinuxKernelCmpxchg(old_value, new_value, ptr))
221 Atomic32 new_value) {
225 }
while (LinuxKernelCmpxchg(old_value, new_value, ptr));
230 Atomic32 increment) {
235 Atomic32 increment) {
238 Atomic32 old_value = *ptr;
239 Atomic32 new_value = old_value + increment;
240 if (!LinuxKernelCmpxchg(old_value, new_value, ptr)) {
250 Atomic32 new_value) {
254 if (prev_value != old_value) {
259 if (!LinuxKernelCmpxchg(old_value, new_value, ptr))
266 Atomic32 new_value) {
281 # error "Your CPU's ARM architecture is not supported yet"
291 inline void Acquire_Store(
volatile Atomic32* ptr, Atomic32 value) {
296 inline void Release_Store(
volatile Atomic32* ptr, Atomic32 value) {
301 inline Atomic32
NoBarrier_Load(
volatile const Atomic32* ptr) {
return *ptr; }
303 inline Atomic32
Acquire_Load(
volatile const Atomic32* ptr) {
304 Atomic32 value = *ptr;
309 inline Atomic32
Release_Load(
volatile const Atomic32* ptr) {
316 #endif // V8_ATOMICOPS_INTERNALS_ARM_GCC_H_
void Acquire_Store(volatile Atomic32 *ptr, Atomic32 value)
Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32 *ptr, Atomic32 old_value, Atomic32 new_value)
Atomic32 Release_CompareAndSwap(volatile Atomic32 *ptr, Atomic32 old_value, Atomic32 new_value)
void NoBarrier_Store(volatile Atomic32 *ptr, Atomic32 value)
Atomic32 NoBarrier_AtomicExchange(volatile Atomic32 *ptr, Atomic32 new_value)
Atomic32 Release_Load(volatile const Atomic32 *ptr)
Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32 *ptr, Atomic32 increment)
void Release_Store(volatile Atomic32 *ptr, Atomic32 value)
Atomic32 Barrier_AtomicIncrement(volatile Atomic32 *ptr, Atomic32 increment)
Atomic32 NoBarrier_Load(volatile const Atomic32 *ptr)
Atomic32 Acquire_Load(volatile const Atomic32 *ptr)
Atomic32 Acquire_CompareAndSwap(volatile Atomic32 *ptr, Atomic32 old_value, Atomic32 new_value)