Messages in this thread | | | Date | Mon, 30 Oct 2023 13:58:49 +0000 | Subject | Re: [RFC] rust: types: Add read_once and write_once | From | Alice Ryhl <> |
| |
Boqun Feng <boqun.feng@gmail.com> writes: >> On Wed, Oct 25, 2023 at 09:51:28PM +0000, Benno Lossin wrote: >>> diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs >>> index d849e1979ac7..b0872f751f97 100644 >>> --- a/rust/kernel/types.rs >>> +++ b/rust/kernel/types.rs >> >> I don't think this should go into `types.rs`. But I do not have a good >> name for the new module. > > kernel::sync?
I think `kernel::sync` is a reasonable choice, but here's another possibility: Put them in the `bindings` crate.
Why? Well, they are a utility that intends to replicate the C `READ_ONCE` and `WRITE_ONCE` macros. All of our other methods that do the same thing for C functions are functions in the bindings crate.
Similarly, if we ever decide to reimplement a C function in Rust for performance/inlining reasons, then I also think that it is reasonable to put that Rust-reimplementation in the bindings crate. This approach also makes it easy to transparently handle cases where we only reimplement a function in Rust under some configurations.
Alice
| |