Commit 21f905e1 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Add parity() helper

parent 6eec2a06
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment