]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: time: make ClockSource unsafe trait
authorFUJITA Tomonori <fujita.tomonori@gmail.com>
Mon, 30 Jun 2025 13:10:11 +0000 (22:10 +0900)
committerAndreas Hindborg <a.hindborg@kernel.org>
Mon, 23 Mar 2026 07:29:48 +0000 (08:29 +0100)
commit67b598db7ef107d80091c4c957694b9a2feffa4c
tree18373d085fef4ef201af719c80316225adf2c2c8
parentc51866f65b8ac37b8883a2e80ada13c8cd4d2f7b
rust: time: make ClockSource unsafe trait

Mark the ClockSource trait as unsafe and document its safety
requirements. Specifically, implementers must guarantee that their
`ktime_get()` implementation returns a value in the inclusive range
[0, KTIME_MAX].

Update all existing implementations to use `unsafe impl` with
corresponding safety comments.

Note that there could be potential users of a customized clock source [1]
so we don't seal the trait.

Link: https://lore.kernel.org/rust-for-linux/Z9xb1r1x5tOzAIZT@boqun-archlinux/
Suggested-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://msgid.link/20250630131011.405219-1-fujita.tomonori@gmail.com
[ Change range expressions in docs. - Andreas ]
Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
rust/kernel/time.rs