Re: [PATCH net-next v2 3/6] rust: time: Implement addition of Ktime and Delta
From: Miguel Ojeda
Date: Sat Oct 05 2024 - 14:37:11 EST
On Sat, Oct 5, 2024 at 2:26 PM FUJITA Tomonori
<fujita.tomonori@xxxxxxxxx> wrote:
>
> + fn add(self, delta: Delta) -> Ktime {
> + // SAFETY: FFI call.
> + let t = unsafe { bindings::ktime_add_ns(self.inner, delta.as_nanos() as u64) };
> + Ktime::from_raw(t)
> + }
I wonder if we want to use the `ktime` macros/operations for this type
or not (even if we still promise it is the same type underneath). It
means having to define helpers, adding `unsafe` code and `SAFETY`
comments, a call penalty in non-LTO, losing overflow checking (if we
want it for these types), and so on.
(And at least C is `-fno-strict-overflow`, otherwise it would be even subtler).
Cheers,
Miguel