ALIGN_UP_POW2
Description
Aligns the given value up to the nearest power-of-two multiple.
Parameters
| Name | Direction | Description |
|---|---|---|
value |
in | The value to be aligned up. |
alignment |
in | The power-of-two alignment boundary. |
Success
Returns power-of-two aligned-up value when alignment > 1.
Failure
Function cannot fail - returns original value if alignment <= 1.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Page.c:150:
size page_size = PageAllocatorPageSize(self);
if (align > page_size) {
return ALIGN_UP_POW2(bytes, align);
}
return ALIGN_UP_POW2(bytes, page_size);- In
Page.c:152:
return ALIGN_UP_POW2(bytes, align);
}
return ALIGN_UP_POW2(bytes, page_size);
}- In
Page.c:195:
want_bytes = *bytes_p * 2;
}
size new_rounded = ALIGN_UP_POW2(want_bytes, page_size);
if (!new_rounded) {
return false;- In
Arena.c:110:
}
size align = self->base.alignment;
size padded = ALIGN_UP_POW2(bytes, align);
void *result = NULL;- In
Arena.c:200:
}
ArenaChunk *chunk = self->tail;
size padded_new = ALIGN_UP_POW2(new_size, align);
size last_off = (size)((u8 *)ptr - chunk->base);
if (last_off + padded_new > chunk->capacity) {- In
Vec.c:25:
return item_size;
}
return v->allocator->alignment > 1 ? ALIGN_UP_POW2(item_size, v->allocator->alignment) : item_size;
}- In
Types.h:483:
///
/// TAGS: Memory, Alignment, PowerOfTwo, Pointer
#define PTR_ALIGN_UP_POW2(ptr, alignment) ((void *)ALIGN_UP_POW2((u64)(ptr), (alignment)))
///
- In
Budget.h:199:
), \
ASSERT_OR_FATAL( \
(size)(total_bytes) >= (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr)) + sizeof(u64) + \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)) + ((alignment_value) - 1), \
"BudgetAllocatorInit: buffer too small for bitmap + one padded slot" \
- In
Budget.h:200:
ASSERT_OR_FATAL( \
(size)(total_bytes) >= (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr)) + sizeof(u64) + \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)) + ((alignment_value) - 1), \
"BudgetAllocatorInit: buffer too small for bitmap + one padded slot" \
), \
- In
Budget.h:207:
0, \
CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
64u \
- In
Budget.h:208:
CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
64u \
) * sizeof(u64) \
- In
Budget.h:227:
.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))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
64u \
- In
Budget.h:228:
.bitmap_words = (u32)CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
64u \
), \
- In
Budget.h:231:
64u \
), \
.slots = (u8 *)ALIGN_UP_POW2( \
ALIGN_UP_POW2((u64)(buf_ptr), 8u) + \
CEIL_DIV( \
- In
Budget.h:232:
), \
.slots = (u8 *)ALIGN_UP_POW2( \
ALIGN_UP_POW2((u64)(buf_ptr), 8u) + \
CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
- In
Budget.h:234:
ALIGN_UP_POW2((u64)(buf_ptr), 8u) + \
CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
64u \
- In
Budget.h:235:
CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
64u \
) * sizeof(u64), \
- In
Budget.h:240:
(alignment_value) \
), \
.slot_size = ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
.slot_count = \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr)) - \
- In
Budget.h:242:
.slot_size = ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
.slot_count = \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr)) - \
CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
- In
Budget.h:244:
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr)) - \
CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
64u \
- In
Budget.h:245:
CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
64u \
) * sizeof(u64) - \
- In
Budget.h:248:
64u \
) * sizeof(u64) - \
(size)(ALIGN_UP_POW2( \
ALIGN_UP_POW2((u64)(buf_ptr), 8u) + \
CEIL_DIV( \
- In
Budget.h:249:
) * sizeof(u64) - \
(size)(ALIGN_UP_POW2( \
ALIGN_UP_POW2((u64)(buf_ptr), 8u) + \
CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
- In
Budget.h:251:
ALIGN_UP_POW2((u64)(buf_ptr), 8u) + \
CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
64u \
- In
Budget.h:252:
CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
64u \
) * sizeof(u64), \
- In
Budget.h:257:
(alignment_value) \
) - \
ALIGN_UP_POW2((u64)(buf_ptr), 8u) - \
CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
- In
Budget.h:259:
ALIGN_UP_POW2((u64)(buf_ptr), 8u) - \
CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
64u \
- In
Budget.h:260:
CEIL_DIV( \
((size)(total_bytes) - (size)(ALIGN_UP_POW2((u64)(buf_ptr), 8u) - (u64)(buf_ptr))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
64u \
) * sizeof(u64))) / \
- In
Budget.h:263:
64u \
) * sizeof(u64))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
}))- In
Access.h:30:
#define VecAlignedOffsetAt(v, idx) \
((idx) * (((v)->allocator && (v)->allocator->alignment > 1) ? \
ALIGN_UP_POW2(sizeof(VEC_DATATYPE(v)), (v)->allocator->alignment) : \
sizeof(VEC_DATATYPE(v))))
Last updated on