[vlc-commits] include: add popcountll() variant of popcount() for long long
Rémi Denis-Courmont
git at videolan.org
Sun Jun 28 14:26:13 CEST 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jun 28 12:40:52 2015 +0300| [cade92d0c4a41a58e03d24d872ee2d0a6ab9ff7c] | committer: Rémi Denis-Courmont
include: add popcountll() variant of popcount() for long long
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cade92d0c4a41a58e03d24d872ee2d0a6ab9ff7c
---
include/vlc_common.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/include/vlc_common.h b/include/vlc_common.h
index 5baeb45..d6a6322 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -557,6 +557,23 @@ static inline unsigned popcount (unsigned x)
#endif
}
+/** Bit weight of long long */
+VLC_USED
+static inline int popcountll(unsigned long long x)
+{
+#if VLC_GCC_VERSION(3,4)
+ return __builtin_popcountll(x);
+#else
+ int count = 0;
+ while (x)
+ {
+ count += x & 1;
+ x = x >> 1;
+ }
+ return count;
+#endif
+}
+
VLC_USED
static inline unsigned parity (unsigned x)
{
More information about the vlc-commits
mailing list