[vlc-commits] Add parity() helper
Rémi Denis-Courmont
git at videolan.org
Sun Mar 18 12:05:00 CET 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Mar 18 11:36:55 2012 +0200| [21f905e175e5851c3c52a01697c7c795460e5067] | committer: Rémi Denis-Courmont
Add parity() helper
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=21f905e175e5851c3c52a01697c7c795460e5067
---
include/vlc_common.h | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/include/vlc_common.h b/include/vlc_common.h
index 5cb0adf..92c36c4 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -616,6 +616,18 @@ static inline unsigned popcount (unsigned x)
#endif
}
+VLC_USED
+static inline unsigned parity (unsigned x)
+{
+#if VLC_GCC_VERSION(3,4)
+ return __builtin_parity (x);
+#else
+ for (unsigned i = 4 * sizeof (x); i > 0; i /= 2)
+ x ^= x >> i;
+ return x & 1;
+#endif
+}
+
#ifdef __OS2__
# undef bswap16
# undef bswap32
More information about the vlc-commits
mailing list