Home
last modified time | relevance | path

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

123

/DragonOS/kernel/crates/bitmap/src/
H A 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/kernel/src/libs/
H A Dvolatile.rs70 pub struct ReadOnly<T: Copy>(T);
73 impl<T: Copy> ReadOnly<T> {
75 pub fn new(value: T) -> Self { in new()
83 pub struct WriteOnly<T: Copy>(T);
88 pub struct Volatile<T: Copy>(T);
91 impl<T: Copy> Volatile<T> {
93 pub fn new(value: T) -> Self { in new()
99 pub trait VolatileReadable<T> {
101 unsafe fn vread(self) -> T; in vread() argument
104 impl<T: Copy> VolatileReadable<T> for *const ReadOnly<T> {
[all …]
H A 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 …]
H A 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()
23 pub fn get_mut(&self) -> &mut T { in get_mut() argument
25 (self.inner.get().as_ref().unwrap() as *const T as *mut T) in get_mut() constant
31 pub fn get(&self) -> &T { in get() argument
36 unsafe impl<T: Sync> Sync for LockFreeFlags<T> {}
37 unsafe impl<T: Send> Send for LockFreeFlags<T> {}
39 impl<T: Clone> Clone for LockFreeFlags<T> {
[all …]
H A Drwlock.rs37 pub struct RwLock<T> {
39 data: UnsafeCell<T>,
44 pub struct RwLockReadGuard<'a, T: 'a> {
45 data: *const T,
54 pub struct RwLockUpgradableGuard<'a, T: 'a> {
55 data: *const T,
56 inner: &'a RwLock<T>,
63 pub struct RwLockWriteGuard<'a, T: 'a> {
64 data: *mut T,
65 inner: &'a RwLock<T>,
[all …]
H A Dnotifier.rs10 pub trait NotifierBlock<V: Clone + Copy, T>: Debug + Send + Sync {
12 fn notifier_call(&self, action: V, data: Option<&T>) -> i32; in notifier_call()
20 struct NotifierChain<V: Clone + Copy, T>(Vec<Arc<dyn NotifierBlock<V, T>>>);
22 impl<V: Clone + Copy, T> NotifierChain<V, T> {
31 block: Arc<dyn NotifierBlock<V, T>>, in register() argument
65 pub fn unregister(&mut self, block: Arc<dyn NotifierBlock<V, T>>) -> Result<(), SystemError> { in unregister()
87 data: Option<&T>, in call_chain() argument
106 pub struct AtomicNotifierChain<V: Clone + Copy, T>(SpinLock<NotifierChain<V, T>>);
108 impl<V: Clone + Copy, T> Default for AtomicNotifierChain<V, T> {
114 impl<V: Clone + Copy, T> AtomicNotifierChain<V, T> {
[all …]
H A 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 …]
H A 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 …]
H A Dmutex.rs30 pub struct Mutex<T> {
32 data: UnsafeCell<T>,
39 pub struct MutexGuard<'a, T: 'a> {
40 lock: &'a Mutex<T>,
43 unsafe impl<T> Sync for Mutex<T> where T: Send {}
45 impl<T> Mutex<T> {
48 pub const fn new(value: T) -> Self { in new()
62 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 …]
H A Dname.rs6 pub fn get_full_type_name<T>(_: &T) -> String { in get_full_type_name()
7 type_name::<T>().to_string() in get_full_type_name()
10 pub fn get_type_name<T>(_: &T) -> String { in get_type_name()
11 let full_name = type_name::<T>(); in get_type_name()
H A Dcasting.rs64 fn downcast_arc<T: Any + Send + Sync>(self: Arc<Self>) -> Option<Arc<T>> { in downcast_arc() argument
66 if x.is::<T>() { in downcast_arc()
69 let new = unsafe { Arc::from_raw(p as *const T) }; in downcast_arc() constant
/DragonOS/tools/debugging/logmonitor/src/backend/monitor/
H A 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/kernel/src/syscall/
H A Duser_access.rs189 pub fn read_from_user<T>(&self, offset: usize) -> Result<&[T], SystemError> { in read_from_user() argument
197 pub fn read_one_from_user<T>(&self, offset: usize) -> Result<&T, SystemError> { in read_one_from_user() argument
206 pub fn copy_from_user<T: core::marker::Copy>( in copy_from_user()
208 dst: &mut [T], in copy_from_user() argument
221 pub fn copy_one_from_user<T: core::marker::Copy>( in copy_one_from_user()
223 dst: &mut T, in copy_one_from_user() argument
226 let data = self.convert_one_with_offset::<T>(self.buffer, offset)?; in copy_one_from_user()
236 pub fn buffer<T>(&self, offset: usize) -> Result<&[T], SystemError> { in buffer() argument
237 self.convert_with_offset::<T>(self.buffer, offset) in buffer()
241 fn convert_with_offset<T>(&self, src: &[u8], offset: usize) -> Result<&[T], SystemError> { in convert_with_offset() argument
[all …]
/DragonOS/kernel/crates/intertrait/src/cast/
H A 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()
H A 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()
H A 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()
H A 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()
H A 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/kernel/src/mm/
H A Dpercpu.rs57 pub struct PerCpuVar<T> {
58 inner: Vec<T>,
62 impl<T> PerCpuVar<T> {
68 pub fn new(data: Vec<T>) -> Option<Self> { in new()
86 pub fn get(&self) -> &T { in get() argument
92 pub fn get_mut(&self) -> &mut T { in get_mut() argument
99 pub unsafe fn force_get(&self, cpu_id: ProcessorId) -> &T { in force_get() argument
104 pub unsafe fn force_get_mut(&self, cpu_id: ProcessorId) -> &mut T { in force_get_mut() argument
110 unsafe impl<T> Sync for PerCpuVar<T> {}
111 unsafe impl<T> Send for PerCpuVar<T> {}
/DragonOS/kernel/crates/intertrait/tests/ui/
H A 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/docs/kernel/locking/
H A 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/kernel/crates/intertrait/src/
H A Dlib.rs167 fn cast_arc_panic<T: ?Sized + 'static>(_: Arc<dyn Any + Sync + Send>) -> Arc<T> { in cast_arc_panic() argument
178 pub struct Caster<T: ?Sized + 'static> {
181 pub cast_ref: fn(from: &dyn Any) -> &T,
185 pub cast_mut: fn(from: &mut dyn Any) -> &mut T,
189 pub cast_box: fn(from: Box<dyn Any>) -> Box<T>,
193 pub cast_rc: fn(from: Rc<dyn Any>) -> Rc<T>,
197 pub cast_arc: fn(from: Arc<dyn Any + Sync + Send + 'static>) -> Arc<T>,
200 impl<T: ?Sized + 'static> Caster<T> {
202 cast_ref: fn(from: &dyn Any) -> &T, in new() argument
203 cast_mut: fn(from: &mut dyn Any) -> &mut T, in new() argument
[all …]
/DragonOS/kernel/crates/rust-slabmalloc/src/
H A Dpages.rs341 pub(crate) struct PageList<'a, T: AllocablePage> {
343 pub(crate) head: Option<&'a mut T>,
348 impl<'a, T: AllocablePage> PageList<'a, T> {
350 pub(crate) const fn new() -> PageList<'a, T> { in new()
358 pub(crate) fn new() -> PageList<'a, T> { in new()
365 pub(crate) fn iter_mut<'b: 'a>(&mut self) -> ObjectPageIterMut<'b, T> { in iter_mut() argument
378 pub(crate) fn insert_front<'b>(&'b mut self, mut new_head: &'a mut T) { in insert_front() argument
396 pub(crate) fn remove_from_list(&mut self, slab_page: &mut T) { in remove_from_list() argument
428 pub(crate) fn pop<'b>(&'b mut self) -> Option<&'a mut T> { in pop() argument
450 pub(crate) fn contains(&mut self, s: *const T) -> bool { in contains()
[all …]
/DragonOS/docs/kernel/core_api/
H A 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/tools/debugging/logmonitor/src/
H A 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

123