kernel::utilities::static_init

Function static_buf_check_used

Source
pub fn static_buf_check_used(used: &mut bool)
Expand description

Internal helper function for static_buf!().

This must be public to work within the macro but should never be used directly.

This is a #[inline(never)] function that panics internally if the passed reference is true. This function is intended for use within the static_buf!() macro to detect multiple uses of the macro on the same buffer.

This function is implemented separately without inlining to removes the size bloat of track_caller saving the location of every single call to static_buf!() or static_init!().

If Tock panics with this message:

Error! Single static_buf!() called twice.

then you have tried to initialize the same static memory twice. This is prohibited because you would have multiple mutable references to the same memory. This is likely due to either calling static_buf!() in a loop or calling a function multiple times which internally contains a call to static_buf!(). Typically, calls to static_buf!() are hidden within calls to static_init!() or component helper macros, so start your search there.