Skip to content

Commit

Permalink
Add popcount to bitops.
Browse files Browse the repository at this point in the history
  • Loading branch information
Themaister committed Jan 9, 2024
1 parent f096456 commit 7709757
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions util/bitops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ namespace Util
#define leading_zeroes64(x) ((x) == 0 ? 64 : __builtin_clzll(x))
#define trailing_zeroes64(x) ((x) == 0 ? 64 : __builtin_ctzll(x))
#define trailing_ones64(x) __builtin_ctzll(~uint64_t(x))
#define popcount32(x) __builtin_popcount(x)
#elif defined(_MSC_VER)
namespace Internal
{
static inline uint32_t popcount32(uint32_t x)
{
return __popcnt(x);
}

static inline uint32_t clz(uint32_t x)
{
unsigned long result;
Expand Down

0 comments on commit 7709757

Please sign in to comment.