Path: blob/main/contrib/llvm-project/libcxx/include/__cxx03/__bit/popcount.h
213799 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78// TODO: __builtin_popcountg is available since Clang 19 and GCC 14. When support for older versions is dropped, we can9// refactor this code to exclusively use __builtin_popcountg.1011#ifndef _LIBCPP___CXX03___BIT_POPCOUNT_H12#define _LIBCPP___CXX03___BIT_POPCOUNT_H1314#include <__cxx03/__bit/rotate.h>15#include <__cxx03/__config>16#include <__cxx03/limits>1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19# pragma GCC system_header20#endif2122_LIBCPP_PUSH_MACROS23#include <__cxx03/__undef_macros>2425_LIBCPP_BEGIN_NAMESPACE_STD2627inline _LIBCPP_HIDE_FROM_ABI int __libcpp_popcount(unsigned __x) _NOEXCEPT { return __builtin_popcount(__x); }2829inline _LIBCPP_HIDE_FROM_ABI int __libcpp_popcount(unsigned long __x) _NOEXCEPT { return __builtin_popcountl(__x); }3031inline _LIBCPP_HIDE_FROM_ABI int __libcpp_popcount(unsigned long long __x) _NOEXCEPT {32return __builtin_popcountll(__x);33}3435_LIBCPP_END_NAMESPACE_STD3637_LIBCPP_POP_MACROS3839#endif // _LIBCPP___CXX03___BIT_POPCOUNT_H404142