Skip to content

Commit eb752db

Browse files
committed
refactor(task): stop using the deprecated method wrapping_offset_from
`wrapping_offset_from` was deprecated by <rust-lang/rust#73580>.
1 parent 9cc6484 commit eb752db

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/constance/src/kernel/task.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Tasks
2-
use core::{cell::UnsafeCell, fmt, hash, marker::PhantomData, sync::atomic::Ordering};
2+
use core::{cell::UnsafeCell, fmt, hash, marker::PhantomData, mem, sync::atomic::Ordering};
33
use num_traits::ToPrimitive;
44

55
use super::{
@@ -131,8 +131,9 @@ impl<System: Kernel> Task<System> {
131131
};
132132

133133
// Calculate an `Id` from the task CB pointer
134-
let offset =
135-
(task_cb as *const TaskCb<_>).wrapping_offset_from(System::task_cb_pool().as_ptr());
134+
let offset_bytes =
135+
task_cb as *const TaskCb<_> as usize - System::task_cb_pool().as_ptr() as usize;
136+
let offset = offset_bytes / mem::size_of::<TaskCb<System>>();
136137

137138
// Safety: Constructing a `Task` for a current task is allowed
138139
let task = unsafe { Self::from_id(Id::new(offset as usize + 1).unwrap()) };

0 commit comments

Comments
 (0)