Support dependency barriers.
authorRobert Haas <rhaas@postgresql.org>
Fri, 13 Jul 2012 20:33:41 +0000 (16:33 -0400)
committerRobert Haas <rhaas@postgresql.org>
Tue, 24 Jul 2012 16:31:53 +0000 (12:31 -0400)
src/include/storage/barrier.h

index 50378709917049fde75e7ff7a2ffecf2bfd5c879..09fc67305b3b4954513fc6b5d14cb59af69d35b9 100644 (file)
@@ -39,6 +39,10 @@ extern slock_t dummy_spinlock;
  * barrier.  In practice, on machines with strong memory ordering, read and
  * write barriers may require nothing more than a compiler barrier.
  *
+ * A dependency barrier need do nothing at all, except on machines that
+ * allow dependent loads to be reordered.  On such machines, it must be defined
+ * as a read barrier.
+ *
  * For an introduction to using memory barriers within the PostgreSQL backend,
  * see src/backend/storage/lmgr/README.barrier
  */
@@ -108,12 +112,13 @@ extern slock_t dummy_spinlock;
 
 /*
  * Unlike all other known architectures, Alpha allows dependent reads to be
- * reordered, but we don't currently find it necessary to provide a conditional
- * read barrier to cover that case.  We might need to add that later.
+ * reordered, so we define pg_read_barrier_depends() as pg_read_barrier().
  */
 #define pg_memory_barrier()            __asm__ __volatile__ ("mb" : : : "memory")
 #define pg_read_barrier()              __asm__ __volatile__ ("rmb" : : : "memory")
+#define pg_read_barrier_depends() pg_read_barrier()
 #define pg_write_barrier()             __asm__ __volatile__ ("wmb" : : : "memory")
+
 #elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
 
 /*
@@ -167,4 +172,12 @@ extern slock_t dummy_spinlock;
 #define pg_write_barrier()                     pg_memory_barrier()
 #endif
 
+/*
+ * If dependency barriers are undefined, we define them as a no-op.  The only
+ * known platform where anything more is required is DEC Alpha.
+ */
+#if !defined(pg_read_barrier_depends)
+#define pg_read_barrier_depends()
+#endif
+
 #endif   /* BARRIER_H */