Home
last modified time | relevance | path

Searched refs:NonNull (Results 1 – 25 of 42) sorted by relevance

12

/linux/rust/kernel/alloc/
H A Dallocator.rs27 NonNull, //
97 ptr: Option<NonNull<u8>>, in call()
102 ) -> Result<NonNull<[u8]>, AllocError> { in call()
131 NonNull::new(raw_ptr).ok_or(AllocError)? in aligned_layout()
134 Ok(NonNull::slice_from_raw_parts(ptr, size)) in aligned_layout()
158 ptr: Option<NonNull<u8>>,
163 ) -> Result<NonNull<[u8]>, AllocError> {
179 /// # NonNull, //
188 /// let ptr = unsafe { NonNull::new_unchecked(from_mut(&mut *vbox)) };
205 pub unsafe fn to_page<'a>(ptr: NonNull<u in to_page()
[all...]
H A Dkvec.rs46 NonNull, //
131 ptr: NonNull<T>,
318 ptr: NonNull::dangling(),
590 ptr: unsafe { NonNull::new_unchecked(ptr) },
842 self.ptr = NonNull::dangling(); in shrink_to()
1243 buf: NonNull<T>,
1253 fn into_raw_parts(self) -> (*mut T, NonNull<T>, usize, usize) { in collect()
/linux/rust/kernel/
H A Dalloc.rs29 ptr::NonNull, //
174 /// On success, returns a buffer represented as `NonNull<[u8]>` that satisfies the layout
188 fn alloc(layout: Layout, flags: Flags, nid: NumaNode) -> Result<NonNull<[u8]>, AllocError> { in alloc()
215 /// The buffer is represented as `NonNull<[u8]>`.
235 ptr: Option<NonNull<u8>>, in realloc()
240 ) -> Result<NonNull<[u8]>, AllocError>;
251 unsafe fn free(ptr: NonNull<u8>, layout: Layout) { in free()
268 pub(crate) fn dangling_from_layout(layout: Layout) -> NonNull<u8> { in dangling_from_layout()
272 unsafe { NonNull::new_unchecked(ptr) }
H A Drbtree.rs14 ptr::{addr_of_mut, from_mut, NonNull},
250 NonNull::new(current).map(|current| { in cursor_front_mut()
265 NonNull::new(current).map(|current| { in cursor_front()
280 NonNull::new(current).map(|current| { in cursor_back_mut()
295 NonNull::new(current).map(|current| { in cursor_back()
463 NonNull::new(best.as_ptr()).map(|current| { in cursor_lower_bound_mut()
484 NonNull::new(best.as_ptr()).map(|current| { in cursor_lower_bound()
494 fn find_best_match(&self, key: &K) -> Option<NonNull<bindings::rb_node>> { in find_best_match()
497 let mut best_links: Option<NonNull<bindings::rb_node>> = None; in find_best_match()
511 best_links = Some(unsafe { NonNull in find_best_match()
[all...]
H A Dfaux.rs18 NonNull, //
31 pub struct Registration(NonNull<bindings::faux_device>); in new()
54 Ok(Self(NonNull::new(dev).ok_or(ENODEV)?)) in as_ref()
H A Dxarray.rs19 use core::{iter, marker::PhantomData, pin::Pin, ptr::NonNull};
111 fn iter(&self) -> impl Iterator<Item = NonNull<c_void>> + '_ { in iter()
124 .map_while(|ptr| NonNull::new(ptr.cast())) in try_lock()
190 F: FnOnce(NonNull<c_void>) -> U,
194 let ptr = NonNull::new(ptr.cast())?; in get()
H A Dmm.rs19 use core::{ops::Deref, ptr::NonNull};
66 unsafe fn dec_ref(obj: NonNull<Self>) { in dec_ref()
102 unsafe fn dec_ref(obj: NonNull<Self>) { in dec_ref()
147 Some(unsafe { ARef::from_raw(NonNull::new_unchecked(self.as_raw().cast())) }) in mmget_not_zero()
H A Dfirmware.rs15 use core::ptr::NonNull;
62 pub struct Firmware(NonNull<bindings::firmware>);
79 Ok(Firmware(unsafe { NonNull::new_unchecked(fw) })) in request_internal()
H A Di2c.rs31 NonNull, //
400 // pointer or NULL. `NonNull::new` guarantees the correct check.
401 let adapter = NonNull::new(unsafe { bindings::i2c_get_adapter(index) }).ok_or(ENODEV)?; in get()
423 unsafe fn dec_ref(obj: NonNull<Self>) { in inc_ref()
499 unsafe fn dec_ref(obj: NonNull<Self>) { in inc_ref()
554 pub struct Registration(NonNull<bindings::i2c_client>);
568 // pointer or NULL. `from_err_ptr` separates errors. Following `NonNull::new` in try_new()
574 let dev_ptr = NonNull::new(raw_dev).ok_or(ENODEV)?; in try_new()
H A Dscatterlist.rs44 use core::{ops::Deref, ptr::NonNull};
185 sgt: NonNull<bindings::sg_table>,
204 sgt: NonNull<bindings::sg_table>, in new()
373 let sgt = unsafe { NonNull::new_unchecked(sgt) }; in new()
H A Ddma.rs39 ptr::NonNull, //
606 cpu_addr: NonNull<T>, in size()
692 let cpu_addr = NonNull::new(addr.cast()).ok_or(ENOMEM)?; in field_write()
809 let cpu_addr = NonNull::slice_from_raw_parts(NonNull::new(addr.cast()).ok_or(ENOMEM)?, len); in init()
1003 cpu_handle: NonNull<c_void>, in write_to_slice()
1038 let cpu_handle = NonNull::new(cpu_handle).ok_or(ENOMEM)?;
H A Dauxiliary.rs37 NonNull, //
385 unsafe fn dec_ref(obj: NonNull<Self>) { in new()
446 adev: NonNull<bindings::auxiliary_device>,
536 adev: unsafe { NonNull::new_unchecked(adev) },
/linux/rust/kernel/sync/
H A Daref.rs24 ptr::NonNull, //
65 unsafe fn dec_ref(obj: NonNull<Self>);
79 ptr: NonNull<T>,
110 pub unsafe fn from_raw(ptr: NonNull<T>) -> Self {
127 /// use core::ptr::NonNull;
135 /// unsafe fn dec_ref(_obj: NonNull<Self>) {}
139 /// let ptr = NonNull::<Empty>::new(&mut data).unwrap();
142 /// let raw_ptr: NonNull<Empty> = ARef::into_raw(data_ref); in clone()
146 pub fn into_raw(me: Self) -> NonNull<T> { in clone()
172 unsafe { Self::from_raw(NonNull in drop()
[all...]
/linux/rust/zerocopy/src/pointer/
H A Dinner.rs11 use core::{marker::PhantomData, ops::Range, ptr::NonNull};
65 ptr: NonNull<T>,
98 pub const unsafe fn new(ptr: NonNull<T>) -> PtrInner<'a, T> { in new()
111 pub const fn as_non_null(&self) -> NonNull<T> { in as_non_null()
132 let ptr = NonNull::from(ptr); in from_ref()
158 let ptr = NonNull::from(ptr); in from_mut()
201 let projected_non_null = unsafe { NonNull::new_unchecked(projected_raw) }; in project()
360 let bytes = unsafe { NonNull::new_unchecked(bytes) }; in trailing_slice()
418 let ptr = unsafe { NonNull::new_unchecked(ptr) }; in slice_unchecked()
486 let elem = unsafe { NonNull::new_unchecked(elem) }; in iter()
[all …]
/linux/rust/pin-init/examples/
H A Dlinked_list.rs10 ptr::{self, NonNull},
60 pub fn next(&self) -> Option<NonNull<Self>> {
64 Some(unsafe { NonNull::new_unchecked(self.next.as_ptr() as *mut Self) }) in next()
95 struct Link(Cell<NonNull<ListHead>>);
105 unsafe fn new_unchecked(ptr: NonNull<ListHead>) -> Self {
/linux/rust/zerocopy/src/util/
H A Dmod.rs21 ptr::NonNull,
94 impl<T: ?Sized> AsAddress for NonNull<T> { implementation
426 match NonNull::new(ptr) { in new_box()
456 unsafe { NonNull::new_unchecked(dangling) } in new_box()
690 use core::ptr::{self, NonNull};
702 fn slice_from_raw_parts(data: Self, len: usize) -> NonNull<[T]>; in slice_from_raw_parts()
705 impl<T> NonNullExt<T> for NonNull<T> { implementation
714 fn slice_from_raw_parts(data: Self, len: usize) -> NonNull<[T]> { in slice_from_raw_parts()
717 unsafe { NonNull::new_unchecked(ptr) } in slice_from_raw_parts()
936 let nn = NonNull::new(p as *mut u8).unwrap(); in test_as_address()
H A Dmacros.rs436 use core::ptr::NonNull;
466 fn raw_from_ptr_len(bytes: NonNull<u8>, _meta: ()) -> NonNull<Self> {
491 use core::ptr::NonNull;
513 …fn raw_from_ptr_len(bytes: NonNull<u8>, meta: <$repr as KnownLayout>::PointerMetadata) -> NonNull<…
517 unsafe { NonNull::new_unchecked(ptr) }
/linux/rust/kernel/mm/
H A Dmmput_async.rs15 use core::{ops::Deref, ptr::NonNull};
45 unsafe fn dec_ref(obj: NonNull<Self>) { in dec_ref()
/linux/rust/zerocopy-derive/derive/
H A Dknown_layout.rs73 bytes: #core::ptr::NonNull<u8>, in derive_known_layout_for_repr_c_struct()
75 ) -> #core::ptr::NonNull<Self> { in derive_known_layout_for_repr_c_struct()
79 unsafe { #core::ptr::NonNull::new_unchecked(slf) } in derive_known_layout_for_repr_c_struct()
296 … fn raw_from_ptr_len(bytes: #core::ptr::NonNull<u8>, _meta: ()) -> #core::ptr::NonNull<Self> { in derive()
/linux/rust/kernel/io/
H A Dresource.rs10 ptr::NonNull, //
32 resource: NonNull<bindings::resource>,
124 resource: NonNull::new(region)?, in request_region()
/linux/rust/kernel/drm/
H A Ddevice.rs40 NonNull, //
236 let raw_drm = NonNull::new(from_err_ptr(raw_drm)?).ok_or(ENOMEM)?; in dec_ref()
308 unsafe fn into_drm_device(ptr: NonNull<Self>) -> *mut bindings::drm_device {
372 unsafe fn dec_ref(obj: NonNull<Self>) {
/linux/rust/kernel/fs/
H A Dfile.rs208 unsafe fn dec_ref(obj: ptr::NonNull<File>) { in dec_ref()
244 unsafe fn dec_ref(obj: ptr::NonNull<LocalFile>) { in dec_ref()
264 let ptr = ptr::NonNull::new(unsafe { bindings::fget(fd) }).ok_or(BadFdError)?; in fget()
/linux/rust/kernel/debugfs/
H A Dcallback_adapters.rs125 let zst_dangle: core::ptr::NonNull<F> = core::ptr::NonNull::dangling();
/linux/rust/zerocopy/src/
H A Dlayout.rs1602 ptr::{self, NonNull}, in test_validate_rust_layout()
1626 fn test<T: ?Sized, W: Fn(usize) -> NonNull<T>>( in test_validate_rust_layout()
1629 addr_of_slice_field: Option<fn(NonNull<T>) -> NonNull<u8>>, in test_validate_rust_layout()
1773 … let slc = NonNull::slice_from_raw_parts(NonNull::from(&aligned_buf.t), elems); in test_validate_rust_layout()
1775 NonNull::new(slc.as_ptr() as *mut Foo).unwrap() in test_validate_rust_layout()
1779 let f = None::<fn(NonNull<Foo>) -> NonNull<u8>>; in test_validate_rust_layout()
1783 … let f: Option<fn(NonNull<Foo>) -> NonNull<u8>> = Some(|ptr: NonNull<Foo>| unsafe { in test_validate_rust_layout()
1784NonNull::new(ptr::addr_of_mut!((*ptr.as_ptr()).1)).unwrap().cast::<u8>() in test_validate_rust_layout()
/linux/rust/kernel/drm/gem/
H A Dmod.rs31 ptr::NonNull, //
61 unsafe fn dec_ref(obj: core::ptr::NonNull<Self>) {
220 // - Our `NonNull` comes from an immutable reference, thus ensuring it is a valid pointer to
319 let ptr = unsafe { NonNull::new_unchecked(ptr) }; in free_callback()

12