10b57cec5SDimitry Andric// -*- C++ -*- 2349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 30b57cec5SDimitry Andric// 40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric// 80b57cec5SDimitry Andric//===---------------------------------------------------------------------===// 90b57cec5SDimitry Andric 100b57cec5SDimitry Andric#ifndef _LIBCPP_BIT 110b57cec5SDimitry Andric#define _LIBCPP_BIT 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric/* 140b57cec5SDimitry Andric bit synopsis 150b57cec5SDimitry Andric 160b57cec5SDimitry Andricnamespace std { 17349cc55cSDimitry Andric // [bit.cast], bit_cast 18349cc55cSDimitry Andric template<class To, class From> 19349cc55cSDimitry Andric constexpr To bit_cast(const From& from) noexcept; // C++20 200b57cec5SDimitry Andric 214824e7fdSDimitry Andric // [bit.byteswap], byteswap 224824e7fdSDimitry Andric template<class T> 234824e7fdSDimitry Andric constexpr T byteswap(T value) noexcept; // C++23 244824e7fdSDimitry Andric 255ffd83dbSDimitry Andric // [bit.pow.two], integral powers of 2 260b57cec5SDimitry Andric template <class T> 27e8d8bef9SDimitry Andric constexpr bool has_single_bit(T x) noexcept; // C++20 280b57cec5SDimitry Andric template <class T> 29e8d8bef9SDimitry Andric constexpr T bit_ceil(T x); // C++20 300b57cec5SDimitry Andric template <class T> 31e8d8bef9SDimitry Andric constexpr T bit_floor(T x) noexcept; // C++20 320b57cec5SDimitry Andric template <class T> 3381ad6265SDimitry Andric constexpr int bit_width(T x) noexcept; // C++20 340b57cec5SDimitry Andric 355ffd83dbSDimitry Andric // [bit.rotate], rotating 360b57cec5SDimitry Andric template<class T> 375f757f3fSDimitry Andric constexpr T rotl(T x, int s) noexcept; // C++20 380b57cec5SDimitry Andric template<class T> 395f757f3fSDimitry Andric constexpr T rotr(T x, int s) noexcept; // C++20 400b57cec5SDimitry Andric 415ffd83dbSDimitry Andric // [bit.count], counting 420b57cec5SDimitry Andric template<class T> 430b57cec5SDimitry Andric constexpr int countl_zero(T x) noexcept; // C++20 440b57cec5SDimitry Andric template<class T> 450b57cec5SDimitry Andric constexpr int countl_one(T x) noexcept; // C++20 460b57cec5SDimitry Andric template<class T> 470b57cec5SDimitry Andric constexpr int countr_zero(T x) noexcept; // C++20 480b57cec5SDimitry Andric template<class T> 490b57cec5SDimitry Andric constexpr int countr_one(T x) noexcept; // C++20 500b57cec5SDimitry Andric template<class T> 510b57cec5SDimitry Andric constexpr int popcount(T x) noexcept; // C++20 520b57cec5SDimitry Andric 535ffd83dbSDimitry Andric // [bit.endian], endian 54e40139ffSDimitry Andric enum class endian { 55e40139ffSDimitry Andric little = see below, // C++20 56e40139ffSDimitry Andric big = see below, // C++20 57e40139ffSDimitry Andric native = see below // C++20 58e40139ffSDimitry Andric }; 59e40139ffSDimitry Andric 600b57cec5SDimitry Andric} // namespace std 610b57cec5SDimitry Andric 620b57cec5SDimitry Andric*/ 630b57cec5SDimitry Andric 64*0fca6ea1SDimitry Andric#include <__config> 65*0fca6ea1SDimitry Andric 66*0fca6ea1SDimitry Andric#if _LIBCPP_STD_VER >= 20 67349cc55cSDimitry Andric# include <__bit/bit_cast.h> 68bdd1243dSDimitry Andric# include <__bit/bit_ceil.h> 69bdd1243dSDimitry Andric# include <__bit/bit_floor.h> 70bdd1243dSDimitry Andric# include <__bit/bit_log2.h> 71bdd1243dSDimitry Andric# include <__bit/bit_width.h> 72bdd1243dSDimitry Andric# include <__bit/countl.h> 73bdd1243dSDimitry Andric# include <__bit/countr.h> 74bdd1243dSDimitry Andric# include <__bit/endian.h> 75bdd1243dSDimitry Andric# include <__bit/has_single_bit.h> 76bdd1243dSDimitry Andric# include <__bit/popcount.h> 77bdd1243dSDimitry Andric# include <__bit/rotate.h> 78*0fca6ea1SDimitry Andric#endif 79*0fca6ea1SDimitry Andric 80*0fca6ea1SDimitry Andric#if _LIBCPP_STD_VER >= 23 81*0fca6ea1SDimitry Andric# include <__bit/byteswap.h> 82*0fca6ea1SDimitry Andric#endif 83*0fca6ea1SDimitry Andric 840b57cec5SDimitry Andric#include <version> 850b57cec5SDimitry Andric 860b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 870b57cec5SDimitry Andric# pragma GCC system_header 880b57cec5SDimitry Andric#endif 890b57cec5SDimitry Andric 90*0fca6ea1SDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 91*0fca6ea1SDimitry Andric# include <cstdint> 92*0fca6ea1SDimitry Andric#endif 93*0fca6ea1SDimitry Andric 94bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 9506c3fb27SDimitry Andric# include <cstdlib> 96bdd1243dSDimitry Andric# include <iosfwd> 97bdd1243dSDimitry Andric# include <limits> 98bdd1243dSDimitry Andric# include <type_traits> 99e40139ffSDimitry Andric#endif 1000b57cec5SDimitry Andric 1010b57cec5SDimitry Andric#endif // _LIBCPP_BIT 102