am c98e2365
: Merge "Fix implementation of generic atomic operations"
* commit 'c98e2365cdd0c2330711118b689171df143f6399': Fix implementation of generic atomic operations
This commit is contained in:
commit
860dc7e25d
@ -47,20 +47,20 @@ __BEGIN_DECLS
|
||||
#define __ATOMIC_INLINE__ static __inline__ __attribute__((always_inline))
|
||||
|
||||
__ATOMIC_INLINE__ int
|
||||
__atomic_cmpxchg(int old, int _new, volatile int *ptr)
|
||||
__atomic_cmpxchg(int old_value, int new_value, volatile int* ptr)
|
||||
{
|
||||
/* We must return 0 on success */
|
||||
return __sync_val_compare_and_swap(ptr, old, _new) != old;
|
||||
return __sync_val_compare_and_swap(ptr, old_value, new_value) != old_value;
|
||||
}
|
||||
|
||||
__ATOMIC_INLINE__ int
|
||||
__atomic_swap(int _new, volatile int *ptr)
|
||||
__atomic_swap(int new_value, volatile int *ptr)
|
||||
{
|
||||
int prev;
|
||||
int old_value;
|
||||
do {
|
||||
prev = *ptr;
|
||||
} while (__sync_val_compare_and_swap(ptr, prev, _new) != prev);
|
||||
return prev;
|
||||
old_value = *ptr;
|
||||
} while (__sync_val_compare_and_swap(ptr, old_value, new_value) != old_value);
|
||||
return old_value;
|
||||
}
|
||||
|
||||
__ATOMIC_INLINE__ int
|
||||
|
@ -31,18 +31,17 @@ __ATOMIC_INLINE__ int
|
||||
__bionic_cmpxchg(int32_t old_value, int32_t new_value, volatile int32_t* ptr)
|
||||
{
|
||||
/* We must return 0 on success */
|
||||
return __sync_bool_compare_and_swap(ptr, old_value, new_value) == 0;
|
||||
return __sync_val_compare_and_swap(ptr, old_value, new_value) != old_value;
|
||||
}
|
||||
|
||||
__ATOMIC_INLINE__ int32_t
|
||||
__bionic_swap(int32_t new_value, volatile int32_t* ptr)
|
||||
{
|
||||
int32_t prev;
|
||||
int32_t old_value;
|
||||
do {
|
||||
prev = *ptr;
|
||||
status = __sync_val_compare_and_swap(ptr, prev, new_value);
|
||||
} while (status == 0);
|
||||
return prev;
|
||||
old_value = *ptr;
|
||||
} while (__sync_val_compare_and_swap(ptr, old_value, new_value) != old_value);
|
||||
return old_value;
|
||||
}
|
||||
|
||||
__ATOMIC_INLINE__ int32_t
|
||||
|
Loading…
Reference in New Issue
Block a user