| 1 | // Derived from code in LLVM, which is: |
| 2 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 3 | // See https://llvm.org/LICENSE.txt for license information. |
| 4 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 5 | |
| 6 | /// Returns a multiple of `align` needed to store `size` bytes. |
| 7 | pub(crate) fn align_to(size: u64, align: u64) -> u64 { |
| 8 | (size + align - 1) & !(align - 1) |
| 9 | } |
| 10 | |
| 11 | /* |
| 12 | /// Returns the offset to the next integer (mod 2**64) that is greater than |
| 13 | /// or equal to \p Value and is a multiple of \p Align. |
| 14 | inline uint64_t offsetToAlignment(uint64_t Value, Align Alignment) { |
| 15 | return alignTo(Value, Alignment) - Value; |
| 16 | } |
| 17 | */ |
| 18 | |
| 19 | pub(crate) fn offset_to_alignment(value: u64, alignment: u64) -> u64 { |
| 20 | align_to(size:value, align:alignment) - value |
| 21 | } |
| 22 | |