Remove Cell

This commit is contained in:
Yuke Peng
2023-03-08 22:08:10 -08:00
committed by Tate, Hongliang Tian
parent 39ea6a417c
commit 3e9c4a8d45
2 changed files with 0 additions and 40 deletions

View File

@ -1,39 +0,0 @@
use core::{
cell::UnsafeCell,
ops::{Deref, DerefMut},
};
#[derive(Debug, Default)]
#[repr(transparent)]
pub struct Cell<T>(UnsafeCell<T>);
unsafe impl<T> Sync for Cell<T> {}
impl<T> Cell<T> {
/// User is responsible to guarantee that inner struct is only used in
/// uniprocessor.
#[inline(always)]
pub const fn new(val: T) -> Self {
Self(UnsafeCell::new(val))
}
#[inline(always)]
pub fn get(&self) -> &mut T {
unsafe { &mut *self.0.get() }
}
}
impl<T> Deref for Cell<T> {
type Target = T;
#[inline(always)]
fn deref(&self) -> &Self::Target {
self.get()
}
}
impl<T> DerefMut for Cell<T> {
#[inline(always)]
fn deref_mut(&mut self) -> &mut Self::Target {
self.get()
}
}

View File

@ -16,7 +16,6 @@
extern crate alloc;
mod boot;
pub(crate) mod cell;
pub mod config;
pub mod cpu;
pub mod device;