diff options
-rw-r--r-- | Alc/ALc.c | 18 | ||||
-rw-r--r-- | OpenAL32/alAuxEffectSlot.c | 2 | ||||
-rw-r--r-- | OpenAL32/alSource.c | 6 | ||||
-rw-r--r-- | common/rwlock.c | 6 | ||||
-rw-r--r-- | include/atomic.h | 24 |
5 files changed, 21 insertions, 35 deletions
@@ -1882,7 +1882,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) { ALsizei pos; - ATOMIC_STORE_UNSAFE(&context->UpdateSources, AL_FALSE); + ATOMIC_STORE(&context->UpdateSources, AL_FALSE); LockUIntMapRead(&context->EffectSlotMap); for(pos = 0;pos < context->EffectSlotMap.size;pos++) { @@ -1914,7 +1914,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) source->Send[s].GainHF = 1.0f; s++; } - ATOMIC_STORE_UNSAFE(&source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&source->NeedsUpdate, AL_TRUE); } UnlockUIntMapRead(&context->SourceMap); @@ -1931,7 +1931,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) } src->Update(src, context); - ATOMIC_STORE_UNSAFE(&source->NeedsUpdate, AL_FALSE); + ATOMIC_STORE(&source->NeedsUpdate, AL_FALSE); } context = context->next; @@ -2110,8 +2110,8 @@ static ALvoid InitContext(ALCcontext *Context) Context->Listener->Params.Velocity[i] = 0.0f; //Validate Context - ATOMIC_STORE_UNSAFE(&Context->LastError, AL_NO_ERROR); - ATOMIC_STORE_UNSAFE(&Context->UpdateSources, AL_FALSE); + ATOMIC_INIT(&Context->LastError, AL_NO_ERROR); + ATOMIC_INIT(&Context->UpdateSources, AL_FALSE); Context->ActiveSourceCount = 0; InitUIntMap(&Context->SourceMap, Context->Device->MaxNoOfSources); InitUIntMap(&Context->EffectSlotMap, Context->Device->AuxiliaryEffectSlotMax); @@ -3076,14 +3076,14 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) InitRef(&device->ref, 1); device->Connected = ALC_TRUE; device->Type = Playback; - ATOMIC_STORE_UNSAFE(&device->LastError, ALC_NO_ERROR); + ATOMIC_INIT(&device->LastError, ALC_NO_ERROR); device->Flags = 0; device->Bs2b = NULL; device->Bs2bLevel = 0; AL_STRING_INIT(device->DeviceName); - ATOMIC_STORE_UNSAFE(&device->ContextList, NULL); + ATOMIC_INIT(&device->ContextList, NULL); device->ClockBase = 0; device->SamplesDone = 0; @@ -3569,14 +3569,14 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN InitRef(&device->ref, 1); device->Connected = ALC_TRUE; device->Type = Loopback; - ATOMIC_STORE_UNSAFE(&device->LastError, ALC_NO_ERROR); + ATOMIC_INIT(&device->LastError, ALC_NO_ERROR); device->Flags = 0; device->Bs2b = NULL; device->Bs2bLevel = 0; AL_STRING_INIT(device->DeviceName); - ATOMIC_STORE_UNSAFE(&device->ContextList, NULL); + ATOMIC_INIT(&device->ContextList, NULL); device->ClockBase = 0; device->SamplesDone = 0; diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index 96056651..ec8890b6 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -522,7 +522,7 @@ ALenum InitEffectSlot(ALeffectslot *slot) slot->Gain = 1.0; slot->AuxSendAuto = AL_TRUE; - ATOMIC_STORE_UNSAFE(&slot->NeedsUpdate, AL_FALSE); + ATOMIC_INIT(&slot->NeedsUpdate, AL_FALSE); for(c = 0;c < 1;c++) { for(i = 0;i < BUFFERSIZE;i++) diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 2cfec346..155a7f8b 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -2423,8 +2423,8 @@ static ALvoid InitSourceParams(ALsource *Source) Source->SourceType = AL_UNDETERMINED; Source->Offset = -1.0; - ATOMIC_STORE_UNSAFE(&Source->queue, NULL); - ATOMIC_STORE_UNSAFE(&Source->current_buffer, NULL); + ATOMIC_INIT(&Source->queue, NULL); + ATOMIC_INIT(&Source->current_buffer, NULL); Source->Direct.Gain = 1.0f; Source->Direct.GainHF = 1.0f; @@ -2440,7 +2440,7 @@ static ALvoid InitSourceParams(ALsource *Source) Source->Send[i].LFReference = HIGHPASSFREQREF; } - ATOMIC_STORE_UNSAFE(&Source->NeedsUpdate, AL_TRUE); + ATOMIC_INIT(&Source->NeedsUpdate, AL_TRUE); } diff --git a/common/rwlock.c b/common/rwlock.c index d7a813df..cfa3aee4 100644 --- a/common/rwlock.c +++ b/common/rwlock.c @@ -21,9 +21,9 @@ void RWLockInit(RWLock *lock) { InitRef(&lock->read_count, 0); InitRef(&lock->write_count, 0); - ATOMIC_STORE_UNSAFE(&lock->read_lock, false); - ATOMIC_STORE_UNSAFE(&lock->read_entry_lock, false); - ATOMIC_STORE_UNSAFE(&lock->write_lock, false); + ATOMIC_INIT(&lock->read_lock, false); + ATOMIC_INIT(&lock->read_entry_lock, false); + ATOMIC_INIT(&lock->write_lock, false); } void ReadLock(RWLock *lock) diff --git a/include/atomic.h b/include/atomic.h index 55a3c439..d761890e 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -23,11 +23,9 @@ inline void *ExchangePtr(XchgPtr *ptr, void *newval) #define ATOMIC(T) struct { T _Atomic value; } +#define ATOMIC_INIT(_val, _newval) atomic_init(&(_val)->value, (_newval)) #define ATOMIC_INIT_STATIC(_newval) {ATOMIC_VAR_INIT(_newval)} -#define ATOMIC_LOAD_UNSAFE(_val) atomic_load_explicit(&(_val)->value, memory_order_relaxed) -#define ATOMIC_STORE_UNSAFE(_val, _newval) atomic_store_explicit(&(_val)->value, (_newval), memory_order_relaxed) - #define ATOMIC_LOAD(_val) atomic_load(&(_val)->value) #define ATOMIC_STORE(_val, _newval) atomic_store(&(_val)->value, (_newval)) @@ -51,13 +49,9 @@ inline void *ExchangePtr(XchgPtr *ptr, void *newval) #define ATOMIC(T) struct { T volatile value; } +#define ATOMIC_INIT(_val, _newval) do { (_val)->value = (_newval); } while(0) #define ATOMIC_INIT_STATIC(_newval) {(_newval)} -#define ATOMIC_LOAD_UNSAFE(_val) __extension__({(_val)->value;}) -#define ATOMIC_STORE_UNSAFE(_val, _newval) do { \ - (_val)->value = (_newval); \ -} while(0) - #define ATOMIC_LOAD(_val) __extension__({ \ __typeof((_val)->value) _r = (_val)->value; \ __asm__ __volatile__("" ::: "memory"); \ @@ -132,13 +126,9 @@ inline void *ExchangePtr(XchgPtr *dest, void *newval) #define ATOMIC(T) struct { T volatile value; } +#define ATOMIC_INIT(_val, _newval) do { (_val)->value = (_newval); } while(0) #define ATOMIC_INIT_STATIC(_newval) {(_newval)} -#define ATOMIC_LOAD_UNSAFE(_val) __extension__({(_val)->value;}) -#define ATOMIC_STORE_UNSAFE(_val, _newval) do { \ - (_val)->value = (_newval); \ -} while(0) - #define ATOMIC_LOAD(_val) __extension__({ \ __typeof((_val)->value) _r = (_val)->value; \ __asm__ __volatile__("" ::: "memory"); \ @@ -246,13 +236,9 @@ inline void *ExchangePtr(XchgPtr *ptr, void *newval) #define ATOMIC(T) struct { T volatile value; } +#define ATOMIC_INIT(_val, _newval) do { (_val)->value = (_newval); } while(0) #define ATOMIC_INIT_STATIC(_newval) {(_newval)} -#define ATOMIC_LOAD_UNSAFE(_val) ((_val)->value) -#define ATOMIC_STORE_UNSAFE(_val, _newval) do { \ - (_val)->value = (_newval); \ -} while(0) - #define ATOMIC_LOAD(_val) ((_val)->value) #define ATOMIC_STORE(_val, _newval) do { \ (_val)->value = (_newval); \ @@ -312,7 +298,7 @@ typedef unsigned int uint; typedef ATOMIC(uint) RefCount; inline void InitRef(RefCount *ptr, uint value) -{ ATOMIC_STORE_UNSAFE(ptr, value); } +{ ATOMIC_INIT(ptr, value); } inline uint ReadRef(RefCount *ptr) { return ATOMIC_LOAD(ptr); } inline uint IncrementRef(RefCount *ptr) |