Warning: This file is not a C or C++ file. It does not have highlighting.

1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// TODO: __builtin_popcountg is available since Clang 19 and GCC 14. When support for older versions is dropped, we can
10// refactor this code to exclusively use __builtin_popcountg.
11
12#ifndef _LIBCPP___CXX03___BIT_POPCOUNT_H
13#define _LIBCPP___CXX03___BIT_POPCOUNT_H
14
15#include <__cxx03/__bit/rotate.h>
16#include <__cxx03/__config>
17#include <__cxx03/limits>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_PUSH_MACROS
24#include <__cxx03/__undef_macros>
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27
28inline _LIBCPP_HIDE_FROM_ABI int __libcpp_popcount(unsigned __x) _NOEXCEPT { return __builtin_popcount(__x); }
29
30inline _LIBCPP_HIDE_FROM_ABI int __libcpp_popcount(unsigned long __x) _NOEXCEPT { return __builtin_popcountl(__x); }
31
32inline _LIBCPP_HIDE_FROM_ABI int __libcpp_popcount(unsigned long long __x) _NOEXCEPT {
33 return __builtin_popcountll(__x);
34}
35
36_LIBCPP_END_NAMESPACE_STD
37
38_LIBCPP_POP_MACROS
39
40#endif // _LIBCPP___CXX03___BIT_POPCOUNT_H
41

Warning: This file is not a C or C++ file. It does not have highlighting.

source code of libcxx/include/__cxx03/__bit/popcount.h