macro_rules! bump_allocator {
($bytes:expr) => { ... };
}Expand description
Install a BumpAlloc of $bytes as the program’s global
allocator, and define reset_heap() beside it.
A macro rather than a static in this crate because
#[global_allocator] must be unique per binary: a static here would
force the arena on every program that links nub-rt, including the
ones that never allocate.
ⓘ
nub_rt::bump_allocator!(64 * 1024);
#[nub_rt::endpoint(0)]
fn run(_: u64) -> u64 {
reset_heap(); // re-entrant: safe to invoke repeatedly
my_kernel() as u64
}On host targets it expands to a reset_heap() that does nothing, so
the same source builds both ways.