[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72=YAumHrwE4fCSy2TqaSYBHgxFTJmvnp336iQBKmGGTMw@mail.gmail.com>
Date: Sat, 5 Oct 2024 20:36:44 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: FUJITA Tomonori <fujita.tomonori@...il.com>
Cc: netdev@...r.kernel.org, rust-for-linux@...r.kernel.org, andrew@...n.ch,
hkallweit1@...il.com, tmgross@...ch.edu, ojeda@...nel.org,
alex.gaynor@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com,
benno.lossin@...ton.me, a.hindborg@...sung.com, aliceryhl@...gle.com,
anna-maria@...utronix.de, frederic@...nel.org, tglx@...utronix.de,
arnd@...db.de, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v2 3/6] rust: time: Implement addition of Ktime
and Delta
On Sat, Oct 5, 2024 at 2:26 PM FUJITA Tomonori
<fujita.tomonori@...il.com> 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
Powered by blists - more mailing lists