Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider alignment contribution from bitfields #2680

Merged
merged 4 commits into from Dec 11, 2023
Merged

Conversation

nbdd0121
Copy link
Contributor

@nbdd0121 nbdd0121 commented Nov 2, 2023

Partial fix to https://lore.kernel.org/rust-for-linux/Y8Ax%2FI5qOcVDZljG@zn.tnic/ (not a full fix, because if short below is replaced with a int then the code still fails to compile)

Currently binding for code like this wouldn't compile:

struct outer {
    struct {
        short a: 16;
        short b: 16;
    };
} __attribute__((packed));

because bindgen sticks an extra #[repr(align(2))] on the inner struct.

This extra alignment is not necessary and can be removed. The removed NB line in this PR is no longer relevant because of the addition _bitfield_align field generated starting in #1950.

Reopen of #2388

bindgen/codegen/struct_layout.rs Show resolved Hide resolved
@emilio emilio merged commit be197f3 into rust-lang:main Dec 11, 2023
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants