pub(crate) unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usize
Expand description
Calculate an element-offset that increases a pointer’s alignment.
Calculate an element-offset (not byte-offset) that when added to a given pointer p
, increases p
’s alignment to at least the given alignment a
.
§Safety
a
must be a power of two.
§Notes
This implementation has been carefully tailored to not panic. It is UB for this to panic.
The only real change that can be made here is change of INV_TABLE_MOD_16
and associated
constants.
If we ever decide to make it possible to call the intrinsic with a
that is not a
power-of-two, it will probably be more prudent to just change to a naive implementation rather
than trying to adapt this to accommodate that change.
Any questions go to @nagisa.