diff options
author | Linus Torvalds <torvalds@macmini.osdl.org> | 2006-07-08 18:24:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@macmini.osdl.org> | 2006-07-08 18:24:18 -0400 |
commit | b862f3b099f3ea672c7438c0b282ce8201d39dfc (patch) | |
tree | 62f8cc2dc2b1c9abb6364b16f3b218a04d121f3e /include/asm-i386/atomic.h | |
parent | e2a3d40258fe20d205f8ed592e1e2c0d5529c2e1 (diff) |
i386: improve and correct inline asm memory constraints
Use "+m" rather than a combination of "=m" and "m" for improved clarity
and consistency.
This also fixes some inlines that incorrectly didn't tell the compiler
that they read the old value at all, potentially causing the compiler to
generate bogus code. It appear that all of those potential bugs were
hidden by the use of extra "volatile" specifiers on the data structures
in question, though.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-i386/atomic.h')
-rw-r--r-- | include/asm-i386/atomic.h | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/include/asm-i386/atomic.h b/include/asm-i386/atomic.h index 4f061fa73794..51a166242522 100644 --- a/include/asm-i386/atomic.h +++ b/include/asm-i386/atomic.h | |||
@@ -46,8 +46,8 @@ static __inline__ void atomic_add(int i, atomic_t *v) | |||
46 | { | 46 | { |
47 | __asm__ __volatile__( | 47 | __asm__ __volatile__( |
48 | LOCK_PREFIX "addl %1,%0" | 48 | LOCK_PREFIX "addl %1,%0" |
49 | :"=m" (v->counter) | 49 | :"+m" (v->counter) |
50 | :"ir" (i), "m" (v->counter)); | 50 | :"ir" (i)); |
51 | } | 51 | } |
52 | 52 | ||
53 | /** | 53 | /** |
@@ -61,8 +61,8 @@ static __inline__ void atomic_sub(int i, atomic_t *v) | |||
61 | { | 61 | { |
62 | __asm__ __volatile__( | 62 | __asm__ __volatile__( |
63 | LOCK_PREFIX "subl %1,%0" | 63 | LOCK_PREFIX "subl %1,%0" |
64 | :"=m" (v->counter) | 64 | :"+m" (v->counter) |
65 | :"ir" (i), "m" (v->counter)); | 65 | :"ir" (i)); |
66 | } | 66 | } |
67 | 67 | ||
68 | /** | 68 | /** |
@@ -80,8 +80,8 @@ static __inline__ int atomic_sub_and_test(int i, atomic_t *v) | |||
80 | 80 | ||
81 | __asm__ __volatile__( | 81 | __asm__ __volatile__( |
82 | LOCK_PREFIX "subl %2,%0; sete %1" | 82 | LOCK_PREFIX "subl %2,%0; sete %1" |
83 | :"=m" (v->counter), "=qm" (c) | 83 | :"+m" (v->counter), "=qm" (c) |
84 | :"ir" (i), "m" (v->counter) : "memory"); | 84 | :"ir" (i) : "memory"); |
85 | return c; | 85 | return c; |
86 | } | 86 | } |
87 | 87 | ||
@@ -95,8 +95,7 @@ static __inline__ void atomic_inc(atomic_t *v) | |||
95 | { | 95 | { |
96 | __asm__ __volatile__( | 96 | __asm__ __volatile__( |
97 | LOCK_PREFIX "incl %0" | 97 | LOCK_PREFIX "incl %0" |
98 | :"=m" (v->counter) | 98 | :"+m" (v->counter)); |
99 | :"m" (v->counter)); | ||
100 | } | 99 | } |
101 | 100 | ||
102 | /** | 101 | /** |
@@ -109,8 +108,7 @@ static __inline__ void atomic_dec(atomic_t *v) | |||
109 | { | 108 | { |
110 | __asm__ __volatile__( | 109 | __asm__ __volatile__( |
111 | LOCK_PREFIX "decl %0" | 110 | LOCK_PREFIX "decl %0" |
112 | :"=m" (v->counter) | 111 | :"+m" (v->counter)); |
113 | :"m" (v->counter)); | ||
114 | } | 112 | } |
115 | 113 | ||
116 | /** | 114 | /** |
@@ -127,8 +125,8 @@ static __inline__ int atomic_dec_and_test(atomic_t *v) | |||
127 | 125 | ||
128 | __asm__ __volatile__( | 126 | __asm__ __volatile__( |
129 | LOCK_PREFIX "decl %0; sete %1" | 127 | LOCK_PREFIX "decl %0; sete %1" |
130 | :"=m" (v->counter), "=qm" (c) | 128 | :"+m" (v->counter), "=qm" (c) |
131 | :"m" (v->counter) : "memory"); | 129 | : : "memory"); |
132 | return c != 0; | 130 | return c != 0; |
133 | } | 131 | } |
134 | 132 | ||
@@ -146,8 +144,8 @@ static __inline__ int atomic_inc_and_test(atomic_t *v) | |||
146 | 144 | ||
147 | __asm__ __volatile__( | 145 | __asm__ __volatile__( |
148 | LOCK_PREFIX "incl %0; sete %1" | 146 | LOCK_PREFIX "incl %0; sete %1" |
149 | :"=m" (v->counter), "=qm" (c) | 147 | :"+m" (v->counter), "=qm" (c) |
150 | :"m" (v->counter) : "memory"); | 148 | : : "memory"); |
151 | return c != 0; | 149 | return c != 0; |
152 | } | 150 | } |
153 | 151 | ||
@@ -166,8 +164,8 @@ static __inline__ int atomic_add_negative(int i, atomic_t *v) | |||
166 | 164 | ||
167 | __asm__ __volatile__( | 165 | __asm__ __volatile__( |
168 | LOCK_PREFIX "addl %2,%0; sets %1" | 166 | LOCK_PREFIX "addl %2,%0; sets %1" |
169 | :"=m" (v->counter), "=qm" (c) | 167 | :"+m" (v->counter), "=qm" (c) |
170 | :"ir" (i), "m" (v->counter) : "memory"); | 168 | :"ir" (i) : "memory"); |
171 | return c; | 169 | return c; |
172 | } | 170 | } |
173 | 171 | ||