CEIL_DIV
Description
Ceiling division: divide num by den rounding up. Equivalent to ceil(num / den) for non-negative inputs. Side-effect-free args only – num is evaluated twice.
Parameters
| Name | Direction | Description |
|---|---|---|
num |
in | Dividend. |
den |
in | Divisor (non-zero). |
Success
Returns the ceiling quotient.
Failure
Function cannot fail. Behaviour is undefined when den is zero.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:373:
u64 IntByteLength(Int *value) {
u64 bits = IntBitLength(value);
return bits == 0 ? 0 : CEIL_DIV(bits, 8u);
}- In
Int.c:933:
u64 bits = IntBitLength(value);
u64 bytes = bits == 0 ? 0 : CEIL_DIV(bits, 8u);
const u8 *magnitude = (const u8 *)BitVecData(INT_BITS(value));
for (u64 i = 0; i < bytes; i++) {- In
Float.c:772:
u64 bits = IntBitLength(&value->significand);
u64 bytes = bits == 0 ? 0 : CEIL_DIV(bits, 8u);
const u8 *magnitude = (const u8 *)BitVecData(&value->significand.bits);
for (u64 i = 0; i < bytes; i++) {- In
Slab.c:126:
}
size slots_per_slab = page_size >> slab->slot_size_shift;
size words = CEIL_DIV(slots_per_slab, 64u);
if (words == 0u) {
words = 1u; // one slot fits in one bitmap bit; still need one word.
- In
Budget.h:148:
PTR_ALIGN_UP_POW2((buf_ptr), 8u), \
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)), \
- In
Budget.h:167:
.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))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
- In
Budget.h:174:
.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))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
- In
Budget.h:184:
.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))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
- In
Budget.h:191:
(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))) / \
ALIGN_UP_POW2((slot_size_bytes), (alignment_value)), \
- In
Budget.h:199:
) - \
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)), \
Last updated on