Skip to content

Commit a99d5ab

Browse files
authored
Merge pull request #470 from wedsonaf/kernel-arc
rust: remove `Arc` from the `kernel` crate.
2 parents 693d937 + 47ebde5 commit a99d5ab

File tree

3 files changed

+3
-52
lines changed

3 files changed

+3
-52
lines changed

rust/kernel/linked_list.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//!
55
//! TODO: This module is a work in progress.
66
7-
use alloc::{boxed::Box, sync::Arc};
7+
use alloc::boxed::Box;
88
use core::ptr::NonNull;
99

1010
pub use crate::raw_list::{Cursor, GetLinks, Links};
@@ -41,20 +41,6 @@ impl<T: ?Sized> Wrapper<T> for Box<T> {
4141
}
4242
}
4343

44-
impl<T: ?Sized> Wrapper<T> for Arc<T> {
45-
fn into_pointer(self) -> NonNull<T> {
46-
NonNull::new(Arc::into_raw(self) as _).unwrap()
47-
}
48-
49-
unsafe fn from_pointer(ptr: NonNull<T>) -> Self {
50-
unsafe { Arc::from_raw(ptr.as_ptr()) }
51-
}
52-
53-
fn as_ref(&self) -> &T {
54-
AsRef::as_ref(self)
55-
}
56-
}
57-
5844
impl<T: ?Sized> Wrapper<T> for Ref<T> {
5945
fn into_pointer(self) -> NonNull<T> {
6046
NonNull::new(Ref::into_raw(self) as _).unwrap()
@@ -104,20 +90,6 @@ impl<T: GetLinks + ?Sized> GetLinks for Box<T> {
10490
}
10591
}
10692

107-
impl<T: ?Sized> GetLinksWrapped for Arc<T>
108-
where
109-
Arc<T>: GetLinks,
110-
{
111-
type Wrapped = Arc<<Arc<T> as GetLinks>::EntryType>;
112-
}
113-
114-
impl<T: GetLinks + ?Sized> GetLinks for Arc<T> {
115-
type EntryType = T::EntryType;
116-
fn get_links(data: &Self::EntryType) -> &Links<Self::EntryType> {
117-
<T as GetLinks>::get_links(data)
118-
}
119-
}
120-
12193
impl<T: ?Sized> GetLinksWrapped for Ref<T>
12294
where
12395
Ref<T>: GetLinks,

rust/kernel/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
pub use core::pin::Pin;
1515

16-
pub use alloc::{boxed::Box, string::String, sync::Arc, vec::Vec};
16+
pub use alloc::{boxed::Box, string::String, vec::Vec};
1717

1818
pub use macros::{module, module_misc_device};
1919

rust/kernel/types.rs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
bindings, c_types,
99
sync::{Ref, RefBorrow},
1010
};
11-
use alloc::{boxed::Box, sync::Arc};
11+
use alloc::boxed::Box;
1212
use core::{ops::Deref, pin::Pin, ptr::NonNull};
1313

1414
/// Permissions.
@@ -100,27 +100,6 @@ impl<T> PointerWrapper for Ref<T> {
100100
}
101101
}
102102

103-
impl<T> PointerWrapper for Arc<T> {
104-
type Borrowed = UnsafeReference<T>;
105-
106-
fn into_pointer(self) -> *const c_types::c_void {
107-
Arc::into_raw(self) as _
108-
}
109-
110-
unsafe fn borrow(ptr: *const c_types::c_void) -> Self::Borrowed {
111-
// SAFETY: The safety requirements for this function ensure that the object is still alive,
112-
// so it is safe to dereference the raw pointer.
113-
// The safety requirements also ensure that the object remains alive for the lifetime of
114-
// the returned value.
115-
unsafe { UnsafeReference::new(&*ptr.cast()) }
116-
}
117-
118-
unsafe fn from_pointer(ptr: *const c_types::c_void) -> Self {
119-
// SAFETY: The passed pointer comes from a previous call to [`Self::into_pointer()`].
120-
unsafe { Arc::from_raw(ptr as _) }
121-
}
122-
}
123-
124103
/// A reference with manually-managed lifetime.
125104
///
126105
/// # Invariants

0 commit comments

Comments
 (0)