diff options
author | Chris Robinson <[email protected]> | 2014-07-26 03:00:49 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-07-26 03:00:49 -0700 |
commit | 531c0d8e6b3d0ad8ff4ad8278a1030785deb3d77 (patch) | |
tree | d0d7085526edb0f31bf4986cbc4dd64d0f5ceee8 | |
parent | a3dbe08c8b9df301dded52ad78f655c2753be56c (diff) |
Explicitly pass the address of atomics and parameters that can be modified
-rw-r--r-- | Alc/ALc.c | 36 | ||||
-rw-r--r-- | Alc/ALu.c | 8 | ||||
-rw-r--r-- | OpenAL32/alAuxEffectSlot.c | 12 | ||||
-rw-r--r-- | OpenAL32/alError.c | 4 | ||||
-rw-r--r-- | OpenAL32/alListener.c | 10 | ||||
-rw-r--r-- | OpenAL32/alSource.c | 54 | ||||
-rw-r--r-- | OpenAL32/alState.c | 18 | ||||
-rw-r--r-- | common/rwlock.c | 10 | ||||
-rw-r--r-- | include/atomic.h | 108 |
9 files changed, 130 insertions, 130 deletions
@@ -1558,9 +1558,9 @@ static void alcSetError(ALCdevice *device, ALCenum errorCode) } if(device) - ATOMIC_STORE(device->LastError, errorCode); + ATOMIC_STORE(&device->LastError, errorCode); else - ATOMIC_STORE(LastNullDeviceError, errorCode); + ATOMIC_STORE(&LastNullDeviceError, errorCode); } @@ -1882,7 +1882,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) { ALsizei pos; - ATOMIC_STORE_UNSAFE(context->UpdateSources, AL_FALSE); + ATOMIC_STORE_UNSAFE(&context->UpdateSources, AL_FALSE); LockUIntMapRead(&context->EffectSlotMap); for(pos = 0;pos < context->EffectSlotMap.size;pos++) { @@ -1895,7 +1895,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) RestoreFPUMode(&oldMode); return ALC_INVALID_DEVICE; } - ATOMIC_STORE(slot->NeedsUpdate, AL_FALSE); + ATOMIC_STORE(&slot->NeedsUpdate, AL_FALSE); V(slot->EffectState,update)(device, slot); } UnlockUIntMapRead(&context->EffectSlotMap); @@ -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_UNSAFE(&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_UNSAFE(&source->NeedsUpdate, AL_FALSE); } context = context->next; @@ -1946,7 +1946,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) RestoreFPUMode(&oldMode); return ALC_INVALID_DEVICE; } - ATOMIC_STORE(slot->NeedsUpdate, AL_FALSE); + ATOMIC_STORE(&slot->NeedsUpdate, AL_FALSE); V(slot->EffectState,update)(device, slot); } ALCdevice_Unlock(device); @@ -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_STORE_UNSAFE(&Context->LastError, AL_NO_ERROR); + ATOMIC_STORE_UNSAFE(&Context->UpdateSources, AL_FALSE); Context->ActiveSourceCount = 0; InitUIntMap(&Context->SourceMap, Context->Device->MaxNoOfSources); InitUIntMap(&Context->EffectSlotMap, Context->Device->AuxiliaryEffectSlotMax); @@ -2191,7 +2191,7 @@ static void ReleaseContext(ALCcontext *context, ALCdevice *device) } origctx = context; - if(ATOMIC_COMPARE_EXCHANGE(ALCcontext*, GlobalContext, origctx, NULL)) + if(ATOMIC_COMPARE_EXCHANGE(ALCcontext*, &GlobalContext, &origctx, NULL)) ALCcontext_DecRef(context); ALCdevice_Lock(device); @@ -2274,7 +2274,7 @@ ALCcontext *GetContextRef(void) else { LockLists(); - context = ATOMIC_LOAD(GlobalContext); + context = ATOMIC_LOAD(&GlobalContext); if(context) ALCcontext_IncRef(context); UnlockLists(); @@ -2298,11 +2298,11 @@ ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device) if(VerifyDevice(device)) { - errorCode = ATOMIC_EXCHANGE(ALCenum, device->LastError, ALC_NO_ERROR); + errorCode = ATOMIC_EXCHANGE(ALCenum, &device->LastError, ALC_NO_ERROR); ALCdevice_DecRef(device); } else - errorCode = ATOMIC_EXCHANGE(ALCenum, LastNullDeviceError, ALC_NO_ERROR); + errorCode = ATOMIC_EXCHANGE(ALCenum, &LastNullDeviceError, ALC_NO_ERROR); return errorCode; } @@ -2856,7 +2856,7 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin return NULL; } - ATOMIC_STORE(device->LastError, ALC_NO_ERROR); + ATOMIC_STORE(&device->LastError, ALC_NO_ERROR); if((err=UpdateDeviceParams(device, attrList)) != ALC_NO_ERROR) { @@ -2955,7 +2955,7 @@ ALC_API ALCvoid ALC_APIENTRY alcDestroyContext(ALCcontext *context) ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void) { ALCcontext *Context = altss_get(LocalContext); - if(!Context) Context = ATOMIC_LOAD(GlobalContext); + if(!Context) Context = ATOMIC_LOAD(&GlobalContext); return Context; } @@ -2983,7 +2983,7 @@ ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context) return ALC_FALSE; } /* context's reference count is already incremented */ - context = ATOMIC_EXCHANGE(ALCcontext*, GlobalContext, context); + context = ATOMIC_EXCHANGE(ALCcontext*, &GlobalContext, context); if(context) ALCcontext_DecRef(context); if((context=altss_get(LocalContext)) != NULL) @@ -3070,7 +3070,7 @@ 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_STORE_UNSAFE(&device->LastError, ALC_NO_ERROR); device->Flags = 0; device->Bs2b = NULL; @@ -3536,7 +3536,7 @@ 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_STORE_UNSAFE(&device->LastError, ALC_NO_ERROR); device->Flags = 0; device->Bs2b = NULL; @@ -1167,7 +1167,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) ALenum UpdateSources = AL_FALSE; if(!DeferUpdates) - UpdateSources = ATOMIC_EXCHANGE(ALenum, ctx->UpdateSources, AL_FALSE); + UpdateSources = ATOMIC_EXCHANGE(ALenum, &ctx->UpdateSources, AL_FALSE); if(UpdateSources) CalcListenerParams(ctx->Listener); @@ -1188,7 +1188,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) continue; } - if(!DeferUpdates && (ATOMIC_EXCHANGE(ALenum, source->NeedsUpdate, AL_FALSE) || + if(!DeferUpdates && (ATOMIC_EXCHANGE(ALenum, &source->NeedsUpdate, AL_FALSE) || UpdateSources)) (*src)->Update(*src, ctx); @@ -1202,7 +1202,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) slot_end = VECTOR_ITER_END(ctx->ActiveAuxSlots); while(slot != slot_end) { - if(!DeferUpdates && ATOMIC_EXCHANGE(ALenum, (*slot)->NeedsUpdate, AL_FALSE)) + if(!DeferUpdates && ATOMIC_EXCHANGE(ALenum, &(*slot)->NeedsUpdate, AL_FALSE)) V((*slot)->EffectState,update)(device, *slot); V((*slot)->EffectState,process)(SamplesToDo, (*slot)->WetBuffer[0], @@ -1220,7 +1220,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) slot = &device->DefaultSlot; if(*slot != NULL) { - if(ATOMIC_EXCHANGE(ALenum, (*slot)->NeedsUpdate, AL_FALSE)) + if(ATOMIC_EXCHANGE(ALenum, &(*slot)->NeedsUpdate, AL_FALSE)) V((*slot)->EffectState,update)(device, *slot); V((*slot)->EffectState,process)(SamplesToDo, (*slot)->WetBuffer[0], diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index a2060f0a..96056651 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -183,7 +183,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param err = InitializeEffect(device, slot, effect); if(err != AL_NO_ERROR) SET_ERROR_AND_GOTO(context, err, done); - ATOMIC_STORE(context->UpdateSources, AL_TRUE); + ATOMIC_STORE(&context->UpdateSources, AL_TRUE); break; case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: @@ -191,7 +191,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); slot->AuxSendAuto = value; - ATOMIC_STORE(context->UpdateSources, AL_TRUE); + ATOMIC_STORE(&context->UpdateSources, AL_TRUE); break; default: @@ -246,7 +246,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); slot->Gain = value; - ATOMIC_STORE(slot->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&slot->NeedsUpdate, AL_TRUE); break; default: @@ -485,7 +485,7 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e /* FIXME: This should be done asynchronously, but since the EffectState * object was changed, it needs an update before its Process method can * be called. */ - ATOMIC_STORE(EffectSlot->NeedsUpdate, AL_FALSE); + ATOMIC_STORE(&EffectSlot->NeedsUpdate, AL_FALSE); V(EffectSlot->EffectState,update)(Device, EffectSlot); ALCdevice_Unlock(Device); @@ -501,7 +501,7 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e ALCdevice_Lock(Device); memcpy(&EffectSlot->EffectProps, &effect->Props, sizeof(effect->Props)); ALCdevice_Unlock(Device); - ATOMIC_STORE(EffectSlot->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&EffectSlot->NeedsUpdate, AL_TRUE); } } @@ -522,7 +522,7 @@ ALenum InitEffectSlot(ALeffectslot *slot) slot->Gain = 1.0; slot->AuxSendAuto = AL_TRUE; - ATOMIC_STORE_UNSAFE(slot->NeedsUpdate, AL_FALSE); + ATOMIC_STORE_UNSAFE(&slot->NeedsUpdate, AL_FALSE); for(c = 0;c < 1;c++) { for(i = 0;i < BUFFERSIZE;i++) diff --git a/OpenAL32/alError.c b/OpenAL32/alError.c index 6d3870fd..e43c7b45 100644 --- a/OpenAL32/alError.c +++ b/OpenAL32/alError.c @@ -46,7 +46,7 @@ ALvoid alSetError(ALCcontext *Context, ALenum errorCode) raise(SIGTRAP); #endif } - (void)ATOMIC_COMPARE_EXCHANGE(ALenum, Context->LastError, curerr, errorCode); + (void)ATOMIC_COMPARE_EXCHANGE(ALenum, &Context->LastError, &curerr, errorCode); } AL_API ALenum AL_APIENTRY alGetError(void) @@ -69,7 +69,7 @@ AL_API ALenum AL_APIENTRY alGetError(void) return AL_INVALID_OPERATION; } - errorCode = ATOMIC_EXCHANGE(ALenum, Context->LastError, AL_NO_ERROR); + errorCode = ATOMIC_EXCHANGE(ALenum, &Context->LastError, AL_NO_ERROR); ALCcontext_DecRef(Context); diff --git a/OpenAL32/alListener.c b/OpenAL32/alListener.c index b98ea7c2..0baae82e 100644 --- a/OpenAL32/alListener.c +++ b/OpenAL32/alListener.c @@ -40,7 +40,7 @@ AL_API ALvoid AL_APIENTRY alListenerf(ALenum param, ALfloat value) SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); context->Listener->Gain = value; - ATOMIC_STORE(context->UpdateSources, AL_TRUE); + ATOMIC_STORE(&context->UpdateSources, AL_TRUE); break; case AL_METERS_PER_UNIT: @@ -48,7 +48,7 @@ AL_API ALvoid AL_APIENTRY alListenerf(ALenum param, ALfloat value) SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); context->Listener->MetersPerUnit = value; - ATOMIC_STORE(context->UpdateSources, AL_TRUE); + ATOMIC_STORE(&context->UpdateSources, AL_TRUE); break; default: @@ -77,7 +77,7 @@ AL_API ALvoid AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat val context->Listener->Position[0] = value1; context->Listener->Position[1] = value2; context->Listener->Position[2] = value3; - ATOMIC_STORE(context->UpdateSources, AL_TRUE); + ATOMIC_STORE(&context->UpdateSources, AL_TRUE); UnlockContext(context); break; @@ -89,7 +89,7 @@ AL_API ALvoid AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat val context->Listener->Velocity[0] = value1; context->Listener->Velocity[1] = value2; context->Listener->Velocity[2] = value3; - ATOMIC_STORE(context->UpdateSources, AL_TRUE); + ATOMIC_STORE(&context->UpdateSources, AL_TRUE); UnlockContext(context); break; @@ -142,7 +142,7 @@ AL_API ALvoid AL_APIENTRY alListenerfv(ALenum param, const ALfloat *values) context->Listener->Up[0] = values[3]; context->Listener->Up[1] = values[4]; context->Listener->Up[2] = values[5]; - ATOMIC_STORE(context->UpdateSources, AL_TRUE); + ATOMIC_STORE(&context->UpdateSources, AL_TRUE); UnlockContext(context); break; diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index a0a7e504..d7859eff 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -375,98 +375,98 @@ static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SrcFloatProp CHECKVAL(*values >= 0.0f); Source->Pitch = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_CONE_INNER_ANGLE: CHECKVAL(*values >= 0.0f && *values <= 360.0f); Source->InnerAngle = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_CONE_OUTER_ANGLE: CHECKVAL(*values >= 0.0f && *values <= 360.0f); Source->OuterAngle = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_GAIN: CHECKVAL(*values >= 0.0f); Source->Gain = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_MAX_DISTANCE: CHECKVAL(*values >= 0.0f); Source->MaxDistance = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_ROLLOFF_FACTOR: CHECKVAL(*values >= 0.0f); Source->RollOffFactor = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_REFERENCE_DISTANCE: CHECKVAL(*values >= 0.0f); Source->RefDistance = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_MIN_GAIN: CHECKVAL(*values >= 0.0f && *values <= 1.0f); Source->MinGain = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_MAX_GAIN: CHECKVAL(*values >= 0.0f && *values <= 1.0f); Source->MaxGain = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_CONE_OUTER_GAIN: CHECKVAL(*values >= 0.0f && *values <= 1.0f); Source->OuterGain = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_CONE_OUTER_GAINHF: CHECKVAL(*values >= 0.0f && *values <= 1.0f); Source->OuterGainHF = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_AIR_ABSORPTION_FACTOR: CHECKVAL(*values >= 0.0f && *values <= 10.0f); Source->AirAbsorptionFactor = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_ROOM_ROLLOFF_FACTOR: CHECKVAL(*values >= 0.0f && *values <= 10.0f); Source->RoomRolloffFactor = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_DOPPLER_FACTOR: CHECKVAL(*values >= 0.0f && *values <= 1.0f); Source->DopplerFactor = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_SEC_OFFSET: @@ -505,7 +505,7 @@ static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SrcFloatProp Source->Position[1] = values[1]; Source->Position[2] = values[2]; UnlockContext(Context); - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_VELOCITY: @@ -516,7 +516,7 @@ static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SrcFloatProp Source->Velocity[1] = values[1]; Source->Velocity[2] = values[2]; UnlockContext(Context); - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_DIRECTION: @@ -527,7 +527,7 @@ static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SrcFloatProp Source->Orientation[1] = values[1]; Source->Orientation[2] = values[2]; UnlockContext(Context); - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; @@ -574,7 +574,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SrcIntProp p CHECKVAL(*values == AL_FALSE || *values == AL_TRUE); Source->HeadRelative = (ALboolean)*values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_LOOPING: @@ -692,35 +692,35 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SrcIntProp p Source->Direct.LFReference = filter->LFReference; } UnlockContext(Context); - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_DIRECT_FILTER_GAINHF_AUTO: CHECKVAL(*values == AL_FALSE || *values == AL_TRUE); Source->DryGainHFAuto = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: CHECKVAL(*values == AL_FALSE || *values == AL_TRUE); Source->WetGainAuto = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: CHECKVAL(*values == AL_FALSE || *values == AL_TRUE); Source->WetGainHFAuto = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_DIRECT_CHANNELS_SOFT: CHECKVAL(*values == AL_FALSE || *values == AL_TRUE); Source->DirectChannels = *values; - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; case AL_DISTANCE_MODEL: @@ -734,7 +734,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SrcIntProp p Source->DistanceModel = *values; if(Context->SourceDistanceModel) - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; @@ -771,7 +771,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SrcIntProp p Source->Send[values[1]].LFReference = filter->LFReference; } UnlockContext(Context); - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); return AL_TRUE; @@ -2435,7 +2435,7 @@ static ALvoid InitSourceParams(ALsource *Source) Source->Send[i].LFReference = HIGHPASSFREQREF; } - ATOMIC_STORE_UNSAFE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE_UNSAFE(&Source->NeedsUpdate, AL_TRUE); } @@ -2530,7 +2530,7 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state) src->Send[i].Moving = AL_FALSE; } } - ATOMIC_STORE(Source->NeedsUpdate, AL_TRUE); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); } else if(state == AL_PAUSED) { diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c index 6e6ca544..d48c268b 100644 --- a/OpenAL32/alState.c +++ b/OpenAL32/alState.c @@ -56,7 +56,7 @@ AL_API ALvoid AL_APIENTRY alEnable(ALenum capability) { case AL_SOURCE_DISTANCE_MODEL: context->SourceDistanceModel = AL_TRUE; - ATOMIC_STORE(context->UpdateSources, AL_TRUE); + ATOMIC_STORE(&context->UpdateSources, AL_TRUE); break; default: @@ -78,7 +78,7 @@ AL_API ALvoid AL_APIENTRY alDisable(ALenum capability) { case AL_SOURCE_DISTANCE_MODEL: context->SourceDistanceModel = AL_FALSE; - ATOMIC_STORE(context->UpdateSources, AL_TRUE); + ATOMIC_STORE(&context->UpdateSources, AL_TRUE); break; default: @@ -643,7 +643,7 @@ AL_API ALvoid AL_APIENTRY alDopplerFactor(ALfloat value) SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); context->DopplerFactor = value; - ATOMIC_STORE(context->UpdateSources, AL_TRUE); + ATOMIC_STORE(&context->UpdateSources, AL_TRUE); done: ALCcontext_DecRef(context); @@ -660,7 +660,7 @@ AL_API ALvoid AL_APIENTRY alDopplerVelocity(ALfloat value) SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); context->DopplerVelocity = value; - ATOMIC_STORE(context->UpdateSources, AL_TRUE); + ATOMIC_STORE(&context->UpdateSources, AL_TRUE); done: ALCcontext_DecRef(context); @@ -677,7 +677,7 @@ AL_API ALvoid AL_APIENTRY alSpeedOfSound(ALfloat value) SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done); context->SpeedOfSound = value; - ATOMIC_STORE(context->UpdateSources, AL_TRUE); + ATOMIC_STORE(&context->UpdateSources, AL_TRUE); done: ALCcontext_DecRef(context); @@ -698,7 +698,7 @@ AL_API ALvoid AL_APIENTRY alDistanceModel(ALenum value) context->DistanceModel = value; if(!context->SourceDistanceModel) - ATOMIC_STORE(context->UpdateSources, AL_TRUE); + ATOMIC_STORE(&context->UpdateSources, AL_TRUE); done: ALCcontext_DecRef(context); @@ -725,7 +725,7 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void) context->DeferUpdates = AL_TRUE; /* Make sure all pending updates are performed */ - UpdateSources = ATOMIC_EXCHANGE(ALenum, context->UpdateSources, AL_FALSE); + UpdateSources = ATOMIC_EXCHANGE(ALenum, &context->UpdateSources, AL_FALSE); src = context->ActiveSources; src_end = src + context->ActiveSourceCount; @@ -742,7 +742,7 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void) continue; } - if(ATOMIC_EXCHANGE(ALenum, source->NeedsUpdate, AL_FALSE) || UpdateSources) + if(ATOMIC_EXCHANGE(ALenum, &source->NeedsUpdate, AL_FALSE) || UpdateSources) (*src)->Update(*src, context); src++; @@ -752,7 +752,7 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void) slot_end = VECTOR_ITER_END(context->ActiveAuxSlots); while(slot != slot_end) { - if(ATOMIC_EXCHANGE(ALenum, (*slot)->NeedsUpdate, AL_FALSE)) + if(ATOMIC_EXCHANGE(ALenum, &(*slot)->NeedsUpdate, AL_FALSE)) V((*slot)->EffectState,update)(context->Device, *slot); slot++; } diff --git a/common/rwlock.c b/common/rwlock.c index 0b185c9b..d7a813df 100644 --- a/common/rwlock.c +++ b/common/rwlock.c @@ -11,19 +11,19 @@ /* A simple spinlock. Yield the thread while the given integer is set by * another. Could probably be improved... */ #define LOCK(l) do { \ - while(ATOMIC_EXCHANGE(int, (l), true) == true) \ + while(ATOMIC_EXCHANGE(int, &(l), true) == true) \ althrd_yield(); \ } while(0) -#define UNLOCK(l) ATOMIC_STORE(l, false) +#define UNLOCK(l) ATOMIC_STORE(&(l), false) 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_STORE_UNSAFE(&lock->read_lock, false); + ATOMIC_STORE_UNSAFE(&lock->read_entry_lock, false); + ATOMIC_STORE_UNSAFE(&lock->write_lock, false); } void ReadLock(RWLock *lock) diff --git a/include/atomic.h b/include/atomic.h index 0780b6a0..184b6c04 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -29,18 +29,18 @@ inline void *CompExchangePtr(XchgPtr *ptr, void *oldval, void *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_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)) +#define ATOMIC_LOAD(_val) atomic_load(&(_val)->value) +#define ATOMIC_STORE(_val, _newval) atomic_store(&(_val)->value, (_newval)) -#define ATOMIC_ADD(T, _val, _incr) atomic_fetch_add(&(_val).value, (_incr)) -#define ATOMIC_SUB(T, _val, _decr) atomic_fetch_sub(&(_val).value, (_decr)) +#define ATOMIC_ADD(T, _val, _incr) atomic_fetch_add(&(_val)->value, (_incr)) +#define ATOMIC_SUB(T, _val, _decr) atomic_fetch_sub(&(_val)->value, (_decr)) -#define ATOMIC_EXCHANGE(T, _val, _newval) atomic_exchange(&(_val).value, (_newval)) +#define ATOMIC_EXCHANGE(T, _val, _newval) atomic_exchange(&(_val)->value, (_newval)) #define ATOMIC_COMPARE_EXCHANGE(T, _val, _oldval, _newval) \ - atomic_compare_exchange_strong(&(_val).value, &(_oldval), (_newval)) + atomic_compare_exchange_strong(&(_val)->value, (_oldval), (_newval)) /* Atomics using GCC intrinsics */ #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && !defined(__QNXNTO__) @@ -59,35 +59,35 @@ inline void *CompExchangePtr(XchgPtr *ptr, void *oldval, void *newval) #define ATOMIC_INIT_STATIC(_newval) {(_newval)} -#define ATOMIC_LOAD_UNSAFE(_val) ((_val).value) +#define ATOMIC_LOAD_UNSAFE(_val) ((_val)->value) #define ATOMIC_STORE_UNSAFE(_val, _newval) do { \ - (_val).value = (_newval); \ + (_val)->value = (_newval); \ } while(0) -#define ATOMIC_LOAD(_val) (__sync_synchronize(),(_val).value) +#define ATOMIC_LOAD(_val) (__sync_synchronize(),(_val)->value) #define ATOMIC_STORE(_val, _newval) do { \ - (_val).value = (_newval); \ + (_val)->value = (_newval); \ __sync_synchronize(); \ } while(0) #define ATOMIC_ADD(T, _val, _incr) __extension__({ \ - static_assert(sizeof(T)==sizeof((_val).value), "Type "#T" has incorrect size!"); \ - __sync_fetch_and_add(&(_val).value, (_incr)); \ + static_assert(sizeof(T)==sizeof((_val)->value), "Type "#T" has incorrect size!"); \ + __sync_fetch_and_add(&(_val)->value, (_incr)); \ }) #define ATOMIC_SUB(T, _val, _decr) __extension__({ \ - static_assert(sizeof(T)==sizeof((_val).value), "Type "#T" has incorrect size!"); \ - __sync_fetch_and_sub(&(_val).value, (_decr)); \ + static_assert(sizeof(T)==sizeof((_val)->value), "Type "#T" has incorrect size!"); \ + __sync_fetch_and_sub(&(_val)->value, (_decr)); \ }) #define ATOMIC_EXCHANGE(T, _val, _newval) __extension__({ \ - static_assert(sizeof(T)==sizeof((_val).value), "Type "#T" has incorrect size!"); \ - __sync_lock_test_and_set(&(_val).value, (_newval)); \ + static_assert(sizeof(T)==sizeof((_val)->value), "Type "#T" has incorrect size!"); \ + __sync_lock_test_and_set(&(_val)->value, (_newval)); \ }) #define ATOMIC_COMPARE_EXCHANGE(T, _val, _oldval, _newval) __extension__({ \ - static_assert(sizeof(T)==sizeof((_val).value), "Type "#T" has incorrect size!"); \ - __typeof(_oldval) _old = (_oldval); \ - (_oldval) = __sync_val_compare_and_swap(&(_val).value, (_oldval), (_newval)); \ - (_oldval) == _old; \ + static_assert(sizeof(T)==sizeof((_val)->value), "Type "#T" has incorrect size!"); \ + __typeof(*_oldval) _old = *(_oldval); \ + *(_oldval) = __sync_val_compare_and_swap(&(_val)->value, _old, (_newval)); \ + *(_oldval) == _old; \ }) /* Atomics using x86/x86-64 GCC inline assembly */ @@ -142,50 +142,50 @@ inline void *CompExchangePtr(XchgPtr *dest, void *oldval, void *newval) #define ATOMIC_INIT_STATIC(_newval) {(_newval)} -#define ATOMIC_LOAD_UNSAFE(_val) ((_val).value) +#define ATOMIC_LOAD_UNSAFE(_val) ((_val)->value) #define ATOMIC_STORE_UNSAFE(_val, _newval) do { \ - (_val).value = (_newval); \ + (_val)->value = (_newval); \ } while(0) inline void _al_mem_barrier(void) { __asm__ __volatile__("" ::: "memory"); } -#define ATOMIC_LOAD(_val) (_al_mem_barrier(),(_val).value) +#define ATOMIC_LOAD(_val) (_al_mem_barrier(),(_val)->value) #define ATOMIC_STORE(_val, _newval) do { \ - (_val).value = (_newval); \ + (_val)->value = (_newval); \ _al_mem_barrier(); \ } while(0) #define ATOMIC_ADD(T, _val, _incr) __extension__({ \ static_assert(sizeof(T)==4, "Type "#T" has incorrect size!"); \ - static_assert(sizeof(T)==sizeof((_val).value), "Type "#T" has incorrect size!"); \ + static_assert(sizeof(T)==sizeof((_val)->value), "Type "#T" has incorrect size!"); \ T _r; \ - WRAP_ADD(_r, &(_val).value, (_incr)); \ + WRAP_ADD(_r, &(_val)->value, (_incr)); \ _r; \ }) #define ATOMIC_SUB(T, _val, _decr) __extension__({ \ static_assert(sizeof(T)==4, "Type "#T" has incorrect size!"); \ - static_assert(sizeof(T)==sizeof((_val).value), "Type "#T" has incorrect size!"); \ + static_assert(sizeof(T)==sizeof((_val)->value), "Type "#T" has incorrect size!"); \ T _r; \ - WRAP_SUB(_r, &(_val).value, (_decr)); \ + WRAP_SUB(_r, &(_val)->value, (_decr)); \ _r; \ }) #define ATOMIC_EXCHANGE(T, _val, _newval) __extension__({ \ static_assert(sizeof(T)==4 || sizeof(T)==8, "Type "#T" has incorrect size!"); \ - static_assert(sizeof(T)==sizeof((_val).value), "Type "#T" has incorrect size!"); \ + static_assert(sizeof(T)==sizeof((_val)->value), "Type "#T" has incorrect size!"); \ T _r; \ - if(sizeof(T) == 4) WRAP_XCHG("l", _r, &(_val).value, (_newval)); \ - else if(sizeof(T) == 8) WRAP_XCHG("q", _r, &(_val).value, (_newval)); \ + if(sizeof(T) == 4) WRAP_XCHG("l", _r, &(_val)->value, (_newval)); \ + else if(sizeof(T) == 8) WRAP_XCHG("q", _r, &(_val)->value, (_newval)); \ _r; \ }) #define ATOMIC_COMPARE_EXCHANGE(T, _val, _oldval, _newval) __extension__({ \ static_assert(sizeof(T)==4 || sizeof(T)==8, "Type "#T" has incorrect size!"); \ - static_assert(sizeof(T)==sizeof((_val).value), "Type "#T" has incorrect size!"); \ - __typeof(_oldval) _old = (_oldval); \ - if(sizeof(T) == 4) WRAP_CMPXCHG("l", (_oldval), &(_val).value, (_oldval), (_newval)); \ - else if(sizeof(T) == 8) WRAP_CMPXCHG("q", (_oldval), &(_val).value, (_oldval), (_newval)); \ - (_oldval) == _old; \ + static_assert(sizeof(T)==sizeof((_val)->value), "Type "#T" has incorrect size!"); \ + __typeof(*_oldval) _old = *(_oldval); \ + if(sizeof(T) == 4) WRAP_CMPXCHG("l", *(_oldval), &(_val)->value, _old, (_newval)); \ + else if(sizeof(T) == 8) WRAP_CMPXCHG("q", *(_oldval), &(_val)->value, _old, (_newval)); \ + *(_oldval) == _old; \ }) /* Atomics using Windows methods */ @@ -235,35 +235,35 @@ inline void *CompExchangePtr(XchgPtr *ptr, void *oldval, void *newval) #define ATOMIC_INIT_STATIC(_newval) {(_newval)} -#define ATOMIC_LOAD_UNSAFE(_val) ((_val).value) +#define ATOMIC_LOAD_UNSAFE(_val) ((_val)->value) #define ATOMIC_STORE_UNSAFE(_val, _newval) do { \ - (_val).value = (_newval); \ + (_val)->value = (_newval); \ } while(0) inline void _al_mem_barrier(void) { _ReadBarrier(); } -#define ATOMIC_LOAD(_val) (_al_mem_barrier(),(_val).value) +#define ATOMIC_LOAD(_val) (_al_mem_barrier(),(_val)->value) #define ATOMIC_STORE(_val, _newval) do { \ - (_val).value = (_newval); \ + (_val)->value = (_newval); \ _WriteBarrier(); \ } while(0) int _al_invalid_atomic_size(); /* not defined */ #define ATOMIC_ADD(T, _val, _incr) \ - ((sizeof(T)==4) ? WRAP_ADD(LONG, T, InterlockedExchangeAdd, &(_val).value, (_incr)) : \ + ((sizeof(T)==4) ? WRAP_ADD(LONG, T, InterlockedExchangeAdd, &(_val)->value, (_incr)) : \ (T)_al_invalid_atomic_size()) #define ATOMIC_SUB(T, _val, _decr) \ - ((sizeof(T)==4) ? WRAP_SUB(LONG, T, InterlockedExchangeAdd, &(_val).value, (_decr)) : \ + ((sizeof(T)==4) ? WRAP_SUB(LONG, T, InterlockedExchangeAdd, &(_val)->value, (_decr)) : \ (T)_al_invalid_atomic_size()) #define ATOMIC_EXCHANGE(T, _val, _newval) \ - ((sizeof(T)==4) ? WRAP_XCHG(LONG, T, InterlockedExchange, &(_val).value, (_newval)) : \ - (sizeof(T)==8) ? WRAP_XCHG(LONGLONG, T, InterlockedExchange64, &(_val).value, (_newval)) : \ + ((sizeof(T)==4) ? WRAP_XCHG(LONG, T, InterlockedExchange, &(_val)->value, (_newval)) : \ + (sizeof(T)==8) ? WRAP_XCHG(LONGLONG, T, InterlockedExchange64, &(_val)->value, (_newval)) : \ (T)_al_invalid_atomic_size()) #define ATOMIC_COMPARE_EXCHANGE(T, _val, _oldval, _newval) \ - ((sizeof(T)==4) ? WRAP_CMPXCHG(LONG, T, CompareAndSwap32, &(_val).value, (_newval), &(_oldval)) : \ - (sizeof(T)==8) ? WRAP_CMPXCHG(LONGLONG, T, CompareAndSwap64, &(_val).value, (_newval), &(_oldval)) : \ + ((sizeof(T)==4) ? WRAP_CMPXCHG(LONG, T, CompareAndSwap32, &(_val)->value, (_newval), (_oldval)) : \ + (sizeof(T)==8) ? WRAP_CMPXCHG(LONGLONG, T, CompareAndSwap64, &(_val)->value, (_newval), (_oldval)) : \ (bool)_al_invalid_atomic_size()) #else @@ -275,17 +275,17 @@ typedef unsigned int uint; typedef ATOMIC(uint) RefCount; inline void InitRef(RefCount *ptr, uint value) -{ ATOMIC_STORE_UNSAFE(*ptr, value); } +{ ATOMIC_STORE_UNSAFE(ptr, value); } inline uint ReadRef(RefCount *ptr) -{ return ATOMIC_LOAD(*ptr); } +{ return ATOMIC_LOAD(ptr); } inline uint IncrementRef(RefCount *ptr) -{ return ATOMIC_ADD(uint, *ptr, 1)+1; } +{ return ATOMIC_ADD(uint, ptr, 1)+1; } inline uint DecrementRef(RefCount *ptr) -{ return ATOMIC_SUB(uint, *ptr, 1)-1; } +{ return ATOMIC_SUB(uint, ptr, 1)-1; } inline uint ExchangeRef(RefCount *ptr, uint newval) -{ return ATOMIC_EXCHANGE(uint, *ptr, newval); } +{ return ATOMIC_EXCHANGE(uint, ptr, newval); } inline uint CompExchangeRef(RefCount *ptr, uint oldval, uint newval) -{ (void)ATOMIC_COMPARE_EXCHANGE(uint, *ptr, oldval, newval); return oldval; } +{ (void)ATOMIC_COMPARE_EXCHANGE(uint, ptr, &oldval, newval); return oldval; } #ifdef __cplusplus } |