[PATCH v2 0/3] rust: time: Introduce typed clock sources and generalize Instant

FUJITA Tomonori posted 3 patches 9 months, 1 week ago
There is a newer version of this series
rust/helpers/time.c         |  16 +++
rust/kernel/time.rs         | 201 ++++++++++++++++++++++--------------
rust/kernel/time/hrtimer.rs |   6 +-
3 files changed, 145 insertions(+), 78 deletions(-)
[PATCH v2 0/3] rust: time: Introduce typed clock sources and generalize Instant
Posted by FUJITA Tomonori 9 months, 1 week ago
This patch series introduces a type-safe abstraction over clock
sources. The goal is to remove the need for runtime clock selection
(via ClockId) and instead leverage Rust's type system to statically
associate the Instant type with a specific clock.

This approach enables compile-time enforcement of clock correctness
across the APIs of Instant type.

This patchset can be applied on top of the division fix for 32-bit
architectures:

https://lore.kernel.org/lkml/20250502004524.230553-1-fujita.tomonori@gmail.com/

Most of the changes to the hrtimer code that were included in v1 have
been removed, as it does not use `Instant` yet. I plan to convert
hrtimer to use `Instant` and `Delta` in a separate patchset.

v2:
- removed most of changes to hrtimer code 
v1: https://lore.kernel.org/rust-for-linux/20250413105629.162349-1-fujita.tomonori@gmail.com/

FUJITA Tomonori (3):
  rust: time: Replace ClockId enum with ClockSource trait
  rust: time: Make Instant generic over ClockSource
  rust: time: Add ktime_get() to ClockSource trait

 rust/helpers/time.c         |  16 +++
 rust/kernel/time.rs         | 201 ++++++++++++++++++++++--------------
 rust/kernel/time/hrtimer.rs |   6 +-
 3 files changed, 145 insertions(+), 78 deletions(-)


base-commit: adf04b7cc66574ec2a43b540046975dbe73e0382
-- 
2.43.0