1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-02-14 12:12:21 +00:00

do not use builtin popcnt

This commit is contained in:
ton 2019-11-01 22:15:04 +04:00
parent 11bd640ee0
commit 950e292264

View file

@ -139,7 +139,13 @@ inline uint64 bswap64(uint64 x) {
}
inline int32 count_bits32(uint32 x) {
return __popcnt(x);
// Do not use __popcnt because it will fail on some platforms.
x -= (x >> 1) & 0x55555555;
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = (x + (x >> 4)) & 0x0F0F0F0F;
x += x >> 8;
return (x + (x >> 16)) & 0x3F;
//return __popcnt(x);
}
inline int32 count_bits64(uint64 x) {