ALIGN_UP
- Macro
- August 22, 2025
Table of Contents
ALIGN_UP
ALIGN_UP
Description
Aligns the given value
up to the nearest multiple of alignment
.
Parameters
Name | Direction | Description |
---|---|---|
value | in | The value to be aligned up. |
alignment | in | The alignment boundary. |
Success
Returns aligned-up value when alignment > 1, original value otherwise.
Failure
Function cannot fail - always returns a valid value.
Usage example (Cross-references)
- In
Access.h:40
:
/// TAGS: Memory, Size, Iter
///
#define IterSize(mi) IterLength(mi) * ALIGN_UP(sizeof(ITER_DATA_TYPE(mi)), (mi)->alignment)
///
- In
Access.h:51
:
/// TAGS: Memory, Iter, Size
///
#define IterRemainingSize(mi) IterRemainingLength(mi) * ALIGN_UP(sizeof(ITER_DATA_TYPE(mi)), (mi)->alignment)
///
- In
Access.h:66
:
(IterRemainingLength(mi) ? \
(ITER_DATA_TYPE(mi) *)(((u64)(mi)->data) + \
(mi)->pos * ALIGN_UP(sizeof(ITER_DATA_TYPE(mi)), (mi)->alignment)) : \
NULL_ITER_DATA(mi))
- In
Init.h:238
:
#define VecInitAlignedWithDeepCopyStack(v, ne, ci, cd, aln, scoped_body) \
do { \
char ___data___[ALIGN_UP(sizeof(VEC_DATATYPE(&(v))), (aln)) * ((ne) + 1)] = {0}; \
\
(v) = VecInitAlignedWithDeepCopyT((v), (ci), (cd), (aln)); \
- In
Access.h:22
:
/// FAILURE : Does not return on failure
///
#define VecAlignedOffsetAt(v, idx) ((idx) * ALIGN_UP(sizeof(VEC_DATATYPE(v)), (v)->alignment))
///
/// Value at given index in a vector.
- In
Vec.Access.c:218
:
// For 8-byte alignment, each int (4 bytes) should be padded to 8 bytes
size aligned_size = ALIGN_UP(sizeof(int), 8);
// Check offsets with alignment