aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-12-05 15:17:39 -0800
committerChris Robinson <[email protected]>2022-12-05 15:17:39 -0800
commit4de5c7dfeebc2335ad3d7c2dd4905284677a68c9 (patch)
tree849a6f5dd7b284e1766671cc13769d257f20ea03
parentdf6d61dd40b602af55f903564358b083bb8b37e4 (diff)
Avoid some uses of the LIKELY/UNLIKELY macros
-rw-r--r--al/buffer.cpp253
-rw-r--r--al/effect.cpp58
-rw-r--r--al/filter.cpp58
-rw-r--r--al/listener.cpp24
-rw-r--r--alc/effects/reverb.cpp2
-rw-r--r--common/alnumeric.h10
-rw-r--r--common/threads.cpp2
-rw-r--r--core/bformatdec.cpp2
-rw-r--r--core/converter.cpp2
-rw-r--r--core/device.h2
-rw-r--r--core/except.cpp2
-rw-r--r--core/logging.h6
-rw-r--r--core/mastering.cpp2
-rw-r--r--core/mixer/hrtfbase.h4
-rw-r--r--core/voice.cpp4
15 files changed, 217 insertions, 214 deletions
diff --git a/al/buffer.cpp b/al/buffer.cpp
index 77b484d0..01c0e2b4 100644
--- a/al/buffer.cpp
+++ b/al/buffer.cpp
@@ -411,14 +411,14 @@ bool EnsureBuffers(ALCdevice *device, size_t needed)
while(needed > count)
{
- if UNLIKELY(device->BufferList.size() >= 1<<25)
+ if(device->BufferList.size() >= 1<<25) [[alunlikely]]
return false;
device->BufferList.emplace_back();
auto sublist = device->BufferList.end() - 1;
sublist->FreeMask = ~0_u64;
sublist->Buffers = static_cast<ALbuffer*>(al_calloc(alignof(ALbuffer), sizeof(ALbuffer)*64));
- if UNLIKELY(!sublist->Buffers)
+ if(!sublist->Buffers) [[alunlikely]]
{
device->BufferList.pop_back();
return false;
@@ -467,10 +467,10 @@ inline ALbuffer *LookupBuffer(ALCdevice *device, ALuint id)
const size_t lidx{(id-1) >> 6};
const ALuint slidx{(id-1) & 0x3f};
- if UNLIKELY(lidx >= device->BufferList.size())
+ if(lidx >= device->BufferList.size()) [[alunlikely]]
return nullptr;
BufferSubList &sublist = device->BufferList[lidx];
- if UNLIKELY(sublist.FreeMask & (1_u64 << slidx))
+ if(sublist.FreeMask & (1_u64 << slidx)) [[alunlikely]]
return nullptr;
return sublist.Buffers + slidx;
}
@@ -531,13 +531,13 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size,
UserFmtChannels SrcChannels, UserFmtType SrcType, const al::byte *SrcData,
ALbitfieldSOFT access)
{
- if UNLIKELY(ReadRef(ALBuf->ref) != 0 || ALBuf->MappedAccess != 0)
+ if(ReadRef(ALBuf->ref) != 0 || ALBuf->MappedAccess != 0) [[alunlikely]]
SETERR_RETURN(context, AL_INVALID_OPERATION,, "Modifying storage for in-use buffer %u",
ALBuf->id);
/* Currently no channel configurations need to be converted. */
auto DstChannels = FmtFromUserFmt(SrcChannels);
- if UNLIKELY(!DstChannels)
+ if(!DstChannels) [[alunlikely]]
SETERR_RETURN(context, AL_INVALID_ENUM, , "Invalid format");
/* IMA4 and MSADPCM convert to 16-bit short.
@@ -548,18 +548,18 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size,
*/
if((access&MAP_READ_WRITE_FLAGS))
{
- if UNLIKELY(SrcType == UserFmtIMA4 || SrcType == UserFmtMSADPCM)
+ if(SrcType == UserFmtIMA4 || SrcType == UserFmtMSADPCM) [[alunlikely]]
SETERR_RETURN(context, AL_INVALID_VALUE,, "%s samples cannot be mapped",
NameFromUserFmtType(SrcType));
}
auto DstType = (SrcType == UserFmtIMA4 || SrcType == UserFmtMSADPCM)
? al::make_optional(FmtShort) : FmtFromUserFmt(SrcType);
- if UNLIKELY(!DstType)
+ if(!DstType) [[alunlikely]]
SETERR_RETURN(context, AL_INVALID_ENUM, , "Invalid format");
const ALuint unpackalign{ALBuf->UnpackAlign};
const ALuint align{SanitizeAlignment(SrcType, unpackalign)};
- if UNLIKELY(align < 1)
+ if(align < 1) [[alunlikely]]
SETERR_RETURN(context, AL_INVALID_VALUE,, "Invalid unpack alignment %u for %s samples",
unpackalign, NameFromUserFmtType(SrcType));
@@ -569,9 +569,9 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size,
if((access&AL_PRESERVE_DATA_BIT_SOFT))
{
/* Can only preserve data with the same format and alignment. */
- if UNLIKELY(ALBuf->mChannels != *DstChannels || ALBuf->OriginalType != SrcType)
+ if(ALBuf->mChannels != *DstChannels || ALBuf->OriginalType != SrcType) [[alunlikely]]
SETERR_RETURN(context, AL_INVALID_VALUE,, "Preserving data of mismatched format");
- if UNLIKELY(ALBuf->OriginalAlign != align)
+ if(ALBuf->OriginalAlign != align) [[alunlikely]]
SETERR_RETURN(context, AL_INVALID_VALUE,, "Preserving data of mismatched alignment");
if(ALBuf->mAmbiOrder != ambiorder)
SETERR_RETURN(context, AL_INVALID_VALUE,, "Preserving data of mismatched order");
@@ -584,12 +584,12 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size,
((SrcType == UserFmtIMA4) ? (align-1)/2 + 4 :
(SrcType == UserFmtMSADPCM) ? (align-2)/2 + 7 :
(align * BytesFromUserFmt(SrcType)))};
- if UNLIKELY((size%SrcByteAlign) != 0)
+ if((size%SrcByteAlign) != 0) [[alunlikely]]
SETERR_RETURN(context, AL_INVALID_VALUE,,
"Data size %d is not a multiple of frame size %d (%d unpack alignment)",
size, SrcByteAlign, align);
- if UNLIKELY(size/SrcByteAlign > std::numeric_limits<ALsizei>::max()/align)
+ if(size/SrcByteAlign > std::numeric_limits<ALsizei>::max()/align) [[alunlikely]]
SETERR_RETURN(context, AL_OUT_OF_MEMORY,,
"Buffer size overflow, %d blocks x %d samples per block", size/SrcByteAlign, align);
const ALuint frames{size / SrcByteAlign * align};
@@ -599,7 +599,7 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, ALuint size,
*/
ALuint NumChannels{ChannelsFromFmt(*DstChannels, ambiorder)};
ALuint FrameSize{NumChannels * BytesFromFmt(*DstType)};
- if UNLIKELY(frames > std::numeric_limits<size_t>::max()/FrameSize)
+ if(frames > std::numeric_limits<size_t>::max()/FrameSize) [[alunlikely]]
SETERR_RETURN(context, AL_OUT_OF_MEMORY,,
"Buffer size overflow, %d frames x %d bytes per frame", frames, FrameSize);
size_t newsize{static_cast<size_t>(frames) * FrameSize};
@@ -686,18 +686,18 @@ void PrepareCallback(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq,
UserFmtChannels SrcChannels, UserFmtType SrcType, ALBUFFERCALLBACKTYPESOFT callback,
void *userptr)
{
- if UNLIKELY(ReadRef(ALBuf->ref) != 0 || ALBuf->MappedAccess != 0)
+ if(ReadRef(ALBuf->ref) != 0 || ALBuf->MappedAccess != 0) [[alunlikely]]
SETERR_RETURN(context, AL_INVALID_OPERATION,, "Modifying callback for in-use buffer %u",
ALBuf->id);
/* Currently no channel configurations need to be converted. */
auto DstChannels = FmtFromUserFmt(SrcChannels);
- if UNLIKELY(!DstChannels)
+ if(!DstChannels) [[alunlikely]]
SETERR_RETURN(context, AL_INVALID_ENUM,, "Invalid format");
/* IMA4 and MSADPCM convert to 16-bit short. Not supported with callbacks. */
auto DstType = FmtFromUserFmt(SrcType);
- if UNLIKELY(!DstType)
+ if(!DstType) [[alunlikely]]
SETERR_RETURN(context, AL_INVALID_ENUM,, "Unsupported callback format");
const ALuint ambiorder{IsBFormat(*DstChannels) ? ALBuf->UnpackAmbiOrder :
@@ -823,11 +823,11 @@ AL_API void AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
- if UNLIKELY(n < 0)
+ if(n < 0) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Generating %d buffers", n);
- if UNLIKELY(n <= 0) return;
+ if(n <= 0) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -837,7 +837,7 @@ START_API_FUNC
return;
}
- if LIKELY(n == 1)
+ if(n == 1) [[allikely]]
{
/* Special handling for the easy and normal case. */
ALbuffer *buffer{AllocBuffer(device)};
@@ -863,11 +863,11 @@ AL_API void AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
- if UNLIKELY(n < 0)
+ if(n < 0) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Deleting %d buffers", n);
- if UNLIKELY(n <= 0) return;
+ if(n <= 0) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -877,12 +877,12 @@ START_API_FUNC
{
if(!bid) return true;
ALbuffer *ALBuf{LookupBuffer(device, bid)};
- if UNLIKELY(!ALBuf)
+ if(!ALBuf) [[alunlikely]]
{
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", bid);
return false;
}
- if UNLIKELY(ReadRef(ALBuf->ref) != 0)
+ if(ReadRef(ALBuf->ref) != 0) [[alunlikely]]
{
context->setError(AL_INVALID_OPERATION, "Deleting in-use buffer %u", bid);
return false;
@@ -891,7 +891,7 @@ START_API_FUNC
};
const ALuint *buffers_end = buffers + n;
auto invbuf = std::find_if_not(buffers, buffers_end, validate_buffer);
- if UNLIKELY(invbuf != buffers_end) return;
+ if(invbuf != buffers_end) [[alunlikely]] return;
/* All good. Delete non-0 buffer IDs. */
auto delete_buffer = [device](const ALuint bid) -> void
@@ -907,7 +907,7 @@ AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if LIKELY(context)
+ if(context) [[allikely]]
{
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
@@ -928,28 +928,28 @@ AL_API void AL_APIENTRY alBufferStorageSOFT(ALuint buffer, ALenum format, const
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if UNLIKELY(!albuf)
+ if(!albuf) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY(size < 0)
+ else if(size < 0) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Negative storage size %d", size);
- else if UNLIKELY(freq < 1)
+ else if(freq < 1) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Invalid sample rate %d", freq);
- else if UNLIKELY((flags&INVALID_STORAGE_MASK) != 0)
+ else if((flags&INVALID_STORAGE_MASK) != 0) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Invalid storage flags 0x%x",
flags&INVALID_STORAGE_MASK);
- else if UNLIKELY((flags&AL_MAP_PERSISTENT_BIT_SOFT) && !(flags&MAP_READ_WRITE_FLAGS))
+ else if((flags&AL_MAP_PERSISTENT_BIT_SOFT) && !(flags&MAP_READ_WRITE_FLAGS)) [[alunlikely]]
context->setError(AL_INVALID_VALUE,
"Declaring persistently mapped storage without read or write access");
else
{
auto usrfmt = DecomposeUserFormat(format);
- if UNLIKELY(!usrfmt)
+ if(!usrfmt) [[alunlikely]]
context->setError(AL_INVALID_ENUM, "Invalid format 0x%04x", format);
else
{
@@ -964,39 +964,40 @@ AL_API void* AL_APIENTRY alMapBufferSOFT(ALuint buffer, ALsizei offset, ALsizei
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return nullptr;
+ if(!context) [[alunlikely]] return nullptr;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if UNLIKELY(!albuf)
+ if(!albuf) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY((access&INVALID_MAP_FLAGS) != 0)
+ else if((access&INVALID_MAP_FLAGS) != 0) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Invalid map flags 0x%x", access&INVALID_MAP_FLAGS);
- else if UNLIKELY(!(access&MAP_READ_WRITE_FLAGS))
+ else if(!(access&MAP_READ_WRITE_FLAGS)) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Mapping buffer %u without read or write access",
buffer);
else
{
ALbitfieldSOFT unavailable = (albuf->Access^access) & access;
- if UNLIKELY(ReadRef(albuf->ref) != 0 && !(access&AL_MAP_PERSISTENT_BIT_SOFT))
+ if(ReadRef(albuf->ref) != 0 && !(access&AL_MAP_PERSISTENT_BIT_SOFT)) [[alunlikely]]
context->setError(AL_INVALID_OPERATION,
"Mapping in-use buffer %u without persistent mapping", buffer);
- else if UNLIKELY(albuf->MappedAccess != 0)
+ else if(albuf->MappedAccess != 0) [[alunlikely]]
context->setError(AL_INVALID_OPERATION, "Mapping already-mapped buffer %u", buffer);
- else if UNLIKELY((unavailable&AL_MAP_READ_BIT_SOFT))
+ else if((unavailable&AL_MAP_READ_BIT_SOFT)) [[alunlikely]]
context->setError(AL_INVALID_VALUE,
"Mapping buffer %u for reading without read access", buffer);
- else if UNLIKELY((unavailable&AL_MAP_WRITE_BIT_SOFT))
+ else if((unavailable&AL_MAP_WRITE_BIT_SOFT)) [[alunlikely]]
context->setError(AL_INVALID_VALUE,
"Mapping buffer %u for writing without write access", buffer);
- else if UNLIKELY((unavailable&AL_MAP_PERSISTENT_BIT_SOFT))
+ else if((unavailable&AL_MAP_PERSISTENT_BIT_SOFT)) [[alunlikely]]
context->setError(AL_INVALID_VALUE,
"Mapping buffer %u persistently without persistent access", buffer);
- else if UNLIKELY(offset < 0 || length <= 0
+ else if(offset < 0 || length <= 0
|| static_cast<ALuint>(offset) >= albuf->OriginalSize
|| static_cast<ALuint>(length) > albuf->OriginalSize - static_cast<ALuint>(offset))
+ [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Mapping invalid range %d+%d for buffer %u",
offset, length, buffer);
else
@@ -1017,15 +1018,15 @@ AL_API void AL_APIENTRY alUnmapBufferSOFT(ALuint buffer)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if UNLIKELY(!albuf)
+ if(!albuf) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY(albuf->MappedAccess == 0)
+ else if(albuf->MappedAccess == 0) [[alunlikely]]
context->setError(AL_INVALID_OPERATION, "Unmapping unmapped buffer %u", buffer);
else
{
@@ -1040,20 +1041,20 @@ AL_API void AL_APIENTRY alFlushMappedBufferSOFT(ALuint buffer, ALsizei offset, A
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if UNLIKELY(!albuf)
+ if(!albuf) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY(!(albuf->MappedAccess&AL_MAP_WRITE_BIT_SOFT))
+ else if(!(albuf->MappedAccess&AL_MAP_WRITE_BIT_SOFT)) [[alunlikely]]
context->setError(AL_INVALID_OPERATION, "Flushing buffer %u while not mapped for writing",
buffer);
- else if UNLIKELY(offset < albuf->MappedOffset || length <= 0
+ else if(offset < albuf->MappedOffset || length <= 0
|| offset >= albuf->MappedOffset+albuf->MappedSize
- || length > albuf->MappedOffset+albuf->MappedSize-offset)
+ || length > albuf->MappedOffset+albuf->MappedSize-offset) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Flushing invalid range %d+%d on buffer %u", offset,
length, buffer);
else
@@ -1072,20 +1073,20 @@ AL_API void AL_APIENTRY alBufferSubDataSOFT(ALuint buffer, ALenum format, const
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if UNLIKELY(!albuf)
+ if(!albuf) [[alunlikely]]
{
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
return;
}
auto usrfmt = DecomposeUserFormat(format);
- if UNLIKELY(!usrfmt)
+ if(!usrfmt) [[alunlikely]]
{
context->setError(AL_INVALID_ENUM, "Invalid format 0x%04x", format);
return;
@@ -1093,18 +1094,18 @@ START_API_FUNC
ALuint unpack_align{albuf->UnpackAlign};
ALuint align{SanitizeAlignment(usrfmt->type, unpack_align)};
- if UNLIKELY(align < 1)
+ if(align < 1) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Invalid unpack alignment %u", unpack_align);
- else if UNLIKELY(long{usrfmt->channels} != long{albuf->mChannels}
- || usrfmt->type != albuf->OriginalType)
+ else if(long{usrfmt->channels} != long{albuf->mChannels}
+ || usrfmt->type != albuf->OriginalType) [[alunlikely]]
context->setError(AL_INVALID_ENUM, "Unpacking data with mismatched format");
- else if UNLIKELY(align != albuf->OriginalAlign)
+ else if(align != albuf->OriginalAlign) [[alunlikely]]
context->setError(AL_INVALID_VALUE,
"Unpacking data with alignment %u does not match original alignment %u", align,
albuf->OriginalAlign);
- else if UNLIKELY(albuf->isBFormat() && albuf->UnpackAmbiOrder != albuf->mAmbiOrder)
+ else if(albuf->isBFormat() && albuf->UnpackAmbiOrder != albuf->mAmbiOrder) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Unpacking data with mismatched ambisonic order");
- else if UNLIKELY(albuf->MappedAccess != 0)
+ else if(albuf->MappedAccess != 0) [[alunlikely]]
context->setError(AL_INVALID_OPERATION, "Unpacking data into mapped buffer %u", buffer);
else
{
@@ -1116,15 +1117,16 @@ START_API_FUNC
(align * frame_size)
};
- if UNLIKELY(offset < 0 || length < 0 || static_cast<ALuint>(offset) > albuf->OriginalSize
+ if(offset < 0 || length < 0 || static_cast<ALuint>(offset) > albuf->OriginalSize
|| static_cast<ALuint>(length) > albuf->OriginalSize-static_cast<ALuint>(offset))
+ [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Invalid data sub-range %d+%d on buffer %u",
offset, length, buffer);
- else if UNLIKELY((static_cast<ALuint>(offset)%byte_align) != 0)
+ else if((static_cast<ALuint>(offset)%byte_align) != 0) [[alunlikely]]
context->setError(AL_INVALID_VALUE,
"Sub-range offset %d is not a multiple of frame size %d (%d unpack alignment)",
offset, byte_align, align);
- else if UNLIKELY((static_cast<ALuint>(length)%byte_align) != 0)
+ else if((static_cast<ALuint>(length)%byte_align) != 0) [[alunlikely]]
context->setError(AL_INVALID_VALUE,
"Sub-range length %d is not a multiple of frame size %d (%d unpack alignment)",
length, byte_align, align);
@@ -1158,7 +1160,7 @@ AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint /*buffer*/, ALuint /*samplera
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
context->setError(AL_INVALID_OPERATION, "alBufferSamplesSOFT not supported");
}
@@ -1169,7 +1171,7 @@ AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint /*buffer*/, ALsizei /*offs
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
context->setError(AL_INVALID_OPERATION, "alBufferSubSamplesSOFT not supported");
}
@@ -1180,7 +1182,7 @@ AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint /*buffer*/, ALsizei /*offs
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
context->setError(AL_INVALID_OPERATION, "alGetBufferSamplesSOFT not supported");
}
@@ -1190,7 +1192,7 @@ AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum /*format*/)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return AL_FALSE;
+ if(!context) [[alunlikely]] return AL_FALSE;
context->setError(AL_INVALID_OPERATION, "alIsBufferFormatSupportedSOFT not supported");
return AL_FALSE;
@@ -1202,12 +1204,12 @@ AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum param, ALfloat /*value*/
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
+ if(LookupBuffer(device, buffer) == nullptr) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
else switch(param)
{
@@ -1222,12 +1224,12 @@ AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum param,
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
+ if(LookupBuffer(device, buffer) == nullptr) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
else switch(param)
{
@@ -1241,14 +1243,14 @@ AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum param, const ALfloat *v
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
+ if(LookupBuffer(device, buffer) == nullptr) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY(!values)
+ else if(!values) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
@@ -1263,52 +1265,53 @@ AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum param, ALint value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if UNLIKELY(!albuf)
+ if(!albuf) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
else switch(param)
{
case AL_UNPACK_BLOCK_ALIGNMENT_SOFT:
- if UNLIKELY(value < 0)
+ if(value < 0) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Invalid unpack block alignment %d", value);
else
albuf->UnpackAlign = static_cast<ALuint>(value);
break;
case AL_PACK_BLOCK_ALIGNMENT_SOFT:
- if UNLIKELY(value < 0)
+ if(value < 0) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Invalid pack block alignment %d", value);
else
albuf->PackAlign = static_cast<ALuint>(value);
break;
case AL_AMBISONIC_LAYOUT_SOFT:
- if UNLIKELY(ReadRef(albuf->ref) != 0)
+ if(ReadRef(albuf->ref) != 0) [[alunlikely]]
context->setError(AL_INVALID_OPERATION, "Modifying in-use buffer %u's ambisonic layout",
buffer);
- else if UNLIKELY(value != AL_FUMA_SOFT && value != AL_ACN_SOFT)
+ else if(value != AL_FUMA_SOFT && value != AL_ACN_SOFT) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Invalid unpack ambisonic layout %04x", value);
else
albuf->mAmbiLayout = AmbiLayoutFromEnum(value).value();
break;
case AL_AMBISONIC_SCALING_SOFT:
- if UNLIKELY(ReadRef(albuf->ref) != 0)
+ if(ReadRef(albuf->ref) != 0) [[alunlikely]]
context->setError(AL_INVALID_OPERATION, "Modifying in-use buffer %u's ambisonic scaling",
buffer);
- else if UNLIKELY(value != AL_FUMA_SOFT && value != AL_SN3D_SOFT && value != AL_N3D_SOFT)
+ else if(value != AL_FUMA_SOFT && value != AL_SN3D_SOFT && value != AL_N3D_SOFT)
+ [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Invalid unpack ambisonic scaling %04x", value);
else
albuf->mAmbiScaling = AmbiScalingFromEnum(value).value();
break;
case AL_UNPACK_AMBISONIC_ORDER_SOFT:
- if UNLIKELY(value < 1 || value > 14)
+ if(value < 1 || value > 14) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Invalid unpack ambisonic order %d", value);
else
albuf->UnpackAmbiOrder = static_cast<ALuint>(value);
@@ -1325,12 +1328,12 @@ AL_API void AL_APIENTRY alBuffer3i(ALuint buffer, ALenum param,
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
+ if(LookupBuffer(device, buffer) == nullptr) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
else switch(param)
{
@@ -1358,24 +1361,24 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if UNLIKELY(!albuf)
+ if(!albuf) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY(!values)
+ else if(!values) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
case AL_LOOP_POINTS_SOFT:
- if UNLIKELY(ReadRef(albuf->ref) != 0)
+ if(ReadRef(albuf->ref) != 0) [[alunlikely]]
context->setError(AL_INVALID_OPERATION, "Modifying in-use buffer %u's loop points",
buffer);
- else if UNLIKELY(values[0] < 0 || values[0] >= values[1]
- || static_cast<ALuint>(values[1]) > albuf->mSampleLen)
+ else if(values[0] < 0 || values[0] >= values[1]
+ || static_cast<ALuint>(values[1]) > albuf->mSampleLen) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Invalid loop point range %d -> %d on buffer %u",
values[0], values[1], buffer);
else
@@ -1396,15 +1399,15 @@ AL_API void AL_APIENTRY alGetBufferf(ALuint buffer, ALenum param, ALfloat *value
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if UNLIKELY(!albuf)
+ if(!albuf) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY(!value)
+ else if(!value) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
@@ -1418,14 +1421,14 @@ AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum param, ALfloat *valu
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
+ if(LookupBuffer(device, buffer) == nullptr) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY(!value1 || !value2 || !value3)
+ else if(!value1 || !value2 || !value3) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
@@ -1446,14 +1449,14 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
+ if(LookupBuffer(device, buffer) == nullptr) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY(!values)
+ else if(!values) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
@@ -1468,14 +1471,14 @@ AL_API void AL_APIENTRY alGetBufferi(ALuint buffer, ALenum param, ALint *value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if UNLIKELY(!albuf)
+ if(!albuf) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY(!value)
+ else if(!value) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
@@ -1525,13 +1528,13 @@ AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum param, ALint *value1
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
+ if(LookupBuffer(device, buffer) == nullptr) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY(!value1 || !value2 || !value3)
+ else if(!value1 || !value2 || !value3) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
@@ -1563,14 +1566,14 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if UNLIKELY(!albuf)
+ if(!albuf) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY(!values)
+ else if(!values) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
@@ -1591,22 +1594,22 @@ AL_API void AL_APIENTRY alBufferCallbackSOFT(ALuint buffer, ALenum format, ALsiz
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if UNLIKELY(!albuf)
+ if(!albuf) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY(freq < 1)
+ else if(freq < 1) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Invalid sample rate %d", freq);
- else if UNLIKELY(callback == nullptr)
+ else if(callback == nullptr) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "NULL callback");
else
{
auto usrfmt = DecomposeUserFormat(format);
- if UNLIKELY(!usrfmt)
+ if(!usrfmt) [[alunlikely]]
context->setError(AL_INVALID_ENUM, "Invalid format 0x%04x", format);
else
PrepareCallback(context.get(), albuf, freq, usrfmt->channels, usrfmt->type, callback,
@@ -1619,14 +1622,14 @@ AL_API void AL_APIENTRY alGetBufferPtrSOFT(ALuint buffer, ALenum param, ALvoid *
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
ALbuffer *albuf = LookupBuffer(device, buffer);
- if UNLIKELY(!albuf)
+ if(!albuf) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY(!value)
+ else if(!value) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
@@ -1647,13 +1650,13 @@ AL_API void AL_APIENTRY alGetBuffer3PtrSOFT(ALuint buffer, ALenum param, ALvoid
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
+ if(LookupBuffer(device, buffer) == nullptr) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY(!value1 || !value2 || !value3)
+ else if(!value1 || !value2 || !value3) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
@@ -1675,13 +1678,13 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->BufferLock};
- if UNLIKELY(LookupBuffer(device, buffer) == nullptr)
+ if(LookupBuffer(device, buffer) == nullptr) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid buffer ID %u", buffer);
- else if UNLIKELY(!values)
+ else if(!values) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "NULL pointer");
else switch(param)
{
diff --git a/al/effect.cpp b/al/effect.cpp
index 90a4dfde..7a3f872d 100644
--- a/al/effect.cpp
+++ b/al/effect.cpp
@@ -166,14 +166,14 @@ bool EnsureEffects(ALCdevice *device, size_t needed)
while(needed > count)
{
- if UNLIKELY(device->EffectList.size() >= 1<<25)
+ if(device->EffectList.size() >= 1<<25) [[alunlikely]]
return false;
device->EffectList.emplace_back();
auto sublist = device->EffectList.end() - 1;
sublist->FreeMask = ~0_u64;
sublist->Effects = static_cast<ALeffect*>(al_calloc(alignof(ALeffect), sizeof(ALeffect)*64));
- if UNLIKELY(!sublist->Effects)
+ if(!sublist->Effects) [[alunlikely]]
{
device->EffectList.pop_back();
return false;
@@ -219,10 +219,10 @@ inline ALeffect *LookupEffect(ALCdevice *device, ALuint id)
const size_t lidx{(id-1) >> 6};
const ALuint slidx{(id-1) & 0x3f};
- if UNLIKELY(lidx >= device->EffectList.size())
+ if(lidx >= device->EffectList.size()) [[alunlikely]]
return nullptr;
EffectSubList &sublist = device->EffectList[lidx];
- if UNLIKELY(sublist.FreeMask & (1_u64 << slidx))
+ if(sublist.FreeMask & (1_u64 << slidx)) [[alunlikely]]
return nullptr;
return sublist.Effects + slidx;
}
@@ -233,11 +233,11 @@ AL_API void AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
- if UNLIKELY(n < 0)
+ if(n < 0) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Generating %d effects", n);
- if UNLIKELY(n <= 0) return;
+ if(n <= 0) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
@@ -247,7 +247,7 @@ START_API_FUNC
return;
}
- if LIKELY(n == 1)
+ if(n == 1) [[allikely]]
{
/* Special handling for the easy and normal case. */
ALeffect *effect{AllocEffect(device)};
@@ -273,11 +273,11 @@ AL_API void AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
- if UNLIKELY(n < 0)
+ if(n < 0) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Deleting %d effects", n);
- if UNLIKELY(n <= 0) return;
+ if(n <= 0) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
@@ -288,7 +288,7 @@ START_API_FUNC
const ALuint *effects_end = effects + n;
auto inveffect = std::find_if_not(effects, effects_end, validate_effect);
- if UNLIKELY(inveffect != effects_end)
+ if(inveffect != effects_end) [[alunlikely]]
{
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", *inveffect);
return;
@@ -308,7 +308,7 @@ AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if LIKELY(context)
+ if(context) [[allikely]]
{
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
@@ -323,13 +323,13 @@ AL_API void AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
- if UNLIKELY(!aleffect)
+ if(!aleffect) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else if(param == AL_EFFECT_TYPE)
{
@@ -373,13 +373,13 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
- if UNLIKELY(!aleffect)
+ if(!aleffect) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else try
{
@@ -396,13 +396,13 @@ AL_API void AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
- if UNLIKELY(!aleffect)
+ if(!aleffect) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else try
{
@@ -419,13 +419,13 @@ AL_API void AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *v
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
ALeffect *aleffect{LookupEffect(device, effect)};
- if UNLIKELY(!aleffect)
+ if(!aleffect) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else try
{
@@ -442,13 +442,13 @@ AL_API void AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
- if UNLIKELY(!aleffect)
+ if(!aleffect) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else if(param == AL_EFFECT_TYPE)
*value = aleffect->type;
@@ -474,13 +474,13 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
- if UNLIKELY(!aleffect)
+ if(!aleffect) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else try
{
@@ -497,13 +497,13 @@ AL_API void AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *value
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
- if UNLIKELY(!aleffect)
+ if(!aleffect) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else try
{
@@ -520,13 +520,13 @@ AL_API void AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *valu
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->EffectLock};
const ALeffect *aleffect{LookupEffect(device, effect)};
- if UNLIKELY(!aleffect)
+ if(!aleffect) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid effect ID %u", effect);
else try
{
diff --git a/al/filter.cpp b/al/filter.cpp
index f4b0ac9d..f0274ed7 100644
--- a/al/filter.cpp
+++ b/al/filter.cpp
@@ -331,14 +331,14 @@ bool EnsureFilters(ALCdevice *device, size_t needed)
while(needed > count)
{
- if UNLIKELY(device->FilterList.size() >= 1<<25)
+ if(device->FilterList.size() >= 1<<25) [[alunlikely]]
return false;
device->FilterList.emplace_back();
auto sublist = device->FilterList.end() - 1;
sublist->FreeMask = ~0_u64;
sublist->Filters = static_cast<ALfilter*>(al_calloc(alignof(ALfilter), sizeof(ALfilter)*64));
- if UNLIKELY(!sublist->Filters)
+ if(!sublist->Filters) [[alunlikely]]
{
device->FilterList.pop_back();
return false;
@@ -386,10 +386,10 @@ inline ALfilter *LookupFilter(ALCdevice *device, ALuint id)
const size_t lidx{(id-1) >> 6};
const ALuint slidx{(id-1) & 0x3f};
- if UNLIKELY(lidx >= device->FilterList.size())
+ if(lidx >= device->FilterList.size()) [[alunlikely]]
return nullptr;
FilterSubList &sublist = device->FilterList[lidx];
- if UNLIKELY(sublist.FreeMask & (1_u64 << slidx))
+ if(sublist.FreeMask & (1_u64 << slidx)) [[alunlikely]]
return nullptr;
return sublist.Filters + slidx;
}
@@ -400,11 +400,11 @@ AL_API void AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
- if UNLIKELY(n < 0)
+ if(n < 0) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Generating %d filters", n);
- if UNLIKELY(n <= 0) return;
+ if(n <= 0) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
@@ -414,7 +414,7 @@ START_API_FUNC
return;
}
- if LIKELY(n == 1)
+ if(n == 1) [[allikely]]
{
/* Special handling for the easy and normal case. */
ALfilter *filter{AllocFilter(device)};
@@ -440,11 +440,11 @@ AL_API void AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
- if UNLIKELY(n < 0)
+ if(n < 0) [[alunlikely]]
context->setError(AL_INVALID_VALUE, "Deleting %d filters", n);
- if UNLIKELY(n <= 0) return;
+ if(n <= 0) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
@@ -455,7 +455,7 @@ START_API_FUNC
const ALuint *filters_end = filters + n;
auto invflt = std::find_if_not(filters, filters_end, validate_filter);
- if UNLIKELY(invflt != filters_end)
+ if(invflt != filters_end) [[alunlikely]]
{
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", *invflt);
return;
@@ -475,7 +475,7 @@ AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if LIKELY(context)
+ if(context) [[allikely]]
{
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
@@ -491,13 +491,13 @@ AL_API void AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
- if UNLIKELY(!alfilt)
+ if(!alfilt) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else
{
@@ -532,13 +532,13 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
- if UNLIKELY(!alfilt)
+ if(!alfilt) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else try
{
@@ -555,13 +555,13 @@ AL_API void AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
- if UNLIKELY(!alfilt)
+ if(!alfilt) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else try
{
@@ -578,13 +578,13 @@ AL_API void AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *v
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
ALfilter *alfilt{LookupFilter(device, filter)};
- if UNLIKELY(!alfilt)
+ if(!alfilt) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else try
{
@@ -601,13 +601,13 @@ AL_API void AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
const ALfilter *alfilt{LookupFilter(device, filter)};
- if UNLIKELY(!alfilt)
+ if(!alfilt) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else
{
@@ -636,13 +636,13 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
const ALfilter *alfilt{LookupFilter(device, filter)};
- if UNLIKELY(!alfilt)
+ if(!alfilt) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else try
{
@@ -659,13 +659,13 @@ AL_API void AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *value
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
const ALfilter *alfilt{LookupFilter(device, filter)};
- if UNLIKELY(!alfilt)
+ if(!alfilt) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else try
{
@@ -682,13 +682,13 @@ AL_API void AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *valu
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALCdevice *device{context->mALDevice.get()};
std::lock_guard<std::mutex> _{device->FilterLock};
const ALfilter *alfilt{LookupFilter(device, filter)};
- if UNLIKELY(!alfilt)
+ if(!alfilt) [[alunlikely]]
context->setError(AL_INVALID_NAME, "Invalid filter ID %u", filter);
else try
{
diff --git a/al/listener.cpp b/al/listener.cpp
index 9484d9b1..a71e2999 100644
--- a/al/listener.cpp
+++ b/al/listener.cpp
@@ -81,7 +81,7 @@ AL_API void AL_APIENTRY alListenerf(ALenum param, ALfloat value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -111,7 +111,7 @@ AL_API void AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat value
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -161,7 +161,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -193,7 +193,7 @@ AL_API void AL_APIENTRY alListeneri(ALenum param, ALint /*value*/)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
std::lock_guard<std::mutex> _{context->mPropLock};
switch(param)
@@ -216,7 +216,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
std::lock_guard<std::mutex> _{context->mPropLock};
switch(param)
@@ -253,7 +253,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
std::lock_guard<std::mutex> _{context->mPropLock};
if(!values)
@@ -271,7 +271,7 @@ AL_API void AL_APIENTRY alGetListenerf(ALenum param, ALfloat *value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -297,7 +297,7 @@ AL_API void AL_APIENTRY alGetListener3f(ALenum param, ALfloat *value1, ALfloat *
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -340,7 +340,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -369,7 +369,7 @@ AL_API void AL_APIENTRY alGetListeneri(ALenum param, ALint *value)
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
std::lock_guard<std::mutex> _{context->mPropLock};
if(!value)
@@ -386,7 +386,7 @@ AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *valu
START_API_FUNC
{
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
@@ -424,7 +424,7 @@ START_API_FUNC
}
ContextRef context{GetContextRef()};
- if UNLIKELY(!context) return;
+ if(!context) [[alunlikely]] return;
ALlistener &listener = context->mListener;
std::lock_guard<std::mutex> _{context->mPropLock};
diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp
index dd89dccd..3464628c 100644
--- a/alc/effects/reverb.cpp
+++ b/alc/effects/reverb.cpp
@@ -1752,7 +1752,7 @@ void ReverbState::process(const size_t samplesToDo, const al::span<const FloatBu
}
/* Process reverb for these samples. */
- if LIKELY(!mDoFading)
+ if(!mDoFading) [[allikely]]
{
/* Generate non-faded early reflections and late reverb. */
earlyUnfaded(offset, samplesToDo);
diff --git a/common/alnumeric.h b/common/alnumeric.h
index 9e7a7f07..b617b363 100644
--- a/common/alnumeric.h
+++ b/common/alnumeric.h
@@ -161,11 +161,11 @@ inline int float2int(float f) noexcept
shift = ((conv.i>>23)&0xff) - (127+23);
/* Over/underflow */
- if UNLIKELY(shift >= 31 || shift < -23)
+ if(shift >= 31 || shift < -23) [[alunlikely]]
return 0;
mant = (conv.i&0x7fffff) | 0x800000;
- if LIKELY(shift < 0)
+ if(shift < 0) [[allikely]]
return (mant >> -shift) * sign;
return (mant << shift) * sign;
@@ -198,11 +198,11 @@ inline int double2int(double d) noexcept
shift = ((conv.i64 >> 52) & 0x7ff) - (1023 + 52);
/* Over/underflow */
- if UNLIKELY(shift >= 63 || shift < -52)
+ if(shift >= 63 || shift < -52) [[alunlikely]]
return 0;
mant = (conv.i64 & 0xfffffffffffff_i64) | 0x10000000000000_i64;
- if LIKELY(shift < 0)
+ if(shift < 0) [[allikely]]
return (int)(mant >> -shift) * sign;
return (int)(mant << shift) * sign;
@@ -251,7 +251,7 @@ inline float fast_roundf(float f) noexcept
sign = (conv.i>>31)&0x01;
expo = (conv.i>>23)&0xff;
- if UNLIKELY(expo >= 150/*+23*/)
+ if(expo >= 150/*+23*/) [[alunlikely]]
{
/* An exponent (base-2) of 23 or higher is incapable of sub-integral
* precision, so it's already an integral value. We don't need to worry
diff --git a/common/threads.cpp b/common/threads.cpp
index 52c61ac4..19a6bbf0 100644
--- a/common/threads.cpp
+++ b/common/threads.cpp
@@ -79,7 +79,7 @@ semaphore::~semaphore()
void semaphore::post()
{
- if UNLIKELY(!ReleaseSemaphore(static_cast<HANDLE>(mSem), 1, nullptr))
+ if(!ReleaseSemaphore(static_cast<HANDLE>(mSem), 1, nullptr))
throw std::system_error(std::make_error_code(std::errc::value_too_large));
}
diff --git a/core/bformatdec.cpp b/core/bformatdec.cpp
index 606093c0..5c3f1864 100644
--- a/core/bformatdec.cpp
+++ b/core/bformatdec.cpp
@@ -115,7 +115,7 @@ void BFormatDec::processStablize(const al::span<FloatBufferLine> OutBuffer,
auto &DelayBuf = mStablizer->DelayBuf[i];
auto buffer_end = OutBuffer[i].begin() + SamplesToDo;
- if LIKELY(SamplesToDo >= FrontStablizer::DelayLength)
+ if(SamplesToDo >= FrontStablizer::DelayLength) [[allikely]]
{
auto delay_end = std::rotate(OutBuffer[i].begin(),
buffer_end - FrontStablizer::DelayLength, buffer_end);
diff --git a/core/converter.cpp b/core/converter.cpp
index 75c37149..e0fbaecd 100644
--- a/core/converter.cpp
+++ b/core/converter.cpp
@@ -143,7 +143,7 @@ void Multi2Mono(uint chanmask, const size_t step, const float scale, float *REST
std::fill_n(dst, frames, 0.0f);
for(size_t c{0};chanmask;++c)
{
- if LIKELY((chanmask&1))
+ if((chanmask&1)) [[allikely]]
{
for(size_t i{0u};i < frames;i++)
dst[i] += LoadSample<T>(ssrc[i*step + c]);
diff --git a/core/device.h b/core/device.h
index 292c1730..a287dd57 100644
--- a/core/device.h
+++ b/core/device.h
@@ -277,7 +277,7 @@ struct DeviceBase {
void ProcessBs2b(const size_t SamplesToDo);
inline void postProcess(const size_t SamplesToDo)
- { if LIKELY(PostProcess) (this->*PostProcess)(SamplesToDo); }
+ { if(PostProcess) [[allikely]] (this->*PostProcess)(SamplesToDo); }
void renderSamples(const al::span<float*> outBuffers, const uint numSamples);
void renderSamples(void *outBuffer, const uint numSamples, const size_t frameStep);
diff --git a/core/except.cpp b/core/except.cpp
index 07bb410a..5e757ed7 100644
--- a/core/except.cpp
+++ b/core/except.cpp
@@ -19,7 +19,7 @@ void base_exception::setMessage(const char* msg, std::va_list args)
std::va_list args2;
va_copy(args2, args);
int msglen{std::vsnprintf(nullptr, 0, msg, args)};
- if LIKELY(msglen > 0)
+ if(msglen > 0) [[allikely]]
{
mMessage.resize(static_cast<size_t>(msglen)+1);
std::vsnprintf(&mMessage[0], mMessage.length(), msg, args2);
diff --git a/core/logging.h b/core/logging.h
index 81465929..87f1c0f5 100644
--- a/core/logging.h
+++ b/core/logging.h
@@ -19,17 +19,17 @@ extern FILE *gLogFile;
#if !defined(_WIN32) && !defined(__ANDROID__)
#define TRACE(...) do { \
- if UNLIKELY(gLogLevel >= LogLevel::Trace) \
+ if(gLogLevel >= LogLevel::Trace) [[alunlikely]] \
fprintf(gLogFile, "[ALSOFT] (II) " __VA_ARGS__); \
} while(0)
#define WARN(...) do { \
- if UNLIKELY(gLogLevel >= LogLevel::Warning) \
+ if(gLogLevel >= LogLevel::Warning) [[alunlikely]] \
fprintf(gLogFile, "[ALSOFT] (WW) " __VA_ARGS__); \
} while(0)
#define ERR(...) do { \
- if UNLIKELY(gLogLevel >= LogLevel::Error) \
+ if(gLogLevel >= LogLevel::Error) [[alunlikely]] \
fprintf(gLogFile, "[ALSOFT] (EE) " __VA_ARGS__); \
} while(0)
diff --git a/core/mastering.cpp b/core/mastering.cpp
index 99850477..6a085c3a 100644
--- a/core/mastering.cpp
+++ b/core/mastering.cpp
@@ -295,7 +295,7 @@ void SignalDelay(Compressor *Comp, const uint SamplesToDo, FloatBufferLine *OutB
float *delaybuf{al::assume_aligned<16>(Comp->mDelay[c].data())};
auto inout_end = inout + SamplesToDo;
- if LIKELY(SamplesToDo >= lookAhead)
+ if(SamplesToDo >= lookAhead) [[allikely]]
{
auto delay_end = std::rotate(inout, inout_end - lookAhead, inout_end);
std::swap_ranges(inout, delay_end, delaybuf);
diff --git a/core/mixer/hrtfbase.h b/core/mixer/hrtfbase.h
index 606f9d4e..c8c78263 100644
--- a/core/mixer/hrtfbase.h
+++ b/core/mixer/hrtfbase.h
@@ -50,7 +50,7 @@ inline void MixHrtfBlendBase(const float *InSamples, float2 *RESTRICT AccumSampl
const ConstHrirSpan NewCoeffs{newparams->Coeffs};
const float newGainStep{newparams->GainStep};
- if LIKELY(oldparams->Gain > GainSilenceThreshold)
+ if(oldparams->Gain > GainSilenceThreshold) [[allikely]]
{
size_t ldelay{HrtfHistoryLength - oldparams->Delay[0]};
size_t rdelay{HrtfHistoryLength - oldparams->Delay[1]};
@@ -66,7 +66,7 @@ inline void MixHrtfBlendBase(const float *InSamples, float2 *RESTRICT AccumSampl
}
}
- if LIKELY(newGainStep*static_cast<float>(BufferSize) > GainSilenceThreshold)
+ if(newGainStep*static_cast<float>(BufferSize) > GainSilenceThreshold) [[allikely]]
{
size_t ldelay{HrtfHistoryLength+1 - newparams->Delay[0]};
size_t rdelay{HrtfHistoryLength+1 - newparams->Delay[1]};
diff --git a/core/voice.cpp b/core/voice.cpp
index 2a524215..0b4884a0 100644
--- a/core/voice.cpp
+++ b/core/voice.cpp
@@ -473,7 +473,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi
VoiceBufferItem *BufferListItem{mCurrentBuffer.load(std::memory_order_relaxed)};
VoiceBufferItem *BufferLoopItem{mLoopBuffer.load(std::memory_order_relaxed)};
const uint increment{mStep};
- if UNLIKELY(increment < 1)
+ if(increment < 1) [[alunlikely]]
{
/* If the voice is supposed to be stopping but can't be mixed, just
* stop it before bailing.
@@ -536,7 +536,7 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi
}
}
}
- else if UNLIKELY(!BufferListItem)
+ else if(!BufferListItem) [[alunlikely]]
Counter = std::min(Counter, 64u);
std::array<float*,DeviceBase::MixerChannelsMax> SamplePointers;