From: Robert Haas Date: Fri, 13 Jul 2012 20:33:41 +0000 (-0400) Subject: Support dependency barriers. X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=cb3936febd8df34b2457958b22c7ddb65eed3426;p=users%2Frhaas%2Fpostgres.git Support dependency barriers. --- diff --git a/src/include/storage/barrier.h b/src/include/storage/barrier.h index 5037870991..09fc67305b 100644 --- a/src/include/storage/barrier.h +++ b/src/include/storage/barrier.h @@ -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 */