diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-11-25 09:17:00 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-11-25 09:17:00 -0500 |
commit | 4e51199f1103d2d9daa563b63d0e8f22c36fbe8a (patch) | |
tree | 707b7cf557f1b9937a58c66f593847bd957e07b3 /util.c | |
parent | e3aa668ef358739148adb1a4965b629d07467575 (diff) |
got windows build to work
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -4,8 +4,16 @@ #include "base.h" static uint util_popcount(u64 x) { - // @TODO: portability +#ifdef __GNUC__ return (uint)__builtin_popcountll(x); +#else + uint count = 0; + while (x) { + x &= x-1; + ++count; + } + return count; +#endif } static bool util_is_power_of_2(u64 x) { |