diff options
| author | 2014-08-06 22:45:13 +0000 | |
|---|---|---|
| committer | 2014-08-06 22:45:13 +0000 | |
| commit | 9dc5c269f74ac76f62515e3d9558e67c6e63067d (patch) | |
| tree | 05d4d3a610c3671761ba5bfdf3a05ad85e96f583 /libs | |
| parent | 88b7541d682a6ad402eff15e58c9c792497096d7 (diff) | |
Revert "Remove incorrect android_atomic_...64 use."
This reverts commit 88b7541d682a6ad402eff15e58c9c792497096d7.
Change-Id: Ie701c308451a3697bb167aff119318b932133f90
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/binder/Binder.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp index d9d4971db9..71e62ab2b4 100644 --- a/libs/binder/Binder.cpp +++ b/libs/binder/Binder.cpp @@ -16,7 +16,7 @@ #include <binder/Binder.h> -#include <stdatomic.h> +#include <utils/Atomic.h> #include <utils/misc.h> #include <binder/BpBinder.h> #include <binder/IInterface.h> @@ -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<Extras*>( - 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<uintptr_t>(e), - memory_order_release, - memory_order_acquire)) { +#ifdef __LP64__ + if (android_atomic_release_cas64(0, reinterpret_cast<int64_t>(e), + reinterpret_cast<volatile int64_t*>(&mExtras)) != 0) { +#else + if (android_atomic_cmpxchg(0, reinterpret_cast<int32_t>(e), + reinterpret_cast<volatile int32_t*>(&mExtras)) != 0) { +#endif delete e; - e = reinterpret_cast<Extras*>(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<Extras*>( - 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<Extras*>( - 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<Extras*>( - atomic_load_explicit(&mExtras, memory_order_relaxed)); - if (e) delete e; + if (mExtras) delete mExtras; } |