Skip to content

Support for both packed and aligned (in repr(C) #118018

@koverstreet

Description

@koverstreet

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamT-opsemRelevant to the opsem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions