Macro kernel::static_init [] [src]

macro_rules! static_init {
    ($T:ty, $e:expr, $size:expr) => { ... };
    ($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.

Note that you will have to specify the array-size as an argument, but a wrong size will result in a compile-time error. This argument will be removed if std::mem::size_of<T> ever becomes a const function.


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.