From ec021f5429d458467e9fd8dcdd452f886b5bf324 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 11 Dec 2016 14:50:18 +0100 Subject: [PATCH] Add support for Windows ARM builds --- src/google/protobuf/stubs/atomicops.h | 14 ++++---- .../stubs/atomicops_internals_arm64_gcc.h | 26 +++++++------- .../stubs/atomicops_internals_arm_gcc.h | 10 +++--- .../stubs/atomicops_internals_arm_qnx.h | 10 +++--- .../atomicops_internals_generic_c11_atomic.h | 10 +++--- .../stubs/atomicops_internals_generic_gcc.h | 2 +- .../stubs/atomicops_internals_macosx.h | 18 +++++----- .../stubs/atomicops_internals_mips_gcc.h | 34 +++++++++---------- .../stubs/atomicops_internals_power.h | 2 +- .../stubs/atomicops_internals_ppc_gcc.h | 18 +++++----- .../stubs/atomicops_internals_solaris.h | 18 +++++----- .../protobuf/stubs/atomicops_internals_tsan.h | 2 +- .../stubs/atomicops_internals_x86_gcc.h | 12 +++---- .../stubs/atomicops_internals_x86_msvc.cc | 7 ++-- .../stubs/atomicops_internals_x86_msvc.h | 4 +-- src/google/protobuf/stubs/platform_macros.h | 2 +- 16 files changed, 95 insertions(+), 94 deletions(-) diff --git a/src/google/protobuf/stubs/atomicops.h b/src/google/protobuf/stubs/atomicops.h index 10a71ed484..c25492f320 100644 --- a/src/google/protobuf/stubs/atomicops.h +++ b/src/google/protobuf/stubs/atomicops.h @@ -123,8 +123,8 @@ Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, // ensure that no later memory access can be reordered ahead of the operation. // "Release" operations ensure that no previous memory access can be reordered // after the operation. "Barrier" operations have both "Acquire" and "Release" -// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory -// access. +// semantics. A MemoryBarrierInternal() has "Barrier" semantics, but does no +// memory access. Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value); @@ -132,10 +132,10 @@ Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value); -#if defined(__MINGW32__) && defined(MemoryBarrier) -#undef MemoryBarrier -#endif -void MemoryBarrier(); +// This function was renamed from MemoryBarrier to MemoryBarrierInternal +// because MemoryBarrier is a define in Windows ARM builds and we do not +// undefine it because we call it from this function. +void MemoryBarrierInternal(); void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value); void Acquire_Store(volatile Atomic32* ptr, Atomic32 value); void Release_Store(volatile Atomic32* ptr, Atomic32 value); @@ -180,7 +180,7 @@ Atomic64 Release_Load(volatile const Atomic64* ptr); #include // MSVC. #elif defined(_MSC_VER) -#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64) +#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64) || defined(GOOGLE_PROTOBUF_ARCH_ARM) #include #else #error GOOGLE_PROTOBUF_ATOMICOPS_ERROR diff --git a/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h b/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h index 0a2d2b894b..9a69d21ad6 100644 --- a/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h +++ b/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h @@ -37,7 +37,7 @@ namespace google { namespace protobuf { namespace internal { -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { __asm__ __volatile__ ("dmb ish" ::: "memory"); // NOLINT } @@ -117,9 +117,9 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic32 result = NoBarrier_AtomicIncrement(ptr, increment); - MemoryBarrier(); + MemoryBarrierInternal(); return result; } @@ -128,7 +128,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value) { Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - MemoryBarrier(); + MemoryBarrierInternal(); return prev; } @@ -136,7 +136,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); return prev; @@ -148,7 +148,7 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { @@ -178,7 +178,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { } inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } @@ -253,9 +253,9 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic64 result = NoBarrier_AtomicIncrement(ptr, increment); - MemoryBarrier(); + MemoryBarrierInternal(); return result; } @@ -264,7 +264,7 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, Atomic64 old_value, Atomic64 new_value) { Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - MemoryBarrier(); + MemoryBarrierInternal(); return prev; } @@ -272,7 +272,7 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, Atomic64 old_value, Atomic64 new_value) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value); return prev; @@ -284,7 +284,7 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { @@ -314,7 +314,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { } inline Atomic64 Release_Load(volatile const Atomic64* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } diff --git a/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h b/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h index 90e727b0bc..6e2de67fa5 100644 --- a/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h +++ b/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h @@ -115,17 +115,17 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; } -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { pLinuxKernelMemoryBarrier(); } inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - MemoryBarrier(); + MemoryBarrierInternal(); *ptr = value; } @@ -135,12 +135,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { Atomic32 value = *ptr; - MemoryBarrier(); + MemoryBarrierInternal(); return value; } inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } diff --git a/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h b/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h index 17dfaa5182..cd97e0c994 100644 --- a/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h +++ b/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h @@ -110,17 +110,17 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; } -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { __sync_synchronize(); } inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - MemoryBarrier(); + MemoryBarrierInternal(); *ptr = value; } @@ -130,12 +130,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { Atomic32 value = *ptr; - MemoryBarrier(); + MemoryBarrierInternal(); return value; } inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } diff --git a/src/google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h b/src/google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h index 7bc584eb21..44ef9c9e03 100644 --- a/src/google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h +++ b/src/google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h @@ -52,7 +52,7 @@ typedef volatile std::atomic* AtomicLocation32; static_assert(sizeof(*(AtomicLocation32) nullptr) == sizeof(Atomic32), "incompatible 32-bit atomic layout"); -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { #if defined(__GLIBCXX__) // Work around libstdc++ bug 51038 where atomic_thread_fence was declared but // not defined, leading to the linker complaining about undefined references. @@ -119,7 +119,7 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { ((AtomicLocation32)ptr)->store(value, std::memory_order_relaxed); - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { @@ -135,7 +135,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { } inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return ((AtomicLocation32)ptr)->load(std::memory_order_relaxed); } @@ -202,7 +202,7 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { ((AtomicLocation64)ptr)->store(value, std::memory_order_relaxed); - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { @@ -218,7 +218,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { } inline Atomic64 Release_Load(volatile const Atomic64* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return ((AtomicLocation64)ptr)->load(std::memory_order_relaxed); } diff --git a/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h b/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h index 7f17b30d02..0b0b06ce6c 100644 --- a/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h +++ b/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h @@ -78,7 +78,7 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { __atomic_store_n(ptr, value, __ATOMIC_RELAXED); } -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { __sync_synchronize(); } diff --git a/src/google/protobuf/stubs/atomicops_internals_macosx.h b/src/google/protobuf/stubs/atomicops_internals_macosx.h index 796332417f..c242ef73f8 100644 --- a/src/google/protobuf/stubs/atomicops_internals_macosx.h +++ b/src/google/protobuf/stubs/atomicops_internals_macosx.h @@ -73,7 +73,7 @@ inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, return OSAtomicAdd32Barrier(increment, const_cast(ptr)); } -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { OSMemoryBarrier(); } @@ -103,11 +103,11 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - MemoryBarrier(); + MemoryBarrierInternal(); *ptr = value; } @@ -117,12 +117,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { Atomic32 value = *ptr; - MemoryBarrier(); + MemoryBarrierInternal(); return value; } inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } @@ -193,11 +193,11 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { - MemoryBarrier(); + MemoryBarrierInternal(); *ptr = value; } @@ -207,12 +207,12 @@ inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { Atomic64 value = *ptr; - MemoryBarrier(); + MemoryBarrierInternal(); return value; } inline Atomic64 Release_Load(volatile const Atomic64* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } diff --git a/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h b/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h index f5837c9ec2..6ce6820ec2 100644 --- a/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h +++ b/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h @@ -125,8 +125,8 @@ inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, // ensure that no later memory access can be reordered ahead of the operation. // "Release" operations ensure that no previous memory access can be reordered // after the operation. "Barrier" operations have both "Acquire" and "Release" -// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory -// access. +// semantics. A MemoryBarrierInternal() has "Barrier" semantics, but does no +// memory access. inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value) { @@ -149,17 +149,17 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; } -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { __asm__ __volatile__("sync" : : : "memory"); } inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - MemoryBarrier(); + MemoryBarrierInternal(); *ptr = value; } @@ -169,12 +169,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { Atomic32 value = *ptr; - MemoryBarrier(); + MemoryBarrierInternal(); return value; } inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } @@ -247,9 +247,9 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic64 res = NoBarrier_AtomicIncrement(ptr, increment); - MemoryBarrier(); + MemoryBarrierInternal(); return res; } @@ -257,20 +257,20 @@ inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, // ensure that no later memory access can be reordered ahead of the operation. // "Release" operations ensure that no previous memory access can be reordered // after the operation. "Barrier" operations have both "Acquire" and "Release" -// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory -// access. +// semantics. A MemoryBarrierInternal() has "Barrier" semantics, but does no +// memory access. inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, Atomic64 old_value, Atomic64 new_value) { Atomic64 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - MemoryBarrier(); + MemoryBarrierInternal(); return res; } inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, Atomic64 old_value, Atomic64 new_value) { - MemoryBarrier(); + MemoryBarrierInternal(); return NoBarrier_CompareAndSwap(ptr, old_value, new_value); } @@ -280,11 +280,11 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { - MemoryBarrier(); + MemoryBarrierInternal(); *ptr = value; } @@ -294,12 +294,12 @@ inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { Atomic64 value = *ptr; - MemoryBarrier(); + MemoryBarrierInternal(); return value; } inline Atomic64 Release_Load(volatile const Atomic64* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } #endif diff --git a/src/google/protobuf/stubs/atomicops_internals_power.h b/src/google/protobuf/stubs/atomicops_internals_power.h index b8a42f21f0..cad9f1e354 100644 --- a/src/google/protobuf/stubs/atomicops_internals_power.h +++ b/src/google/protobuf/stubs/atomicops_internals_power.h @@ -93,7 +93,7 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, return result; } -inline void MemoryBarrier(void) { +inline void MemoryBarrierInternal(void) { asm volatile ( " lwsync \n\t" " isync \n\t" diff --git a/src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h b/src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h index 8231a578f3..d477dc6dda 100644 --- a/src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h +++ b/src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h @@ -97,22 +97,22 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32 *ptr, inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32 *ptr, Atomic32 increment) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic32 res = NoBarrier_AtomicIncrement(ptr, increment); - MemoryBarrier(); + MemoryBarrierInternal(); return res; } inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32 *ptr, Atomic32 old_value, Atomic32 new_value) { Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - MemoryBarrier(); + MemoryBarrierInternal(); return res; } inline Atomic32 Release_CompareAndSwap(volatile Atomic32 *ptr, Atomic32 old_value, Atomic32 new_value) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value); return res; } @@ -121,15 +121,15 @@ inline void NoBarrier_Store(volatile Atomic32 *ptr, Atomic32 value) { *ptr = value; } -inline void MemoryBarrier() { __asm__ __volatile__("sync" : : : "memory"); } +inline void MemoryBarrierInternal() { __asm__ __volatile__("sync" : : : "memory"); } inline void Acquire_Store(volatile Atomic32 *ptr, Atomic32 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic32 *ptr, Atomic32 value) { - MemoryBarrier(); + MemoryBarrierInternal(); *ptr = value; } @@ -137,12 +137,12 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32 *ptr) { return *ptr; } inline Atomic32 Acquire_Load(volatile const Atomic32 *ptr) { Atomic32 value = *ptr; - MemoryBarrier(); + MemoryBarrierInternal(); return value; } inline Atomic32 Release_Load(volatile const Atomic32 *ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } diff --git a/src/google/protobuf/stubs/atomicops_internals_solaris.h b/src/google/protobuf/stubs/atomicops_internals_solaris.h index d8057ecdea..baecb993bc 100644 --- a/src/google/protobuf/stubs/atomicops_internals_solaris.h +++ b/src/google/protobuf/stubs/atomicops_internals_solaris.h @@ -54,16 +54,16 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, return (Atomic32)atomic_add_32_nv((volatile uint32_t*)ptr, (uint32_t)increment); } -inline void MemoryBarrier(void) { +inline void MemoryBarrierInternal(void) { membar_producer(); membar_consumer(); } inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic32 ret = NoBarrier_AtomicIncrement(ptr, increment); - MemoryBarrier(); + MemoryBarrierInternal(); return ret; } @@ -72,7 +72,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value) { Atomic32 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - MemoryBarrier(); + MemoryBarrierInternal(); return ret; } @@ -80,7 +80,7 @@ inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value) { - MemoryBarrier(); + MemoryBarrierInternal(); return NoBarrier_CompareAndSwap(ptr, old_value, new_value); } @@ -129,9 +129,9 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 incre } inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) { - MemoryBarrier(); + MemoryBarrierInternal(); Atomic64 ret = atomic_add_64_nv((volatile uint64_t*)ptr, increment); - MemoryBarrier(); + MemoryBarrierInternal(); return ret; } @@ -139,14 +139,14 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, Atomic64 old_value, Atomic64 new_value) { Atomic64 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value); - MemoryBarrier(); + MemoryBarrierInternal(); return ret; } inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, Atomic64 old_value, Atomic64 new_value) { - MemoryBarrier(); + MemoryBarrierInternal(); return NoBarrier_CompareAndSwap(ptr, old_value, new_value); } diff --git a/src/google/protobuf/stubs/atomicops_internals_tsan.h b/src/google/protobuf/stubs/atomicops_internals_tsan.h index 0c903545cd..676380b1d5 100644 --- a/src/google/protobuf/stubs/atomicops_internals_tsan.h +++ b/src/google/protobuf/stubs/atomicops_internals_tsan.h @@ -206,7 +206,7 @@ inline Atomic64 Release_CompareAndSwap(volatile Atomic64 *ptr, return cmp; } -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { __tsan_atomic_thread_fence(__tsan_memory_order_seq_cst); } diff --git a/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h b/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h index edccc59dee..e80121fdf8 100644 --- a/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h +++ b/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h @@ -119,18 +119,18 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { // 64-bit implementations of memory barrier can be simpler, because it // "mfence" is guaranteed to exist. -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { __asm__ __volatile__("mfence" : : : "memory"); } inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } #else -inline void MemoryBarrier() { +inline void MemoryBarrierInternal() { if (AtomicOps_Internalx86CPUFeatures.has_sse2) { __asm__ __volatile__("mfence" : : : "memory"); } else { // mfence is faster but not present on PIII @@ -168,7 +168,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { } inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } @@ -225,7 +225,7 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { *ptr = value; - MemoryBarrier(); + MemoryBarrierInternal(); } inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { @@ -262,7 +262,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { } inline Atomic64 Release_Load(volatile const Atomic64* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } diff --git a/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc b/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc index 741b164f0f..74a1bd4e06 100644 --- a/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc +++ b/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc @@ -44,9 +44,10 @@ namespace google { namespace protobuf { namespace internal { -inline void MemoryBarrier() { - // We use MemoryBarrier from WinNT.h - ::MemoryBarrier(); +inline void MemoryBarrierInternal() { + // On ARM this is a define while on x86/x64 this is + // a function declared in WinNT.h + MemoryBarrier(); } Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, diff --git a/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h b/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h index e53a641f09..34d60d98e0 100644 --- a/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h +++ b/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h @@ -82,7 +82,7 @@ inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { } inline Atomic32 Release_Load(volatile const Atomic32* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } @@ -125,7 +125,7 @@ inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { } inline Atomic64 Release_Load(volatile const Atomic64* ptr) { - MemoryBarrier(); + MemoryBarrierInternal(); return *ptr; } diff --git a/src/google/protobuf/stubs/platform_macros.h b/src/google/protobuf/stubs/platform_macros.h index 8b7f224f3e..7a54060dfa 100644 --- a/src/google/protobuf/stubs/platform_macros.h +++ b/src/google/protobuf/stubs/platform_macros.h @@ -47,7 +47,7 @@ #elif defined(__QNX__) #define GOOGLE_PROTOBUF_ARCH_ARM_QNX 1 #define GOOGLE_PROTOBUF_ARCH_32_BIT 1 -#elif defined(__ARMEL__) +#elif defined(_M_ARM) || defined(__ARMEL__) #define GOOGLE_PROTOBUF_ARCH_ARM 1 #define GOOGLE_PROTOBUF_ARCH_32_BIT 1 #elif defined(__aarch64__)