From 9959ed953069ac9a7f08bebd2df55440e9370c0f Mon Sep 17 00:00:00 2001 From: Hans Boehm Date: Thu, 31 Jul 2014 15:56:50 -0700 Subject: [PATCH] Remove android_... store_barriers and 64-bit atomics. These are no longer used, and we want to strongly discourage future use. Keep the 32-bit variants while there are still uses. All users should move to C11 or C++11 atomics. Change-Id: I122b541cfd29ef4a6c932647f85d0d6a9d802061 --- include/cutils/atomic-arm.h | 9 ----- include/cutils/atomic-arm64.h | 58 ------------------------------- include/cutils/atomic-inline.h | 6 ---- include/cutils/atomic-mips.h | 8 ----- include/cutils/atomic-mips64.h | 57 ------------------------------- include/cutils/atomic-x86.h | 8 ----- include/cutils/atomic-x86_64.h | 62 ---------------------------------- include/cutils/atomic.h | 17 ---------- 8 files changed, 225 deletions(-) diff --git a/include/cutils/atomic-arm.h b/include/cutils/atomic-arm.h index 172a0cde5..6b031b678 100644 --- a/include/cutils/atomic-arm.h +++ b/include/cutils/atomic-arm.h @@ -37,15 +37,6 @@ extern ANDROID_ATOMIC_INLINE void android_memory_barrier() #endif } -extern ANDROID_ATOMIC_INLINE void android_memory_store_barrier() -{ -#if ANDROID_SMP == 0 - android_compiler_barrier(); -#else - __asm__ __volatile__ ("dmb st" : : : "memory"); -#endif -} - extern ANDROID_ATOMIC_INLINE int32_t android_atomic_acquire_load(volatile const int32_t *ptr) { diff --git a/include/cutils/atomic-arm64.h b/include/cutils/atomic-arm64.h index ba5a218ae..7ae47d7b5 100644 --- a/include/cutils/atomic-arm64.h +++ b/include/cutils/atomic-arm64.h @@ -51,11 +51,6 @@ void android_memory_barrier(void) { __asm__ __volatile__ ("dmb ish" : : : "memory"); } -extern ANDROID_ATOMIC_INLINE -void android_memory_store_barrier(void) -{ - __asm__ __volatile__ ("dmb ishst" : : : "memory"); -} extern ANDROID_ATOMIC_INLINE int32_t android_atomic_acquire_load(volatile const int32_t *ptr) @@ -65,14 +60,6 @@ int32_t android_atomic_acquire_load(volatile const int32_t *ptr) return value; } -extern ANDROID_ATOMIC_INLINE -int64_t android_atomic_acquire_load64(volatile const int64_t *ptr) -{ - int64_t value = *ptr; - android_memory_barrier(); - return value; -} - extern ANDROID_ATOMIC_INLINE int32_t android_atomic_release_load(volatile const int32_t *ptr) { @@ -80,13 +67,6 @@ int32_t android_atomic_release_load(volatile const int32_t *ptr) return *ptr; } -extern ANDROID_ATOMIC_INLINE -int64_t android_atomic_release_load64(volatile const int64_t *ptr) -{ - android_memory_barrier(); - return *ptr; -} - extern ANDROID_ATOMIC_INLINE void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) { @@ -94,13 +74,6 @@ void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) android_memory_barrier(); } -extern ANDROID_ATOMIC_INLINE -void android_atomic_acquire_store64(int64_t value, volatile int64_t *ptr) -{ - *ptr = value; - android_memory_barrier(); -} - extern ANDROID_ATOMIC_INLINE void android_atomic_release_store(int32_t value, volatile int32_t *ptr) { @@ -108,13 +81,6 @@ void android_atomic_release_store(int32_t value, volatile int32_t *ptr) *ptr = value; } -extern ANDROID_ATOMIC_INLINE -void android_atomic_release_store64(int64_t value, volatile int64_t *ptr) -{ - android_memory_barrier(); - *ptr = value; -} - extern ANDROID_ATOMIC_INLINE int android_atomic_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr) @@ -122,13 +88,6 @@ int android_atomic_cas(int32_t old_value, int32_t new_value, return __sync_val_compare_and_swap(ptr, old_value, new_value) != old_value; } -extern ANDROID_ATOMIC_INLINE -int64_t android_atomic_cas64(int64_t old_value, int64_t new_value, - volatile int64_t *ptr) -{ - return __sync_val_compare_and_swap(ptr, old_value, new_value) != old_value; -} - extern ANDROID_ATOMIC_INLINE int android_atomic_acquire_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr) @@ -138,15 +97,6 @@ int android_atomic_acquire_cas(int32_t old_value, int32_t new_value, return status; } -extern ANDROID_ATOMIC_INLINE -int64_t android_atomic_acquire_cas64(int64_t old_value, int64_t new_value, - volatile int64_t *ptr) -{ - int status = android_atomic_cas64(old_value, new_value, ptr); - android_memory_barrier(); - return status; -} - extern ANDROID_ATOMIC_INLINE int android_atomic_release_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr) @@ -155,14 +105,6 @@ int android_atomic_release_cas(int32_t old_value, int32_t new_value, return android_atomic_cas(old_value, new_value, ptr); } -extern ANDROID_ATOMIC_INLINE -int64_t android_atomic_release_cas64(int64_t old_value, int64_t new_value, - volatile int64_t *ptr) -{ - android_memory_barrier(); - return android_atomic_cas64(old_value, new_value, ptr); -} - extern ANDROID_ATOMIC_INLINE int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr) { diff --git a/include/cutils/atomic-inline.h b/include/cutils/atomic-inline.h index 007a9053b..a31e91357 100644 --- a/include/cutils/atomic-inline.h +++ b/include/cutils/atomic-inline.h @@ -65,12 +65,6 @@ extern "C" { #define ANDROID_MEMBAR_FULL android_memory_barrier #endif -#if ANDROID_SMP == 0 -#define ANDROID_MEMBAR_STORE android_compiler_barrier -#else -#define ANDROID_MEMBAR_STORE android_memory_store_barrier -#endif - #ifdef __cplusplus } #endif diff --git a/include/cutils/atomic-mips.h b/include/cutils/atomic-mips.h index 1ed833de3..5d4f097fe 100644 --- a/include/cutils/atomic-mips.h +++ b/include/cutils/atomic-mips.h @@ -33,19 +33,11 @@ extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) { android_compiler_barrier(); } -extern ANDROID_ATOMIC_INLINE void android_memory_store_barrier(void) -{ - android_compiler_barrier(); -} #else extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) { __asm__ __volatile__ ("sync" : : : "memory"); } -extern ANDROID_ATOMIC_INLINE void android_memory_store_barrier(void) -{ - __asm__ __volatile__ ("sync" : : : "memory"); -} #endif extern ANDROID_ATOMIC_INLINE int32_t diff --git a/include/cutils/atomic-mips64.h b/include/cutils/atomic-mips64.h index 6215621e9..9d8f65e5f 100644 --- a/include/cutils/atomic-mips64.h +++ b/include/cutils/atomic-mips64.h @@ -32,10 +32,6 @@ extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) { __asm__ __volatile__ ("sync" : : : "memory"); } -extern ANDROID_ATOMIC_INLINE void android_memory_store_barrier(void) -{ - __asm__ __volatile__ ("sync" : : : "memory"); -} extern ANDROID_ATOMIC_INLINE int32_t android_atomic_acquire_load(volatile const int32_t *ptr) @@ -45,14 +41,6 @@ int32_t android_atomic_acquire_load(volatile const int32_t *ptr) return value; } -extern ANDROID_ATOMIC_INLINE -int64_t android_atomic_acquire_load64(volatile const int64_t *ptr) -{ - int64_t value = *ptr; - android_memory_barrier(); - return value; -} - extern ANDROID_ATOMIC_INLINE int32_t android_atomic_release_load(volatile const int32_t *ptr) { @@ -60,13 +48,6 @@ int32_t android_atomic_release_load(volatile const int32_t *ptr) return *ptr; } -extern ANDROID_ATOMIC_INLINE -int64_t android_atomic_release_load64(volatile const int64_t *ptr) -{ - android_memory_barrier(); - return *ptr; -} - extern ANDROID_ATOMIC_INLINE void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) { @@ -74,13 +55,6 @@ void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) android_memory_barrier(); } -extern ANDROID_ATOMIC_INLINE -void android_atomic_acquire_store64(int64_t value, volatile int64_t *ptr) -{ - *ptr = value; - android_memory_barrier(); -} - extern ANDROID_ATOMIC_INLINE void android_atomic_release_store(int32_t value, volatile int32_t *ptr) { @@ -88,13 +62,6 @@ void android_atomic_release_store(int32_t value, volatile int32_t *ptr) *ptr = value; } -extern ANDROID_ATOMIC_INLINE -void android_atomic_release_store64(int64_t value, volatile int64_t *ptr) -{ - android_memory_barrier(); - *ptr = value; -} - extern ANDROID_ATOMIC_INLINE int android_atomic_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr) { @@ -114,13 +81,6 @@ int android_atomic_cas(int32_t old_value, int32_t new_value, volatile int32_t *p return prev != old_value; } -extern ANDROID_ATOMIC_INLINE -int64_t android_atomic_cas64(int64_t old_value, int64_t new_value, - volatile int64_t *ptr) -{ - return __sync_val_compare_and_swap(ptr, old_value, new_value) != old_value; -} - extern ANDROID_ATOMIC_INLINE int android_atomic_acquire_cas(int32_t old_value, int32_t new_value, @@ -131,15 +91,6 @@ int android_atomic_acquire_cas(int32_t old_value, return status; } -extern ANDROID_ATOMIC_INLINE -int64_t android_atomic_acquire_cas64(int64_t old_value, int64_t new_value, - volatile int64_t *ptr) -{ - int status = android_atomic_cas64(old_value, new_value, ptr); - android_memory_barrier(); - return status; -} - extern ANDROID_ATOMIC_INLINE int android_atomic_release_cas(int32_t old_value, int32_t new_value, @@ -149,14 +100,6 @@ int android_atomic_release_cas(int32_t old_value, return android_atomic_cas(old_value, new_value, ptr); } -extern ANDROID_ATOMIC_INLINE -int64_t android_atomic_release_cas64(int64_t old_value, int64_t new_value, - volatile int64_t *ptr) -{ - android_memory_barrier(); - return android_atomic_cas64(old_value, new_value, ptr); -} - extern ANDROID_ATOMIC_INLINE 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 9480f57fe..06bf1a3a1 100644 --- a/include/cutils/atomic-x86.h +++ b/include/cutils/atomic-x86.h @@ -33,19 +33,11 @@ extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) { android_compiler_barrier(); } -extern ANDROID_ATOMIC_INLINE void android_memory_store_barrier(void) -{ - android_compiler_barrier(); -} #else extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) { __asm__ __volatile__ ("mfence" : : : "memory"); } -extern ANDROID_ATOMIC_INLINE void android_memory_store_barrier(void) -{ - android_compiler_barrier(); -} #endif extern ANDROID_ATOMIC_INLINE int32_t diff --git a/include/cutils/atomic-x86_64.h b/include/cutils/atomic-x86_64.h index 025ba1910..99cb070f1 100644 --- a/include/cutils/atomic-x86_64.h +++ b/include/cutils/atomic-x86_64.h @@ -46,11 +46,6 @@ void android_memory_barrier(void) { __asm__ __volatile__ ("mfence" : : : "memory"); } -extern ANDROID_ATOMIC_INLINE -void android_memory_store_barrier(void) -{ - android_compiler_barrier(); -} extern ANDROID_ATOMIC_INLINE int32_t android_atomic_acquire_load(volatile const int32_t *ptr) @@ -60,14 +55,6 @@ int32_t android_atomic_acquire_load(volatile const int32_t *ptr) return value; } -extern ANDROID_ATOMIC_INLINE -int64_t android_atomic_acquire_load64(volatile const int64_t *ptr) -{ - int64_t value = *ptr; - android_compiler_barrier(); - return value; -} - extern ANDROID_ATOMIC_INLINE int32_t android_atomic_release_load(volatile const int32_t *ptr) { @@ -75,13 +62,6 @@ int32_t android_atomic_release_load(volatile const int32_t *ptr) return *ptr; } -extern ANDROID_ATOMIC_INLINE -int64_t android_atomic_release_load64(volatile const int64_t *ptr) -{ - android_memory_barrier(); - return *ptr; -} - extern ANDROID_ATOMIC_INLINE void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) { @@ -89,13 +69,6 @@ void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) android_memory_barrier(); } -extern ANDROID_ATOMIC_INLINE -void android_atomic_acquire_store64(int64_t value, volatile int64_t *ptr) -{ - *ptr = value; - android_memory_barrier(); -} - extern ANDROID_ATOMIC_INLINE void android_atomic_release_store(int32_t value, volatile int32_t *ptr) { @@ -103,13 +76,6 @@ void android_atomic_release_store(int32_t value, volatile int32_t *ptr) *ptr = value; } -extern ANDROID_ATOMIC_INLINE -void android_atomic_release_store64(int64_t value, volatile int64_t *ptr) -{ - android_compiler_barrier(); - *ptr = value; -} - extern ANDROID_ATOMIC_INLINE int android_atomic_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr) @@ -122,18 +88,6 @@ int android_atomic_cas(int32_t old_value, int32_t new_value, return prev != old_value; } -extern ANDROID_ATOMIC_INLINE -int64_t android_atomic_cas64(int64_t old_value, int64_t new_value, - volatile int64_t *ptr) -{ - int64_t prev; - __asm__ __volatile__ ("lock; cmpxchgq %1, %2" - : "=a" (prev) - : "q" (new_value), "m" (*ptr), "0" (old_value) - : "memory"); - return prev != old_value; -} - extern ANDROID_ATOMIC_INLINE int android_atomic_acquire_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr) @@ -142,14 +96,6 @@ int android_atomic_acquire_cas(int32_t old_value, int32_t new_value, return android_atomic_cas(old_value, new_value, ptr); } -extern ANDROID_ATOMIC_INLINE -int64_t android_atomic_acquire_cas64(int64_t old_value, int64_t new_value, - volatile int64_t *ptr) -{ - /* Loads are not reordered with other loads. */ - return android_atomic_cas64(old_value, new_value, ptr); -} - extern ANDROID_ATOMIC_INLINE int android_atomic_release_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr) @@ -158,14 +104,6 @@ int android_atomic_release_cas(int32_t old_value, int32_t new_value, return android_atomic_cas(old_value, new_value, ptr); } -extern ANDROID_ATOMIC_INLINE -int64_t android_atomic_release_cas64(int64_t old_value, int64_t new_value, - volatile int64_t *ptr) -{ - /* Stores are not reordered with other stores. */ - return android_atomic_cas64(old_value, new_value, ptr); -} - extern ANDROID_ATOMIC_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 b9b18c44f..79409a7d8 100644 --- a/include/cutils/atomic.h +++ b/include/cutils/atomic.h @@ -103,11 +103,6 @@ int32_t android_atomic_or(int32_t value, volatile int32_t* addr); int32_t android_atomic_acquire_load(volatile const int32_t* addr); int32_t android_atomic_release_load(volatile const int32_t* addr); -#if defined (__LP64__) -int64_t android_atomic_acquire_load64(volatile const int64_t* addr); -int64_t android_atomic_release_load64(volatile const int64_t* addr); -#endif - /* * Perform an atomic store with "acquire" or "release" ordering. * @@ -125,11 +120,6 @@ int64_t android_atomic_release_load64(volatile const int64_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); -#if defined (__LP64__) -void android_atomic_acquire_store64(int64_t value, volatile int64_t* addr); -void android_atomic_release_store64(int64_t value, volatile int64_t* addr); -#endif - /* * Compare-and-set operation with "acquire" or "release" ordering. * @@ -147,13 +137,6 @@ int android_atomic_acquire_cas(int32_t oldvalue, int32_t newvalue, int android_atomic_release_cas(int32_t oldvalue, int32_t newvalue, volatile int32_t* addr); -#if defined (__LP64__) -int64_t android_atomic_acquire_cas64(int64_t old_value, int64_t new_value, - volatile int64_t *ptr); -int64_t android_atomic_release_cas64(int64_t old_value, int64_t new_value, - volatile int64_t *ptr); -#endif - /* * Aliases for code using an older version of this header. These are now * deprecated and should not be used. The definitions will be removed