diff --git a/include/cutils/atomic-arm.h b/include/cutils/atomic-arm.h index 004cc0cea..16fe51242 100644 --- a/include/cutils/atomic-arm.h +++ b/include/cutils/atomic-arm.h @@ -145,38 +145,6 @@ extern inline int android_atomic_release_cas(int32_t old_value, } -#if defined(__thumb__) -extern int32_t android_atomic_swap(int32_t new_value, - volatile int32_t *ptr); -#elif defined(__ARM_HAVE_LDREX_STREX) -extern inline int32_t android_atomic_swap(int32_t new_value, - volatile int32_t *ptr) -{ - int32_t prev, status; - do { - __asm__ __volatile__ ("ldrex %0, [%3]\n" - "strex %1, %4, [%3]" - : "=&r" (prev), "=&r" (status), "+m" (*ptr) - : "r" (ptr), "r" (new_value) - : "cc"); - } while (__builtin_expect(status != 0, 0)); - android_memory_barrier(); - return prev; -} -#else -extern inline int32_t android_atomic_swap(int32_t new_value, - volatile int32_t *ptr) -{ - int32_t prev; - __asm__ __volatile__ ("swp %0, %2, [%3]" - : "=&r" (prev), "+m" (*ptr) - : "r" (new_value), "r" (ptr) - : "cc"); - android_memory_barrier(); - return prev; -} -#endif - #if defined(__thumb__) extern int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr); diff --git a/include/cutils/atomic-x86.h b/include/cutils/atomic-x86.h index bce23ade6..438012e50 100644 --- a/include/cutils/atomic-x86.h +++ b/include/cutils/atomic-x86.h @@ -98,17 +98,6 @@ extern inline int android_atomic_release_cas(int32_t old_value, return android_atomic_cas(old_value, new_value, ptr); } -extern inline int32_t android_atomic_swap(int32_t new_value, - volatile int32_t *ptr) -{ - __asm__ __volatile__ ("xchgl %1, %0" - : "=r" (new_value) - : "m" (*ptr), "0" (new_value) - : "memory"); - /* new_value now holds the old value of *ptr */ - return new_value; -} - extern inline int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr) { diff --git a/include/cutils/atomic.h b/include/cutils/atomic.h index a50bf0fe5..ae42eb8a0 100644 --- a/include/cutils/atomic.h +++ b/include/cutils/atomic.h @@ -89,13 +89,6 @@ int32_t android_atomic_release_load(volatile const int32_t* addr); void android_atomic_acquire_store(int32_t value, volatile int32_t* addr); void android_atomic_release_store(int32_t value, volatile int32_t* addr); -/* - * Unconditional swap operation with release ordering. - * - * Stores the new value at *addr, and returns the previous value. - */ -int32_t android_atomic_swap(int32_t value, volatile int32_t* addr); - /* * Compare-and-set operation with "acquire" or "release" ordering. * diff --git a/libcutils/atomic-android-sh.c b/libcutils/atomic-android-sh.c index f8f1f57bd..8bac68ad3 100644 --- a/libcutils/atomic-android-sh.c +++ b/libcutils/atomic-android-sh.c @@ -113,18 +113,6 @@ int32_t android_atomic_or(int32_t value, volatile int32_t* addr) { return oldValue; } -int32_t android_atomic_acquire_swap(int32_t value, volatile int32_t* addr) { - return android_atomic_release_swap(value, addr); -} - -int32_t android_atomic_release_swap(int32_t value, volatile int32_t* addr) { - int32_t oldValue; - do { - oldValue = *addr; - } while (android_atomic_cmpxchg(oldValue, value, addr)); - return oldValue; -} - int android_atomic_acquire_cmpxchg(int32_t oldvalue, int32_t newvalue, volatile int32_t* addr) { return android_atomic_release_cmpxchg(oldValue, newValue, addr);