31 concept kalignable = std::unsigned_integral<T> || std::is_pointer_v<T>;
35 template<kalignable T>
46 template<igros_u
size_t ALIGN, kalignable T>
54 template<igros_u
size_t ALIGN, kalignable T>
62 template<kalignable T>
70 template<kalignable T>
82 template<igros_u
size_t ALIGN = 0_usize, kalignable T>
83 requires (std::has_single_bit(ALIGN) || (0_usize == ALIGN))
85 constexpr static auto check(
const T value)
noexcept -> bool;
92 template<igros_u
size_t ALIGN = 0_usize, kalignable T>
93 requires (std::has_single_bit(ALIGN) || (0_usize == ALIGN))
95 constexpr static auto up(
const T value)
noexcept -> T;
101 template<igros_u
size_t ALIGN = 0_usize, kalignable T>
102 requires (std::has_single_bit(ALIGN) || (0_usize == ALIGN))
104 constexpr static auto down(
const T value)
noexcept -> T;
109 template<igros_u
size_t ALIGN, kalignable T>
112 if constexpr (0_usize != ALIGN) {
114 }
else if constexpr (std::is_pointer_v<T> && !std::is_void_v<std::remove_pointer_t<T>>) {
115 return alignof(std::remove_pointer_t<T>);
122 template<igros_u
size_t ALIGN, kalignable T>
129 template<kalignable T>
132 if constexpr (std::is_pointer_v<T>) {
133 return std::bit_cast<igros_usize_t>(value);
140 template<kalignable T>
143 if constexpr (std::is_pointer_v<T>) {
144 return std::bit_cast<T>(value);
152 template<igros_u
size_t ALIGN, kalignable T>
153 requires (std::has_single_bit(ALIGN) || (0_usize == ALIGN))
160 template<igros_u
size_t ALIGN, kalignable T>
161 requires (std::has_single_bit(ALIGN) || (0_usize == ALIGN))
169 template<igros_u
size_t ALIGN, kalignable T>
170 requires (std::has_single_bit(ALIGN) || (0_usize == ALIGN))
Kernel alignment handling (ALIGN in bytes, power of two; 0 - natural alignment of pointed type).
static constexpr auto from(const kalign_int_t< T > value) noexcept -> T
Integer as value.
static consteval auto alignment() noexcept -> igros_usize_t
Alignment in bytes.
static constexpr auto check(const T value) noexcept -> bool
Check alignment.
static consteval auto mask() noexcept -> kalign_int_t< T >
Alignment mask.
static constexpr auto up(const T value) noexcept -> T
Align up.
static constexpr auto integer(const T value) noexcept -> kalign_int_t< T >
Value as integer.
static constexpr auto down(const T value) noexcept -> T
Align down.
Alignable value: unsigned integer (address) or pointer.
std::size_t igros_usize_t
Unsigned size.
Freestanding kernel library: printing, math, alignment, flags, strings.
std::conditional_t< std::is_pointer_v< T >, igros_usize_t, T > kalign_int_t
Integer type for alignment arithmetic (pointers as addresses, integers as is: 64-bit on i386 too).
Common C++ types redefinition.