IgrOS-Kernel 0.1.34.545
Simple C++20 Kernel for i386/x86_64
Loading...
Searching...
No Matches
igros::klib::kAlign Class Referencefinal

Kernel alignment handling (ALIGN in bytes, power of two; 0 - natural alignment of pointed type). More...

#include <klib/kAlign.hpp>

Static Public Member Functions

template<igros_usize_t ALIGN = 0_usize, kalignable T>
requires (std::has_single_bit(ALIGN) || (0_usize == ALIGN))
static constexpr auto check (const T value) noexcept -> bool
 Check alignment.
template<igros_usize_t ALIGN = 0_usize, kalignable T>
requires (std::has_single_bit(ALIGN) || (0_usize == ALIGN))
static constexpr auto up (const T value) noexcept -> T
 Align up.
template<igros_usize_t ALIGN = 0_usize, kalignable T>
requires (std::has_single_bit(ALIGN) || (0_usize == ALIGN))
static constexpr auto down (const T value) noexcept -> T
 Align down.

Static Private Member Functions

template<igros_usize_t ALIGN, kalignable T>
static consteval auto alignment () noexcept -> igros_usize_t
 Alignment in bytes.
template<igros_usize_t ALIGN, kalignable T>
static consteval auto mask () noexcept -> kalign_int_t< T >
 Alignment mask.
template<kalignable T>
static constexpr auto integer (const T value) noexcept -> kalign_int_t< T >
 Value as integer.
template<kalignable T>
static constexpr auto from (const kalign_int_t< T > value) noexcept -> T
 Integer as value.

Detailed Description

Kernel alignment handling (ALIGN in bytes, power of two; 0 - natural alignment of pointed type).

Definition at line 40 of file kAlign.hpp.

Member Function Documentation

◆ alignment()

template<igros_usize_t ALIGN, kalignable T>
auto igros::klib::kAlign::alignment ( ) ->igros_usize_t
staticnodiscardconstevalprivatenoexcept

Alignment in bytes.

Template Parameters
ALIGNRequested alignment in bytes (0 - natural alignment)
TAligned type
Returns
Alignment in bytes (1 for integers without requested alignment)

Definition at line 111 of file kAlign.hpp.

◆ check()

template<igros_usize_t ALIGN, kalignable T>
requires (std::has_single_bit(ALIGN) || (0_usize == ALIGN))
auto igros::klib::kAlign::check ( const T value) ->bool
staticnodiscardconstexprnoexcept

Check alignment.

Template Parameters
ALIGNAlignment in bytes, power of two (0 - natural alignment of pointed type)
TInteger or pointer type
Parameters
valueChecked value
Returns
true if value is aligned

Definition at line 155 of file kAlign.hpp.

◆ down()

template<igros_usize_t ALIGN, kalignable T>
requires (std::has_single_bit(ALIGN) || (0_usize == ALIGN))
auto igros::klib::kAlign::down ( const T value) ->T
staticnodiscardconstexprnoexcept

Align down.

Template Parameters
ALIGNAlignment in bytes, power of two (0 - natural alignment of pointed type)
TInteger or pointer type
Parameters
valueValue to align
Returns
Largest aligned value not greater than value

Definition at line 172 of file kAlign.hpp.

◆ from()

template<kalignable T>
auto igros::klib::kAlign::from ( const kalign_int_t< T > value) ->T
staticnodiscardconstexprprivatenoexcept

Integer as value.

Template Parameters
TAlignable type
Parameters
valueInteger value (address for pointers)
Returns
Value of type T

Definition at line 142 of file kAlign.hpp.

◆ integer()

template<kalignable T>
auto igros::klib::kAlign::integer ( const T value) ->kalign_int_t< T >
staticnodiscardconstexprprivatenoexcept

Value as integer.

Template Parameters
TAlignable type
Parameters
valueInteger or pointer
Returns
Integer value (address for pointers)

Definition at line 131 of file kAlign.hpp.

◆ mask()

template<igros_usize_t ALIGN, kalignable T>
auto igros::klib::kAlign::mask ( ) ->kalign_int_t< T >
staticnodiscardconstevalprivatenoexcept

Alignment mask.

Template Parameters
ALIGNRequested alignment in bytes (0 - natural alignment)
TAligned type
Returns
Mask of low bits that must be zero in aligned value

Definition at line 124 of file kAlign.hpp.

◆ up()

template<igros_usize_t ALIGN, kalignable T>
requires (std::has_single_bit(ALIGN) || (0_usize == ALIGN))
auto igros::klib::kAlign::up ( const T value) ->T
staticnodiscardconstexprnoexcept

Align up.

Template Parameters
ALIGNAlignment in bytes, power of two (0 - natural alignment of pointed type)
TInteger or pointer type
Parameters
valueValue to align
Returns
Smallest aligned value not less than value

Definition at line 163 of file kAlign.hpp.


The documentation for this class was generated from the following file: