PTR_ALIGN_UP_POW2
Description
Round ptr up to a power-of-two alignment boundary, preserving pointer type via a void * round-trip. The pointer’s underlying integer goes through u64 so the bit-math doesn’t truncate on 64-bit targets.
Parameters
| Name | Direction | Description |
|---|---|---|
ptr |
in | Pointer to align up. Any pointer type accepted. |
alignment |
in | Power-of-two alignment boundary. Caller’s contract. |
Success
Returns a void * whose address is the smallest alignment-multiple at or above ptr.
Failure
Function cannot fail. Behaviour is undefined when alignment is not a power of two.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Budget.h:146:
), \
MemSet( \
PTR_ALIGN_UP_POW2((buf_ptr), 8u), \
0, \
CEIL_DIV( \
- In
Budget.h:166:
.buf = (u8 *)(buf_ptr), \
.buf_bytes = (total_bytes), \
.bitmap = (u64 *)PTR_ALIGN_UP_POW2((buf_ptr), 8u), \
.bitmap_words = (u32)CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
Last updated on