Skip to main content

stack_unused_bytes

Function stack_unused_bytes 

Source
pub fn stack_unused_bytes() -> usize
Expand description

Smallest number of bytes ever left unused on the CALLING task’s stack, or 0 if this port does not instrument it.

Lives at the crate root, NOT in task, because that module is #[cfg(feature = "alloc")]PlatformTask allocates its own storage – while this is a bare extern "C" query returning a usize. Gating it behind alloc made it unavailable on exactly the no_std targets whose stacks are worth watching, and broke the executor’s stack-headroom rule on the Zephyr build.

The heap has had heap_used_bytes since RFC-0034 D7; this is the stack’s counterpart. HEADROOM, not usage, and for the CALLING task only – both kernels answer for self with no handle, and answering for an arbitrary task needs a native handle this ABI does not carry.

0 means “not instrumented”, not “no headroom”.