diff --git a/include/ircd/util/popcount.h b/include/ircd/util/popcount.h index d0d639cb7..bdd3887c7 100644 --- a/include/ircd/util/popcount.h +++ b/include/ircd/util/popcount.h @@ -20,6 +20,8 @@ inline namespace util template<> constexpr int popcount(const unsigned long long) noexcept; template<> constexpr int popcount(const unsigned long) noexcept; template<> constexpr int popcount(const unsigned int) noexcept; + template<> constexpr int popcount(const unsigned short) noexcept; + template<> constexpr int popcount(const unsigned char) noexcept; }} template<> @@ -57,3 +59,27 @@ noexcept return __builtin_popcount(a); #endif } + +template<> +constexpr int +ircd::util::popcount(const unsigned short a) +noexcept +{ + #if __has_feature(__cpp_lib_bitops) + return std::popcount(a); + #else + return __builtin_popcount(a); + #endif +} + +template<> +constexpr int +ircd::util::popcount(const unsigned char a) +noexcept +{ + #if __has_feature(__cpp_lib_bitops) + return std::popcount(a); + #else + return __builtin_popcount(a); + #endif +}