mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-16 17:57:38 -04:00
Merge tag 'rust-hrtimer-for-v6.15-v3' of https://github.com/Rust-for-Linux/linux into rust-next
Pull rust-hrtimer updates from Andreas Hindborg:
"Introduce Rust support for the 'hrtimer' subsystem:
- Add a way to use the 'hrtimer' subsystem from Rust. Rust code can
now set up intrusive timers without allocating when starting the
timer.
- Add support for 'Pin<Box<_>>', 'Arc<_>', 'Pin<&_>' and
'Pin<&mut _>' as pointer types for use with timer callbacks.
- Add support for setting clock source and timer mode.
'kernel' crate:
- Add 'Arc::as_ptr' for converting an 'Arc' to a raw pointer. This is
a dependency for the 'hrtimer' API.
- Add 'Box::into_pin' for converting a 'Box<_>' into a 'Pin<Box<_>>'
to align with Rust 'alloc'. This is a dependency for the 'hrtimer'
API."
* tag 'rust-hrtimer-for-v6.15-v3' of https://github.com/Rust-for-Linux/linux:
rust: hrtimer: add maintainer entry
rust: hrtimer: add clocksource selection through `ClockId`
rust: hrtimer: add `HrTimerMode`
rust: hrtimer: implement `HrTimerPointer` for `Pin<Box<T>>`
rust: alloc: add `Box::into_pin`
rust: hrtimer: implement `UnsafeHrTimerPointer` for `Pin<&mut T>`
rust: hrtimer: implement `UnsafeHrTimerPointer` for `Pin<&T>`
rust: hrtimer: add `hrtimer::ScopedHrTimerPointer`
rust: hrtimer: add `UnsafeHrTimerPointer`
rust: hrtimer: allow timer restart from timer handler
rust: hrtimer: implement `HrTimerPointer` for `Arc`
rust: sync: add `Arc::as_ptr`
rust: hrtimer: introduce hrtimer support
This commit is contained in:
@@ -266,6 +266,15 @@ pub fn into_raw(self) -> *const T {
|
||||
unsafe { core::ptr::addr_of!((*ptr).data) }
|
||||
}
|
||||
|
||||
/// Return a raw pointer to the data in this arc.
|
||||
pub fn as_ptr(this: &Self) -> *const T {
|
||||
let ptr = this.ptr.as_ptr();
|
||||
|
||||
// SAFETY: As `ptr` points to a valid allocation of type `ArcInner`,
|
||||
// field projection to `data`is within bounds of the allocation.
|
||||
unsafe { core::ptr::addr_of!((*ptr).data) }
|
||||
}
|
||||
|
||||
/// Recreates an [`Arc`] instance previously deconstructed via [`Arc::into_raw`].
|
||||
///
|
||||
/// # Safety
|
||||
@@ -559,11 +568,11 @@ unsafe fn new(inner: NonNull<ArcInner<T>>) -> Self {
|
||||
}
|
||||
|
||||
/// Creates an [`ArcBorrow`] to an [`Arc`] that has previously been deconstructed with
|
||||
/// [`Arc::into_raw`].
|
||||
/// [`Arc::into_raw`] or [`Arc::as_ptr`].
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// * The provided pointer must originate from a call to [`Arc::into_raw`].
|
||||
/// * The provided pointer must originate from a call to [`Arc::into_raw`] or [`Arc::as_ptr`].
|
||||
/// * For the duration of the lifetime annotated on this `ArcBorrow`, the reference count must
|
||||
/// not hit zero.
|
||||
/// * For the duration of the lifetime annotated on this `ArcBorrow`, there must not be a
|
||||
|
||||
Reference in New Issue
Block a user