From 8c10ae99f831cad18194c571d5e44e22bb1001cd Mon Sep 17 00:00:00 2001 From: jkim Date: Wed, 21 Aug 2013 21:14:16 +0000 Subject: Use '+' modifier for a memory operand that is both an input and an output. It was actually done in r86301 but reverted in r150182 because GCC 3.x was not able to handle it for a memory operand. Apparently, this problem was fixed in GCC 4.1+ and several contrib sources already rely on this feature. --- sys/amd64/include/atomic.h | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) (limited to 'sys/amd64') diff --git a/sys/amd64/include/atomic.h b/sys/amd64/include/atomic.h index ef92c02..11e7b57 100644 --- a/sys/amd64/include/atomic.h +++ b/sys/amd64/include/atomic.h @@ -108,8 +108,8 @@ static __inline void \ atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ { \ __asm __volatile(MPLOCKED OP \ - : "=m" (*p) \ - : CONS (V), "m" (*p) \ + : "+m" (*p) \ + : CONS (V) \ : "cc"); \ } \ \ @@ -117,8 +117,8 @@ static __inline void \ atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ { \ __asm __volatile(MPLOCKED OP \ - : "=m" (*p) \ - : CONS (V), "m" (*p) \ + : "+m" (*p) \ + : CONS (V) \ : "memory", "cc"); \ } \ struct __hack @@ -142,10 +142,9 @@ atomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src) " sete %0 ; " "# atomic_cmpset_int" : "=a" (res), /* 0 */ - "=m" (*dst) /* 1 */ + "+m" (*dst) /* 1 */ : "r" (src), /* 2 */ - "a" (expect), /* 3 */ - "m" (*dst) /* 4 */ + "a" (expect) /* 3 */ : "memory", "cc"); return (res); @@ -162,10 +161,9 @@ atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src) " sete %0 ; " "# atomic_cmpset_long" : "=a" (res), /* 0 */ - "=m" (*dst) /* 1 */ + "+m" (*dst) /* 1 */ : "r" (src), /* 2 */ - "a" (expect), /* 3 */ - "m" (*dst) /* 4 */ + "a" (expect) /* 3 */ : "memory", "cc"); return (res); @@ -184,9 +182,8 @@ atomic_fetchadd_int(volatile u_int *p, u_int v) " xaddl %0,%1 ; " "# atomic_fetchadd_int" : "+r" (v), /* 0 */ - "=m" (*p) /* 1 */ - : "m" (*p) /* 2 */ - : "cc"); + "+m" (*p) /* 1 */ + : : "cc"); return (v); } @@ -203,9 +200,8 @@ atomic_fetchadd_long(volatile u_long *p, u_long v) " xaddq %0,%1 ; " "# atomic_fetchadd_long" : "+r" (v), /* 0 */ - "=m" (*p) /* 1 */ - : "m" (*p) /* 2 */ - : "cc"); + "+m" (*p) /* 1 */ + : : "cc"); return (v); } @@ -253,9 +249,8 @@ atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ \ __asm __volatile(MPLOCKED LOP \ : "=a" (res), /* 0 */ \ - "=m" (*p) /* 1 */ \ - : "m" (*p) /* 2 */ \ - : "memory", "cc"); \ + "+m" (*p) /* 1 */ \ + : : "memory", "cc"); \ \ return (res); \ } \ @@ -314,8 +309,7 @@ atomic_readandclear_int(volatile u_int *p) " xchgl %1,%0 ; " "# atomic_readandclear_int" : "+r" (res), /* 0 */ - "=m" (*p) /* 1 */ - : "m" (*p)); + "+m" (*p)); /* 1 */ return (res); } @@ -330,8 +324,7 @@ atomic_readandclear_long(volatile u_long *p) " xchgq %1,%0 ; " "# atomic_readandclear_long" : "+r" (res), /* 0 */ - "=m" (*p) /* 1 */ - : "m" (*p)); + "+m" (*p)); /* 1 */ return (res); } -- cgit v1.1