aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/alcontext.h5
-rw-r--r--CMakeLists.txt1
-rw-r--r--OpenAL32/Include/alMain.h38
-rw-r--r--common/alnumeric.h31
4 files changed, 42 insertions, 33 deletions
diff --git a/Alc/alcontext.h b/Alc/alcontext.h
index 213949f2..bdf5f2fe 100644
--- a/Alc/alcontext.h
+++ b/Alc/alcontext.h
@@ -15,6 +15,7 @@
#include "vector.h"
#include "threads.h"
#include "almalloc.h"
+#include "alnumeric.h"
#include "alListener.h"
@@ -41,13 +42,13 @@ enum class DistanceModel {
};
struct SourceSubList {
- uint64_t FreeMask{~uint64_t{}};
+ uint64_t FreeMask{~0_u64};
ALsource *Sources{nullptr}; /* 64 */
SourceSubList() noexcept = default;
SourceSubList(const SourceSubList&) = delete;
SourceSubList(SourceSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Sources{rhs.Sources}
- { rhs.FreeMask = ~uint64_t{}; rhs.Sources = nullptr; }
+ { rhs.FreeMask = ~0_u64; rhs.Sources = nullptr; }
~SourceSubList();
SourceSubList& operator=(const SourceSubList&) = delete;
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bc61cc9b..5265cc66 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -694,6 +694,7 @@ SET(COMMON_OBJS
common/alcomplex.h
common/almalloc.cpp
common/almalloc.h
+ common/alnumeric.h
common/atomic.h
common/math_defs.h
common/opthelpers.h
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index c8fb31ef..1c1d9d90 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -30,6 +30,7 @@
#include "atomic.h"
#include "vector.h"
#include "almalloc.h"
+#include "alnumeric.h"
#include "threads.h"
#include "ambidefs.h"
#include "opthelpers.h"
@@ -63,9 +64,6 @@ constexpr inline size_t countof(const T(&)[N]) noexcept
using ALint64 = ALint64SOFT;
using ALuint64 = ALuint64SOFT;
-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
* are *UNDEFINED* if the value is 0.
@@ -202,28 +200,6 @@ struct bs2b;
#define MIN_OUTPUT_RATE (8000)
-/* Find the next power-of-2 for non-power-of-2 numbers. */
-inline ALuint NextPowerOf2(ALuint value) noexcept
-{
- if(value > 0)
- {
- value--;
- value |= value>>1;
- value |= value>>2;
- value |= value>>4;
- value |= value>>8;
- value |= value>>16;
- }
- return value+1;
-}
-
-/** Round up a value to the next multiple. */
-inline size_t RoundUp(size_t value, size_t r) noexcept
-{
- value += r-1;
- return value - (value%r);
-}
-
/* Fast float-to-int conversion. No particular rounding mode is assumed; the
* IEEE-754 default is round-to-nearest with ties-to-even, though an app could
* change it on its own threads. On some systems, a truncating conversion may
@@ -482,13 +458,13 @@ enum RenderMode {
struct BufferSubList {
- uint64_t FreeMask{~uint64_t{}};
+ uint64_t FreeMask{~0_u64};
ALbuffer *Buffers{nullptr}; /* 64 */
BufferSubList() noexcept = default;
BufferSubList(const BufferSubList&) = delete;
BufferSubList(BufferSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Buffers{rhs.Buffers}
- { rhs.FreeMask = ~uint64_t{}; rhs.Buffers = nullptr; }
+ { rhs.FreeMask = ~0_u64; rhs.Buffers = nullptr; }
~BufferSubList();
BufferSubList& operator=(const BufferSubList&) = delete;
@@ -497,13 +473,13 @@ struct BufferSubList {
};
struct EffectSubList {
- uint64_t FreeMask{~uint64_t{}};
+ uint64_t FreeMask{~0_u64};
ALeffect *Effects{nullptr}; /* 64 */
EffectSubList() noexcept = default;
EffectSubList(const EffectSubList&) = delete;
EffectSubList(EffectSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Effects{rhs.Effects}
- { rhs.FreeMask = ~uint64_t{}; rhs.Effects = nullptr; }
+ { rhs.FreeMask = ~0_u64; rhs.Effects = nullptr; }
~EffectSubList();
EffectSubList& operator=(const EffectSubList&) = delete;
@@ -512,13 +488,13 @@ struct EffectSubList {
};
struct FilterSubList {
- uint64_t FreeMask{~uint64_t{}};
+ uint64_t FreeMask{~0_u64};
ALfilter *Filters{nullptr}; /* 64 */
FilterSubList() noexcept = default;
FilterSubList(const FilterSubList&) = delete;
FilterSubList(FilterSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Filters{rhs.Filters}
- { rhs.FreeMask = ~uint64_t{}; rhs.Filters = nullptr; }
+ { rhs.FreeMask = ~0_u64; rhs.Filters = nullptr; }
~FilterSubList();
FilterSubList& operator=(const FilterSubList&) = delete;
diff --git a/common/alnumeric.h b/common/alnumeric.h
new file mode 100644
index 00000000..fb38bff6
--- /dev/null
+++ b/common/alnumeric.h
@@ -0,0 +1,31 @@
+#ifndef AL_NUMERIC_H
+#define AL_NUMERIC_H
+
+#include <stdint.h>
+
+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); }
+
+/** Find the next power-of-2 for non-power-of-2 numbers. */
+inline uint32_t NextPowerOf2(uint32_t value) noexcept
+{
+ if(value > 0)
+ {
+ value--;
+ value |= value>>1;
+ value |= value>>2;
+ value |= value>>4;
+ value |= value>>8;
+ value |= value>>16;
+ }
+ return value+1;
+}
+
+/** Round up a value to the next multiple. */
+inline size_t RoundUp(size_t value, size_t r) noexcept
+{
+ value += r-1;
+ return value - (value%r);
+}
+
+#endif /* AL_NUMERIC_H */