Macro kernel::static_init

source ·
macro_rules! static_init {
    ($T:ty, $e:expr $(,)?) => { ... };
}
Expand description

Allocates a statically-sized global array of memory and initializes the memory for a particular data structure.

This macro creates the static buffer, ensures it is initialized to the proper type, and then returns a &'static mut reference to it.

Note: Because this instantiates a static object, you generally cannot pass a type with generic parameters. github.com/tock/tock/issues/2995 for detail.

Safety

As this macro will write directly to a global area without acquiring a lock or similar, calling this macro is inherently unsafe. The caller should take care to never call the code that initializes this buffer twice, as doing so will overwrite the value from first allocation without running its destructor.