diff --git a/src/backend/port/atomics.c b/src/backend/port/atomics.c index 3f53ec13300ca687fa7fc6edb1ac30fbc0b21c2d..f57e6723017560147d1348efe2161191a5c51b53 100644 --- a/src/backend/port/atomics.c +++ b/src/backend/port/atomics.c @@ -32,6 +32,14 @@ pg_spinlock_barrier(void) } #endif +#ifdef PG_HAVE_COMPILER_BARRIER_EMULATION +void +pg_extern_compiler_barrier(void) +{ + /* do nothing */ +} +#endif + #ifdef PG_HAVE_ATOMIC_FLAG_SIMULATION diff --git a/src/include/port/atomics/fallback.h b/src/include/port/atomics/fallback.h index be04ed3c123f2e46b8409b8964a42e0de6c5bba4..b1a9a6a7cc743bbe291c0faec402cbbfd9367099 100644 --- a/src/include/port/atomics/fallback.h +++ b/src/include/port/atomics/fallback.h @@ -35,6 +35,22 @@ extern void pg_spinlock_barrier(void); #define pg_memory_barrier_impl pg_spinlock_barrier #endif +#ifndef pg_compiler_barrier_impl +/* + * If the compiler/arch combination does not provide compiler barriers, + * provide a fallback. That fallback simply consists out of a function call + * into a externally defined function. That should guarantee compiler barrier + * semantics except for compilers that do inter translation unit/global + * optimization - those better provide an actual compiler barrier. + * + * Using a native compiler barrier for sure is a lot faster than this... + */ +#define PG_HAVE_COMPILER_BARRIER_EMULATION +extern void pg_extern_compiler_barrier(void); +#define pg_compiler_barrier_impl pg_extern_compiler_barrier +#endif + + /* * If we have atomics implementation for this platform fall back to providing * the atomics API using a spinlock to protect the internal state. Possibly