* Checks whether given value is aligned based on alignment value. * Alignment must be power of 2. * * @param value Value to be checked. * @param alignment Alignment to check. Must be power of 2. * @param remainder Output value that is non-zero if value is not aligned * and zero if it is aligned. It contains @c value modulo @c alignment. * Contains undefined value if alignment is not pow
| 23 | * If alignment is not power of 2 the return value is undefined. |
| 24 | */ |
| 25 | bool isAligned( |
| 26 | std::uint64_t value, |
| 27 | std::uint64_t alignment, |
| 28 | std::uint64_t& remainder) |
| 29 | { |
| 30 | return (remainder = (value & (alignment - 1))) == 0; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Aligns given value down by specified alignment. Alignment must be power of 2. |
no outgoing calls