diff options
| author | Alexander Fokin <[email protected]> | 2022-02-10 16:45:38 +0300 |
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:38 +0300 |
| commit | bf9e69a933f89af083d895185f01ed65e4d90766 (patch) | |
| tree | b2cc84ee7850122e7ccf51d0ea21e4fa7e7a5685 /util/generic/bitops.h | |
| parent | 863a59a65247c24db7cb06789bc5cf79d04da32f (diff) | |
Restoring authorship annotation for Alexander Fokin <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'util/generic/bitops.h')
| -rw-r--r-- | util/generic/bitops.h | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/util/generic/bitops.h b/util/generic/bitops.h index 704540da9d3..2db15fc59b6 100644 --- a/util/generic/bitops.h +++ b/util/generic/bitops.h @@ -269,7 +269,7 @@ Y_FORCE_INLINE ui64 InverseMaskLowerBits(ui64 bits, ui64 skipbits) { } /* - * Returns 0-based position of the most significant bit that is set. 0 for 0. + * Returns 0-based position of the most significant bit that is set. 0 for 0. */ Y_FORCE_INLINE ui64 MostSignificantBit(ui64 v) { #ifdef __GNUC__ @@ -287,28 +287,28 @@ Y_FORCE_INLINE ui64 MostSignificantBit(ui64 v) { return res; } -/** - * Returns 0-based position of the least significant bit that is set. 0 for 0. - */ -Y_FORCE_INLINE ui64 LeastSignificantBit(ui64 v) { -#ifdef __GNUC__ - ui64 res = v ? __builtin_ffsll(v) - 1 : 0; -#elif defined(_MSC_VER) && defined(_64_) - unsigned long res = 0; - if (v) - _BitScanForward64(&res, v); -#else - ui64 res = 0; - if (v) { - while (!(v & 1)) { +/** + * Returns 0-based position of the least significant bit that is set. 0 for 0. + */ +Y_FORCE_INLINE ui64 LeastSignificantBit(ui64 v) { +#ifdef __GNUC__ + ui64 res = v ? __builtin_ffsll(v) - 1 : 0; +#elif defined(_MSC_VER) && defined(_64_) + unsigned long res = 0; + if (v) + _BitScanForward64(&res, v); +#else + ui64 res = 0; + if (v) { + while (!(v & 1)) { ++res; - v >>= 1; - } - } -#endif - return res; -} - + v >>= 1; + } + } +#endif + return res; +} + /* * Returns 0 - based position of the most significant bit (compile time) * 0 for 0. |
