From f010a05c7e9a23b6083294aff4a8183ab01f686e Mon Sep 17 00:00:00 2001 From: Hans Boehm Date: Sat, 9 Aug 2014 01:17:13 +0000 Subject: Revert "Revert "Revert "Remove incorrect android_atomic_...64 use.""" This reverts commit 66629e0de532376fa3ef43175ad05eccd21114da. Change-Id: Ic298b345d0e500d18e4297b00e755ce3340f13fb --- include/binder/Binder.h | 4 +--- libs/binder/Binder.cpp | 32 ++++++++++++++------------------ 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/include/binder/Binder.h b/include/binder/Binder.h index 86628a0..ba3ac4b 100644 --- a/include/binder/Binder.h +++ b/include/binder/Binder.h @@ -17,8 +17,6 @@ #ifndef ANDROID_BINDER_H #define ANDROID_BINDER_H -#include -#include #include // --------------------------------------------------------------------------- @@ -71,7 +69,7 @@ private: class Extras; - atomic_uintptr_t mExtras; // should be atomic + Extras* mExtras; void* mReserved0; }; diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp index d9d4971..71e62ab 100644 --- a/libs/binder/Binder.cpp +++ b/libs/binder/Binder.cpp @@ -16,7 +16,7 @@ #include -#include +#include #include #include #include @@ -71,8 +71,8 @@ public: // --------------------------------------------------------------------------- BBinder::BBinder() + : mExtras(NULL) { - atomic_init(&mExtras, 0); } bool BBinder::isBinderAlive() const @@ -139,19 +139,19 @@ void BBinder::attachObject( const void* objectID, void* object, void* cleanupCookie, object_cleanup_func func) { - Extras* e = reinterpret_cast( - atomic_load_explicit(&mExtras, memory_order_acquire)); + Extras* e = mExtras; if (!e) { e = new Extras; - uintptr_t* expected = 0; - if (!atomic_compare_exchange_strong_explicit( - &mExtras, &expected, - reinterpret_cast(e), - memory_order_release, - memory_order_acquire)) { +#ifdef __LP64__ + if (android_atomic_release_cas64(0, reinterpret_cast(e), + reinterpret_cast(&mExtras)) != 0) { +#else + if (android_atomic_cmpxchg(0, reinterpret_cast(e), + reinterpret_cast(&mExtras)) != 0) { +#endif delete e; - e = reinterpret_cast(expected); // Filled in by CAS + e = mExtras; } if (e == 0) return; // out of memory } @@ -162,8 +162,7 @@ void BBinder::attachObject( void* BBinder::findObject(const void* objectID) const { - Extras* e = reinterpret_cast( - atomic_load_explicit(&mExtras, memory_order_acquire)); + Extras* e = mExtras; if (!e) return NULL; AutoMutex _l(e->mLock); @@ -172,8 +171,7 @@ void* BBinder::findObject(const void* objectID) const void BBinder::detachObject(const void* objectID) { - Extras* e = reinterpret_cast( - atomic_load_explicit(&mExtras, memory_order_acquire)); + Extras* e = mExtras; if (!e) return; AutoMutex _l(e->mLock); @@ -187,9 +185,7 @@ BBinder* BBinder::localBinder() BBinder::~BBinder() { - Extras* e = reinterpret_cast( - atomic_load_explicit(&mExtras, memory_order_relaxed)); - if (e) delete e; + if (mExtras) delete mExtras; } -- cgit v1.1