1414#include < __concepts/arithmetic.h>
1515#include < __config>
1616#include < limits>
17+ #ifdef _EZ80
18+ #include < __bit/bit_width.h>
19+ #endif // _EZ80
1720
1821#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1922# pragma GCC system_header
@@ -23,6 +26,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2326
2427#if _LIBCPP_STD_VER >= 20
2528
29+ #ifndef _EZ80
30+
2631template <__libcpp_unsigned_integer _Tp>
2732_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil (_Tp __t ) noexcept {
2833 if (__t < 2 )
@@ -39,6 +44,43 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noex
3944 }
4045}
4146
47+ #else // _EZ80
48+
49+ template <class _Tp > _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
50+ _Tp bit_ceil (_Tp __t ) noexcept ;
51+
52+ template <> _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
53+ unsigned char bit_ceil (unsigned char __t ) noexcept {
54+ return ((__t < 2 ) ? 1 : (static_cast <unsigned char >(2 ) << (bit_width<unsigned char >(__t - 1 ) - 1 )));
55+ }
56+
57+ template <> _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
58+ unsigned short bit_ceil (unsigned short __t ) noexcept {
59+ return ((__t < 2 ) ? 1 : (static_cast <unsigned short >(2 ) << (bit_width<unsigned short >(__t - 1 ) - 1 )));
60+ }
61+
62+ template <> _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
63+ unsigned int bit_ceil (unsigned int __t ) noexcept {
64+ return ((__t < 2 ) ? 1 : (static_cast <unsigned int >(2 ) << (bit_width<unsigned int >(__t - 1 ) - 1 )));
65+ }
66+
67+ template <> _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
68+ unsigned long bit_ceil (unsigned long __t ) noexcept {
69+ return ((__t < 2 ) ? 1 : (static_cast <unsigned long >(2 ) << (bit_width<unsigned long >(__t - 1 ) - 1 )));
70+ }
71+
72+ template <> _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
73+ unsigned __int48 bit_ceil (unsigned __int48 __t ) noexcept {
74+ return ((__t < 2 ) ? 1 : (static_cast <unsigned __int48>(2 ) << (bit_width<unsigned __int48>(__t - 1 ) - 1 )));
75+ }
76+
77+ template <> _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
78+ unsigned long long bit_ceil (unsigned long long __t ) noexcept {
79+ return ((__t < 2 ) ? 1 : (static_cast <unsigned long long >(2 ) << (bit_width<unsigned long long >(__t - 1 ) - 1 )));
80+ }
81+
82+ #endif // _EZ80
83+
4284#endif // _LIBCPP_STD_VER >= 20
4385
4486_LIBCPP_END_NAMESPACE_STD
0 commit comments