diff options
author | Chris Dearman <chris@mips.com> | 2012-07-23 17:30:04 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2012-07-24 13:56:38 -0700 |
commit | 958dad705a8c2c191e4352547fc9950c4feaa9fb (patch) | |
tree | 1c73bc42b0aafd48ea3b8317427939f3d4b970b7 /libc/private | |
parent | 344aca8ced2522074f799439e201226377d02dba (diff) | |
download | bionic-958dad705a8c2c191e4352547fc9950c4feaa9fb.zip bionic-958dad705a8c2c191e4352547fc9950c4feaa9fb.tar.gz bionic-958dad705a8c2c191e4352547fc9950c4feaa9fb.tar.bz2 |
Fix implementation of generic atomic operations
Change-Id: Ie1ea5aacc561e2d6d40125d2952ed0e9116b7b0d
Diffstat (limited to 'libc/private')
-rw-r--r-- | libc/private/bionic_atomic_gcc_builtin.h | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/libc/private/bionic_atomic_gcc_builtin.h b/libc/private/bionic_atomic_gcc_builtin.h index e7c5761..2919f7f 100644 --- a/libc/private/bionic_atomic_gcc_builtin.h +++ b/libc/private/bionic_atomic_gcc_builtin.h @@ -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 |