summaryrefslogtreecommitdiffstats
path: root/sys/i386
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2009-10-09 15:51:40 +0000
committerattilio <attilio@FreeBSD.org>2009-10-09 15:51:40 +0000
commit615a58802f06ef3e957ea7ecc91290dbcc5b0157 (patch)
treed6ad44aa37bf891c77a3d73ac0b8862e1d1ec5d1 /sys/i386
parent98d1caad622f502d371da7167c39347470e2d3a7 (diff)
downloadFreeBSD-src-615a58802f06ef3e957ea7ecc91290dbcc5b0157.zip
FreeBSD-src-615a58802f06ef3e957ea7ecc91290dbcc5b0157.tar.gz
atomic_cmpset_barr_* was added in order to cope with compilers willing to
specify their own version of atomic_cmpset_* which could have been different than the membar version. Right now, however, FreeBSD is bound mostly to GCC-like compilers and it is desired to add new support and compat shim mostly when there is a real necessity, in order to avoid too much compatibility bloats. In this optic, bring back atomic_cmpset_{acq, rel}_* to be the same as atomic_cmpset_* and unwind the atomic_cmpset_barr_* introduction. Requested by: jhb Reviewed by: jhb Tested by: Giovanni Trematerra <giovanni dot trematerra at gmail dot com>
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/include/atomic.h112
1 files changed, 48 insertions, 64 deletions
diff --git a/sys/i386/include/atomic.h b/sys/i386/include/atomic.h
index b60f2a1..b00eb45 100644
--- a/sys/i386/include/atomic.h
+++ b/sys/i386/include/atomic.h
@@ -77,7 +77,6 @@ void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v); \
void atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##TYPE v)
int atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src);
-int atomic_cmpset_barr_int(volatile u_int *dst, u_int exp, u_int src);
u_int atomic_fetchadd_int(volatile u_int *p, u_int v);
#define ATOMIC_STORE_LOAD(TYPE, LOP, SOP) \
@@ -130,62 +129,55 @@ struct __hack
#ifdef CPU_DISABLE_CMPXCHG
-#define DEFINE_CMPSET_GEN(NAME) \
-static __inline int \
-atomic_cmpset_##NAME(volatile u_int *dst, u_int exp, u_int src)\
-{ \
- u_char res; \
- \
- __asm __volatile( \
- " pushfl ; " \
- " cli ; " \
- " cmpl %3,%4 ; " \
- " jne 1f ; " \
- " movl %2,%1 ; " \
- "1: " \
- " sete %0 ; " \
- " popfl ; " \
- "# atomic_cmpset_##NAME" \
- : "=q" (res), /* 0 */ \
- "=m" (*dst) /* 1 */ \
- : "r" (src), /* 2 */ \
- "r" (exp), /* 3 */ \
- "m" (*dst) /* 4 */ \
- : "memory"); \
- \
- return (res); \
-} \
-struct __hack
+static __inline int
+atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src)
+{
+ u_char res;
+
+ __asm __volatile(
+ " pushfl ; "
+ " cli ; "
+ " cmpl %3,%4 ; "
+ " jne 1f ; "
+ " movl %2,%1 ; "
+ "1: "
+ " sete %0 ; "
+ " popfl ; "
+ "# atomic_cmpset_int"
+ : "=q" (res), /* 0 */
+ "=m" (*dst) /* 1 */
+ : "r" (src), /* 2 */
+ "r" (exp), /* 3 */
+ "m" (*dst) /* 4 */
+ : "memory");
+
+ return (res);
+}
#else /* !CPU_DISABLE_CMPXCHG */
-#define DEFINE_CMPSET_GEN(NAME) \
-static __inline int \
-atomic_cmpset_##NAME(volatile u_int *dst, u_int exp, u_int src)\
-{ \
- u_char res; \
- \
- __asm __volatile( \
- " " MPLOCKED " " \
- " cmpxchgl %2,%1 ; " \
- " sete %0 ; " \
- "1: " \
- "# atomic_cmpset_##NAME" \
- : "=a" (res), /* 0 */ \
- "=m" (*dst) /* 1 */ \
- : "r" (src), /* 2 */ \
- "a" (exp), /* 3 */ \
- "m" (*dst) /* 4 */ \
- : "memory"); \
- \
- return (res); \
-} \
-struct __hack
+static __inline int
+atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src)
+{
+ u_char res;
-#endif /* CPU_DISABLE_CMPXCHG */
+ __asm __volatile(
+ " " MPLOCKED " "
+ " cmpxchgl %2,%1 ; "
+ " sete %0 ; "
+ "1: "
+ "# atomic_cmpset_int"
+ : "=a" (res), /* 0 */
+ "=m" (*dst) /* 1 */
+ : "r" (src), /* 2 */
+ "a" (exp), /* 3 */
+ "m" (*dst) /* 4 */
+ : "memory");
+
+ return (res);
+}
-DEFINE_CMPSET_GEN(int);
-DEFINE_CMPSET_GEN(barr_int);
+#endif /* CPU_DISABLE_CMPXCHG */
/*
* Atomically add the value of v to the integer pointed to by p and return
@@ -307,14 +299,6 @@ atomic_cmpset_long(volatile u_long *dst, u_long exp, u_long src)
(u_int)src));
}
-static __inline int
-atomic_cmpset_barr_long(volatile u_long *dst, u_long exp, u_long src)
-{
-
- return (atomic_cmpset_barr_int((volatile u_int *)dst, (u_int)exp,
- (u_int)src));
-}
-
static __inline u_long
atomic_fetchadd_long(volatile u_long *p, u_long v)
{
@@ -390,8 +374,8 @@ u_long atomic_readandclear_long(volatile u_long *addr);
#define atomic_add_rel_int atomic_add_barr_int
#define atomic_subtract_acq_int atomic_subtract_barr_int
#define atomic_subtract_rel_int atomic_subtract_barr_int
-#define atomic_cmpset_acq_int atomic_cmpset_barr_int
-#define atomic_cmpset_rel_int atomic_cmpset_barr_int
+#define atomic_cmpset_acq_int atomic_cmpset_int
+#define atomic_cmpset_rel_int atomic_cmpset_int
#define atomic_set_acq_long atomic_set_barr_long
#define atomic_set_rel_long atomic_set_barr_long
@@ -401,8 +385,8 @@ u_long atomic_readandclear_long(volatile u_long *addr);
#define atomic_add_rel_long atomic_add_barr_long
#define atomic_subtract_acq_long atomic_subtract_barr_long
#define atomic_subtract_rel_long atomic_subtract_barr_long
-#define atomic_cmpset_acq_long atomic_cmpset_barr_long
-#define atomic_cmpset_rel_long atomic_cmpset_barr_long
+#define atomic_cmpset_acq_long atomic_cmpset_long
+#define atomic_cmpset_rel_long atomic_cmpset_long
/* Operations on 8-bit bytes. */
#define atomic_set_8 atomic_set_char
OpenPOWER on IntegriCloud