mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-19 00:46:31 +00:00
chore: update toolchain version to 2024-11-05 (#1031)
* chore: update toolchain version to 2024-11-05 * update dragon reach to e945c217b3 * update dog to 6f2c0c8f12 --------- Co-authored-by: longjin <longjin@DragonOS.org>
This commit is contained in:
@ -18,11 +18,9 @@
|
||||
//! # Implementing GlobalAlloc
|
||||
//! See the [global alloc](https://github.com/gz/rust-slabmalloc/tree/master/examples/global_alloc.rs) example.
|
||||
#![allow(unused_features)]
|
||||
#![cfg_attr(feature = "unstable", feature(const_mut_refs))]
|
||||
#![no_std]
|
||||
#![crate_name = "slabmalloc"]
|
||||
#![crate_type = "lib"]
|
||||
#![feature(new_uninit)]
|
||||
#![feature(maybe_uninit_as_bytes)]
|
||||
|
||||
extern crate alloc;
|
||||
@ -65,6 +63,8 @@ pub enum AllocationError {
|
||||
/// Needs to adhere to safety requirements of a rust allocator (see GlobalAlloc et. al.).
|
||||
pub unsafe trait Allocator<'a> {
|
||||
fn allocate(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocationError>;
|
||||
/// # Safety
|
||||
/// The caller must ensure that the memory is valid and that the layout is correct.
|
||||
unsafe fn deallocate(
|
||||
&mut self,
|
||||
ptr: NonNull<u8>,
|
||||
@ -85,5 +85,7 @@ pub unsafe trait Allocator<'a> {
|
||||
|
||||
/// 将slab_page归还Buddy的回调函数
|
||||
pub trait CallBack: Send + Sync {
|
||||
/// # Safety
|
||||
/// The caller must ensure that the memory is valid and that the size is correct.
|
||||
unsafe fn free_slab_page(&self, _: *mut u8, _: usize) {}
|
||||
}
|
||||
|
@ -303,10 +303,10 @@ impl<'a> ObjectPage<'a> {
|
||||
}
|
||||
|
||||
// These needs some more work to be really safe...
|
||||
unsafe impl<'a> Send for ObjectPage<'a> {}
|
||||
unsafe impl<'a> Sync for ObjectPage<'a> {}
|
||||
unsafe impl Send for ObjectPage<'_> {}
|
||||
unsafe impl Sync for ObjectPage<'_> {}
|
||||
|
||||
impl<'a> AllocablePage for ObjectPage<'a> {
|
||||
impl AllocablePage for ObjectPage<'_> {
|
||||
const SIZE: usize = OBJECT_PAGE_SIZE;
|
||||
|
||||
fn bitfield(&self) -> &[AtomicU64; 8] {
|
||||
@ -331,7 +331,7 @@ impl<'a> Default for ObjectPage<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> fmt::Debug for ObjectPage<'a> {
|
||||
impl fmt::Debug for ObjectPage<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "ObjectPage")
|
||||
}
|
||||
|
@ -314,6 +314,9 @@ impl<'a, P: AllocablePage> SCAllocator<'a, P> {
|
||||
/// May return an error in case an invalid `layout` is provided.
|
||||
/// The function may also move internal slab pages between lists partial -> empty
|
||||
/// or full -> partial lists.
|
||||
///
|
||||
/// # Safety
|
||||
/// The caller must ensure that the `layout` is valid.
|
||||
pub unsafe fn deallocate(
|
||||
&mut self,
|
||||
ptr: NonNull<u8>,
|
||||
|
Reference in New Issue
Block a user