From: Hans Boehm Date: Thu, 26 Jan 2017 07:16:54 +0000 (+0300) Subject: Implement compiler_barrier using C11 __atomic_signal_fence (GCC) X-Git-Tag: v7.6.0~121 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=01b8da7d71c5030bb35dd67d88c0b0f4b6131a88;p=libatomic_ops Implement compiler_barrier using C11 __atomic_signal_fence (GCC) Use __atomic_signal_fence(__ATOMIC_SEQ_CST) as AO_compiler_barrier. That was the intended use of __atomic_signal_fence. The only standards-relevant context in which you can tell apart a compiler and real fence is in the case if signal handlers. * src/atomic_ops/sysdeps/gcc/generic.h (AO_compiler_barrier): Redefine using GCC atomic intrinsic (__atomic_signal_fence). --- diff --git a/src/atomic_ops/sysdeps/gcc/generic.h b/src/atomic_ops/sysdeps/gcc/generic.h index ba82e0d..3f736ef 100644 --- a/src/atomic_ops/sysdeps/gcc/generic.h +++ b/src/atomic_ops/sysdeps/gcc/generic.h @@ -45,6 +45,9 @@ # define AO_GCC_HAVE_SYNC_CAS #endif +#undef AO_compiler_barrier +#define AO_compiler_barrier() __atomic_signal_fence(__ATOMIC_SEQ_CST) + #ifdef AO_UNIPROCESSOR /* If only a single processor (core) is used, AO_UNIPROCESSOR could */ /* be defined by the client to avoid unnecessary memory barrier. */