[][src]Macro kernel::static_buf

macro_rules! static_buf {
    ($T:ty) => { ... };

Allocates a statically-sized global array of memory for data structures but does not initialize the memory.

This macro creates the static buffer, and returns a StaticUninitializedBuffer wrapper containing the buffer. The memory is allocated, but it is guaranteed to be uninitialized inside of the wrapper.

Before the static buffer can be used it must be initialized. For example:

This example is not tested
let mut static_buffer = static_buf!(T);
let static_reference: &'static mut T = static_buffer.initialize(T::new());

Separating the creation of the static buffer into its own macro is not strictly necessary, but it allows for more flexibility in Rust when boards are initialized and the static structures are being created. Since creating and initializing static buffers requires knowing the particular types (and their sizes), writing shared initialization code (in components for example) where the types are unknown since they vary across boards is difficult. By splitting buffer creating from initialization, creating shared components is possible.