From: Ivan Maidanski Date: Fri, 29 Mar 2013 03:31:06 +0000 (+0400) Subject: Fix asm constraints of primitives in sunc/x86.h X-Git-Tag: libatomic_ops-7_2e~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2dee407b5e0c589d4ca1fa6e4ad70860caed923d;p=libatomic_ops Fix asm constraints of primitives in sunc/x86.h (Apply commit 31df7fa from 'master' branch.) * src/atomic_ops/sysdeps/sunc/x86.h (AO_fetch_and_add_full, AO_char_fetch_and_add_full, AO_short_fetch_and_add_full, AO_or_full, AO_test_and_set_full, AO_compare_and_swap_full): Use "+m" asm constraint for *addr instead of "=m" (because the value pointed by addr is read and written by the code). Conflicts: src/atomic_ops/sysdeps/sunc/x86.h --- diff --git a/src/atomic_ops/sysdeps/sunc/x86.h b/src/atomic_ops/sysdeps/sunc/x86.h index ac1ee1e..fd8e132 100644 --- a/src/atomic_ops/sysdeps/sunc/x86.h +++ b/src/atomic_ops/sysdeps/sunc/x86.h @@ -59,7 +59,7 @@ AO_fetch_and_add_full (volatile AO_t *p, AO_t incr) AO_t result; __asm__ __volatile__ ("lock; xaddl %0, %1" : - "=r" (result), "=m" (*p) : "0" (incr) /* , "m" (*p) */ + "=r" (result), "+m" (*p) : "0" (incr) : "memory"); return result; } @@ -71,7 +71,7 @@ AO_char_fetch_and_add_full (volatile unsigned char *p, unsigned char incr) unsigned char result; __asm__ __volatile__ ("lock; xaddb %0, %1" : - "=q" (result), "=m" (*p) : "0" (incr) /* , "m" (*p) */ + "=q" (result), "+m" (*p) : "0" (incr) : "memory"); return result; } @@ -83,7 +83,7 @@ AO_short_fetch_and_add_full (volatile unsigned short *p, unsigned short incr) unsigned short result; __asm__ __volatile__ ("lock; xaddw %0, %1" : - "=r" (result), "=m" (*p) : "0" (incr) /* , "m" (*p) */ + "=r" (result), "+m" (*p) : "0" (incr) : "memory"); return result; } @@ -94,7 +94,7 @@ AO_INLINE void AO_or_full (volatile AO_t *p, AO_t incr) { __asm__ __volatile__ ("lock; orl %1, %0" : - "=m" (*p) : "r" (incr) /* , "m" (*p) */ + "+m" (*p) : "r" (incr) : "memory"); } #define AO_HAVE_or_full @@ -105,8 +105,8 @@ AO_test_and_set_full (volatile AO_TS_t *addr) AO_TS_t oldval; /* Note: the "xchg" instruction does not need a "lock" prefix */ __asm__ __volatile__ ("xchg %b0, %1" - : "=q"(oldval), "=m"(*addr) - : "0"(0xff) /* , "m"(*addr) */ + : "=q" (oldval), "+m" (*addr) + : "0" (0xff) : "memory"); return (AO_TS_VAL_t)oldval; } @@ -118,7 +118,7 @@ AO_compare_and_swap_full (volatile AO_t *addr, AO_t old, AO_t new_val) { char result; __asm__ __volatile__ ("lock; cmpxchgl %2, %0; setz %1" - : "=m"(*addr), "=a"(result) + : "+m" (*addr), "=a" (result) : "r" (new_val), "a"(old) : "memory"); return (int) result; }