Support for both packed and aligned (in repr(C) #118018
Labels
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
T-opsem
Relevant to the opsem team
bcachefs uses types that are both packed and aligned (to 4 or 8 bytes). We're looking to expand our use of Rust, and we need these types available via bindgen - they're our on disk format, so not easily changed.
Right now we're making this work via a bindgen patch that strips off aligned when packed is specified; however, this is incorrect and a lurking bug since specifying the alignment of at type can change the size - thus, Rust and C may end up disagreeing about the size and layout of these types.
Additionally, specifying aligned may give rustc additional useful information - in a packed, aligned(4) type, members up to 4 byte alignment may still be aligned correctly (depending on struct layout), whereas in a packed type rustc would not be able to assume that.
The text was updated successfully, but these errors were encountered: