aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-24 21:16:53 -0800
committerChris Robinson <[email protected]>2018-11-24 21:16:53 -0800
commitf5f2cdaaf334a1481d063cdf03893bfad1768475 (patch)
treea59fe29e966b4af8c964b217a6fc3a51ea4e36a7 /OpenAL32/Include
parent71660df5e50bf44784c8bd06d80af96eb3a5a479 (diff)
Add a POPCNT64 macro
To count the number of 1/on bits in a 64-bit value
Diffstat (limited to 'OpenAL32/Include')
-rw-r--r--OpenAL32/Include/alMain.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 21aa1e89..5adabb18 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -135,13 +135,21 @@ typedef ALuint64SOFT ALuint64;
#ifdef __GNUC__
#if SIZEOF_LONG == 8
+#define POPCNT64 __builtin_popcountl
#define CTZ64 __builtin_ctzl
#else
+#define POPCNT64 __builtin_popcountll
#define CTZ64 __builtin_ctzll
#endif
#elif defined(HAVE_BITSCANFORWARD64_INTRINSIC)
+inline int msvc64_popcnt64(ALuint64 v)
+{
+ return __popcnt64(v);
+}
+#define POPCNT64 msvc64_popcnt64
+
inline int msvc64_ctz64(ALuint64 v)
{
unsigned long idx = 64;
@@ -152,6 +160,12 @@ inline int msvc64_ctz64(ALuint64 v)
#elif defined(HAVE_BITSCANFORWARD_INTRINSIC)
+inline int msvc_popcnt64(ALuint64 v)
+{
+ return __popcnt((ALuint)v) + __popcnt((ALuint)(v>>32));
+}
+#define POPCNT64 msvc_popcnt64
+
inline int msvc_ctz64(ALuint64 v)
{
unsigned long idx = 64;
@@ -180,6 +194,7 @@ inline int fallback_popcnt64(ALuint64 v)
v = (v + (v >> 4)) & U64(0x0f0f0f0f0f0f0f0f);
return (int)((v * U64(0x0101010101010101)) >> 56);
}
+#define POPCNT64 fallback_popcnt64
inline int fallback_ctz64(ALuint64 value)
{