linux-yocto/rust/kernel
Gary Guo f3accd0437 rust: map long to isize and char to u8
commit 1bae8729e50a900f41e9a1c17ae81113e4cf62b8 upstream.

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.

Signed-off-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20240913213041.395655-5-gary@garyguo.net
[ Moved `uaccess` changes from the next commit, since they were
  irrefutable patterns that Rust >= 1.82.0 warns about. Reworded
  slightly and reformatted a few documentation comments. Rebased on
  top of `rust-next`. Added the removal of two casts to avoid Clippy
  warnings. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-03-13 13:02:13 +01:00
..
alloc rust: alloc: Fix ArrayLayout allocations 2025-03-13 13:01:49 +01:00
block rust: use custom FFI integer types 2025-03-13 13:01:49 +01:00
init rust: treewide: switch to our kernel Box type 2025-03-13 13:01:44 +01:00
list rust: start using the #[expect(...)] attribute 2025-03-13 13:01:42 +01:00
net rust: use custom FFI integer types 2025-03-13 13:01:49 +01:00
sync rust: use custom FFI integer types 2025-03-13 13:01:49 +01:00
alloc.rs rust: alloc: update module comment of alloc.rs 2025-03-13 13:01:47 +01:00
block.rs rust: block: introduce kernel::block::mq module 2024-06-14 07:45:04 -06:00
build_assert.rs rust: upgrade to Rust 1.68.2 2023-05-31 17:35:03 +02:00
device.rs rust: device: change the from_raw() function 2024-10-03 13:54:48 +02:00
error.rs rust: map long to isize and char to u8 2025-03-13 13:02:13 +01:00
firmware.rs rust: map long to isize and char to u8 2025-03-13 13:02:13 +01:00
init.rs rust: use custom FFI integer types 2025-03-13 13:01:49 +01:00
ioctl.rs rust: start using the #[expect(...)] attribute 2025-03-13 13:01:42 +01:00
kunit.rs rust: kunit: use C-string literals to clean warning 2024-10-01 23:46:42 +02:00
lib.rs rust: use custom FFI integer types 2025-03-13 13:01:49 +01:00
list.rs rust: enable clippy::undocumented_unsafe_blocks lint 2025-03-13 13:01:41 +01:00
net.rs rust: core abstractions for network PHY drivers 2023-12-15 09:35:50 +00:00
page.rs rust: add abstraction for struct page 2024-07-08 23:44:01 +02:00
prelude.rs rust: alloc: add Vec to prelude 2025-03-13 13:01:46 +01:00
print.rs rust: start using the #[expect(...)] attribute 2025-03-13 13:01:42 +01:00
rbtree.rs rust: treewide: switch to our kernel Box type 2025-03-13 13:01:44 +01:00
sizes.rs rust: sizes: add commonly used constants 2024-08-30 10:27:34 +01:00
static_assert.rs rust: static_assert: add static_assert! macro 2022-12-04 01:59:16 +01:00
std_vendor.rs rust: start using the #[expect(...)] attribute 2025-03-13 13:01:42 +01:00
str.rs rust: use custom FFI integer types 2025-03-13 13:01:49 +01:00
sync.rs rust: sync: implement Default for LockClassKey 2024-05-05 19:22:25 +02:00
task.rs rust: use custom FFI integer types 2025-03-13 13:01:49 +01:00
time.rs rust: use custom FFI integer types 2025-03-13 13:01:49 +01:00
types.rs rust: use custom FFI integer types 2025-03-13 13:01:49 +01:00
uaccess.rs rust: map long to isize and char to u8 2025-03-13 13:02:13 +01:00
workqueue.rs rust: treewide: switch to our kernel Box type 2025-03-13 13:01:44 +01:00