/* Count the number of bits set */
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
-
static inline uint bit_count(uint w)
{
return __builtin_popcount(w);
}
-#else
-
-static inline uint bit_count(uint w)
-{
- uint n = 0;
- while (w)
- {
- w &= w - 1;
- n++;
- }
- return n;
-}
-
-#endif
-
#endif