mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-26 19:03:27 +00:00
Inject a scalable slab allocator
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
fdbe52c2ee
commit
a708a0c046
@ -13,11 +13,31 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
|
||||
unsafe { __ostd_panic_handler(info); }
|
||||
}
|
||||
|
||||
use ostd::mm::frame::GlobalFrameAllocator;
|
||||
mod default_frame_allocator {
|
||||
use ostd::mm::frame::GlobalFrameAllocator;
|
||||
|
||||
use osdk_frame_allocator::FrameAllocator;
|
||||
static FRAME_ALLOCATOR: FrameAllocator = FrameAllocator;
|
||||
use osdk_frame_allocator::FrameAllocator;
|
||||
static FRAME_ALLOCATOR: FrameAllocator = FrameAllocator;
|
||||
|
||||
#[no_mangle]
|
||||
#[linkage = "weak"]
|
||||
static __GLOBAL_FRAME_ALLOCATOR_REF: &'static dyn GlobalFrameAllocator = &FRAME_ALLOCATOR;
|
||||
#[no_mangle]
|
||||
#[linkage = "weak"]
|
||||
static __GLOBAL_FRAME_ALLOCATOR_REF: &'static dyn GlobalFrameAllocator = &FRAME_ALLOCATOR;
|
||||
}
|
||||
|
||||
mod default_heap_allocator {
|
||||
use ostd::mm::heap::GlobalHeapAllocator;
|
||||
|
||||
use osdk_heap_allocator::{HeapAllocator, type_from_layout};
|
||||
static HEAP_ALLOCATOR: HeapAllocator = HeapAllocator;
|
||||
|
||||
#[no_mangle]
|
||||
#[linkage = "weak"]
|
||||
static __GLOBAL_HEAP_ALLOCATOR_REF: &'static dyn GlobalHeapAllocator = &HEAP_ALLOCATOR;
|
||||
|
||||
#[no_mangle]
|
||||
#[linkage = "weak"]
|
||||
#[expect(non_snake_case)]
|
||||
fn __GLOBAL_HEAP_SLOT_SIZE_FROM_LAYOUT(layout: core::alloc::Layout) -> Option<ostd::mm::heap::SlotInfo> {
|
||||
type_from_layout(layout)
|
||||
}
|
||||
}
|
||||
|
@ -238,6 +238,12 @@ fn add_manifest_dependency(
|
||||
Path::new("deps").join("frame-allocator"),
|
||||
);
|
||||
|
||||
add_manifest_dependency_to(
|
||||
dependencies,
|
||||
"osdk-heap-allocator",
|
||||
Path::new("deps").join("heap-allocator"),
|
||||
);
|
||||
|
||||
add_manifest_dependency_to(dependencies, "ostd", Path::new("..").join("ostd"));
|
||||
|
||||
let content = toml::to_string(&manifest).unwrap();
|
||||
|
Reference in New Issue
Block a user