From: Benno Lossin <benno.lossin@proton.me>
To: "Gary Guo" <gary@garyguo.net>, "Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Wedson Almeida Filho" <wedsonaf@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@samsung.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>
Cc: rust-for-linux@vger.kernel.org
Subject: Re: [PATCH 0/5] use custom FFI integer types
Date: Fri, 13 Sep 2024 21:42:49 +0000 [thread overview]
Message-ID: <14389f99-dfa9-4646-a24e-e5eef1beacf0@proton.me> (raw)
In-Reply-To: <20240913213041.395655-1-gary@garyguo.net>
On 13.09.24 23:29, Gary Guo wrote:
> This patch series aim to reduce the unnecessary type casts needed in
> Rust code doing FFI calls.
>
> With this series, we can ensure:
>
> * `size_t` is mapped to usize. Currently this is mostly true except for
> C builtin functions, which gets translated by bindgen to c_ulong/c_uint.
>
> * `__kernel_size_t` is mapped to usize. Currently this is mapped to
> c_ulong/c_uint.
>
> * `unsigned long` is mapped to usize. Currently this is mapped by Rust
> libcore to either u32 or u64.
>
> * `char` is mapped to `u8`. Currently this is mapped by Rust libcore to
> either i8 or u8.
Great work!
> After this series, FFI code needs to use `kernel::ffi` types instead of
> `core::ffi`.
I think we should have a lint that checks for this. Can probably be a
checkpatch.pl check and a good-first-issue.
---
Cheers,
Benno
> Gary Guo (5):
> rust: fix size_t in bindgen prototypes of C builtins
> rust: map `__kernel_size_t` and friends also to usize/isize
> rust: use custom FFI integer types
> rust: map `long` to `isize` and `char` to `u8`
> rust: cleanup unnecessary casts
>
> rust/Makefile | 24 ++++++++++-----
> rust/bindgen_parameters | 5 ++++
> rust/bindings/lib.rs | 5 ++++
> rust/ffi.rs | 48 ++++++++++++++++++++++++++++++
> rust/kernel/alloc/allocator.rs | 4 +--
> rust/kernel/block/mq/operations.rs | 18 +++++------
> rust/kernel/block/mq/raw_writer.rs | 2 +-
> rust/kernel/block/mq/tag_set.rs | 2 +-
> rust/kernel/error.rs | 25 +++++++---------
> rust/kernel/firmware.rs | 2 +-
> rust/kernel/init.rs | 2 +-
> rust/kernel/kunit.rs | 10 ++-----
> rust/kernel/lib.rs | 2 ++
> rust/kernel/net/phy.rs | 14 ++++-----
> rust/kernel/print.rs | 4 +--
> rust/kernel/str.rs | 10 +++----
> rust/kernel/sync/arc.rs | 6 ++--
> rust/kernel/sync/condvar.rs | 2 +-
> rust/kernel/sync/lock.rs | 2 +-
> rust/kernel/sync/lock/mutex.rs | 2 +-
> rust/kernel/sync/lock/spinlock.rs | 2 +-
> rust/kernel/task.rs | 8 ++---
> rust/kernel/time.rs | 4 +--
> rust/kernel/types.rs | 26 ++++++++--------
> rust/kernel/uaccess.rs | 31 ++++++-------------
> rust/macros/module.rs | 8 ++---
> rust/uapi/lib.rs | 5 ++++
> 27 files changed, 161 insertions(+), 112 deletions(-)
> create mode 100644 rust/ffi.rs
>
>
> base-commit: 93dc3be19450447a3a7090bd1dfb9f3daac3e8d2
> --
> 2.44.1
>
next prev parent reply other threads:[~2024-09-13 21:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-13 21:29 [PATCH 0/5] use custom FFI integer types Gary Guo
2024-09-13 21:29 ` [PATCH 1/5] rust: fix size_t in bindgen prototypes of C builtins Gary Guo
2024-09-29 21:00 ` Trevor Gross
2024-10-05 22:10 ` Gary Guo
2024-09-13 21:29 ` [PATCH 2/5] rust: map `__kernel_size_t` and friends also to usize/isize Gary Guo
2024-09-23 9:20 ` Alice Ryhl
2024-09-29 21:02 ` Trevor Gross
2024-09-13 21:29 ` [PATCH 3/5] rust: use custom FFI integer types Gary Guo
2024-09-13 21:29 ` [PATCH 4/5] rust: map `long` to `isize` and `char` to `u8` Gary Guo
2024-09-23 9:20 ` Alice Ryhl
2024-09-13 21:29 ` [PATCH 5/5] rust: cleanup unnecessary casts Gary Guo
2024-09-23 9:19 ` Alice Ryhl
2024-09-13 21:42 ` Benno Lossin [this message]
[not found] ` <CAOcBZOS6BAJ1FTFkB3x6jdag_hL7zrLbFy7TxkvZWKxRZ_+ggA@mail.gmail.com>
2024-09-14 2:51 ` [PATCH 0/5] use custom FFI integer types Ramon de C Valle
2024-09-14 8:52 ` Alice Ryhl
2024-09-14 23:52 ` Gary Guo
2024-09-16 17:17 ` Ramon de C Valle
2024-09-16 17:26 ` Miguel Ojeda
2024-11-11 0:14 ` Miguel Ojeda
2024-12-15 22:25 ` Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=14389f99-dfa9-4646-a24e-e5eef1beacf0@proton.me \
--to=benno.lossin@proton.me \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=gary@garyguo.net \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=wedsonaf@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).