unsigned long new,
int size)
{
+ smp_mb();
if (!__int_cmpxchg(ptr, &old, new, size, false, 0))
ASSERT_UNREACHABLE();
-
- return old;
-}
-
-static always_inline unsigned long __cmpxchg_mb(volatile void *ptr,
- unsigned long old,
- unsigned long new, int size)
-{
- unsigned long ret;
-
- smp_mb();
- ret = __cmpxchg(ptr, old, new, size);
smp_mb();
- return ret;
+ return old;
}
/*
* The helper will return true when the update has succeeded (i.e no
* timeout) and false if the update has failed.
*/
-static always_inline bool __cmpxchg_mb_timeout(volatile void *ptr,
- unsigned long *old,
- unsigned long new,
- int size,
- unsigned int max_try)
+static always_inline bool __cmpxchg_timeout(volatile void *ptr,
+ unsigned long *old,
+ unsigned long new,
+ int size,
+ unsigned int max_try)
{
bool ret;
}
#define cmpxchg(ptr,o,n) \
- ((__typeof__(*(ptr)))__cmpxchg_mb((ptr), \
- (unsigned long)(o), \
- (unsigned long)(n), \
- sizeof(*(ptr))))
-
-#define cmpxchg_local(ptr,o,n) \
((__typeof__(*(ptr)))__cmpxchg((ptr), \
(unsigned long)(o), \
(unsigned long)(n), \
unsigned long new,
int size)
{
+ smp_mb();
if (!__int_cmpxchg(ptr, &old, new, size, false, 0))
ASSERT_UNREACHABLE();
-
- return old;
-}
-
-static always_inline unsigned long __cmpxchg_mb(volatile void *ptr,
- unsigned long old,
- unsigned long new, int size)
-{
- unsigned long ret;
-
- smp_mb();
- ret = __cmpxchg(ptr, old, new, size);
smp_mb();
- return ret;
+ return old;
}
/*
* The helper will return true when the update has succeeded (i.e no
* timeout) and false if the update has failed.
*/
-static always_inline bool __cmpxchg_mb_timeout(volatile void *ptr,
- unsigned long *old,
- unsigned long new,
- int size,
- unsigned int max_try)
+static always_inline bool __cmpxchg_timeout(volatile void *ptr,
+ unsigned long *old,
+ unsigned long new,
+ int size,
+ unsigned int max_try)
{
bool ret;
({ \
__typeof__(*(ptr)) __ret; \
__ret = (__typeof__(*(ptr))) \
- __cmpxchg_mb((ptr), (unsigned long)(o), (unsigned long)(n), \
- sizeof(*(ptr))); \
- __ret; \
-})
-
-#define cmpxchg_local(ptr, o, n) \
-({ \
- __typeof__(*(ptr)) __ret; \
- __ret = (__typeof__(*(ptr))) \
- __cmpxchg((ptr), (unsigned long)(o), \
- (unsigned long)(n), sizeof(*(ptr))); \
+ __cmpxchg((ptr), (unsigned long)(o), (unsigned long)(n), \
+ sizeof(*(ptr))); \
__ret; \
})
perfc_incr(atomics_guest);
- if ( __cmpxchg_mb_timeout(ptr, &oldval, new, size,
- this_cpu(guest_safe_atomic_max)) )
+ if ( __cmpxchg_timeout(ptr, &oldval, new, size,
+ this_cpu(guest_safe_atomic_max)) )
return oldval;
perfc_incr(atomics_guest_paused);
domain_pause_nosync(d);
- oldval = __cmpxchg_mb(ptr, old, new, size);
+ oldval = __cmpxchg(ptr, old, new, size);
domain_unpause(d);
return oldval;