Skip to content

use custom FFI integer types

Gary Guo linux-block linux-kselftest lkml llvm netdev rust-for-linux 1 version Applied

Status from this message: Applied to `rust-next` -- thanks everyone!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 14 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/5rust: fix size_t in bindgen prototypes of C builtinsrust/Makefile+5 -12 replies
2/5rust: map `__kernel_size_t` and friends also to usize/isizerust/bindgen_parameters rust/bindings/lib.rs rust/uapi/lib.rs+15 -02 replies
3/5rust: use custom FFI integer typesrust/Makefile rust/ffi.rs rust/kernel/alloc/allocator.rs +18 more+91 -740 replies
4/5rust: map `long` to `isize` and `char` to `u8`rust/ffi.rs rust/kernel/error.rs rust/kernel/firmware.rs+38 -61 reply
5/5rust: cleanup unnecessary castsrust/kernel/kunit.rs rust/kernel/print.rs rust/kernel/str.rs +1 more+14 -331 reply

Reviews trailers per patch

3 of 5 patches have a Reviewed-by or Acked-by.

PatchAlice RyhlTrevor Gross
1/5
2/5R-b R-b
3/5
4/5R-b
5/5R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/5] use custom FFI integer types

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.

After this series, FFI code needs to use kernel::ffi types instead of core::ffi.

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

Signature · 1 line
2.44.1