Module conversions

Module conversions 

Source
Expand description

Calculation, conversion and rounding for memory related numbers.

Functionsยง

address_to_chunk_index
Convert an address to the chunk index (aligned down).
bytes_to_chunks_up
Convert size in bytes to the number of chunks (aligned up).
bytes_to_formatted_string
Convert size in bytes to a readable short string, such as 1GB, 2TB, etc. It only keeps the major unit and keeps no fraction.
bytes_to_pages_up
Convert size in bytes to the number of pages (aligned up)
chunk_align_down
Align down an address to the nearest chunk.
chunk_align_up
Align up an address to the nearest chunk.
chunk_index_to_address
Convert a chunk index to the start address of the chunk.
is_address_aligned
Is the address aligned to word boundary?
is_page_aligned
Is the address aligned to page boundary?
mmap_chunk_align_down
Align down an address to the nearest chunk at which granularity we mmap memory.
mmap_chunk_align_up
Align up an address to the nearest chunk at which granularity we mmap memory.
page_align_down
Align down an address to the nearest page.
pages_to_bytes
Convert the number of pages to bytes.
raw_align_down
Align down an integer to the given alignment. align must be a power of two.
raw_align_up
Align up an integer to the given alignment. align must be a power of two.
raw_is_aligned
Is the integer aligned to the given alignment? align must be a power of two.
rshift_align_up
Shift num by bits to the right. Add 1 to the result if any 1 bits are shifted out to the right. This is equivalent to dividing num by 2 to the power of bits, rounding up.