From d7dbc882d3deecee3c00cfe9fd50eb0903c5651a Mon Sep 17 00:00:00 2001 From: Tom Lane <tgl@sss.pgh.pa.us> Date: Fri, 15 Apr 2016 16:49:48 -0400 Subject: [PATCH] Sync 9.2 and 9.3 versions of barrier.h with 9.4's version. We weren't particularly maintaining barrier.h before 9.4, because nothing was using it in those branches. Well, nothing until commit 37de8de9e got back-patched. That broke 9.2 and 9.3 for some non-mainstream platforms that we haven't been testing in the buildfarm, including icc on ia64, HPPA, and Alpha. This commit effectively back-patches commits e5592c61a, 89779bf2c, and 747ca6697, though I did it just by copying the file (less copyright date updates) rather than by cherry-picking those commits. Per an attempt to run gaur and pademelon over old branches they've not been run on since ~2013. --- src/include/storage/barrier.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/include/storage/barrier.h b/src/include/storage/barrier.h index 33a6d4ee689..cde9cf7d0e3 100644 --- a/src/include/storage/barrier.h +++ b/src/include/storage/barrier.h @@ -53,7 +53,12 @@ extern slock_t dummy_spinlock; /* * icc defines __GNUC__, but doesn't support gcc's inline asm syntax */ +#if defined(__ia64__) || defined(__ia64) +#define pg_memory_barrier() __mf() +#elif defined(__i386__) || defined(__x86_64__) #define pg_memory_barrier() _mm_mfence() +#endif + #define pg_compiler_barrier() __memory_barrier() #elif defined(__GNUC__) @@ -112,8 +117,12 @@ extern slock_t dummy_spinlock; * read barrier to cover that case. We might need to add that later. */ #define pg_memory_barrier() __asm__ __volatile__ ("mb" : : : "memory") -#define pg_read_barrier() __asm__ __volatile__ ("rmb" : : : "memory") +#define pg_read_barrier() __asm__ __volatile__ ("mb" : : : "memory") #define pg_write_barrier() __asm__ __volatile__ ("wmb" : : : "memory") +#elif defined(__hppa) || defined(__hppa__) /* HP PA-RISC */ + +/* HPPA doesn't do either read or write reordering */ +#define pg_memory_barrier() pg_compiler_barrier() #elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) /* @@ -148,7 +157,7 @@ extern slock_t dummy_spinlock; * fence. But all of our actual implementations seem OK in this regard. */ #if !defined(pg_memory_barrier) -#define pg_memory_barrier(x) \ +#define pg_memory_barrier() \ do { S_LOCK(&dummy_spinlock); S_UNLOCK(&dummy_spinlock); } while (0) #endif -- GitLab