summaryrefslogtreecommitdiffstats
path: root/sys/amd64/include/atomic.h
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-12-18 08:51:34 +0000
committerjhb <jhb@FreeBSD.org>2001-12-18 08:51:34 +0000
commit6eb183d2d9131b2183bbb6e0fdd4330f15244475 (patch)
tree819ca5f9cf0f5453b0c9b5975ba33abd2a3ce38c /sys/amd64/include/atomic.h
parent9e9ee826ede46587dbd581b17a5a76b5a92a2fe5 (diff)
downloadFreeBSD-src-6eb183d2d9131b2183bbb6e0fdd4330f15244475.zip
FreeBSD-src-6eb183d2d9131b2183bbb6e0fdd4330f15244475.tar.gz
Allow the ATOMIC_ASM() macro to pass in the constraints on the V parameter
since the char versions need to use either ax, bx, cx, or dx. Submitted by: Peter Jeremy (mostly) Recommended by: bde
Diffstat (limited to 'sys/amd64/include/atomic.h')
-rw-r--r--sys/amd64/include/atomic.h46
1 files changed, 23 insertions, 23 deletions
diff --git a/sys/amd64/include/atomic.h b/sys/amd64/include/atomic.h
index 0da8133..88e7348 100644
--- a/sys/amd64/include/atomic.h
+++ b/sys/amd64/include/atomic.h
@@ -64,7 +64,7 @@
* This allows kernel modules to be portable between UP and SMP systems.
*/
#if defined(KLD_MODULE)
-#define ATOMIC_ASM(NAME, TYPE, OP, V) \
+#define ATOMIC_ASM(NAME, TYPE, OP, CONS, V) \
void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v);
int atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src);
@@ -94,13 +94,13 @@ void atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v);
* The assembly is volatilized to demark potential before-and-after side
* effects if an interrupt or SMP collision were to occur.
*/
-#define ATOMIC_ASM(NAME, TYPE, OP, V) \
+#define ATOMIC_ASM(NAME, TYPE, OP, CONS, V) \
static __inline void \
atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
{ \
__asm __volatile(MPLOCKED OP \
: "+m" (*p) \
- : "ir" (V)); \
+ : CONS (V)); \
}
/*
@@ -188,7 +188,7 @@ atomic_load_acq_##TYPE(volatile u_##TYPE *p) \
__asm __volatile(MPLOCKED LOP \
: "=a" (res), /* 0 (result) */\
"+m" (*p) /* 1 */ \
- : : "cc", "memory"); \
+ : : "memory"); \
\
return (res); \
} \
@@ -209,25 +209,25 @@ atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
#endif /* KLD_MODULE */
#if !defined(LOCORE)
-ATOMIC_ASM(set, char, "orb %b1,%0", v)
-ATOMIC_ASM(clear, char, "andb %b1,%0", ~v)
-ATOMIC_ASM(add, char, "addb %b1,%0", v)
-ATOMIC_ASM(subtract, char, "subb %b1,%0", v)
-
-ATOMIC_ASM(set, short, "orw %w1,%0", v)
-ATOMIC_ASM(clear, short, "andw %w1,%0", ~v)
-ATOMIC_ASM(add, short, "addw %w1,%0", v)
-ATOMIC_ASM(subtract, short, "subw %w1,%0", v)
-
-ATOMIC_ASM(set, int, "orl %1,%0", v)
-ATOMIC_ASM(clear, int, "andl %1,%0", ~v)
-ATOMIC_ASM(add, int, "addl %1,%0", v)
-ATOMIC_ASM(subtract, int, "subl %1,%0", v)
-
-ATOMIC_ASM(set, long, "orl %1,%0", v)
-ATOMIC_ASM(clear, long, "andl %1,%0", ~v)
-ATOMIC_ASM(add, long, "addl %1,%0", v)
-ATOMIC_ASM(subtract, long, "subl %1,%0", v)
+ATOMIC_ASM(set, char, "orb %b1,%0", "iq", v)
+ATOMIC_ASM(clear, char, "andb %b1,%0", "iq", ~v)
+ATOMIC_ASM(add, char, "addb %b1,%0", "iq", v)
+ATOMIC_ASM(subtract, char, "subb %b1,%0", "iq", v)
+
+ATOMIC_ASM(set, short, "orw %w1,%0", "ir", v)
+ATOMIC_ASM(clear, short, "andw %w1,%0", "ir", ~v)
+ATOMIC_ASM(add, short, "addw %w1,%0", "ir", v)
+ATOMIC_ASM(subtract, short, "subw %w1,%0", "ir", v)
+
+ATOMIC_ASM(set, int, "orl %1,%0", "ir", v)
+ATOMIC_ASM(clear, int, "andl %1,%0", "ir", ~v)
+ATOMIC_ASM(add, int, "addl %1,%0", "ir", v)
+ATOMIC_ASM(subtract, int, "subl %1,%0", "ir", v)
+
+ATOMIC_ASM(set, long, "orl %1,%0", "ir", v)
+ATOMIC_ASM(clear, long, "andl %1,%0", "ir", ~v)
+ATOMIC_ASM(add, long, "addl %1,%0", "ir", v)
+ATOMIC_ASM(subtract, long, "subl %1,%0", "ir", v)
ATOMIC_STORE_LOAD(char, "cmpxchgb %b0,%1", "xchgb %b1,%0")
ATOMIC_STORE_LOAD(short,"cmpxchgw %w0,%1", "xchgw %w1,%0")
OpenPOWER on IntegriCloud