PERFORCE change 72647 for review
John Baldwin
jhb at FreeBSD.org
Mon Mar 7 11:39:03 PST 2005
http://perforce.freebsd.org/chv.cgi?CH=72647
Change 72647 by jhb at jhb_slimer on 2005/03/07 19:38:05
- List memory addresses as both an input and an output rather than
using the + modifier with memory operands.
- Use alpha_wmb() rather than alpha_mb() for rel variants.
- Don't clobbery memory in each atomic op but only do it for acq
variants.
- Move the membar for acq variants before the operation. (This
probably has no affect, but I think this is more correct.)
Affected files ...
.. //depot/projects/smpng/sys/alpha/include/atomic.h#10 edit
Differences ...
==== //depot/projects/smpng/sys/alpha/include/atomic.h#10 (text+ko) ====
@@ -53,12 +53,11 @@
#ifdef __GNUC__
__asm __volatile (
"1:\tldl_l %0, %2\n\t" /* load old value */
- "bis %0, %3, %0\n\t" /* calculate new value */
+ "bis %0, %2, %0\n\t" /* calculate new value */
"stl_c %0, %1\n\t" /* attempt to store */
"beq %0, 1b\n" /* spin if failed */
: "=&r" (temp), "=m" (*p)
- : "m" (*p), "r" (v)
- : "memory");
+ : "r" (v), "m" (*p));
#endif
}
@@ -72,9 +71,8 @@
"bic %0, %2, %0\n\t" /* calculate new value */
"stl_c %0, %1\n\t" /* attempt to store */
"beq %0, 1b\n" /* spin if failed */
- : "=&r" (temp), "+m" (*p)
- : "r" (v)
- : "memory");
+ : "=&r" (temp), "=m" (*p)
+ : "r" (v), "m" (*p));
#endif
}
@@ -88,9 +86,8 @@
"addl %0, %2, %0\n\t" /* calculate new value */
"stl_c %0, %1\n\t" /* attempt to store */
"beq %0, 1b\n" /* spin if failed */
- : "=&r" (temp), "+m" (*p)
- : "r" (v)
- : "memory");
+ : "=&r" (temp), "=m" (*p)
+ : "r" (v), "m" (*p));
#endif
}
@@ -104,9 +101,8 @@
"subl %0, %2, %0\n\t" /* calculate new value */
"stl_c %0, %1\n\t" /* attempt to store */
"beq %0, 1b\n" /* spin if failed */
- : "=&r" (temp), "+m" (*p)
- : "r" (v)
- : "memory");
+ : "=&r" (temp), "=m" (*p)
+ : "r" (v), "m" (*p));
#endif
}
@@ -121,9 +117,8 @@
"ldiq %1,0\n\t" /* value to store */
"stl_c %1,%2\n\t" /* attempt to store */
"beq %1,1b\n" /* if the store failed, spin */
- : "=&r"(result), "=&r"(temp), "+m" (*addr)
- :
- : "memory");
+ : "=&r"(result), "=&r"(temp), "=m" (*addr)
+ : "m" (*addr));
#endif
return result;
@@ -139,9 +134,8 @@
"bis %0, %2, %0\n\t" /* calculate new value */
"stq_c %0, %1\n\t" /* attempt to store */
"beq %0, 1b\n" /* spin if failed */
- : "=&r" (temp), "+m" (*p)
- : "r" (v)
- : "memory");
+ : "=&r" (temp), "=m" (*p)
+ : "r" (v), "m" (*p));
#endif
}
@@ -155,9 +149,8 @@
"bic %0, %2, %0\n\t" /* calculate new value */
"stq_c %0, %1\n\t" /* attempt to store */
"beq %0, 1b\n" /* spin if failed */
- : "=&r" (temp), "+m" (*p)
- : "r" (v)
- : "memory");
+ : "=&r" (temp), "=m" (*p)
+ : "r" (v), "m" (*p));
#endif
}
@@ -171,9 +164,8 @@
"addq %0, %2, %0\n\t" /* calculate new value */
"stq_c %0, %1\n\t" /* attempt to store */
"beq %0, 1b\n" /* spin if failed */
- : "=&r" (temp), "+m" (*p)
- : "r" (v)
- : "memory");
+ : "=&r" (temp), "=m" (*p)
+ : "r" (v), "m" (*p));
#endif
}
@@ -187,9 +179,8 @@
"subq %0, %2, %0\n\t" /* calculate new value */
"stq_c %0, %1\n\t" /* attempt to store */
"beq %0, 1b\n" /* spin if failed */
- : "=&r" (temp), "+m" (*p)
- : "r" (v)
- : "memory");
+ : "=&r" (temp), "=m" (*p)
+ : "r" (v), "m" (*p));
#endif
}
@@ -205,8 +196,7 @@
"stq_c %1,%2\n\t" /* attempt to store */
"beq %1,1b\n" /* if the store failed, spin */
: "=&r"(result), "=&r"(temp), "+m" (*addr)
- :
- : "memory");
+ : "m" (*addr));
#endif
return result;
@@ -238,28 +228,30 @@
static __inline void \
atomic_##NAME##_acq_##WIDTH(volatile u_int##WIDTH##_t *p, u_int##WIDTH##_t v)\
{ \
+ alpha_mb(); \
+ __asm __volatile("" ::: "memory"); \
atomic_##NAME##_##WIDTH(p, v); \
- alpha_mb(); \
} \
\
static __inline void \
atomic_##NAME##_rel_##WIDTH(volatile u_int##WIDTH##_t *p, u_int##WIDTH##_t v)\
{ \
- alpha_mb(); \
+ alpha_wmb(); \
atomic_##NAME##_##WIDTH(p, v); \
} \
\
static __inline void \
atomic_##NAME##_acq_##TYPE(volatile u_int##WIDTH##_t *p, u_int##WIDTH##_t v)\
{ \
+ alpha_mb(); \
+ __asm __volatile("" ::: "memory"); \
atomic_##NAME##_##WIDTH(p, v); \
- alpha_mb(); \
} \
\
static __inline void \
atomic_##NAME##_rel_##TYPE(volatile u_int##WIDTH##_t *p, u_int##WIDTH##_t v)\
{ \
- alpha_mb(); \
+ alpha_wmb(); \
atomic_##NAME##_##WIDTH(p, v); \
}
@@ -291,31 +283,34 @@
{ \
u_##TYPE v; \
\
+ alpha_mb(); \
+ __asm __volatile("" ::: "memory"); \
v = *p; \
- alpha_mb(); \
return (v); \
} \
\
static __inline void \
atomic_store_rel_##WIDTH(volatile u_##TYPE *p, u_##TYPE v)\
{ \
- alpha_mb(); \
+ alpha_wmb(); \
*p = v; \
} \
+ \
static __inline u_##TYPE \
atomic_load_acq_##TYPE(volatile u_##TYPE *p) \
{ \
u_##TYPE v; \
\
+ alpha_mb(); \
+ __asm __volatile("" ::: "memory"); \
v = *p; \
- alpha_mb(); \
return (v); \
} \
\
static __inline void \
atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
{ \
- alpha_mb(); \
+ alpha_wmb(); \
*p = v; \
}
@@ -345,9 +340,8 @@
"stl_c %0, %1\n\t" /* attempt to store */
"beq %0, 1b\n\t" /* if it failed, spin */
"2:\n"
- : "=&r" (ret), "+m" (*p)
- : "r" ((long)(int)cmpval), "r" (newval)
- : "memory");
+ : "=&r" (ret), "=m" (*p)
+ : "r" ((long)(int)cmpval), "r" (newval), "m" (*p));
#endif
return ret;
@@ -372,9 +366,8 @@
"stq_c %0, %1\n\t" /* attempt to store */
"beq %0, 1b\n\t" /* if it failed, spin */
"2:\n"
- : "=&r" (ret), "+m" (*p)
- : "r" (cmpval), "r" (newval)
- : "memory");
+ : "=&r" (ret), "=m" (*p)
+ : "r" (cmpval), "r" (newval), "m" (*p));
#endif
return ret;
@@ -396,15 +389,16 @@
{
int retval;
+ alpha_mb();
+ __asm __volatile("" ::: "memory");
retval = atomic_cmpset_32(p, cmpval, newval);
- alpha_mb();
return (retval);
}
static __inline u_int32_t
atomic_cmpset_rel_32(volatile u_int32_t *p, u_int32_t cmpval, u_int32_t newval)
{
- alpha_mb();
+ alpha_wmb();
return (atomic_cmpset_32(p, cmpval, newval));
}
@@ -413,15 +407,16 @@
{
int retval;
+ alpha_mb();
+ __asm __volatile("" ::: "memory");
retval = atomic_cmpset_64(p, cmpval, newval);
- alpha_mb();
return (retval);
}
static __inline u_int64_t
atomic_cmpset_rel_64(volatile u_int64_t *p, u_int64_t cmpval, u_int64_t newval)
{
- alpha_mb();
+ alpha_wmb();
return (atomic_cmpset_64(p, cmpval, newval));
}
More information about the p4-projects
mailing list