MCPcopy Create free account
hub / github.com/avast/retdec / isAligned

Function isAligned

src/utils/alignment.cpp:25–31  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

23 * If alignment is not power of 2 the return value is undefined.
24 */
25bool 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.

Callers 2

TEST_FFunction · 0.85

Calls

no outgoing calls

Tested by 1

TEST_FFunction · 0.68