hololink::module::round_up
hololink::module::round_up
Round a value up to a multiple of an alignment.
Used to size and place buffers so they start and end on the boundaries the hardware or an API requires, for example round_up(size, PAGE_SIZE).
The alignment may be any positive value; it need not be a power of two. A value that is already a multiple of alignment (including zero) is returned unchanged.
Returns: The smallest multiple of alignment that is not less than value.
Throws: std::runtime_error if alignment is zero.
Throws: std::overflow_error if the rounded result is too large to be represented in a size_t.
Parameters
value
The size or offset to round.
alignment
The multiple to round up to. Must be greater than zero.