Align a value up to the given power-of-two-alignment. See https://sites.google.com/site/theoryofoperatingsystems/labs/malloc/align8
(value: N, alignment: N)
| 644 | /// Align a value up to the given power-of-two-alignment. |
| 645 | // See https://sites.google.com/site/theoryofoperatingsystems/labs/malloc/align8 |
| 646 | pub(crate) fn align_to<N>(value: N, alignment: N) -> N |
| 647 | where |
| 648 | N: Not<Output = N> |
| 649 | + BitAnd<N, Output = N> |
| 650 | + Add<N, Output = N> |
| 651 | + Sub<N, Output = N> |
| 652 | + From<u8> |
| 653 | + Copy, |
| 654 | { |
| 655 | let alignment_mask = alignment - 1.into(); |
| 656 | (value + alignment_mask) & !alignment_mask |
| 657 | } |
| 658 | |
| 659 | /// Calculates the delta needed to adjust a function's frame plus some |
| 660 | /// addend to a given alignment. |
no outgoing calls
no test coverage detected