From e7f2937962283d69fd1153ebca46b615fca4a2a2 Mon Sep 17 00:00:00 2001 From: "xiaofeng@google.com" Date: Mon, 5 May 2014 22:06:41 +0000 Subject: [PATCH] Fix a bug in Arm64 atomicops. (https://codereview.appspot.com/88800045/) --- .../stubs/atomicops_internals_arm64_gcc.h | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h b/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h index b852c43c72..fe9727ad09 100644 --- a/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h +++ b/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h @@ -117,10 +117,8 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment) { - Atomic32 result; - MemoryBarrier(); - result = NoBarrier_AtomicIncrement(ptr, increment); + Atomic32 result = NoBarrier_AtomicIncrement(ptr, increment); MemoryBarrier(); return result; @@ -129,9 +127,7 @@ inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value) { - Atomic32 prev; - - prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); + Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); MemoryBarrier(); return prev; @@ -140,10 +136,8 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value) { - Atomic32 prev; - MemoryBarrier(); - prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); + Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); return prev; } @@ -259,10 +253,8 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) { - Atomic64 result; - MemoryBarrier(); - result = NoBarrier_AtomicIncrement(ptr, increment); + Atomic64 result = NoBarrier_AtomicIncrement(ptr, increment); MemoryBarrier(); return result; @@ -271,9 +263,7 @@ inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, Atomic64 old_value, Atomic64 new_value) { - Atomic64 prev; - - prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); + Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); MemoryBarrier(); return prev; @@ -282,10 +272,8 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, Atomic64 old_value, Atomic64 new_value) { - Atomic64 prev; - MemoryBarrier(); - prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); + Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); return prev; } @@ -313,7 +301,7 @@ inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { } inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { - Atomic32 value; + Atomic64 value; __asm__ __volatile__ ( // NOLINT "ldar %x[value], %[ptr] \n\t"