Content-Length: 270609 | pFad | http://github.com/postgrespro/postgres/commit/e5603a2f35baa0bc9d61b16373383fdd37e49509

5C Mark x86's memory barrier inline assembly as clobbering the cpu flags. · postgrespro/postgres@e5603a2 · GitHub
Skip to content

Commit e5603a2

Browse files
committed
Mark x86's memory barrier inline assembly as clobbering the cpu flags.
x86's memory barrier assembly was marked as clobbering "memory" but not "cc" even though 'addl' sets various flags. As it turns out gcc on x86 implicitly assumes "cc" on every inline assembler statement, so it's not a bug. But as that's poorly documented and might get copied to architectures or compilers where that's not the case, it seems better to be precise. Discussion: 20140919100016.GH4277@alap3.anarazel.de To keep the code common, backpatch to 9.2 where explicit memory barriers were introduced.
1 parent afaefa1 commit e5603a2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/include/storage/barrier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ extern slock_t dummy_spinlock;
7575
* "lock; addl" has worked for longer than "mfence".
7676
*/
7777
#define pg_memory_barrier() \
78-
__asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
78+
__asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory", "cc")
7979
#define pg_read_barrier() pg_compiler_barrier()
8080
#define pg_write_barrier() pg_compiler_barrier()
8181
#elif defined(__x86_64__) /* 64 bit x86 */
@@ -89,7 +89,7 @@ extern slock_t dummy_spinlock;
8989
* do those things, a compiler barrier should be enough.
9090
*/
9191
#define pg_memory_barrier() \
92-
__asm__ __volatile__ ("lock; addl $0,0(%%rsp)" : : : "memory")
92+
__asm__ __volatile__ ("lock; addl $0,0(%%rsp)" : : : "memory", "cc")
9393
#define pg_read_barrier() pg_compiler_barrier()
9494
#define pg_write_barrier() pg_compiler_barrier()
9595
#elif defined(__ia64__) || defined(__ia64)

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/e5603a2f35baa0bc9d61b16373383fdd37e49509

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy