Use an ATOMIC_INIT macro instead of ATOMIC_LOAD_UNSAFE

This commit is contained in:
Chris Robinson 2014-08-03 00:26:21 -07:00
parent 659b340716
commit f5194a9d8e
5 changed files with 21 additions and 35 deletions

View File

@ -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;

View File

@ -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++)

View File

@ -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);
}

View File

@ -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)

View File

@ -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)