diff options
author | Hans Boehm <hboehm@google.com> | 2014-07-16 12:13:16 -0700 |
---|---|---|
committer | Hans Boehm <hboehm@google.com> | 2014-07-31 15:44:16 -0700 |
commit | e6fa1b7fdc74bec3292d6a10c99f25f9fd989d3f (patch) | |
tree | 06b39ec27ac3c54b02d1dde99b3be297e29cfe81 /services/audioflinger/StateQueue.cpp | |
parent | 3c6fac2c807e4234953dcdc793029a82d1f3a089 (diff) | |
download | frameworks_av-e6fa1b7fdc74bec3292d6a10c99f25f9fd989d3f.zip frameworks_av-e6fa1b7fdc74bec3292d6a10c99f25f9fd989d3f.tar.gz frameworks_av-e6fa1b7fdc74bec3292d6a10c99f25f9fd989d3f.tar.bz2 |
Remove 64-bit android_atomic uses from StateQueue.
Use stdatomic.h instead. We're trying to remove android_atomic use
wherever possible. The 64-bit uses seem easiest to remove first.
This cleans up the code, though not as much as C++ <atomic> would,
if it worked everywhere.
(cherry picked from commit f39b560952d3706a7ff47ef0d82c1a836daeea42)
Change-Id: I3c29bdbd5915cb9d47118834a3a742fe296cf87f
Diffstat (limited to 'services/audioflinger/StateQueue.cpp')
-rw-r--r-- | services/audioflinger/StateQueue.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/services/audioflinger/StateQueue.cpp b/services/audioflinger/StateQueue.cpp index 7e01c9f..40d7bcd 100644 --- a/services/audioflinger/StateQueue.cpp +++ b/services/audioflinger/StateQueue.cpp @@ -41,13 +41,14 @@ void StateQueueMutatorDump::dump(int fd) // Constructor and destructor template<typename T> StateQueue<T>::StateQueue() : - mNext(NULL), mAck(NULL), mCurrent(NULL), + mAck(NULL), mCurrent(NULL), mMutating(&mStates[0]), mExpecting(NULL), mInMutation(false), mIsDirty(false), mIsInitialized(false) #ifdef STATE_QUEUE_DUMP , mObserverDump(&mObserverDummyDump), mMutatorDump(&mMutatorDummyDump) #endif { + atomic_init(&mNext, 0); } template<typename T> StateQueue<T>::~StateQueue() @@ -58,11 +59,8 @@ template<typename T> StateQueue<T>::~StateQueue() template<typename T> const T* StateQueue<T>::poll() { -#ifdef __LP64__ - const T *next = (const T *) android_atomic_acquire_load64((volatile int64_t *) &mNext); -#else - const T *next = (const T *) android_atomic_acquire_load((volatile int32_t *) &mNext); -#endif + const T *next = (const T *) atomic_load_explicit(&mNext, memory_order_acquire); + if (next != mCurrent) { mAck = next; // no additional barrier needed mCurrent = next; @@ -144,11 +142,7 @@ template<typename T> bool StateQueue<T>::push(StateQueue<T>::block_t block) } // publish -#ifdef __LP64__ - android_atomic_release_store64((int64_t) mMutating, (volatile int64_t *) &mNext); -#else - android_atomic_release_store((int32_t) mMutating, (volatile int32_t *) &mNext); -#endif + atomic_store_explicit(&mNext, (uintptr_t)mMutating, memory_order_release); mExpecting = mMutating; // copy with circular wraparound |