Use user-defined literals for 64-bit literals
This commit is contained in:
parent
67c9cf8174
commit
4d047e2bc1
@ -2102,7 +2102,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
||||
ALsizei idx = CTZ64(usemask);
|
||||
ALsource *source = sublist.Sources + idx;
|
||||
|
||||
usemask &= ~(U64(1) << idx);
|
||||
usemask &= ~(1_u64 << idx);
|
||||
|
||||
if(old_sends != device->NumAuxSends)
|
||||
{
|
||||
|
@ -695,7 +695,7 @@ ALCboolean AlsaPlayback::reset()
|
||||
|
||||
bool allowmmap{!!GetConfigValueBool(mDevice->DeviceName.c_str(), "alsa", "mmap", 1)};
|
||||
ALuint periods{mDevice->NumUpdates};
|
||||
ALuint periodLen{static_cast<ALuint>(mDevice->UpdateSize * U64(1000000) / mDevice->Frequency)};
|
||||
ALuint periodLen{static_cast<ALuint>(mDevice->UpdateSize * 1000000_u64 / mDevice->Frequency)};
|
||||
ALuint bufferLen{periodLen * periods};
|
||||
ALuint rate{mDevice->Frequency};
|
||||
|
||||
|
@ -65,7 +65,7 @@ inline int double2int(double d)
|
||||
if(UNLIKELY(shift >= 63 || shift < -52))
|
||||
return 0;
|
||||
|
||||
mant = (conv.i64&I64(0xfffffffffffff)) | I64(0x10000000000000);
|
||||
mant = (conv.i64&0xfffffffffffff_i64) | 0x10000000000000_i64;
|
||||
if(LIKELY(shift < 0))
|
||||
return (ALint)(mant >> -shift) * sign;
|
||||
return (ALint)(mant << shift) * sign;
|
||||
|
@ -63,25 +63,8 @@ constexpr inline size_t countof(const T(&)[N]) noexcept
|
||||
using ALint64 = ALint64SOFT;
|
||||
using ALuint64 = ALuint64SOFT;
|
||||
|
||||
#ifndef U64
|
||||
#if defined(_MSC_VER)
|
||||
#define U64(x) ((ALuint64)(x##ui64))
|
||||
#elif SIZEOF_LONG == 8
|
||||
#define U64(x) ((ALuint64)(x##ul))
|
||||
#elif SIZEOF_LONG_LONG == 8
|
||||
#define U64(x) ((ALuint64)(x##ull))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef I64
|
||||
#if defined(_MSC_VER)
|
||||
#define I64(x) ((ALint64)(x##i64))
|
||||
#elif SIZEOF_LONG == 8
|
||||
#define I64(x) ((ALint64)(x##l))
|
||||
#elif SIZEOF_LONG_LONG == 8
|
||||
#define I64(x) ((ALint64)(x##ll))
|
||||
#endif
|
||||
#endif
|
||||
inline constexpr int64_t operator "" _i64(unsigned long long int n) noexcept { return static_cast<int64_t>(n); }
|
||||
inline constexpr uint64_t operator "" _u64(unsigned long long int n) noexcept { return static_cast<uint64_t>(n); }
|
||||
|
||||
/* Define CTZ macros (count trailing zeros), and POPCNT macros (population
|
||||
* count/count 1 bits), for 32- and 64-bit integers. The CTZ macros' results
|
||||
@ -174,10 +157,10 @@ inline int fallback_ctz32(ALuint value)
|
||||
|
||||
inline int fallback_popcnt64(ALuint64 v)
|
||||
{
|
||||
v = v - ((v >> 1) & U64(0x5555555555555555));
|
||||
v = (v & U64(0x3333333333333333)) + ((v >> 2) & U64(0x3333333333333333));
|
||||
v = (v + (v >> 4)) & U64(0x0f0f0f0f0f0f0f0f);
|
||||
return (int)((v * U64(0x0101010101010101)) >> 56);
|
||||
v = v - ((v >> 1) & 0x5555555555555555_u64);
|
||||
v = (v & 0x3333333333333333_u64) + ((v >> 2) & 0x3333333333333333_u64);
|
||||
v = (v + (v >> 4)) & 0x0f0f0f0f0f0f0f0f_u64;
|
||||
return (int)((v * 0x0101010101010101_u64) >> 56);
|
||||
}
|
||||
#define POPCNT64 fallback_popcnt64
|
||||
inline int fallback_ctz64(ALuint64 value)
|
||||
@ -775,7 +758,7 @@ struct ALCdevice {
|
||||
|
||||
|
||||
/* Nanosecond resolution for the device clock time. */
|
||||
#define DEVICE_CLOCK_RES U64(1000000000)
|
||||
#define DEVICE_CLOCK_RES 1000000000_u64
|
||||
|
||||
|
||||
/* Must be less than 15 characters (16 including terminating null) for
|
||||
|
@ -58,7 +58,7 @@ inline ALeffect *LookupEffect(ALCdevice *device, ALuint id) noexcept
|
||||
if(UNLIKELY(lidx >= device->EffectList.size()))
|
||||
return nullptr;
|
||||
EffectSubList &sublist = device->EffectList[lidx];
|
||||
if(UNLIKELY(sublist.FreeMask & (U64(1)<<slidx)))
|
||||
if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
|
||||
return nullptr;
|
||||
return sublist.Effects + slidx;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ ALbuffer *AllocBuffer(ALCcontext *context)
|
||||
}
|
||||
device->BufferList.emplace_back();
|
||||
sublist = device->BufferList.end() - 1;
|
||||
sublist->FreeMask = ~U64(0);
|
||||
sublist->FreeMask = ~0_u64;
|
||||
sublist->Buffers = reinterpret_cast<ALbuffer*>(al_calloc(16, sizeof(ALbuffer)*64));
|
||||
if(UNLIKELY(!sublist->Buffers))
|
||||
{
|
||||
@ -96,7 +96,7 @@ ALbuffer *AllocBuffer(ALCcontext *context)
|
||||
/* Add 1 to avoid buffer ID 0. */
|
||||
buffer->id = ((lidx<<6) | slidx) + 1;
|
||||
|
||||
sublist->FreeMask &= ~(U64(1)<<slidx);
|
||||
sublist->FreeMask &= ~(1_u64 << slidx);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
@ -109,7 +109,7 @@ void FreeBuffer(ALCdevice *device, ALbuffer *buffer)
|
||||
|
||||
buffer->~ALbuffer();
|
||||
|
||||
device->BufferList[lidx].FreeMask |= U64(1) << slidx;
|
||||
device->BufferList[lidx].FreeMask |= 1_u64 << slidx;
|
||||
}
|
||||
|
||||
inline ALbuffer *LookupBuffer(ALCdevice *device, ALuint id)
|
||||
@ -120,7 +120,7 @@ inline ALbuffer *LookupBuffer(ALCdevice *device, ALuint id)
|
||||
if(UNLIKELY(lidx >= device->BufferList.size()))
|
||||
return nullptr;
|
||||
BufferSubList &sublist = device->BufferList[lidx];
|
||||
if(UNLIKELY(sublist.FreeMask & (U64(1)<<slidx)))
|
||||
if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
|
||||
return nullptr;
|
||||
return sublist.Buffers + slidx;
|
||||
}
|
||||
@ -1174,7 +1174,7 @@ BufferSubList::~BufferSubList()
|
||||
{
|
||||
ALsizei idx{CTZ64(usemask)};
|
||||
Buffers[idx].~ALbuffer();
|
||||
usemask &= ~(U64(1) << idx);
|
||||
usemask &= ~(1_u64 << idx);
|
||||
}
|
||||
FreeMask = ~usemask;
|
||||
al_free(Buffers);
|
||||
|
@ -236,7 +236,7 @@ ALeffect *AllocEffect(ALCcontext *context)
|
||||
}
|
||||
device->EffectList.emplace_back();
|
||||
sublist = device->EffectList.end() - 1;
|
||||
sublist->FreeMask = ~U64(0);
|
||||
sublist->FreeMask = ~0_u64;
|
||||
sublist->Effects = static_cast<ALeffect*>(al_calloc(16, sizeof(ALeffect)*64));
|
||||
if(UNLIKELY(!sublist->Effects))
|
||||
{
|
||||
@ -255,7 +255,7 @@ ALeffect *AllocEffect(ALCcontext *context)
|
||||
/* Add 1 to avoid effect ID 0. */
|
||||
effect->id = ((lidx<<6) | slidx) + 1;
|
||||
|
||||
sublist->FreeMask &= ~(U64(1)<<slidx);
|
||||
sublist->FreeMask &= ~(1_u64 << slidx);
|
||||
|
||||
return effect;
|
||||
}
|
||||
@ -268,7 +268,7 @@ void FreeEffect(ALCdevice *device, ALeffect *effect)
|
||||
|
||||
effect->~ALeffect();
|
||||
|
||||
device->EffectList[lidx].FreeMask |= U64(1) << slidx;
|
||||
device->EffectList[lidx].FreeMask |= 1_u64 << slidx;
|
||||
}
|
||||
|
||||
inline ALeffect *LookupEffect(ALCdevice *device, ALuint id)
|
||||
@ -279,7 +279,7 @@ inline ALeffect *LookupEffect(ALCdevice *device, ALuint id)
|
||||
if(UNLIKELY(lidx >= device->EffectList.size()))
|
||||
return nullptr;
|
||||
EffectSubList &sublist = device->EffectList[lidx];
|
||||
if(UNLIKELY(sublist.FreeMask & (U64(1)<<slidx)))
|
||||
if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
|
||||
return nullptr;
|
||||
return sublist.Effects + slidx;
|
||||
}
|
||||
@ -574,7 +574,7 @@ EffectSubList::~EffectSubList()
|
||||
{
|
||||
ALsizei idx = CTZ64(usemask);
|
||||
Effects[idx].~ALeffect();
|
||||
usemask &= ~(U64(1) << idx);
|
||||
usemask &= ~(1_u64 << idx);
|
||||
}
|
||||
FreeMask = ~usemask;
|
||||
al_free(Effects);
|
||||
|
@ -296,7 +296,7 @@ ALfilter *AllocFilter(ALCcontext *context)
|
||||
}
|
||||
device->FilterList.emplace_back();
|
||||
sublist = device->FilterList.end() - 1;
|
||||
sublist->FreeMask = ~U64(0);
|
||||
sublist->FreeMask = ~0_u64;
|
||||
sublist->Filters = static_cast<ALfilter*>(al_calloc(16, sizeof(ALfilter)*64));
|
||||
if(UNLIKELY(!sublist->Filters))
|
||||
{
|
||||
@ -315,7 +315,7 @@ ALfilter *AllocFilter(ALCcontext *context)
|
||||
/* Add 1 to avoid filter ID 0. */
|
||||
filter->id = ((lidx<<6) | slidx) + 1;
|
||||
|
||||
sublist->FreeMask &= ~(U64(1)<<slidx);
|
||||
sublist->FreeMask &= ~(1_u64 << slidx);
|
||||
|
||||
return filter;
|
||||
}
|
||||
@ -328,7 +328,7 @@ void FreeFilter(ALCdevice *device, ALfilter *filter)
|
||||
|
||||
filter->~ALfilter();
|
||||
|
||||
device->FilterList[lidx].FreeMask |= U64(1) << slidx;
|
||||
device->FilterList[lidx].FreeMask |= 1_u64 << slidx;
|
||||
}
|
||||
|
||||
|
||||
@ -340,7 +340,7 @@ inline ALfilter *LookupFilter(ALCdevice *device, ALuint id)
|
||||
if(UNLIKELY(lidx >= device->FilterList.size()))
|
||||
return nullptr;
|
||||
FilterSubList &sublist = device->FilterList[lidx];
|
||||
if(UNLIKELY(sublist.FreeMask & (U64(1)<<slidx)))
|
||||
if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
|
||||
return nullptr;
|
||||
return sublist.Filters + slidx;
|
||||
}
|
||||
@ -625,7 +625,7 @@ FilterSubList::~FilterSubList()
|
||||
{
|
||||
ALsizei idx = CTZ64(usemask);
|
||||
Filters[idx].~ALfilter();
|
||||
usemask &= ~(U64(1) << idx);
|
||||
usemask &= ~(1_u64 << idx);
|
||||
}
|
||||
FreeMask = ~usemask;
|
||||
al_free(Filters);
|
||||
|
@ -188,7 +188,7 @@ ALint64 GetSourceSampleOffset(ALsource *Source, ALCcontext *context, std::chrono
|
||||
readPos += (ALuint64)BufferList->max_samples << 32;
|
||||
BufferList = BufferList->next.load(std::memory_order_relaxed);
|
||||
}
|
||||
readPos = minu64(readPos, U64(0x7fffffffffffffff));
|
||||
readPos = minu64(readPos, 0x7fffffffffffffff_u64);
|
||||
}
|
||||
|
||||
return (ALint64)readPos;
|
||||
@ -495,7 +495,7 @@ ALsource *AllocSource(ALCcontext *context)
|
||||
context->SourceList.emplace_back();
|
||||
sublist = context->SourceList.end() - 1;
|
||||
|
||||
sublist->FreeMask = ~U64(0);
|
||||
sublist->FreeMask = ~0_u64;
|
||||
sublist->Sources = static_cast<ALsource*>(al_calloc(16, sizeof(ALsource)*64));
|
||||
if(UNLIKELY(!sublist->Sources))
|
||||
{
|
||||
@ -514,7 +514,7 @@ ALsource *AllocSource(ALCcontext *context)
|
||||
source->id = ((lidx<<6) | slidx) + 1;
|
||||
|
||||
context->NumSources += 1;
|
||||
sublist->FreeMask &= ~(U64(1)<<slidx);
|
||||
sublist->FreeMask &= ~(1_u64 << slidx);
|
||||
|
||||
return source;
|
||||
}
|
||||
@ -536,7 +536,7 @@ void FreeSource(ALCcontext *context, ALsource *source)
|
||||
|
||||
source->~ALsource();
|
||||
|
||||
context->SourceList[lidx].FreeMask |= U64(1) << slidx;
|
||||
context->SourceList[lidx].FreeMask |= 1_u64 << slidx;
|
||||
context->NumSources--;
|
||||
}
|
||||
|
||||
@ -549,7 +549,7 @@ inline ALsource *LookupSource(ALCcontext *context, ALuint id) noexcept
|
||||
if(UNLIKELY(lidx >= context->SourceList.size()))
|
||||
return nullptr;
|
||||
SourceSubList &sublist{context->SourceList[lidx]};
|
||||
if(UNLIKELY(sublist.FreeMask & (U64(1)<<slidx)))
|
||||
if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
|
||||
return nullptr;
|
||||
return sublist.Sources + slidx;
|
||||
}
|
||||
@ -562,7 +562,7 @@ inline ALbuffer *LookupBuffer(ALCdevice *device, ALuint id) noexcept
|
||||
if(UNLIKELY(lidx >= device->BufferList.size()))
|
||||
return nullptr;
|
||||
BufferSubList &sublist = device->BufferList[lidx];
|
||||
if(UNLIKELY(sublist.FreeMask & (U64(1)<<slidx)))
|
||||
if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
|
||||
return nullptr;
|
||||
return sublist.Buffers + slidx;
|
||||
}
|
||||
@ -575,7 +575,7 @@ inline ALfilter *LookupFilter(ALCdevice *device, ALuint id) noexcept
|
||||
if(UNLIKELY(lidx >= device->FilterList.size()))
|
||||
return nullptr;
|
||||
FilterSubList &sublist = device->FilterList[lidx];
|
||||
if(UNLIKELY(sublist.FreeMask & (U64(1)<<slidx)))
|
||||
if(UNLIKELY(sublist.FreeMask & (1_u64 << slidx)))
|
||||
return nullptr;
|
||||
return sublist.Filters + slidx;
|
||||
}
|
||||
@ -3401,7 +3401,7 @@ SourceSubList::~SourceSubList()
|
||||
{
|
||||
ALsizei idx{CTZ64(usemask)};
|
||||
Sources[idx].~ALsource();
|
||||
usemask &= ~(U64(1) << idx);
|
||||
usemask &= ~(1_u64 << idx);
|
||||
}
|
||||
FreeMask = ~usemask;
|
||||
al_free(Sources);
|
||||
|
Loading…
x
Reference in New Issue
Block a user