RFR: 7903481: Jextract doesn't enforce group layout alignment correctly in some cases
Maurizio Cimadamore
mcimadamore at openjdk.org
Tue May 30 11:57:30 UTC 2023
This patch overhauls the treatment of pragma packs directives.
The current logic tries to detect fields occurring at misaligned offsets, and relaxes alignment constraints for these fields.
However, in cases like this:
#pragma pack(push, 1)
struct A {
long long a;
int b;
}
Each field is correctly aligned. But the struct size (12) is not a multiple of its natural alignment (8). As a result, we run into issues when building a sequence layout out of this struct, because of the eager checks added to the layout API.
This patch fixes support for packed structs "the right way", that is, by asking clang the struct/union alignment, and then making sure that any field is aligned accordingly before the group layout is created.
-------------
Commit messages:
- Initial push
Changes: https://git.openjdk.org/jextract/pull/121/files
Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=121&range=00
Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903481
Stats: 105 lines in 9 files changed: 79 ins; 6 del; 20 mod
Patch: https://git.openjdk.org/jextract/pull/121.diff
Fetch: git fetch https://git.openjdk.org/jextract.git pull/121/head:pull/121
PR: https://git.openjdk.org/jextract/pull/121
More information about the jextract-dev
mailing list