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.
alignmust be a power of two. - raw_
align_ up - Align up an integer to the given alignment.
alignmust be a power of two. - raw_
is_ aligned - Is the integer aligned to the given alignment?
alignmust be a power of two. - rshift_
align_ up - Shift
numbybitsto the right. Add 1 to the result if any1bits are shifted out to the right. This is equivalent to dividingnumby 2 to the power ofbits, rounding up.