linux/rust/kernel/sync
Gary Guo 1fc1f82756 rust: mem: add transmute with deferred size check
Implement a `transmute/safe_transmute` that checks size at
monomorphization time instead of type-checking time. This allows more cases
where we know that the size matches but this is not generically checkable.

The signature is equivalent to the unstable `transmute_neo` function in the
standard library. A safe variant is provided to use with types implementing
`FromBytes` and `IntoBytes`.

Existing users of `transmute_copy` to bypass size checks are converted.

Signed-off-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Tested-by: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://patch.msgid.link/20260901-typed_register-v4-2-5552b1d59525@garyguo.net
[ Fix doc heading to use plural "Examples", add missing closing code
  block delimiter and fix a few other nits. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-09-06 13:39:26 +02:00
..
arc rust: provide proper code documentation titles 2024-10-07 21:39:57 +02:00
atomic rust: sync: Add generic memory barriers 2026-08-04 05:52:54 -07:00
lock rust: sync: Introduce SpinLockIrq::lock_with() and friends 2026-08-10 12:53:11 +02:00
arc.rs rust: sync: improve Arc documentation links 2026-08-10 06:44:10 +02:00
aref.rs rust: types: implement ForeignOwnable for ARef<T> 2026-08-10 07:58:27 +02:00
atomic.rs rust: mem: add transmute with deferred size check 2026-09-06 13:39:26 +02:00
barrier.rs rust: sync: Add generic memory barriers 2026-08-04 05:52:54 -07:00
completion.rs rust: sync: completion: Mark inline complete_all and wait_for_completion 2026-06-09 10:28:06 +02:00
condvar.rs Rust changes for v6.19 2025-12-03 14:16:49 -08:00
lock.rs rust: sync: Inline various lock related methods 2026-01-10 10:53:46 +08:00
locked_by.rs rust: make build_assert module the home of related macros 2026-06-10 09:07:13 +02:00
poll.rs Char/Misc/IIO/etc driver update for 7.3-rc1 2026-08-25 09:38:50 -07:00
rcu.rs Locking updates for v7.3: 2026-08-18 13:07:17 -07:00
refcount.rs rust: make build_assert module the home of related macros 2026-06-10 09:07:13 +02:00
set_once.rs rust: sync: set_once: Implement Send and Sync 2026-01-09 19:01:40 +08:00
srcu.rs rust: sync: add SRCU abstraction 2026-07-15 15:34:26 -07:00