xref: /freebsd/contrib/llvm-project/libcxx/include/bit (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
10b57cec5SDimitry Andric// -*- C++ -*-
2*349cc55cSDimitry 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 {
17*349cc55cSDimitry Andric    // [bit.cast], bit_cast
18*349cc55cSDimitry Andric    template<class To, class From>
19*349cc55cSDimitry Andric      constexpr To bit_cast(const From& from) noexcept; // C++20
200b57cec5SDimitry Andric
215ffd83dbSDimitry Andric  // [bit.pow.two], integral powers of 2
220b57cec5SDimitry Andric  template <class T>
23e8d8bef9SDimitry Andric    constexpr bool has_single_bit(T x) noexcept; // C++20
240b57cec5SDimitry Andric  template <class T>
25e8d8bef9SDimitry Andric    constexpr T bit_ceil(T x);                   // C++20
260b57cec5SDimitry Andric  template <class T>
27e8d8bef9SDimitry Andric    constexpr T bit_floor(T x) noexcept;         // C++20
280b57cec5SDimitry Andric  template <class T>
29e8d8bef9SDimitry Andric    constexpr T bit_width(T x) noexcept;         // C++20
300b57cec5SDimitry Andric
315ffd83dbSDimitry Andric  // [bit.rotate], rotating
320b57cec5SDimitry Andric  template<class T>
330b57cec5SDimitry Andric    constexpr T rotl(T x, unsigned int s) noexcept; // C++20
340b57cec5SDimitry Andric  template<class T>
350b57cec5SDimitry Andric    constexpr T rotr(T x, unsigned int s) noexcept; // C++20
360b57cec5SDimitry Andric
375ffd83dbSDimitry Andric  // [bit.count], counting
380b57cec5SDimitry Andric  template<class T>
390b57cec5SDimitry Andric    constexpr int countl_zero(T x) noexcept;  // C++20
400b57cec5SDimitry Andric  template<class T>
410b57cec5SDimitry Andric    constexpr int countl_one(T x) noexcept;   // C++20
420b57cec5SDimitry Andric  template<class T>
430b57cec5SDimitry Andric    constexpr int countr_zero(T x) noexcept;  // C++20
440b57cec5SDimitry Andric  template<class T>
450b57cec5SDimitry Andric    constexpr int countr_one(T x) noexcept;   // C++20
460b57cec5SDimitry Andric  template<class T>
470b57cec5SDimitry Andric    constexpr int popcount(T x) noexcept;     // C++20
480b57cec5SDimitry Andric
495ffd83dbSDimitry Andric  // [bit.endian], endian
50e40139ffSDimitry Andric  enum class endian {
51e40139ffSDimitry Andric    little = see below,        // C++20
52e40139ffSDimitry Andric    big = see below,           // C++20
53e40139ffSDimitry Andric    native = see below         // C++20
54e40139ffSDimitry Andric};
55e40139ffSDimitry Andric
560b57cec5SDimitry Andric} // namespace std
570b57cec5SDimitry Andric
580b57cec5SDimitry Andric*/
590b57cec5SDimitry Andric
60*349cc55cSDimitry Andric#include <__bit/bit_cast.h>
61fe6060f1SDimitry Andric#include <__bits> // __libcpp_clz
62*349cc55cSDimitry Andric#include <__config>
63fe6060f1SDimitry Andric#include <__debug>
640b57cec5SDimitry Andric#include <limits>
650b57cec5SDimitry Andric#include <type_traits>
660b57cec5SDimitry Andric#include <version>
670b57cec5SDimitry Andric
680b57cec5SDimitry Andric#if defined(__IBMCPP__)
69d409305fSDimitry Andric#include "__support/ibm/support.h"
700b57cec5SDimitry Andric#endif
710b57cec5SDimitry Andric#if defined(_LIBCPP_COMPILER_MSVC)
720b57cec5SDimitry Andric#include <intrin.h>
730b57cec5SDimitry Andric#endif
740b57cec5SDimitry Andric
750b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
760b57cec5SDimitry Andric#pragma GCC system_header
770b57cec5SDimitry Andric#endif
780b57cec5SDimitry Andric
790b57cec5SDimitry Andric_LIBCPP_PUSH_MACROS
800b57cec5SDimitry Andric#include <__undef_macros>
810b57cec5SDimitry Andric
820b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
830b57cec5SDimitry Andric
840b57cec5SDimitry Andrictemplate<class _Tp>
850b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
860b57cec5SDimitry Andric_Tp __rotl(_Tp __t, unsigned int __cnt) _NOEXCEPT
870b57cec5SDimitry Andric{
88fe6060f1SDimitry Andric    static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type");
890b57cec5SDimitry Andric    const unsigned int __dig = numeric_limits<_Tp>::digits;
900b57cec5SDimitry Andric    if ((__cnt % __dig) == 0)
910b57cec5SDimitry Andric        return __t;
920b57cec5SDimitry Andric    return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig)));
930b57cec5SDimitry Andric}
940b57cec5SDimitry Andric
950b57cec5SDimitry Andrictemplate<class _Tp>
960b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
970b57cec5SDimitry Andric_Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT
980b57cec5SDimitry Andric{
99fe6060f1SDimitry Andric    static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type");
1000b57cec5SDimitry Andric    const unsigned int __dig = numeric_limits<_Tp>::digits;
1010b57cec5SDimitry Andric    if ((__cnt % __dig) == 0)
1020b57cec5SDimitry Andric        return __t;
1030b57cec5SDimitry Andric    return (__t >> (__cnt % __dig)) | (__t << (__dig - (__cnt % __dig)));
1040b57cec5SDimitry Andric}
1050b57cec5SDimitry Andric
1060b57cec5SDimitry Andrictemplate<class _Tp>
1070b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1080b57cec5SDimitry Andricint __countr_zero(_Tp __t) _NOEXCEPT
1090b57cec5SDimitry Andric{
110fe6060f1SDimitry Andric    static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countr_zero requires an unsigned integer type");
1110b57cec5SDimitry Andric    if (__t == 0)
1120b57cec5SDimitry Andric        return numeric_limits<_Tp>::digits;
1130b57cec5SDimitry Andric
1140b57cec5SDimitry Andric    if      (sizeof(_Tp) <= sizeof(unsigned int))
1150b57cec5SDimitry Andric        return __libcpp_ctz(static_cast<unsigned int>(__t));
1160b57cec5SDimitry Andric    else if (sizeof(_Tp) <= sizeof(unsigned long))
1170b57cec5SDimitry Andric        return __libcpp_ctz(static_cast<unsigned long>(__t));
1180b57cec5SDimitry Andric    else if (sizeof(_Tp) <= sizeof(unsigned long long))
1190b57cec5SDimitry Andric        return __libcpp_ctz(static_cast<unsigned long long>(__t));
1200b57cec5SDimitry Andric    else
1210b57cec5SDimitry Andric    {
1220b57cec5SDimitry Andric        int __ret = 0;
1230b57cec5SDimitry Andric        const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
124fe6060f1SDimitry Andric        while (static_cast<unsigned long long>(__t) == 0uLL)
1250b57cec5SDimitry Andric        {
126fe6060f1SDimitry Andric            __ret += __ulldigits;
1270b57cec5SDimitry Andric            __t >>= __ulldigits;
1280b57cec5SDimitry Andric        }
129fe6060f1SDimitry Andric        return __ret + __libcpp_ctz(static_cast<unsigned long long>(__t));
1300b57cec5SDimitry Andric    }
1310b57cec5SDimitry Andric}
1320b57cec5SDimitry Andric
1330b57cec5SDimitry Andrictemplate<class _Tp>
1340b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1350b57cec5SDimitry Andricint __countl_zero(_Tp __t) _NOEXCEPT
1360b57cec5SDimitry Andric{
137fe6060f1SDimitry Andric    static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type");
1380b57cec5SDimitry Andric    if (__t == 0)
1390b57cec5SDimitry Andric        return numeric_limits<_Tp>::digits;
1400b57cec5SDimitry Andric
1410b57cec5SDimitry Andric    if      (sizeof(_Tp) <= sizeof(unsigned int))
1420b57cec5SDimitry Andric        return __libcpp_clz(static_cast<unsigned int>(__t))
1430b57cec5SDimitry Andric              - (numeric_limits<unsigned int>::digits - numeric_limits<_Tp>::digits);
1440b57cec5SDimitry Andric    else if (sizeof(_Tp) <= sizeof(unsigned long))
1450b57cec5SDimitry Andric        return __libcpp_clz(static_cast<unsigned long>(__t))
1460b57cec5SDimitry Andric              - (numeric_limits<unsigned long>::digits - numeric_limits<_Tp>::digits);
1470b57cec5SDimitry Andric    else if (sizeof(_Tp) <= sizeof(unsigned long long))
1480b57cec5SDimitry Andric        return __libcpp_clz(static_cast<unsigned long long>(__t))
1490b57cec5SDimitry Andric              - (numeric_limits<unsigned long long>::digits - numeric_limits<_Tp>::digits);
1500b57cec5SDimitry Andric    else
1510b57cec5SDimitry Andric    {
1520b57cec5SDimitry Andric        int __ret = 0;
1530b57cec5SDimitry Andric        int __iter = 0;
1540b57cec5SDimitry Andric        const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
1550b57cec5SDimitry Andric        while (true) {
1560b57cec5SDimitry Andric            __t = __rotr(__t, __ulldigits);
1570b57cec5SDimitry Andric            if ((__iter = __countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits)
1580b57cec5SDimitry Andric                break;
1590b57cec5SDimitry Andric            __ret += __iter;
1600b57cec5SDimitry Andric            }
1610b57cec5SDimitry Andric        return __ret + __iter;
1620b57cec5SDimitry Andric    }
1630b57cec5SDimitry Andric}
1640b57cec5SDimitry Andric
1650b57cec5SDimitry Andrictemplate<class _Tp>
1660b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1670b57cec5SDimitry Andricint __countl_one(_Tp __t) _NOEXCEPT
1680b57cec5SDimitry Andric{
169fe6060f1SDimitry Andric    static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_one requires an unsigned integer type");
1700b57cec5SDimitry Andric    return __t != numeric_limits<_Tp>::max()
1710b57cec5SDimitry Andric        ? __countl_zero(static_cast<_Tp>(~__t))
1720b57cec5SDimitry Andric        : numeric_limits<_Tp>::digits;
1730b57cec5SDimitry Andric}
1740b57cec5SDimitry Andric
1750b57cec5SDimitry Andrictemplate<class _Tp>
1760b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1770b57cec5SDimitry Andricint __countr_one(_Tp __t) _NOEXCEPT
1780b57cec5SDimitry Andric{
179fe6060f1SDimitry Andric    static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countr_one requires an unsigned integer type");
1800b57cec5SDimitry Andric    return __t != numeric_limits<_Tp>::max()
1810b57cec5SDimitry Andric        ? __countr_zero(static_cast<_Tp>(~__t))
1820b57cec5SDimitry Andric        : numeric_limits<_Tp>::digits;
1830b57cec5SDimitry Andric}
1840b57cec5SDimitry Andric
1850b57cec5SDimitry Andrictemplate<class _Tp>
1860b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
187fe6060f1SDimitry Andricint __popcount(_Tp __t) _NOEXCEPT
1880b57cec5SDimitry Andric{
189fe6060f1SDimitry Andric    static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__popcount requires an unsigned integer type");
1900b57cec5SDimitry Andric    if      (sizeof(_Tp) <= sizeof(unsigned int))
1910b57cec5SDimitry Andric        return __libcpp_popcount(static_cast<unsigned int>(__t));
1920b57cec5SDimitry Andric    else if (sizeof(_Tp) <= sizeof(unsigned long))
1930b57cec5SDimitry Andric        return __libcpp_popcount(static_cast<unsigned long>(__t));
1940b57cec5SDimitry Andric    else if (sizeof(_Tp) <= sizeof(unsigned long long))
1950b57cec5SDimitry Andric        return __libcpp_popcount(static_cast<unsigned long long>(__t));
1960b57cec5SDimitry Andric    else
1970b57cec5SDimitry Andric    {
1980b57cec5SDimitry Andric        int __ret = 0;
1990b57cec5SDimitry Andric        while (__t != 0)
2000b57cec5SDimitry Andric        {
2010b57cec5SDimitry Andric            __ret += __libcpp_popcount(static_cast<unsigned long long>(__t));
2020b57cec5SDimitry Andric            __t >>= numeric_limits<unsigned long long>::digits;
2030b57cec5SDimitry Andric        }
2040b57cec5SDimitry Andric        return __ret;
2050b57cec5SDimitry Andric    }
2060b57cec5SDimitry Andric}
2070b57cec5SDimitry Andric
2080b57cec5SDimitry Andric// integral log base 2
2090b57cec5SDimitry Andrictemplate<class _Tp>
2100b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
2110b57cec5SDimitry Andricunsigned __bit_log2(_Tp __t) _NOEXCEPT
2120b57cec5SDimitry Andric{
213fe6060f1SDimitry Andric    static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__bit_log2 requires an unsigned integer type");
214e8d8bef9SDimitry Andric    return numeric_limits<_Tp>::digits - 1 - __countl_zero(__t);
2150b57cec5SDimitry Andric}
2160b57cec5SDimitry Andric
2170b57cec5SDimitry Andrictemplate <class _Tp>
2180b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
219e8d8bef9SDimitry Andricbool __has_single_bit(_Tp __t) _NOEXCEPT
2200b57cec5SDimitry Andric{
221fe6060f1SDimitry Andric    static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__has_single_bit requires an unsigned integer type");
2220b57cec5SDimitry Andric    return __t != 0 && (((__t & (__t - 1)) == 0));
2230b57cec5SDimitry Andric}
2240b57cec5SDimitry Andric
2250b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
2260b57cec5SDimitry Andric
2270b57cec5SDimitry Andrictemplate<class _Tp>
2280b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY constexpr
229*349cc55cSDimitry Andricenable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
2300b57cec5SDimitry Andricrotl(_Tp __t, unsigned int __cnt) noexcept
2310b57cec5SDimitry Andric{
2320b57cec5SDimitry Andric    return __rotl(__t, __cnt);
2330b57cec5SDimitry Andric}
2340b57cec5SDimitry Andric
2350b57cec5SDimitry Andrictemplate<class _Tp>
2360b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY constexpr
237*349cc55cSDimitry Andricenable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
2380b57cec5SDimitry Andricrotr(_Tp __t, unsigned int __cnt) noexcept
2390b57cec5SDimitry Andric{
2400b57cec5SDimitry Andric    return __rotr(__t, __cnt);
2410b57cec5SDimitry Andric}
2420b57cec5SDimitry Andric
2430b57cec5SDimitry Andrictemplate<class _Tp>
2440b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY constexpr
245*349cc55cSDimitry Andricenable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>
2460b57cec5SDimitry Andriccountl_zero(_Tp __t) noexcept
2470b57cec5SDimitry Andric{
2480b57cec5SDimitry Andric    return __countl_zero(__t);
2490b57cec5SDimitry Andric}
2500b57cec5SDimitry Andric
2510b57cec5SDimitry Andrictemplate<class _Tp>
2520b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY constexpr
253*349cc55cSDimitry Andricenable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>
2540b57cec5SDimitry Andriccountl_one(_Tp __t) noexcept
2550b57cec5SDimitry Andric{
2560b57cec5SDimitry Andric    return __countl_one(__t);
2570b57cec5SDimitry Andric}
2580b57cec5SDimitry Andric
2590b57cec5SDimitry Andrictemplate<class _Tp>
2600b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY constexpr
261*349cc55cSDimitry Andricenable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>
2620b57cec5SDimitry Andriccountr_zero(_Tp __t) noexcept
2630b57cec5SDimitry Andric{
2640b57cec5SDimitry Andric    return __countr_zero(__t);
2650b57cec5SDimitry Andric}
2660b57cec5SDimitry Andric
2670b57cec5SDimitry Andrictemplate<class _Tp>
2680b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY constexpr
269*349cc55cSDimitry Andricenable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>
2700b57cec5SDimitry Andriccountr_one(_Tp __t) noexcept
2710b57cec5SDimitry Andric{
2720b57cec5SDimitry Andric    return __countr_one(__t);
2730b57cec5SDimitry Andric}
2740b57cec5SDimitry Andric
2750b57cec5SDimitry Andrictemplate<class _Tp>
2760b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY constexpr
277*349cc55cSDimitry Andricenable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int>
2780b57cec5SDimitry Andricpopcount(_Tp __t) noexcept
2790b57cec5SDimitry Andric{
2800b57cec5SDimitry Andric    return __popcount(__t);
2810b57cec5SDimitry Andric}
2820b57cec5SDimitry Andric
2830b57cec5SDimitry Andrictemplate <class _Tp>
2840b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY constexpr
285*349cc55cSDimitry Andricenable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, bool>
286e8d8bef9SDimitry Andrichas_single_bit(_Tp __t) noexcept
2870b57cec5SDimitry Andric{
288e8d8bef9SDimitry Andric    return __has_single_bit(__t);
2890b57cec5SDimitry Andric}
2900b57cec5SDimitry Andric
2910b57cec5SDimitry Andrictemplate <class _Tp>
2920b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY constexpr
293*349cc55cSDimitry Andricenable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
294e8d8bef9SDimitry Andricbit_floor(_Tp __t) noexcept
2950b57cec5SDimitry Andric{
2960b57cec5SDimitry Andric    return __t == 0 ? 0 : _Tp{1} << __bit_log2(__t);
2970b57cec5SDimitry Andric}
2980b57cec5SDimitry Andric
2990b57cec5SDimitry Andrictemplate <class _Tp>
3000b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY constexpr
301*349cc55cSDimitry Andricenable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
302e8d8bef9SDimitry Andricbit_ceil(_Tp __t) noexcept
3030b57cec5SDimitry Andric{
3040b57cec5SDimitry Andric    if (__t < 2) return 1;
3050b57cec5SDimitry Andric    const unsigned __n = numeric_limits<_Tp>::digits - countl_zero((_Tp)(__t - 1u));
306e8d8bef9SDimitry Andric    _LIBCPP_DEBUG_ASSERT(__libcpp_is_constant_evaluated() || __n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil");
3070b57cec5SDimitry Andric
3080b57cec5SDimitry Andric    if constexpr (sizeof(_Tp) >= sizeof(unsigned))
3090b57cec5SDimitry Andric        return _Tp{1} << __n;
3100b57cec5SDimitry Andric    else
3110b57cec5SDimitry Andric    {
3120b57cec5SDimitry Andric        const unsigned __extra = numeric_limits<unsigned>::digits  - numeric_limits<_Tp>::digits;
3130b57cec5SDimitry Andric        const unsigned __retVal = 1u << (__n + __extra);
3140b57cec5SDimitry Andric        return (_Tp) (__retVal >> __extra);
3150b57cec5SDimitry Andric    }
3160b57cec5SDimitry Andric}
3170b57cec5SDimitry Andric
3180b57cec5SDimitry Andrictemplate <class _Tp>
3190b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY constexpr
320*349cc55cSDimitry Andricenable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
321e8d8bef9SDimitry Andricbit_width(_Tp __t) noexcept
3220b57cec5SDimitry Andric{
3230b57cec5SDimitry Andric    return __t == 0 ? 0 : __bit_log2(__t) + 1;
3240b57cec5SDimitry Andric}
3250b57cec5SDimitry Andric
326e40139ffSDimitry Andricenum class endian
327e40139ffSDimitry Andric{
328e40139ffSDimitry Andric    little = 0xDEAD,
329e40139ffSDimitry Andric    big    = 0xFACE,
330e40139ffSDimitry Andric#if defined(_LIBCPP_LITTLE_ENDIAN)
331e40139ffSDimitry Andric    native = little
332e40139ffSDimitry Andric#elif defined(_LIBCPP_BIG_ENDIAN)
333e40139ffSDimitry Andric    native = big
334e40139ffSDimitry Andric#else
335e40139ffSDimitry Andric    native = 0xCAFE
336e40139ffSDimitry Andric#endif
337e40139ffSDimitry Andric};
338e40139ffSDimitry Andric
3390b57cec5SDimitry Andric#endif // _LIBCPP_STD_VER > 17
3400b57cec5SDimitry Andric
3410b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
3420b57cec5SDimitry Andric
3430b57cec5SDimitry Andric_LIBCPP_POP_MACROS
3440b57cec5SDimitry Andric
3450b57cec5SDimitry Andric#endif // _LIBCPP_BIT
346