[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72mbWVVCA_EjV_7DtMYHH_RF9P9Br=sRdyLtPFkythST1w@mail.gmail.com>
Date: Thu, 17 Oct 2024 18:33:23 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: FUJITA Tomonori <fujita.tomonori@...il.com>
Cc: boqun.feng@...il.com, 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, jstultz@...gle.com, sboyd@...nel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v3 4/8] rust: time: Implement addition of Ktime
and Delta
On Thu, Oct 17, 2024 at 11:31 AM FUJITA Tomonori
<fujita.tomonori@...il.com> wrote:
>
> We could add the Rust version of add_safe method. But looks like
> ktime_add_safe() is used by only some core systems so we don't need to
> add it now?
There was some discussion in the past about this -- I wrote there a
summary of the `add` variants:
https://lore.kernel.org/rust-for-linux/CANiq72ka4UvJzb4dN12fpA1WirgDHXcvPurvc7B9t+iPUfWnew@mail.gmail.com/
I think this is a case where following the naming of the C side would
be worse, i.e. where it is worth not applying our usual guideline.
Calling something `_safe`/`_unsafe` like the C macros would be quite
confusing for Rust.
Personally, I would prefer that we stay consistent, which will help
when dealing with more code. That is (from the message above):
- No suffix: not supposed to wrap. So, in Rust, map it to operators.
- `_unsafe()`: wraps. So, in Rust, map it to `wrapping` methods.
- `_safe()`: saturates. So, in Rust, map it to `saturating` methods.
(assuming I read the C code correctly back then.)
And if there are any others that are Rust-unsafe, then map it to
`unchecked` methods, of course.
Cheers,
Miguel
Powered by blists - more mailing lists