Mjolnir Core
Core functionality of the Mjolnir API
Core Utility
bit_construct
bit_construct_from_ints
bit_construct_set_first_n_bits
clear_bit
clear_bits
default_tolerance_abs
get_bit
get_bit
get_bit_shift_max
get_bit_shift_max
get_bits
get_bits
get_bits_shift_max
get_bits_shift_max
integer_to_pointer
is_aligned
is_aligned
is_any_of
is_bit_set
is_close_abs
misalignment
misalignment
num_bits
pack_all
pack_all_false
pack_all_less
pack_all_true
PackType
pointer_to_integer
set_bit
set_bit_to
set_bits
set_bits_with_int
signed_to_unsigned
◆
is_aligned()
[2/2]
auto is_aligned
(
const volatile T_Type *
pointer
,
UST
alignment
)
-> bool
inline
noexcept
Check if a passed pointer is aligned.
Template Parameters
T_Type
The pointer type
Parameters
[in]
pointer
Pointer that should be checked
[in]
alignment
Required alignment
Returns
true
or
false
Remarks
Use the template version if the required alignment is known at compile-time. It is usually faster. Clang 10 with
-O3
generates the following assembly for this function:
is_aligned
(
void
const
volatile
*,
unsigned
long
):
mov rax, rdi
xor edx, edx
div rsi
test rdx, rdx
sete al
ret
mjolnir::is_aligned
auto is_aligned(const volatile T_Type *pointer) noexcept -> bool
Check if a passed pointer is aligned.
Definition:
pointer_operations.h:191
The output for the template version with 4 byte alignment looks like this:
bool
is_aligned<4ul>(
void
const
volatile
*):
test dil, 3
sete al
ret
Note that it consists of less instructions and that the expensive
div
instruction is removed.
Generated by
1.9.1