Attribute Macro global_frame_allocator
#[global_frame_allocator]
Expand description
A macro attribute for the global frame allocator.
The attributed static variable will be used to provide frame allocation for the kernel.
§Example
ⓘ
use core::alloc::Layout;
use ostd::{mm::{frame::GlobalFrameAllocator, Paddr}, global_frame_allocator};
// Of course it won't work because all allocations will fail.
// It's just an example.
#[global_frame_allocator]
static ALLOCATOR: MyFrameAllocator = MyFrameAllocator;
struct MyFrameAllocator;
impl GlobalFrameAllocator for MyFrameAllocator {
fn alloc(&self, _layout: Layout) -> Option<Paddr> { None }
fn dealloc(&self, _paddr: Paddr, _size: usize) {}
}