Attribute Macro cls::cpu_local

source ·
#[cpu_local]
Expand description

A macro for declaring CPU-local variables.

Variables must be an unsigned integer, bar u128.

The initialisation expression has no effect; to set the initial value, per_cpu::PerCpuData::new must be modified.

Arguments

The macro supports additional named arguments defined after the offset (e.g. #[cpu_local(0, cls_dep = false)]):

  • cls_dep: Whether to define methods that depend on cls indirectly adding a dependency on preemption and irq_safety. This is only really useful for CPU locals defined in preemption to avoid a circular dependency. Defaults to true.
  • stores_guard: If defined, must be set to either HeldInterrupts or PreemptionGuard and signifies that the CPU local has the type Option<Guard>. This option defines special methods that use the guard being switched into the CPU local, rather than an additional guard parameter, as proof that the CPU local can be safely accessed.