RFR: 7904115: Fix for AIX test case failures due to incorrect alignment for double and pointer [v2]
Jorn Vernee
jvernee at openjdk.org
Mon Dec 1 18:12:28 UTC 2025
On Fri, 21 Nov 2025 15:40:01 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> Varada M has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - addition of -m64 at right place
>> - addition of -m64 at right place
>
> @varada1110
>
> You could also try the following patch:
>
>
> diff --git a/src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java b/src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java
> index 7c1ae3a..a317dc5 100644
> --- a/src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java
> +++ b/src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java
> @@ -30,7 +30,6 @@ import org.openjdk.jextract.Type.Declared;
> import org.openjdk.jextract.Type.Delegated;
> import org.openjdk.jextract.Type.Function;
> import org.openjdk.jextract.Type.Primitive;
> -import org.openjdk.jextract.impl.DeclarationImpl.ClangAlignOf;
> import org.openjdk.jextract.impl.DeclarationImpl.ClangEnumType;
> import org.openjdk.jextract.impl.DeclarationImpl.DeclarationString;
> import org.openjdk.jextract.impl.DeclarationImpl.JavaName;
> @@ -201,19 +200,25 @@ abstract class ClassSourceBuilder {
> throw new IllegalArgumentException("Not handled: " + type);
> }
>
> + private static final int NO_ALIGN_REQUIRED_MARKER = -1;
> +
> String layoutString(Type type) {
> - return layoutString(type, Long.MAX_VALUE);
> + return fieldLayoutString(type, -1, NO_ALIGN_REQUIRED_MARKER);
> }
>
> - String layoutString(Type type, long align) {
> + String fieldLayoutString(Type type, long typeAlign, long expectedAlign) {
> return switch (type) {
> - case Primitive p -> primitiveLayoutString(p, align);
> - case Declared d when Utils.isEnum(d) -> layoutString(ClangEnumType.get(d.tree()).get(), align);
> - case Declared d when Utils.isStructOrUnion(d) -> alignIfNeeded(JavaName.getFullNameOrThrow(d.tree()) + ".layout()", ClangAlignOf.getOrThrow(d.tree()) / 8, align);
> - case Delegated d when d.kind() == Delegated.Kind.POINTER -> alignIfNeeded(runtimeHelperName() + ".C_POINTER", 8, align);
> - case Delegated d -> layoutString(d.type(), align);
> - case Function _ -> alignIfNeeded(runtimeHelperName() + ".C_POINTER", 8, align);
> - case Array a -> String.format("MemoryLayout.sequenceLayout(%1$d, %2$s)", a.elementCount().orElse(0L), layoutString(a.elementType(), align));
> + case Primitive p -> primitiveLayoutString(p, typeAlign, expectedAlign);
> + case Declared d when Utils.isEnum(d) ->
> + fieldLayoutString(ClangEnumType.get(d.tree()).get(), typeAlign, expectedAlign);
> + case Declared d when Utils.isStructOrUnion(d) ->
> + alignIfNeeded(JavaName.getFull...
> @JornVernee can we have another round of reviews for this PR ?
I was still waiting for the changes we discussed last time to be implemented. I was assuming @varada1110 was still working on them.
-------------
PR Comment: https://git.openjdk.org/jextract/pull/296#issuecomment-3598113587
More information about the jextract-dev
mailing list