aboutsummaryrefslogtreecommitdiffstats
path: root/al
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-01-22 04:58:42 -0800
committerChris Robinson <[email protected]>2021-01-22 04:58:42 -0800
commitda59ad51057ce7343e3db4632e8679e1e537779d (patch)
tree6b4c1f5bd5d6b4bd4b83b9bc290e63ca837f8bc0 /al
parent5ff5fd8eccbdc5888b350059cb1f341a33ddf05f (diff)
Make PopCount and CountTrailingZeros more standard-like
Diffstat (limited to 'al')
-rw-r--r--al/auxeffectslot.cpp9
-rw-r--r--al/buffer.cpp7
-rw-r--r--al/effect.cpp7
-rw-r--r--al/filter.cpp7
-rw-r--r--al/source.cpp7
5 files changed, 21 insertions, 16 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp
index 4af2acf2..8b31ab80 100644
--- a/al/auxeffectslot.cpp
+++ b/al/auxeffectslot.cpp
@@ -35,6 +35,7 @@
#include "AL/alc.h"
#include "AL/efx.h"
+#include "albit.h"
#include "alcmain.h"
#include "alcontext.h"
#include "almalloc.h"
@@ -240,7 +241,7 @@ bool EnsureEffectSlots(ALCcontext *context, size_t needed)
size_t count{std::accumulate(context->mEffectSlotList.cbegin(),
context->mEffectSlotList.cend(), size_t{0},
[](size_t cur, const EffectSlotSubList &sublist) noexcept -> size_t
- { return cur + static_cast<ALuint>(PopCount(sublist.FreeMask)); })};
+ { return cur + static_cast<ALuint>(al::popcount(sublist.FreeMask)); })};
while(needed > count)
{
@@ -268,7 +269,7 @@ ALeffectslot *AllocEffectSlot(ALCcontext *context)
[](const EffectSlotSubList &entry) noexcept -> bool
{ return entry.FreeMask != 0; });
auto lidx = static_cast<ALuint>(std::distance(context->mEffectSlotList.begin(), sublist));
- auto slidx = static_cast<ALuint>(CountTrailingZeros(sublist->FreeMask));
+ auto slidx = static_cast<ALuint>(al::countr_zero(sublist->FreeMask));
ALeffectslot *slot{::new(sublist->EffectSlots + slidx) ALeffectslot{}};
aluInitEffectPanning(&slot->mSlot, context);
@@ -991,7 +992,7 @@ void UpdateAllEffectSlotProps(ALCcontext *context)
uint64_t usemask{~sublist.FreeMask};
while(usemask)
{
- const int idx{CountTrailingZeros(usemask)};
+ const int idx{al::countr_zero(usemask)};
ALeffectslot *slot{sublist.EffectSlots + idx};
usemask &= ~(1_u64 << idx);
@@ -1007,7 +1008,7 @@ EffectSlotSubList::~EffectSlotSubList()
uint64_t usemask{~FreeMask};
while(usemask)
{
- const ALsizei idx{CountTrailingZeros(usemask)};
+ const int idx{al::countr_zero(usemask)};
al::destroy_at(EffectSlots+idx);
usemask &= ~(1_u64 << idx);
}
diff --git a/al/buffer.cpp b/al/buffer.cpp
index cdbedf70..14fae1ee 100644
--- a/al/buffer.cpp
+++ b/al/buffer.cpp
@@ -41,6 +41,7 @@
#include "AL/alc.h"
#include "AL/alext.h"
+#include "albit.h"
#include "albyte.h"
#include "alcmain.h"
#include "alcontext.h"
@@ -326,7 +327,7 @@ bool EnsureBuffers(ALCdevice *device, size_t needed)
{
size_t count{std::accumulate(device->BufferList.cbegin(), device->BufferList.cend(), size_t{0},
[](size_t cur, const BufferSubList &sublist) noexcept -> size_t
- { return cur + static_cast<ALuint>(PopCount(sublist.FreeMask)); })};
+ { return cur + static_cast<ALuint>(al::popcount(sublist.FreeMask)); })};
while(needed > count)
{
@@ -355,7 +356,7 @@ ALbuffer *AllocBuffer(ALCdevice *device)
);
auto lidx = static_cast<ALuint>(std::distance(device->BufferList.begin(), sublist));
- auto slidx = static_cast<ALuint>(CountTrailingZeros(sublist->FreeMask));
+ auto slidx = static_cast<ALuint>(al::countr_zero(sublist->FreeMask));
ALbuffer *buffer{::new (sublist->Buffers + slidx) ALbuffer{}};
@@ -1621,7 +1622,7 @@ BufferSubList::~BufferSubList()
uint64_t usemask{~FreeMask};
while(usemask)
{
- const ALsizei idx{CountTrailingZeros(usemask)};
+ const int idx{al::countr_zero(usemask)};
al::destroy_at(Buffers+idx);
usemask &= ~(1_u64 << idx);
}
diff --git a/al/effect.cpp b/al/effect.cpp
index 02b31fac..93aa5547 100644
--- a/al/effect.cpp
+++ b/al/effect.cpp
@@ -38,6 +38,7 @@
#include "AL/efx-presets.h"
#include "AL/efx.h"
+#include "albit.h"
#include "alcmain.h"
#include "alcontext.h"
#include "almalloc.h"
@@ -155,7 +156,7 @@ bool EnsureEffects(ALCdevice *device, size_t needed)
{
size_t count{std::accumulate(device->EffectList.cbegin(), device->EffectList.cend(), size_t{0},
[](size_t cur, const EffectSubList &sublist) noexcept -> size_t
- { return cur + static_cast<ALuint>(PopCount(sublist.FreeMask)); })};
+ { return cur + static_cast<ALuint>(al::popcount(sublist.FreeMask)); })};
while(needed > count)
{
@@ -183,7 +184,7 @@ ALeffect *AllocEffect(ALCdevice *device)
{ return entry.FreeMask != 0; }
);
auto lidx = static_cast<ALuint>(std::distance(device->EffectList.begin(), sublist));
- auto slidx = static_cast<ALuint>(CountTrailingZeros(sublist->FreeMask));
+ auto slidx = static_cast<ALuint>(al::countr_zero(sublist->FreeMask));
ALeffect *effect{::new (sublist->Effects + slidx) ALeffect{}};
InitEffectParams(effect, AL_EFFECT_NULL);
@@ -543,7 +544,7 @@ EffectSubList::~EffectSubList()
uint64_t usemask{~FreeMask};
while(usemask)
{
- const ALsizei idx{CountTrailingZeros(usemask)};
+ const int idx{al::countr_zero(usemask)};
al::destroy_at(Effects+idx);
usemask &= ~(1_u64 << idx);
}
diff --git a/al/filter.cpp b/al/filter.cpp
index e549b1c9..0bcfe408 100644
--- a/al/filter.cpp
+++ b/al/filter.cpp
@@ -36,6 +36,7 @@
#include "AL/alc.h"
#include "AL/efx.h"
+#include "albit.h"
#include "alcmain.h"
#include "alcontext.h"
#include "almalloc.h"
@@ -324,7 +325,7 @@ bool EnsureFilters(ALCdevice *device, size_t needed)
{
size_t count{std::accumulate(device->FilterList.cbegin(), device->FilterList.cend(), size_t{0},
[](size_t cur, const FilterSubList &sublist) noexcept -> size_t
- { return cur + static_cast<ALuint>(PopCount(sublist.FreeMask)); })};
+ { return cur + static_cast<ALuint>(al::popcount(sublist.FreeMask)); })};
while(needed > count)
{
@@ -353,7 +354,7 @@ ALfilter *AllocFilter(ALCdevice *device)
{ return entry.FreeMask != 0; }
);
auto lidx = static_cast<ALuint>(std::distance(device->FilterList.begin(), sublist));
- auto slidx = static_cast<ALuint>(CountTrailingZeros(sublist->FreeMask));
+ auto slidx = static_cast<ALuint>(al::countr_zero(sublist->FreeMask));
ALfilter *filter{::new(sublist->Filters + slidx) ALfilter{}};
InitFilterParams(filter, AL_FILTER_NULL);
@@ -704,7 +705,7 @@ FilterSubList::~FilterSubList()
uint64_t usemask{~FreeMask};
while(usemask)
{
- const ALsizei idx{CountTrailingZeros(usemask)};
+ const int idx{al::countr_zero(usemask)};
al::destroy_at(Filters+idx);
usemask &= ~(1_u64 << idx);
}
diff --git a/al/source.cpp b/al/source.cpp
index 770e3778..a4e59e59 100644
--- a/al/source.cpp
+++ b/al/source.cpp
@@ -45,6 +45,7 @@
#include "AL/alext.h"
#include "AL/efx.h"
+#include "albit.h"
#include "alcmain.h"
#include "alcontext.h"
#include "almalloc.h"
@@ -684,7 +685,7 @@ bool EnsureSources(ALCcontext *context, size_t needed)
size_t count{std::accumulate(context->mSourceList.cbegin(), context->mSourceList.cend(),
size_t{0},
[](size_t cur, const SourceSubList &sublist) noexcept -> size_t
- { return cur + static_cast<ALuint>(PopCount(sublist.FreeMask)); })};
+ { return cur + static_cast<ALuint>(al::popcount(sublist.FreeMask)); })};
while(needed > count)
{
@@ -712,7 +713,7 @@ ALsource *AllocSource(ALCcontext *context)
{ return entry.FreeMask != 0; }
);
auto lidx = static_cast<ALuint>(std::distance(context->mSourceList.begin(), sublist));
- auto slidx = static_cast<ALuint>(CountTrailingZeros(sublist->FreeMask));
+ auto slidx = static_cast<ALuint>(al::countr_zero(sublist->FreeMask));
ALsource *source{::new(sublist->Sources + slidx) ALsource{}};
@@ -3484,7 +3485,7 @@ SourceSubList::~SourceSubList()
uint64_t usemask{~FreeMask};
while(usemask)
{
- const ALsizei idx{CountTrailingZeros(usemask)};
+ const int idx{al::countr_zero(usemask)};
al::destroy_at(Sources+idx);
usemask &= ~(1_u64 << idx);
}