Re: [PATCH v6 9/9] rust: sync: atomic: Add Atomic<{usize,isize}>
Miguel Ojeda <[email protected]> Fri, 11 Jul 2025 16:40:15 +0200
| Newsgroups | dev.linux.lists.lkmm,org.kernel.vger.linux-arch,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux |
|---|---|
| Message-ID | <CANiq72kvZ7-fMoE9g7SBUrBZy4QMbSL1p8KgBqGhOkenrsr=3w@mail.gmail.com> |
On Fri, Jul 11, 2025 at 4:07 PM Boqun Feng <[email protected]> wrote: > > Thanks Miguel. > > Maybe we can do even better: having a type alias mapping to the exact > i{32,64,128} based on kernel configs? Like > > (in kernel/lib.rs or ffi.rs) > > // Want to buy a better name ;-) > #[cfg(CONFIG_128BIT)] > type isize_mapping = i128; > #[cfg(CONFIG_64BIT)] > type isize_mapping = i64; > #[cfg(not(any(CONFIG_128BIT, CONFIG_64BIT)))] > type isize_mapping = i32; > > similar for usize. > > Thoughts? Yeah, I wondered about that too, but I don't know how common it will be (so you may want to keep it local anyway), and I wasn't sure what to call it either, because e.g. something like `isize_mapping` sounds like we are talking about `c_long`. What we want is a Rust fixed-width integer of the same size of `isize` -- so I think you should try to pick a word that evokes a bit that part. Something like `fixed_isize` or words like `underlying` or `repr` perhaps? Cheers, Miguel