Macro kernel::static_init[][src]

macro_rules! static_init {
    ($T:ty, $e:expr) => { ... };
}

Allocates a global array of static size to initialize data structures.

The global array is initially set to zero. When this macro is hit, it will initialize the array to the value given and return a &'static mut reference to it.

If std::mem::size_of<T> ever becomes a const function then static_init will be optimized to save up to a word of memory for every use.

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.