From 01b8da7d71c5030bb35dd67d88c0b0f4b6131a88 Mon Sep 17 00:00:00 2001 From: Hans Boehm Date: Thu, 26 Jan 2017 10:16:54 +0300 Subject: [PATCH] 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). --- src/atomic_ops/sysdeps/gcc/generic.h | 3 +++ 1 file changed, 3 insertions(+) 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. */ -- 2.40.0