#[repr(align(8))]pub struct StackStorage<const N: usize> {
pub stack: [MaybeUninit<u8>; N],
}Expand description
The memory backing a thread’s stack before it has been started.
Stacks are aligned to 8 bytes for broad ABI compatibility.
After a thread has been started, ownership of its stack’s memory is (from the Rust Abstract Machine (AM) perspective) relinquished, and so the type we use to represent that memory is irrelevant.
However, while we are initializing a thread in preparation for starting it, we are operating on that memory as a normal Rust variable, and so its type is important.
Using MaybeUninit<u8> instead of u8 is important for two reasons:
- It ensures that it is sound to write values which are not entirely initialized (e.g., which contain padding bytes).
- It ensures that pointers written to the stack retain provenance.
Fields§
§stack: [MaybeUninit<u8>; N]