Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Sync 9.2 and 9.3 versions of barrier.h with 9.4's version.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 15 Apr 2016 20:49:48 +0000 (16:49 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 15 Apr 2016 20:49:48 +0000 (16:49 -0400)
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 e5592c61a89779bf2c,
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

index de7ffdefb92aa67e6f779fbcf1403fe0f12c4a58..7480599ef84346db63d90c87c0f1c69e8d716124 100644 (file)
@@ -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