Commit e7f29379 authored by xiaofeng@google.com's avatar xiaofeng@google.com

Fix a bug in Arm64 atomicops. (https://codereview.appspot.com/88800045/)

parent 3aa5ea95
...@@ -117,10 +117,8 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, ...@@ -117,10 +117,8 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
Atomic32 increment) { Atomic32 increment) {
Atomic32 result;
MemoryBarrier(); MemoryBarrier();
result = NoBarrier_AtomicIncrement(ptr, increment); Atomic32 result = NoBarrier_AtomicIncrement(ptr, increment);
MemoryBarrier(); MemoryBarrier();
return result; return result;
...@@ -129,9 +127,7 @@ inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, ...@@ -129,9 +127,7 @@ inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value, Atomic32 old_value,
Atomic32 new_value) { Atomic32 new_value) {
Atomic32 prev; Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
MemoryBarrier(); MemoryBarrier();
return prev; return prev;
...@@ -140,10 +136,8 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, ...@@ -140,10 +136,8 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value, Atomic32 old_value,
Atomic32 new_value) { Atomic32 new_value) {
Atomic32 prev;
MemoryBarrier(); MemoryBarrier();
prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
return prev; return prev;
} }
...@@ -259,10 +253,8 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, ...@@ -259,10 +253,8 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
Atomic64 increment) { Atomic64 increment) {
Atomic64 result;
MemoryBarrier(); MemoryBarrier();
result = NoBarrier_AtomicIncrement(ptr, increment); Atomic64 result = NoBarrier_AtomicIncrement(ptr, increment);
MemoryBarrier(); MemoryBarrier();
return result; return result;
...@@ -271,9 +263,7 @@ inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, ...@@ -271,9 +263,7 @@ inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 old_value, Atomic64 old_value,
Atomic64 new_value) { Atomic64 new_value) {
Atomic64 prev; Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
MemoryBarrier(); MemoryBarrier();
return prev; return prev;
...@@ -282,10 +272,8 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, ...@@ -282,10 +272,8 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 old_value, Atomic64 old_value,
Atomic64 new_value) { Atomic64 new_value) {
Atomic64 prev;
MemoryBarrier(); MemoryBarrier();
prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
return prev; return prev;
} }
...@@ -313,7 +301,7 @@ inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { ...@@ -313,7 +301,7 @@ inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
} }
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
Atomic32 value; Atomic64 value;
__asm__ __volatile__ ( // NOLINT __asm__ __volatile__ ( // NOLINT
"ldar %x[value], %[ptr] \n\t" "ldar %x[value], %[ptr] \n\t"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment