diff options
author | kmosienko <kmosienko@yandex-team.ru> | 2022-02-10 16:46:53 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:53 +0300 |
commit | 3f323c9df018d4e22aed7bfb99d27749b8c1d180 (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /library/cpp/pop_count/popcount.h | |
parent | b5a9a2b99dd4fa6005304f0f60f4005137f18cb3 (diff) | |
download | ydb-3f323c9df018d4e22aed7bfb99d27749b8c1d180.tar.gz |
Restoring authorship annotation for <kmosienko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/pop_count/popcount.h')
-rw-r--r-- | library/cpp/pop_count/popcount.h | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/library/cpp/pop_count/popcount.h b/library/cpp/pop_count/popcount.h index d6f12d7a190..3d67737ed25 100644 --- a/library/cpp/pop_count/popcount.h +++ b/library/cpp/pop_count/popcount.h @@ -1,15 +1,15 @@ -#pragma once - +#pragma once + #include <util/generic/typelist.h> #include <util/system/cpu_id.h> -#include <util/system/defaults.h> +#include <util/system/defaults.h> #include <util/system/hi_lo.h> -#include <util/system/platform.h> - +#include <util/system/platform.h> + #if defined(_MSC_VER) #include <intrin.h> -#endif - +#endif + static inline ui32 PopCountImpl(ui8 n) { #if defined(_ppc64_) ui32 r; @@ -23,20 +23,20 @@ static inline ui32 PopCountImpl(ui8 n) { return PopCountLUT8[n]; #endif } - + static inline ui32 PopCountImpl(ui16 n) { #if defined(_MSC_VER) return __popcnt16(n); -#else +#else extern ui8 const* PopCountLUT16; return PopCountLUT16[n]; -#endif +#endif } - + static inline ui32 PopCountImpl(ui32 n) { #if defined(_MSC_VER) return __popcnt(n); -#else +#else #if defined(_x86_64_) if (NX86::CachedHavePOPCNT()) { ui32 r; @@ -62,13 +62,13 @@ static inline ui32 PopCountImpl(ui32 n) { #endif return PopCountImpl((ui16)Lo16(n)) + PopCountImpl((ui16)Hi16(n)); -#endif +#endif } - + static inline ui32 PopCountImpl(ui64 n) { #if defined(_MSC_VER) && !defined(_i386_) return __popcnt64(n); -#else +#else #if defined(_x86_64_) if (NX86::CachedHavePOPCNT()) { ui64 r; @@ -94,12 +94,12 @@ static inline ui32 PopCountImpl(ui64 n) { #endif return PopCountImpl((ui32)Lo32(n)) + PopCountImpl((ui32)Hi32(n)); -#endif +#endif } - + template <class T> static inline ui32 PopCount(T n) { using TCvt = TFixedWidthUnsignedInt<T>; - + return PopCountImpl((TCvt)n); -} +} |