aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-i386/atomic.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@macmini.osdl.org>2006-07-08 15:24:18 -0700
committerLinus Torvalds <torvalds@macmini.osdl.org>2006-07-08 15:24:18 -0700
commitb862f3b099f3ea672c7438c0b282ce8201d39dfc (patch)
tree62f8cc2dc2b1c9abb6364b16f3b218a04d121f3e /include/asm-i386/atomic.h
parentpower: improve inline asm memory constraints (diff)
downloadlinux-dev-b862f3b099f3ea672c7438c0b282ce8201d39dfc.tar.xz
linux-dev-b862f3b099f3ea672c7438c0b282ce8201d39dfc.zip
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.h30
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)
{
__asm__ __volatile__(
LOCK_PREFIX "addl %1,%0"
- :"=m" (v->counter)
- :"ir" (i), "m" (v->counter));
+ :"+m" (v->counter)
+ :"ir" (i));
}
/**
@@ -61,8 +61,8 @@ static __inline__ void atomic_sub(int i, atomic_t *v)
{
__asm__ __volatile__(
LOCK_PREFIX "subl %1,%0"
- :"=m" (v->counter)
- :"ir" (i), "m" (v->counter));
+ :"+m" (v->counter)
+ :"ir" (i));
}
/**
@@ -80,8 +80,8 @@ static __inline__ int atomic_sub_and_test(int i, atomic_t *v)
__asm__ __volatile__(
LOCK_PREFIX "subl %2,%0; sete %1"
- :"=m" (v->counter), "=qm" (c)
- :"ir" (i), "m" (v->counter) : "memory");
+ :"+m" (v->counter), "=qm" (c)
+ :"ir" (i) : "memory");
return c;
}
@@ -95,8 +95,7 @@ static __inline__ void atomic_inc(atomic_t *v)
{
__asm__ __volatile__(
LOCK_PREFIX "incl %0"
- :"=m" (v->counter)
- :"m" (v->counter));
+ :"+m" (v->counter));
}
/**
@@ -109,8 +108,7 @@ static __inline__ void atomic_dec(atomic_t *v)
{
__asm__ __volatile__(
LOCK_PREFIX "decl %0"
- :"=m" (v->counter)
- :"m" (v->counter));
+ :"+m" (v->counter));
}
/**
@@ -127,8 +125,8 @@ static __inline__ int atomic_dec_and_test(atomic_t *v)
__asm__ __volatile__(
LOCK_PREFIX "decl %0; sete %1"
- :"=m" (v->counter), "=qm" (c)
- :"m" (v->counter) : "memory");
+ :"+m" (v->counter), "=qm" (c)
+ : : "memory");
return c != 0;
}
@@ -146,8 +144,8 @@ static __inline__ int atomic_inc_and_test(atomic_t *v)
__asm__ __volatile__(
LOCK_PREFIX "incl %0; sete %1"
- :"=m" (v->counter), "=qm" (c)
- :"m" (v->counter) : "memory");
+ :"+m" (v->counter), "=qm" (c)
+ : : "memory");
return c != 0;
}
@@ -166,8 +164,8 @@ static __inline__ int atomic_add_negative(int i, atomic_t *v)
__asm__ __volatile__(
LOCK_PREFIX "addl %2,%0; sets %1"
- :"=m" (v->counter), "=qm" (c)
- :"ir" (i), "m" (v->counter) : "memory");
+ :"+m" (v->counter), "=qm" (c)
+ :"ir" (i) : "memory");
return c;
}