diff options
author | Chris Robinson <[email protected]> | 2018-11-19 03:21:58 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-19 03:21:58 -0800 |
commit | e24435ef58b2f28555e6397f502f41f36524dac9 (patch) | |
tree | 5b828032fff7d64a2d613a40e7dac09cc5c05840 | |
parent | c5142530d675885415c9168869eb6c125ce10876 (diff) |
Remove the atomic exchange macros
-rw-r--r-- | Alc/alc.cpp | 29 | ||||
-rw-r--r-- | Alc/alu.cpp | 23 | ||||
-rw-r--r-- | Alc/backends/jack.cpp | 2 | ||||
-rw-r--r-- | Alc/backends/null.cpp | 3 | ||||
-rw-r--r-- | Alc/backends/opensl.cpp | 2 | ||||
-rw-r--r-- | Alc/backends/qsa.cpp | 2 | ||||
-rw-r--r-- | Alc/backends/sndio.cpp | 4 | ||||
-rw-r--r-- | Alc/backends/solaris.cpp | 2 | ||||
-rw-r--r-- | Alc/backends/wave.cpp | 3 | ||||
-rw-r--r-- | OpenAL32/alAuxEffectSlot.cpp | 18 | ||||
-rw-r--r-- | OpenAL32/alError.cpp | 8 | ||||
-rw-r--r-- | OpenAL32/alListener.cpp | 10 | ||||
-rw-r--r-- | OpenAL32/alSource.cpp | 16 | ||||
-rw-r--r-- | OpenAL32/alState.cpp | 10 | ||||
-rw-r--r-- | OpenAL32/event.cpp | 12 | ||||
-rw-r--r-- | common/atomic.h | 10 |
16 files changed, 67 insertions, 87 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index 6bb632f7..879dba00 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -1614,7 +1614,7 @@ void ALCcontext_DeferUpdates(ALCcontext *context) void ALCcontext_ProcessUpdates(ALCcontext *context) { almtx_lock(&context->PropLock); - if(ATOMIC_EXCHANGE_SEQ(&context->DeferUpdates, AL_FALSE)) + if(context->DeferUpdates.exchange(AL_FALSE)) { /* Tell the mixer to stop applying updates, then wait for any active * updating to finish, before providing updates. @@ -1623,9 +1623,9 @@ void ALCcontext_ProcessUpdates(ALCcontext *context) while((ATOMIC_LOAD(&context->UpdateCount, almemory_order_acquire)&1) != 0) althrd_yield(); - if(!ATOMIC_EXCHANGE(&context->PropsClean, AL_TRUE, almemory_order_acq_rel)) + if(!context->PropsClean.exchange(AL_TRUE, std::memory_order_acq_rel)) UpdateContextProps(context); - if(!ATOMIC_EXCHANGE(&context->Listener.PropsClean, AL_TRUE, almemory_order_acq_rel)) + if(!context->Listener.PropsClean.exchange(AL_TRUE, std::memory_order_acq_rel)) UpdateListenerProps(context); UpdateAllEffectSlotProps(context); UpdateAllSourceProps(context); @@ -2330,11 +2330,10 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) * auxiliary sends is changing. Active sources will have updates * respecified in UpdateAllSourceProps. */ - vprops = ATOMIC_EXCHANGE(&context->FreeVoiceProps, static_cast<ALvoiceProps*>(nullptr), - almemory_order_acq_rel); + vprops = context->FreeVoiceProps.exchange(nullptr, std::memory_order_acq_rel); while(vprops) { - struct ALvoiceProps *next = ATOMIC_LOAD(&vprops->next, almemory_order_relaxed); + struct ALvoiceProps *next = vprops->next.load(std::memory_order_relaxed); al_free(vprops); vprops = next; } @@ -2344,10 +2343,9 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) { ALvoice *voice = context->Voices[pos]; - al_free(ATOMIC_EXCHANGE(&voice->Update, static_cast<ALvoiceProps*>(nullptr), - almemory_order_acq_rel)); + al_free(voice->Update.exchange(nullptr, std::memory_order_acq_rel)); - if(ATOMIC_LOAD(&voice->Source, almemory_order_acquire) == nullptr) + if(voice->Source.load(std::memory_order_acquire) == nullptr) continue; if(device->AvgSpeakerDist > 0.0f) @@ -2698,7 +2696,7 @@ static bool ReleaseContext(ALCcontext *context, ALCdevice *device) V0(device->Backend,lock)(); origctx = context; newhead = ATOMIC_LOAD(&context->next, almemory_order_relaxed); - if(!ATOMIC_COMPARE_EXCHANGE_STRONG_SEQ(&device->ContextList, &origctx, newhead)) + if(!device->ContextList.compare_exchange_strong(origctx, newhead)) { ALCcontext *list; do { @@ -2707,7 +2705,7 @@ static bool ReleaseContext(ALCcontext *context, ALCdevice *device) */ list = origctx; origctx = context; - } while(!ATOMIC_COMPARE_EXCHANGE_STRONG_SEQ(&list->next, &origctx, newhead)); + } while(!list->next.compare_exchange_strong(origctx, newhead)); } else ret = !!newhead; @@ -2893,7 +2891,7 @@ ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device) if(VerifyDevice(&device)) { - errorCode = ATOMIC_EXCHANGE_SEQ(&device->LastError, ALC_NO_ERROR); + errorCode = device->LastError.exchange(ALC_NO_ERROR); ALCdevice_DecRef(device); } else @@ -3720,8 +3718,7 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin ALCcontext *head = ATOMIC_LOAD_SEQ(&device->ContextList); do { ATOMIC_STORE(&ALContext->next, head, almemory_order_relaxed); - } while(ATOMIC_COMPARE_EXCHANGE_WEAK_SEQ(&device->ContextList, &head, - ALContext) == 0); + } while(!device->ContextList.compare_exchange_weak(head, ALContext)); } almtx_unlock(&device->BackendLock); @@ -4068,7 +4065,7 @@ ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device) do { list = origdev; origdev = device; - } while(!ATOMIC_COMPARE_EXCHANGE_STRONG_SEQ(&list->next, &origdev, nextdev)); + } while(!list->next.compare_exchange_strong(origdev, nextdev)); } listlock.unlock(); @@ -4188,7 +4185,7 @@ ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device) do { list = origdev; origdev = device; - } while(!ATOMIC_COMPARE_EXCHANGE_STRONG_SEQ(&list->next, &origdev, nextdev)); + } while(!list->next.compare_exchange_strong(origdev, nextdev)); } listlock.unlock(); diff --git a/Alc/alu.cpp b/Alc/alu.cpp index e26f5f57..f9a53139 100644 --- a/Alc/alu.cpp +++ b/Alc/alu.cpp @@ -75,7 +75,7 @@ static HrtfDirectMixerFunc MixDirectHrtf = MixDirectHrtf_C; void DeinitVoice(ALvoice *voice) { - al_free(ATOMIC_EXCHANGE_SEQ(&voice->Update, static_cast<ALvoiceProps*>(nullptr))); + al_free(voice->Update.exchange(nullptr)); } @@ -315,8 +315,7 @@ static bool CalcContextParams(ALCcontext *Context) ALlistener &Listener = Context->Listener; struct ALcontextProps *props; - props = ATOMIC_EXCHANGE(&Context->Update, static_cast<ALcontextProps*>(nullptr), - almemory_order_acq_rel); + props = Context->Update.exchange(nullptr, std::memory_order_acq_rel); if(!props) return false; Listener.Params.MetersPerUnit = props->MetersPerUnit; @@ -341,8 +340,7 @@ static bool CalcListenerParams(ALCcontext *Context) struct ALlistenerProps *props; aluVector vel; - props = ATOMIC_EXCHANGE(&Listener.Update, static_cast<ALlistenerProps*>(nullptr), - almemory_order_acq_rel); + props = Listener.Update.exchange(nullptr, std::memory_order_acq_rel); if(!props) return false; /* AT then UP */ @@ -385,8 +383,7 @@ static bool CalcEffectSlotParams(ALeffectslot *slot, ALCcontext *context, bool f struct ALeffectslotProps *props; ALeffectState *state; - props = ATOMIC_EXCHANGE(&slot->Update, static_cast<ALeffectslotProps*>(nullptr), - almemory_order_acq_rel); + props = slot->Update.exchange(nullptr, std::memory_order_acq_rel); if(!props && !force) return false; if(props) @@ -1455,8 +1452,7 @@ static void CalcSourceParams(ALvoice *voice, ALCcontext *context, bool force) ALbufferlistitem *BufferListItem; struct ALvoiceProps *props; - props = ATOMIC_EXCHANGE(&voice->Update, static_cast<ALvoiceProps*>(nullptr), - almemory_order_acq_rel); + props = voice->Update.exchange(nullptr, std::memory_order_acq_rel); if(!props && !force) return; if(props) @@ -1830,7 +1826,7 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...) va_list args; int msglen; - if(!ATOMIC_EXCHANGE(&device->Connected, AL_FALSE, almemory_order_acq_rel)) + if(!device->Connected.exchange(AL_FALSE, std::memory_order_acq_rel)) return; evt.u.user.type = AL_EVENT_TYPE_DISCONNECTED_SOFT; @@ -1857,9 +1853,8 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...) for(i = 0;i < ctx->VoiceCount;i++) { ALvoice *voice = ctx->Voices[i]; - ALsource *source = ATOMIC_EXCHANGE(&voice->Source, static_cast<ALsource*>(nullptr), - almemory_order_relaxed); - if(source && ATOMIC_LOAD(&voice->Playing, almemory_order_relaxed)) + ALsource *source = voice->Source.exchange(nullptr, std::memory_order_relaxed); + if(source && voice->Playing.load(std::memory_order_relaxed)) { /* If the source's voice was playing, it's now effectively * stopped (the source state will be updated the next time it's @@ -1867,7 +1862,7 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...) */ SendSourceStoppedEvent(ctx, source->id); } - ATOMIC_STORE(&voice->Playing, false, almemory_order_release); + voice->Playing.store(false, std::memory_order_release); } ctx = ATOMIC_LOAD(&ctx->next, almemory_order_relaxed); diff --git a/Alc/backends/jack.cpp b/Alc/backends/jack.cpp index c72958e7..924e1926 100644 --- a/Alc/backends/jack.cpp +++ b/Alc/backends/jack.cpp @@ -488,7 +488,7 @@ static void ALCjackPlayback_stop(ALCjackPlayback *self) { int res; - if(ATOMIC_EXCHANGE(&self->killNow, AL_TRUE, almemory_order_acq_rel)) + if(self->killNow.exchange(AL_TRUE, std::memory_order_acq_rel)) return; alsem_post(&self->Sem); diff --git a/Alc/backends/null.cpp b/Alc/backends/null.cpp index 255aa01f..47ebd0ae 100644 --- a/Alc/backends/null.cpp +++ b/Alc/backends/null.cpp @@ -168,8 +168,7 @@ ALCboolean ALCnullBackend_start(ALCnullBackend *self) void ALCnullBackend_stop(ALCnullBackend *self) { - if(ATOMIC_EXCHANGE(&self->killNow, AL_TRUE, almemory_order_acq_rel) || - !self->thread.joinable()) + if(self->killNow.exchange(AL_TRUE, std::memory_order_acq_rel) || !self->thread.joinable()) return; self->thread.join(); } diff --git a/Alc/backends/opensl.cpp b/Alc/backends/opensl.cpp index d0b1a7b1..0eb194e0 100644 --- a/Alc/backends/opensl.cpp +++ b/Alc/backends/opensl.cpp @@ -610,7 +610,7 @@ static void ALCopenslPlayback_stop(ALCopenslPlayback *self) SLresult result; int res; - if(ATOMIC_EXCHANGE_SEQ(&self->mKillNow, AL_TRUE)) + if(self->mKillNow.exchange(AL_TRUE)) return; alsem_post(&self->mSem); diff --git a/Alc/backends/qsa.cpp b/Alc/backends/qsa.cpp index 9803d77d..09082357 100644 --- a/Alc/backends/qsa.cpp +++ b/Alc/backends/qsa.cpp @@ -614,7 +614,7 @@ static void qsa_stop_playback(PlaybackWrapper *self) qsa_data *data = self->ExtraData; int res; - if(ATOMIC_EXCHANGE(&data->killNow, AL_TRUE, almemory_order_acq_rel)) + if(data->killNow.exchange(AL_TRUE, std::memory_order_acq_rel)) return; althrd_join(data->thread, &res); } diff --git a/Alc/backends/sndio.cpp b/Alc/backends/sndio.cpp index 958bc2ff..cc5eacbe 100644 --- a/Alc/backends/sndio.cpp +++ b/Alc/backends/sndio.cpp @@ -267,7 +267,7 @@ static void SndioPlayback_stop(SndioPlayback *self) { int res; - if(ATOMIC_EXCHANGE(&self->killNow, AL_TRUE, almemory_order_acq_rel)) + if(self->killNow.exchange(AL_TRUE, std::memory_order_acq_rel)) return; althrd_join(self->thread, &res); @@ -513,7 +513,7 @@ static void SndioCapture_stop(SndioCapture *self) { int res; - if(ATOMIC_EXCHANGE(&self->killNow, AL_TRUE, almemory_order_acq_rel)) + if(self->killNow.exchange(AL_TRUE, std::memory_order_acq_rel)) return; althrd_join(self->thread, &res); diff --git a/Alc/backends/solaris.cpp b/Alc/backends/solaris.cpp index 86120491..c757e5e1 100644 --- a/Alc/backends/solaris.cpp +++ b/Alc/backends/solaris.cpp @@ -282,7 +282,7 @@ static void ALCsolarisBackend_stop(ALCsolarisBackend *self) { int res; - if(ATOMIC_EXCHANGE_SEQ(&self->killNow, AL_TRUE)) + if(self->killNow.exchange(AL_TRUE)) return; althrd_join(self->thread, &res); diff --git a/Alc/backends/wave.cpp b/Alc/backends/wave.cpp index 3f8d8c97..83af40a8 100644 --- a/Alc/backends/wave.cpp +++ b/Alc/backends/wave.cpp @@ -367,8 +367,7 @@ ALCboolean ALCwaveBackend_start(ALCwaveBackend *self) void ALCwaveBackend_stop(ALCwaveBackend *self) { - if(ATOMIC_EXCHANGE(&self->killNow, AL_TRUE, almemory_order_acq_rel) || - !self->thread.joinable()) + if(self->killNow.exchange(AL_TRUE, std::memory_order_acq_rel) || !self->thread.joinable()) return; self->thread.join(); diff --git a/OpenAL32/alAuxEffectSlot.cpp b/OpenAL32/alAuxEffectSlot.cpp index 9c11720e..ff0f7eaa 100644 --- a/OpenAL32/alAuxEffectSlot.cpp +++ b/OpenAL32/alAuxEffectSlot.cpp @@ -618,7 +618,7 @@ static void AddActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontex newarray->count = newcount; } - curarray = ATOMIC_EXCHANGE(&context->ActiveAuxSlots, newarray, almemory_order_acq_rel); + curarray = context->ActiveAuxSlots.exchange(newarray, std::memory_order_acq_rel); while((ATOMIC_LOAD(&device->MixCount, almemory_order_acquire)&1)) althrd_yield(); al_free(curarray); @@ -653,7 +653,7 @@ static void RemoveActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcon /* TODO: Could reallocate newarray now that we know it's needed size. */ - curarray = ATOMIC_EXCHANGE(&context->ActiveAuxSlots, newarray, almemory_order_acq_rel); + curarray = context->ActiveAuxSlots.exchange(newarray, std::memory_order_acq_rel); while((ATOMIC_LOAD(&device->MixCount, almemory_order_acquire)&1)) althrd_yield(); al_free(curarray); @@ -693,16 +693,16 @@ void UpdateEffectSlotProps(ALeffectslot *slot, ALCcontext *context) ALeffectState *oldstate; /* Get an unused property container, or allocate a new one as needed. */ - props = ATOMIC_LOAD(&context->FreeEffectslotProps, almemory_order_relaxed); + props = context->FreeEffectslotProps.load(std::memory_order_relaxed); if(!props) props = static_cast<ALeffectslotProps*>(al_calloc(16, sizeof(*props))); else { struct ALeffectslotProps *next; do { - next = ATOMIC_LOAD(&props->next, almemory_order_relaxed); - } while(ATOMIC_COMPARE_EXCHANGE_WEAK(&context->FreeEffectslotProps, &props, next, - almemory_order_seq_cst, almemory_order_acquire) == 0); + next = props->next.load(std::memory_order_relaxed); + } while(context->FreeEffectslotProps.compare_exchange_weak(props, next, + std::memory_order_seq_cst, std::memory_order_acquire) == 0); } /* Copy in current property values. */ @@ -719,7 +719,7 @@ void UpdateEffectSlotProps(ALeffectslot *slot, ALCcontext *context) props->State = slot->Effect.State; /* Set the new container for updating internal parameters. */ - props = ATOMIC_EXCHANGE(&slot->Update, props, almemory_order_acq_rel); + props = slot->Update.exchange(props, std::memory_order_acq_rel); if(props) { /* If there was an unused update container, put it back in the @@ -741,11 +741,11 @@ void UpdateAllEffectSlotProps(ALCcontext *context) ALsizei i; LockEffectSlotList(context); - auxslots = ATOMIC_LOAD(&context->ActiveAuxSlots, almemory_order_acquire); + auxslots = context->ActiveAuxSlots.load(std::memory_order_acquire); for(i = 0;i < auxslots->count;i++) { ALeffectslot *slot = auxslots->slot[i]; - if(!ATOMIC_EXCHANGE(&slot->PropsClean, AL_TRUE, almemory_order_acq_rel)) + if(!slot->PropsClean.exchange(AL_TRUE, std::memory_order_acq_rel)) UpdateEffectSlotProps(slot, context); } UnlockEffectSlotList(context); diff --git a/OpenAL32/alError.cpp b/OpenAL32/alError.cpp index 6d8ca882..16c89273 100644 --- a/OpenAL32/alError.cpp +++ b/OpenAL32/alError.cpp @@ -70,11 +70,11 @@ void alSetError(ALCcontext *context, ALenum errorCode, const char *msg, ...) } ALenum curerr{AL_NO_ERROR}; - ATOMIC_COMPARE_EXCHANGE_STRONG_SEQ(&context->LastError, &curerr, errorCode); - if((ATOMIC_LOAD(&context->EnabledEvts, almemory_order_relaxed)&EventType_Error)) + context->LastError.compare_exchange_strong(curerr, errorCode); + if((context->EnabledEvts.load(std::memory_order_relaxed)&EventType_Error)) { std::lock_guard<almtx_t> _{context->EventCbLock}; - ALbitfieldSOFT enabledevts{ATOMIC_LOAD(&context->EnabledEvts, almemory_order_relaxed)}; + ALbitfieldSOFT enabledevts{context->EnabledEvts.load(std::memory_order_relaxed)}; if((enabledevts&EventType_Error) && context->EventCb) (*context->EventCb)(AL_EVENT_TYPE_ERROR_SOFT, 0, errorCode, msglen, msg, context->EventParam); @@ -100,5 +100,5 @@ AL_API ALenum AL_APIENTRY alGetError(void) return deferror; } - return ATOMIC_EXCHANGE_SEQ(&context->LastError, AL_NO_ERROR); + return context->LastError.exchange(AL_NO_ERROR); } diff --git a/OpenAL32/alListener.cpp b/OpenAL32/alListener.cpp index 574f897c..bf1ac3f9 100644 --- a/OpenAL32/alListener.cpp +++ b/OpenAL32/alListener.cpp @@ -461,16 +461,16 @@ void UpdateListenerProps(ALCcontext *context) struct ALlistenerProps *props; /* Get an unused proprty container, or allocate a new one as needed. */ - props = ATOMIC_LOAD(&context->FreeListenerProps, almemory_order_acquire); + props = context->FreeListenerProps.load(std::memory_order_acquire); if(!props) props = static_cast<ALlistenerProps*>(al_calloc(16, sizeof(*props))); else { struct ALlistenerProps *next; do { - next = ATOMIC_LOAD(&props->next, almemory_order_relaxed); - } while(ATOMIC_COMPARE_EXCHANGE_WEAK(&context->FreeListenerProps, &props, next, - almemory_order_seq_cst, almemory_order_acquire) == 0); + next = props->next.load(std::memory_order_relaxed); + } while(context->FreeListenerProps.compare_exchange_weak(props, next, + std::memory_order_seq_cst, std::memory_order_acquire) == 0); } /* Copy in current property values. */ @@ -492,7 +492,7 @@ void UpdateListenerProps(ALCcontext *context) props->Gain = listener->Gain; /* Set the new container for updating internal parameters. */ - props = ATOMIC_EXCHANGE(&listener->Update, props, almemory_order_acq_rel); + props = listener->Update.exchange(props, std::memory_order_acq_rel); if(props) { /* If there was an unused update container, put it back in the diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp index ac220a2e..ea83d578 100644 --- a/OpenAL32/alSource.cpp +++ b/OpenAL32/alSource.cpp @@ -2488,9 +2488,9 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) if(vidx == -1) vidx = context->VoiceCount++; voice = context->Voices[vidx]; - ATOMIC_STORE(&voice->Playing, false, almemory_order_release); + voice->Playing.store(false, std::memory_order_release); - ATOMIC_EXCHANGE(&source->PropsClean, AL_TRUE, almemory_order_acquire); + source->PropsClean.exchange(AL_TRUE, std::memory_order_acquire); UpdateSourceProps(source, voice, device->NumAuxSends, context); /* A source that's not playing or paused has any offset applied when it @@ -3157,7 +3157,7 @@ static void UpdateSourceProps(ALsource *source, ALvoice *voice, ALsizei num_send ALsizei i; /* Get an unused property container, or allocate a new one as needed. */ - props = ATOMIC_LOAD(&context->FreeVoiceProps, almemory_order_acquire); + props = context->FreeVoiceProps.load(std::memory_order_acquire); if(!props) props = static_cast<ALvoiceProps*>(al_calloc(16, FAM_SIZE(struct ALvoiceProps, Send, num_sends))); @@ -3165,9 +3165,9 @@ static void UpdateSourceProps(ALsource *source, ALvoice *voice, ALsizei num_send { struct ALvoiceProps *next; do { - next = ATOMIC_LOAD(&props->next, almemory_order_relaxed); - } while(ATOMIC_COMPARE_EXCHANGE_WEAK(&context->FreeVoiceProps, &props, next, - almemory_order_acq_rel, almemory_order_acquire) == 0); + next = props->next.load(std::memory_order_relaxed); + } while(context->FreeVoiceProps.compare_exchange_weak(props, next, + std::memory_order_acq_rel, std::memory_order_acquire) == 0); } /* Copy in current property values. */ @@ -3230,7 +3230,7 @@ static void UpdateSourceProps(ALsource *source, ALvoice *voice, ALsizei num_send } /* Set the new container for updating internal parameters. */ - props = ATOMIC_EXCHANGE(&voice->Update, props, almemory_order_acq_rel); + props = voice->Update.exchange(props, std::memory_order_acq_rel); if(props) { /* If there was an unused update container, put it back in the @@ -3249,7 +3249,7 @@ void UpdateAllSourceProps(ALCcontext *context) { ALvoice *voice = context->Voices[pos]; ALsource *source = ATOMIC_LOAD(&voice->Source, almemory_order_acquire); - if(source && !ATOMIC_EXCHANGE(&source->PropsClean, AL_TRUE, almemory_order_acq_rel)) + if(source && !source->PropsClean.exchange(AL_TRUE, std::memory_order_acq_rel)) UpdateSourceProps(source, voice, num_sends, context); } } diff --git a/OpenAL32/alState.cpp b/OpenAL32/alState.cpp index 836853bb..a3c3cc1f 100644 --- a/OpenAL32/alState.cpp +++ b/OpenAL32/alState.cpp @@ -765,16 +765,16 @@ AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index) void UpdateContextProps(ALCcontext *context) { /* Get an unused proprty container, or allocate a new one as needed. */ - struct ALcontextProps *props{ATOMIC_LOAD(&context->FreeContextProps, almemory_order_acquire)}; + struct ALcontextProps *props{context->FreeContextProps.load(std::memory_order_acquire)}; if(!props) props = static_cast<ALcontextProps*>(al_calloc(16, sizeof(*props))); else { struct ALcontextProps *next; do { - next = ATOMIC_LOAD(&props->next, almemory_order_relaxed); - } while(ATOMIC_COMPARE_EXCHANGE_WEAK(&context->FreeContextProps, &props, next, - almemory_order_seq_cst, almemory_order_acquire) == 0); + next = props->next.load(std::memory_order_relaxed); + } while(context->FreeContextProps.compare_exchange_weak(props, next, + std::memory_order_seq_cst, std::memory_order_acquire) == 0); } /* Copy in current property values. */ @@ -788,7 +788,7 @@ void UpdateContextProps(ALCcontext *context) props->mDistanceModel = context->mDistanceModel; /* Set the new container for updating internal parameters. */ - props = ATOMIC_EXCHANGE(&context->Update, props, almemory_order_acq_rel); + props = context->Update.exchange(props, std::memory_order_acq_rel); if(props) { /* If there was an unused update container, put it back in the diff --git a/OpenAL32/event.cpp b/OpenAL32/event.cpp index e4b5eee0..fcbcba66 100644 --- a/OpenAL32/event.cpp +++ b/OpenAL32/event.cpp @@ -107,9 +107,9 @@ AL_API void AL_APIENTRY alEventControlSOFT(ALsizei count, const ALenum *types, A if(enable) { - ALbitfieldSOFT enabledevts{ATOMIC_LOAD(&context->EnabledEvts, almemory_order_relaxed)}; - while(ATOMIC_COMPARE_EXCHANGE_WEAK(&context->EnabledEvts, &enabledevts, enabledevts|flags, - almemory_order_acq_rel, almemory_order_acquire) == 0) + ALbitfieldSOFT enabledevts{context->EnabledEvts.load(std::memory_order_relaxed)}; + while(context->EnabledEvts.compare_exchange_weak(enabledevts, enabledevts|flags, + std::memory_order_acq_rel, std::memory_order_acquire) == 0) { /* enabledevts is (re-)filled with the current value on failure, so * just try again. @@ -118,9 +118,9 @@ AL_API void AL_APIENTRY alEventControlSOFT(ALsizei count, const ALenum *types, A } else { - ALbitfieldSOFT enabledevts{ATOMIC_LOAD(&context->EnabledEvts, almemory_order_relaxed)}; - while(ATOMIC_COMPARE_EXCHANGE_WEAK(&context->EnabledEvts, &enabledevts, enabledevts&~flags, - almemory_order_acq_rel, almemory_order_acquire) == 0) + ALbitfieldSOFT enabledevts{context->EnabledEvts.load(std::memory_order_relaxed)}; + while(context->EnabledEvts.compare_exchange_weak(enabledevts, enabledevts&~flags, + std::memory_order_acq_rel, std::memory_order_acquire) == 0) { } /* Wait to ensure the event handler sees the changed flags before diff --git a/common/atomic.h b/common/atomic.h index d1557ffb..e58a363c 100644 --- a/common/atomic.h +++ b/common/atomic.h @@ -54,10 +54,6 @@ using std::atomic_thread_fence; #define ATOMIC_ADD atomic_fetch_add_explicit #define ATOMIC_SUB atomic_fetch_sub_explicit -#define ATOMIC_EXCHANGE atomic_exchange_explicit -#define ATOMIC_COMPARE_EXCHANGE_STRONG atomic_compare_exchange_strong_explicit -#define ATOMIC_COMPARE_EXCHANGE_WEAK atomic_compare_exchange_weak_explicit - #define ATOMIC_THREAD_FENCE atomic_thread_fence @@ -67,12 +63,6 @@ using std::atomic_thread_fence; #define ATOMIC_ADD_SEQ(_val, _incr) ATOMIC_ADD(_val, _incr, almemory_order_seq_cst) #define ATOMIC_SUB_SEQ(_val, _decr) ATOMIC_SUB(_val, _decr, almemory_order_seq_cst) -#define ATOMIC_EXCHANGE_SEQ(_val, _newval) ATOMIC_EXCHANGE(_val, _newval, almemory_order_seq_cst) -#define ATOMIC_COMPARE_EXCHANGE_STRONG_SEQ(_val, _oldval, _newval) \ - ATOMIC_COMPARE_EXCHANGE_STRONG(_val, _oldval, _newval, almemory_order_seq_cst, almemory_order_seq_cst) -#define ATOMIC_COMPARE_EXCHANGE_WEAK_SEQ(_val, _oldval, _newval) \ - ATOMIC_COMPARE_EXCHANGE_WEAK(_val, _oldval, _newval, almemory_order_seq_cst, almemory_order_seq_cst) - using RefCount = std::atomic<unsigned int>; |