Skip to content

Commit

Permalink
Change double alignment to 4 in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealMDoerr committed Oct 5, 2023
1 parent 92b8f27 commit b7ae247
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion test/jdk/java/foreign/NativeTestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

public class NativeTestHelper {

public static final boolean IS_AIX = System.getProperty("os.name").startsWith("AIX");
public static final boolean IS_WINDOWS = System.getProperty("os.name").startsWith("Windows");

private static final MethodHandle MH_SAVER;
Expand Down Expand Up @@ -116,7 +117,8 @@ public static boolean isPointer(MemoryLayout layout) {
/**
* The layout for the {@code double} C type
*/
public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE;
public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE.withByteAlignment(IS_AIX ? 4 : 8);

/**
* The {@code T*} native type.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ private AArch64() {}
* This class defines layout constants modelling standard primitive types supported by the PPC64 ABI.
*/
public static final class PPC64 {
public static final boolean IS_AIX = System.getProperty("os.name").startsWith("AIX");

private PPC64() {
//just the one
Expand Down Expand Up @@ -244,7 +245,7 @@ private PPC64() {
/**
* The {@code double} native type.
*/
public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE;
public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE.withByteAlignment(IS_AIX ? 4 : 8);

/**
* The {@code T*} native type.
Expand Down
4 changes: 3 additions & 1 deletion test/micro/org/openjdk/bench/java/lang/foreign/CLayouts.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.lang.invoke.MethodHandle;

public class CLayouts {
private static final boolean IS_AIX = System.getProperty("os.name").startsWith("AIX");

// the constants below are useful aliases for C types. The type/carrier association is only valid for 64-bit platforms.

Expand Down Expand Up @@ -64,7 +65,8 @@ public class CLayouts {
/**
* The layout for the {@code double} C type
*/
public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE;
public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE.withByteAlignment(IS_AIX ? 4 : 8);

/**
* The {@code T*} native type.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.lang.foreign.ValueLayout;

public sealed abstract class NativeType<X> {
private static final boolean IS_AIX = System.getProperty("os.name").startsWith("AIX");

public abstract MemoryLayout layout();

Expand Down Expand Up @@ -63,7 +64,7 @@ public ValueLayout.OfInt layout() {
public static final OfDouble<Double> C_DOUBLE = new OfDouble<>() {
@Override
public ValueLayout.OfDouble layout() {
return ValueLayout.JAVA_DOUBLE;
return ValueLayout.JAVA_DOUBLE.withByteAlignment(IS_AIX ? 4 : 8);
}
};

Expand Down

0 comments on commit b7ae247

Please sign in to comment.