diff options
author | Maxim Yurchuk <maxim-yurchuk@ydb.tech> | 2024-11-20 17:37:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-20 17:37:57 +0000 |
commit | f76323e9b295c15751e51e3443aa47a36bee8023 (patch) | |
tree | 4113c8cad473a33e0f746966e0cf087252fa1d7a /util/generic/bitops.h | |
parent | 753ecb8d410a4cb459c26f3a0082fb2d1724fe63 (diff) | |
parent | a7b9a6afea2a9d7a7bfac4c5eb4c1a8e60adb9e6 (diff) | |
download | ydb-f76323e9b295c15751e51e3443aa47a36bee8023.tar.gz |
Merge pull request #11788 from ydb-platform/mergelibs-241120-1113
Library import 241120-1113
Diffstat (limited to 'util/generic/bitops.h')
-rw-r--r-- | util/generic/bitops.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/util/generic/bitops.h b/util/generic/bitops.h index 0a2396bfee..601daf7a30 100644 --- a/util/generic/bitops.h +++ b/util/generic/bitops.h @@ -276,13 +276,16 @@ Y_FORCE_INLINE ui64 MostSignificantBit(ui64 v) { ui64 res = v ? (63 - __builtin_clzll(v)) : 0; #elif defined(_MSC_VER) && defined(_64_) unsigned long res = 0; - if (v) + if (v) { _BitScanReverse64(&res, v); + } #else ui64 res = 0; - if (v) - while (v >>= 1) + if (v) { + while (v >>= 1) { ++res; + } + } #endif return res; } @@ -295,8 +298,9 @@ Y_FORCE_INLINE ui64 LeastSignificantBit(ui64 v) { ui64 res = v ? __builtin_ffsll(v) - 1 : 0; #elif defined(_MSC_VER) && defined(_64_) unsigned long res = 0; - if (v) + if (v) { _BitScanForward64(&res, v); + } #else ui64 res = 0; if (v) { |