From b41efb6c4da9b1180b5178a55ceb31c68791dfdc Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 13 Feb 2023 21:16:16 -0700 Subject: [PATCH] [atomic] Use no-op asm for compiler barrier Fixes https://github.com/harfbuzz/harfbuzz/pull/4119 --- src/hb-atomic.hh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/hb-atomic.hh b/src/hb-atomic.hh index a47493035..a6283de14 100644 --- a/src/hb-atomic.hh +++ b/src/hb-atomic.hh @@ -111,10 +111,15 @@ _hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N) #endif +/* This should never be disabled, even under HB_NO_MT. + * except that MSVC gives me an internal compiler error, so disabled there. + * + * https://github.com/harfbuzz/harfbuzz/pull/4119 + */ #ifndef _hb_compiler_memory_r_barrier -/* This we always use std::atomic for; and should never be disabled... - * except that MSVC gives me an internal compiler error on it. */ -#if !defined(_MSC_VER) +#if defined(__ATOMIC_ACQUIRE) // gcc-like +#define _hb_compiler_memory_r_barrier() asm volatile("": : :"memory") +#elif !defined(_MSC_VER) #include #define _hb_compiler_memory_r_barrier() std::atomic_signal_fence (std::memory_order_acquire) #else