diff options
author | Kevin Strasser <[email protected]> | 2019-06-14 14:27:53 -0700 |
---|---|---|
committer | Adam Jackson <[email protected]> | 2019-08-21 18:36:57 +0000 |
commit | 3562f48c9d58793429fc5ea655b8b4629b495ce0 (patch) | |
tree | 0fe01f5763f164f92656a9f52d5a91603d437bcc /src/util/u_math.h | |
parent | 5a747306ce6dd3021c15cfabc83465ec3fb4bb1c (diff) |
util: move bitcount to bitscan.h
bitcount is free from the pipe header dependencies that make u_math.h hard
to include by non-gallium specific code, so move it to bitscan.h. bitscan.h
is included by u_math.h so existing references will continue working.
Signed-off-by: Kevin Strasser <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/util/u_math.h')
-rw-r--r-- | src/util/u_math.h | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/src/util/u_math.h b/src/util/u_math.h index a9fa35457ff..11fbfb45761 100644 --- a/src/util/u_math.h +++ b/src/util/u_math.h @@ -548,42 +548,6 @@ util_next_power_of_two64(uint64_t x) #endif } - -/** - * Return number of bits set in n. - */ -static inline unsigned -util_bitcount(unsigned n) -{ -#if defined(HAVE___BUILTIN_POPCOUNT) - return __builtin_popcount(n); -#else - /* K&R classic bitcount. - * - * For each iteration, clear the LSB from the bitfield. - * Requires only one iteration per set bit, instead of - * one iteration per bit less than highest set bit. - */ - unsigned bits; - for (bits = 0; n; bits++) { - n &= n - 1; - } - return bits; -#endif -} - - -static inline unsigned -util_bitcount64(uint64_t n) -{ -#ifdef HAVE___BUILTIN_POPCOUNTLL - return __builtin_popcountll(n); -#else - return util_bitcount(n) + util_bitcount(n >> 32); -#endif -} - - /** * Reverse bits in n * Algorithm taken from: |