diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-04-23 18:37:12 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-04-23 18:37:12 +0300 |
commit | 372752c7393025342997f8ba6c076576280b3019 (patch) | |
tree | 72fdd54167e8e5315b738dff3e96e33d3eaf9aff /source/blender/blenlib/BLI_math_bits.h | |
parent | 27e03dcd21872d9daf73adf42c69c04c5806ac07 (diff) |
Math Lib: add count_bits_i utility function
Diffstat (limited to 'source/blender/blenlib/BLI_math_bits.h')
-rw-r--r-- | source/blender/blenlib/BLI_math_bits.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_bits.h b/source/blender/blenlib/BLI_math_bits.h index 2569c4cb41e..876c0d92e31 100644 --- a/source/blender/blenlib/BLI_math_bits.h +++ b/source/blender/blenlib/BLI_math_bits.h @@ -34,6 +34,12 @@ extern "C" { MINLINE unsigned int highest_order_bit_i(unsigned int n); MINLINE unsigned short highest_order_bit_s(unsigned short n); +#ifdef __GNUC__ +# define count_bits_i(i) __builtin_popcount(i) +#else +MINLINE int count_bits_i(unsigned int n); +#endif + #if BLI_MATH_DO_INLINE #include "intern/math_bits_inline.c" #endif |