diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/asm.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/common/asm.c b/src/common/asm.c index f29d599..692256f 100644 --- a/src/common/asm.c +++ b/src/common/asm.c @@ -25,6 +25,18 @@ +/** + * Indice du bit de poids fort dans un quartet. + */ + +static const unsigned int _bval[16] = { + + 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4 + +}; + + + /****************************************************************************** * * * Paramètres : v = valeur quelconque sur 32 bits. * @@ -40,8 +52,6 @@ bool msb_32(uint32_t v, unsigned int *p) { - static const unsigned int bval[] = { 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4 }; - /* S'il n'y a aucun bit à 1... */ if (v == 0) return false; @@ -60,7 +70,7 @@ bool msb_32(uint32_t v, unsigned int *p) if (v & 0x0000ff00) { *p += 16 / 2; v >>= 16 / 2; } if (v & 0x000000f0) { *p += 16 / 4; v >>= 16 / 4; } - *p += bval[v]; + *p += _bval[v]; return true; @@ -82,8 +92,6 @@ bool msb_32(uint32_t v, unsigned int *p) bool msb_64(uint64_t v, unsigned int *p) { - static const unsigned int bval[] = { 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4 }; - /* S'il n'y a aucun bit à 1... */ if (v == 0) return false; @@ -98,7 +106,7 @@ bool msb_64(uint64_t v, unsigned int *p) if (v & 0x000000000000ff00ull) { *p += 32 / 4; v >>= 32 / 4; } if (v & 0x00000000000000f0ull) { *p += 32 / 8; v >>= 32 / 8; } - *p += bval[v]; + *p += _bval[v]; return true; |