Mercurial > hg > Members > anatofuz > MoarVM
view src/bithacks.h @ 19:073d6fd557dc
adapt C90 for gcc
author | Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 25 Oct 2018 14:40:22 +0900 |
parents | 2cf249471370 |
children |
line wrap: on
line source
static MVMuint32 MVM_bithacks_count_bits(MVMuint64 value) { MVMuint32 count; for (count = 0; value; count++) value &= value - 1; return count; } static int MVM_bithacks_is_pow2z(MVMuint64 value) { return (value & (value - 1)) == 0; } static MVMuint64 MVM_bithacks_next_greater_pow2(MVMuint64 value) { enum { BITS = 64 }; int exp; for(exp = 0; (1 << exp) < BITS; exp++) value |= value >> (1 << exp); return value + 1; }