X-Git-Url: http://git.nguyen.vg/gitweb/?p=SXSI%2Flibbp.git;a=blobdiff_plain;f=bp-utils.h;fp=bp-utils.h;h=6ead4faf02e8cffd46870852330f2eeb622a780d;hp=b54868876a27dd14637a586b1ea2e7dcd5fff7e2;hb=7e784b76fbed5924499b586bedeb51057f62e05f;hpb=45ff7a2260f890f6ef6a7b56f654ffa1a057a7e7 diff --git a/bp-utils.h b/bp-utils.h index b548688..6ead4fa 100644 --- a/bp-utils.h +++ b/bp-utils.h @@ -36,7 +36,25 @@ static inline unsigned int popcount8(unsigned int n) { } #else +#ifdef HAS_POPCOUNT_TABLE + +extern unsigned char popCount[256]; +static unsigned int popcount8(unsigned int x) +{ + return (unsigned int) popCount[x & 0xff]; +} + +static unsigned int popcount(unsigned int x) +{ + return popcount8(x) + + popcount8((x >> 8)) + + popcount8((x >> 16)) + + popcount8((x >> 24)); +} + + +#else static unsigned int popcount8(unsigned int x) { unsigned int r; @@ -58,6 +76,7 @@ static inline unsigned int popcount(unsigned int x) } #endif +#endif void * bp_malloc(size_t);