[atomic] Use no-op asm for compiler barrier

Fixes https://github.com/harfbuzz/harfbuzz/pull/4119
This commit is contained in:
Behdad Esfahbod 2023-02-13 21:16:16 -07:00
parent 2f1aa032b4
commit b41efb6c4d
1 changed files with 8 additions and 3 deletions

View File

@ -111,10 +111,15 @@ _hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N)
#endif #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 #ifndef _hb_compiler_memory_r_barrier
/* This we always use std::atomic for; and should never be disabled... #if defined(__ATOMIC_ACQUIRE) // gcc-like
* except that MSVC gives me an internal compiler error on it. */ #define _hb_compiler_memory_r_barrier() asm volatile("": : :"memory")
#if !defined(_MSC_VER) #elif !defined(_MSC_VER)
#include <atomic> #include <atomic>
#define _hb_compiler_memory_r_barrier() std::atomic_signal_fence (std::memory_order_acquire) #define _hb_compiler_memory_r_barrier() std::atomic_signal_fence (std::memory_order_acquire)
#else #else