Home
last modified time | relevance | path

Searched refs:T (Results 1 – 25 of 50) sorted by relevance

12

/DragonOS-0.1.9/kernel/crates/bitmap/src/
Dbitmap_core.rs6 pub(crate) struct BitMapCore<T: BitOps> {
7 phantom: PhantomData<T>,
10 impl<T: BitOps> BitMapCore<T> {
18 pub(crate) fn get(&self, n: usize, data: &[T], index: usize) -> Option<bool> { in get() argument
23 let element_index = index / T::bit_size(); in get()
24 let bit_index = index % T::bit_size(); in get()
27 let bit = <T as BitOps>::get(element, bit_index); in get()
33 pub(crate) fn set(&self, n: usize, data: &mut [T], index: usize, value: bool) -> Option<bool> { in set() argument
37 let element_index = index / T::bit_size(); in set()
38 let bit_index = index % T::bit_size(); in set()
[all …]
/DragonOS-0.1.9/kernel/src/libs/
Dvolatile.rs71 pub struct ReadOnly<T: Copy>(T);
74 impl<T: Copy> ReadOnly<T> {
76 pub fn new(value: T) -> Self { in new()
84 pub struct WriteOnly<T: Copy>(T);
89 pub struct Volatile<T: Copy>(T);
92 impl<T: Copy> Volatile<T> {
94 pub fn new(value: T) -> Self { in new()
100 pub trait VolatileReadable<T> {
102 unsafe fn vread(self) -> T; in vread() argument
105 impl<T: Copy> VolatileReadable<T> for *const ReadOnly<T> {
[all …]
Dlock_free_flags.rs11 pub struct LockFreeFlags<T> {
12 inner: UnsafeCell<T>,
15 impl<T> LockFreeFlags<T> {
16 pub unsafe fn new(inner: T) -> Self { in new()
22 pub fn get_mut(&self) -> &mut T { in get_mut() argument
24 (self.inner.get().as_ref().unwrap() as *const T as *mut T) in get_mut() constant
30 pub fn get(&self) -> &T { in get() argument
35 unsafe impl<T: Sync> Sync for LockFreeFlags<T> {}
36 unsafe impl<T: Send> Send for LockFreeFlags<T> {}
38 impl<T: Clone> Clone for LockFreeFlags<T> {
[all …]
Dlazy_init.rs28 pub struct Lazy<T> {
32 value: UnsafeCell<MaybeUninit<T>>,
37 impl<T> Lazy<T> {
40 pub const fn new() -> Lazy<T> { in new()
68 pub fn init(&self, value: T) { in init() argument
86 pub fn get(&self) -> &T { in get() argument
93 pub fn try_get(&self) -> Option<&T> { in try_get() argument
104 pub fn get_mut(&mut self) -> &mut T { in get_mut() argument
110 pub unsafe fn get_unchecked(&self) -> &T { in get_unchecked() argument
115 pub unsafe fn get_mut_unchecked(&mut self) -> &mut T { in get_mut_unchecked() argument
[all …]
Drwlock.rs38 pub struct RwLock<T> {
40 data: UnsafeCell<T>,
45 pub struct RwLockReadGuard<'a, T: 'a> {
46 data: *const T,
55 pub struct RwLockUpgradableGuard<'a, T: 'a> {
56 data: *const T,
57 inner: &'a RwLock<T>,
64 pub struct RwLockWriteGuard<'a, T: 'a> {
65 data: *mut T,
66 inner: &'a RwLock<T>,
[all …]
Dspinlock.rs17 pub struct SpinLock<T> {
20 data: UnsafeCell<T>,
27 pub struct SpinLockGuard<'a, T: 'a> {
28 lock: &'a SpinLock<T>,
29 data: *mut T,
34 impl<'a, T: 'a> SpinLockGuard<'a, T> {
44 pub unsafe fn leak(this: Self) -> &'a mut T { in leak() argument
60 unsafe impl<T> Sync for SpinLock<T> where T: Send {}
62 impl<T> SpinLock<T> {
63 pub const fn new(value: T) -> Self { in new()
[all …]
Dnotifier.rs12 pub trait NotifierBlock<V: Clone + Copy, T>: Debug + Send + Sync {
14 fn notifier_call(&self, action: V, data: Option<&T>) -> i32; in notifier_call()
22 struct NotifierChain<V: Clone + Copy, T>(Vec<Arc<dyn NotifierBlock<V, T>>>);
24 impl<V: Clone + Copy, T> NotifierChain<V, T> {
33 block: Arc<dyn NotifierBlock<V, T>>, in register() argument
67 pub fn unregister(&mut self, block: Arc<dyn NotifierBlock<V, T>>) -> Result<(), SystemError> { in unregister()
89 data: Option<&T>, in call_chain() argument
108 pub struct AtomicNotifierChain<V: Clone + Copy, T>(SpinLock<NotifierChain<V, T>>);
110 impl<V: Clone + Copy, T> AtomicNotifierChain<V, T> {
112 Self(SpinLock::new(NotifierChain::<V, T>::new())) in new()
[all …]
Dalign.rs18 pub struct AlignedBox<T, const ALIGN: usize> {
19 inner: Unique<T>,
22 impl<T, const ALIGN: usize> AlignedBox<T, ALIGN> {
32 core::mem::size_of::<T>(),
33 max(ALIGN, core::mem::align_of::<T>()),
51 T: SafeForZero, in new_zeroed()
63 pub unsafe fn new_unchecked(ptr: *mut T) -> Self { in new_unchecked()
70 impl<T, const ALIGN: usize> Debug for AlignedBox<T, ALIGN> {
75 core::any::type_name::<T>(), in fmt()
76 core::mem::align_of::<T>(), in fmt()
[all …]
Dmutex.rs29 pub struct Mutex<T> {
31 data: UnsafeCell<T>,
38 pub struct MutexGuard<'a, T: 'a> {
39 lock: &'a Mutex<T>,
42 unsafe impl<T> Sync for Mutex<T> where T: Send {}
44 impl<T> Mutex<T> {
47 pub const fn new(value: T) -> Self { in new()
61 pub fn lock(&self) -> MutexGuard<T> { in lock() argument
92 pub fn try_lock(&self) -> Result<MutexGuard<T>, SystemError> { in try_lock() argument
149 impl<T> Deref for MutexGuard<'_, T> {
[all …]
Dcasting.rs65 fn downcast_arc<T: Any + Send + Sync>(self: Arc<Self>) -> Option<Arc<T>> { in downcast_arc() argument
67 if x.is::<T>() { in downcast_arc()
70 let new = unsafe { Arc::from_raw(p as *const T) }; in downcast_arc() constant
Dffi_convert.rs2 pub trait FFIBind2Rust<T> {
4 fn convert_ref(src: *const T) -> Option<&'static Self>; in convert_ref()
6 fn convert_mut(src: *mut T) -> Option<&'static mut Self>; in convert_mut()
/DragonOS-0.1.9/tools/debugging/logmonitor/src/backend/monitor/
Dmod.rs10 pub struct ObjectWrapper<T> {
11 object: Box<T>,
14 impl<T: Debug + Sized> ObjectWrapper<T> {
16 if buf.len() != std::mem::size_of::<T>() { in new()
20 std::mem::size_of::<T>() in new()
24 let x = unsafe { std::ptr::read(buf.as_ptr() as *const T) }; in new() constant
33 impl<T> DerefMut for ObjectWrapper<T> {
39 impl<T> Deref for ObjectWrapper<T> {
40 type Target = T;
/DragonOS-0.1.9/kernel/src/driver/net/
Dvirtio_net.rs32 pub struct VirtioNICDriver<T: Transport> {
33 pub inner: Arc<SpinLock<VirtIONet<HalImpl, T, 2>>>,
36 impl<T: Transport> Clone for VirtioNICDriver<T> {
48 struct VirtioNICDriverWrapper<T: Transport>(UnsafeCell<VirtioNICDriver<T>>);
49 unsafe impl<T: Transport> Send for VirtioNICDriverWrapper<T> {}
50 unsafe impl<T: Transport> Sync for VirtioNICDriverWrapper<T> {}
52 impl<T: Transport> Deref for VirtioNICDriverWrapper<T> {
53 type Target = VirtioNICDriver<T>;
58 impl<T: Transport> DerefMut for VirtioNICDriverWrapper<T> {
64 impl<T: Transport> VirtioNICDriverWrapper<T> {
[all …]
/DragonOS-0.1.9/kernel/src/libs/intertrait/src/cast/
Dcast_ref.rs57 fn cast<T: ?Sized + 'static>(&self) -> Option<&T>; in cast() argument
60 fn impls<T: ?Sized + 'static>(&self) -> bool; in impls()
65 fn cast<T: ?Sized + 'static>(&self) -> Option<&T> { in cast() argument
68 let caster = caster::<T>(any.type_id())?; in cast()
73 fn impls<T: ?Sized + 'static>(&self) -> bool { in impls()
75 CASTER_MAP.contains_key(&(self.type_id(), TypeId::of::<Caster<T>>())) in impls()
79 fn impls<T: ?Sized + 'static>(&self) -> bool { in impls()
82 caster_map().contains_key(&(self.type_id(), TypeId::of::<Caster<T>>())) in impls()
Dcast_mut.rs31 fn cast<T: ?Sized + 'static>(&mut self) -> Option<&mut T>; in cast() argument
36 fn cast<T: ?Sized + 'static>(&mut self) -> Option<&mut T> { in cast() argument
38 let caster = caster::<T>((*any).type_id())?; in cast()
Dcast_arc.rs34 fn cast<T: ?Sized + 'static>(self: Arc<Self>) -> Result<Arc<T>, Arc<Self>>; in cast() argument
39 fn cast<T: ?Sized + 'static>(self: Arc<Self>) -> Result<Arc<T>, Arc<Self>> { in cast() argument
40 match caster::<T>((*self).type_id()) { in cast()
Dcast_box.rs33 fn cast<T: ?Sized + 'static>(self: Box<Self>) -> Result<Box<T>, Box<Self>>; in cast() argument
38 fn cast<T: ?Sized + 'static>(self: Box<Self>) -> Result<Box<T>, Box<Self>> { in cast() argument
39 match caster::<T>((*self).type_id()) { in cast()
Dcast_rc.rs33 fn cast<T: ?Sized + 'static>(self: Rc<Self>) -> Result<Rc<T>, Rc<Self>>; in cast() argument
38 fn cast<T: ?Sized + 'static>(self: Rc<Self>) -> Result<Rc<T>, Rc<Self>> { in cast() argument
39 match caster::<T>((*self).type_id()) { in cast()
/DragonOS-0.1.9/kernel/src/syscall/
Duser_access.rs184 pub fn read_from_user<T>(&self, offset: usize) -> Result<&[T], SystemError> { in read_from_user() argument
192 pub fn read_one_from_user<T>(&self, offset: usize) -> Result<&T, SystemError> { in read_one_from_user() argument
201 pub fn copy_from_user<T: core::marker::Copy>( in copy_from_user()
203 dst: &mut [T], in copy_from_user() argument
216 pub fn copy_one_from_user<T: core::marker::Copy>( in copy_one_from_user()
218 dst: &mut T, in copy_one_from_user() argument
221 let data = self.convert_one_with_offset::<T>(&self.buffer, offset)?; in copy_one_from_user()
231 pub fn buffer<T>(&self, offset: usize) -> Result<&[T], SystemError> { in buffer() argument
233 .convert_with_offset::<T>(self.buffer, offset) in buffer()
237 fn convert_with_offset<T>(&self, src: &[u8], offset: usize) -> Result<&[T], SystemError> { in convert_with_offset() argument
[all …]
/DragonOS-0.1.9/kernel/src/mm/
Dpercpu.rs49 pub struct PerCpuVar<T> {
50 inner: Vec<T>,
54 impl<T> PerCpuVar<T> {
60 pub fn new(data: Vec<T>) -> Option<Self> { in new()
78 pub fn get(&self) -> &T { in get() argument
83 pub fn get_mut(&mut self) -> &mut T { in get_mut() argument
88 pub unsafe fn force_get(&self, cpu_id: ProcessorId) -> &T { in force_get() argument
92 pub unsafe fn force_get_mut(&mut self, cpu_id: ProcessorId) -> &mut T { in force_get_mut() argument
98 unsafe impl<T> Sync for PerCpuVar<T> {}
99 unsafe impl<T> Send for PerCpuVar<T> {}
/DragonOS-0.1.9/kernel/src/libs/intertrait/tests/ui/
Don-generic-type.rs6 struct Data<T: 'static> {
7 phantom: PhantomData<T>,
16 impl<T: 'static> Greet for Data<T> {
22 impl<T: 'static> Source for Data<T> {}
/DragonOS-0.1.9/docs/kernel/locking/
Drwlock.md29 pub struct RwLock<T> {
31 data: UnsafeCell<T>,
36 pub struct RwLockReadGuard<'a, T: 'a> {
37 data: *const T,
44 pub struct RwLockUpgradableGuard<'a, T: 'a> {
45 data: *const T,
46 inner: &'a RwLock<T>,
52 pub struct RwLockWriteGuard<'a, T: 'a> {
53 data: *mut T,
54 inner: &'a RwLock<T>,
[all …]
/DragonOS-0.1.9/kernel/src/libs/intertrait/src/
Dlib.rs166 fn cast_arc_panic<T: ?Sized + 'static>(_: Arc<dyn Any + Sync + Send>) -> Arc<T> { in cast_arc_panic() argument
177 pub struct Caster<T: ?Sized + 'static> {
180 pub cast_ref: fn(from: &dyn Any) -> &T,
184 pub cast_mut: fn(from: &mut dyn Any) -> &mut T,
188 pub cast_box: fn(from: Box<dyn Any>) -> Box<T>,
192 pub cast_rc: fn(from: Rc<dyn Any>) -> Rc<T>,
196 pub cast_arc: fn(from: Arc<dyn Any + Sync + Send + 'static>) -> Arc<T>,
199 impl<T: ?Sized + 'static> Caster<T> {
201 cast_ref: fn(from: &dyn Any) -> &T, in new() argument
202 cast_mut: fn(from: &mut dyn Any) -> &mut T, in new() argument
[all …]
/DragonOS-0.1.9/docs/kernel/core_api/
Dcasting.md42 ### 2.1 从Arc<dyn U>转换为Arc<T>
44 &emsp;&emsp;当我们需要把一个`Arc<dyn U>`转换为`Arc<T>`的具体类型指针时,我们要为`U`这个trait实现`DowncastArc`trait。这个trait定义在`k…
60 let arc_t: Arc<T> = arc.downcast_arc::<T>().unwrap();
63 &emsp;&emsp;如果`arc`的具体类型不是`Arc<T>`,那么`downcast_arc::<T>()`会返回`None`。
/DragonOS-0.1.9/tools/debugging/logmonitor/src/
Dapp.rs7 pub type AppResult<T> = std::result::Result<T, Box<dyn error::Error>>;
172 pub struct StatefulList<T> {
174 pub items: Vec<T>,
177 impl<T> StatefulList<T> {
178 pub fn with_items(items: Vec<T>) -> StatefulList<T> { in with_items() argument

12