[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72m7NrKB3MhKT2gS7TwdL=Ug5LbLm1Z35NvApgYz=cuCiw@mail.gmail.com>
Date: Thu, 9 Jan 2025 12:19:17 +0100
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Abdiel Janulgue <abdiel.janulgue@...il.com>
Cc: Daniel Almeida <daniel.almeida@...labora.com>, Daniel Sedlak <daniel@...lak.dev>,
aliceryhl@...gle.com, robin.murphy@....com, rust-for-linux@...r.kernel.org,
Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>,
Valentin Obst <kernel@...entinobst.de>, open list <linux-kernel@...r.kernel.org>,
Christoph Hellwig <hch@....de>, Marek Szyprowski <m.szyprowski@...sung.com>, airlied@...hat.com,
"open list:DMA MAPPING HELPERS" <iommu@...ts.linux.dev>
Subject: Re: [PATCH v8 2/2] rust: add dma coherent allocator abstraction.
On Thu, Jan 9, 2025 at 12:14 PM Abdiel Janulgue
<abdiel.janulgue@...il.com> wrote:
>
> We are interested in the last argument 'attrs'. For some reason it seems
> ffi::c_ulong is defined as usize at least on top of `rust-next` commit
> 0c5928deada15a8d075516e6e0d9ee19011bb000.
We are moving to a custom mapping instead of using `core::ffi`
directly. Please see commit 1bae8729e50a ("rust: map `long` to `isize`
and `char` to `u8`"):
The following FFI types are replaced compared to `core::ffi`:
1. `char` type is now always mapped to `u8`, since kernel uses
`-funsigned-char` on the C code. `core::ffi` maps it to platform
default ABI, which can be either signed or unsigned.
2. `long` is now always mapped to `isize`. It's very common in the
kernel to use `long` to represent a pointer-sized integer, and in
fact `intptr_t` is a typedef of `long` in the kernel. Enforce this
mapping rather than mapping to `i32/i64` depending on platform can
save us a lot of unnecessary casts.
+ // In the kernel, `intptr_t` is defined to be `long` in
all platforms, so we can map the type to
+ // `isize`.
+ c_long = isize;
+ c_ulong = usize;
Cheers,
Miguel
Powered by blists - more mailing lists