Bug 1480732 - make ipc/'s atomicops.h work on aarch64 windows; r=jld

I'm not entirely sure how this works on x86-64 Windows, which also uses
a #define for MemoryBarrier...I think something about intrinsics.
This commit is contained in:
Nathan Froyd 2018-08-27 09:31:28 -04:00
Родитель e3601d2177
Коммит 3eab353d3f
2 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@ -98,6 +98,20 @@ Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value);
// On AArch64 Windows, MemoryBarrier is defined as:
//
// #define MemoryBarrier() __dmb(_ARM_BARRIER_SY)
//
// which wreaks havoc with the declaration below. Capture the definition
// before undefining the macro.
#if defined(_M_ARM64) && defined(MemoryBarrier)
static inline void
MemoryBarrierARM64()
{
MemoryBarrier();
}
#undef MemoryBarrier
#endif
void MemoryBarrier();
void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value);
void Acquire_Store(volatile Atomic32* ptr, Atomic32 value);
@ -136,6 +150,9 @@ Atomic64 Release_Load(volatile const Atomic64* ptr);
// Include our platform specific implementation.
#if defined(OS_WIN) && defined(ARCH_CPU_X86_FAMILY)
#include "base/atomicops_internals_x86_msvc.h"
#elif defined(OS_WIN) && defined(ARCH_CPU_AARCH64_FAMILY)
// Works just fine, separate case in case we need to change things.
#include "base/atomicops_internals_x86_msvc.h"
#elif defined(OS_MACOSX) && defined(ARCH_CPU_X86_FAMILY)
#include "base/atomicops_internals_x86_macosx.h"
#elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY)

Просмотреть файл

@ -45,8 +45,13 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
}
inline void MemoryBarrier() {
// We use MemoryBarrier from WinNT.h
// We use MemoryBarrier from WinNT.h, except for AArch64.
// See the comment in atomicops.h.
#if defined(_M_ARM64)
MemoryBarrierARM64();
#else
::MemoryBarrier();
#endif
}
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,