Skip to content

Commit

Permalink
Merge pull request #16566 from ChengJin01/ffi_test_update_long_alignm…
Browse files Browse the repository at this point in the history
…ent__jdk17

[Test/FFI] Change the alignment of long in JDK17
  • Loading branch information
tajila committed Jan 24, 2023
2 parents 287ac60 + b7cc8c3 commit ab5679e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2022 IBM Corp. and others
* Copyright (c) 2021, 2023 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -859,12 +859,12 @@ public void test_addDoubleAndFloatDoubleFloatFromStructByUpcallMH() throws Throw

@Test
public void test_addDoubleAndIntDoubleLongFromStructByUpcallMH() throws Throwable {
/* The size of [int, double, long] on AIX/PPC 64-bit is 16 bytes without padding by default
/* The size of [int, double, long] on AIX/PPC 64-bit is 20 bytes without padding by default
* while the same struct is 24 bytes with padding on other platforms.
*/
GroupLayout structLayout = isAixOS ? MemoryLayout.structLayout(C_INT.withName("elem1"),
C_DOUBLE.withName("elem2"), longLayout.withName("elem3")) : MemoryLayout.structLayout(C_INT.withName("elem1"),
MemoryLayout.paddingLayout(32), C_DOUBLE.withName("elem2"), longLayout.withName("elem3"));
GroupLayout structLayout = isAixOS ? MemoryLayout.structLayout(C_INT.withName("elem1"), C_DOUBLE.withName("elem2"),
longLayout.withName("elem3").withBitAlignment(32)) : MemoryLayout.structLayout(C_INT.withName("elem1"),
MemoryLayout.paddingLayout(32), C_DOUBLE.withName("elem2"), longLayout.withName("elem3"));
VarHandle elemHandle1 = structLayout.varHandle(int.class, PathElement.groupElement("elem1"));
VarHandle elemHandle2 = structLayout.varHandle(double.class, PathElement.groupElement("elem2"));
VarHandle elemHandle3 = structLayout.varHandle(long.class, PathElement.groupElement("elem3"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2022 IBM Corp. and others
* Copyright (c) 2021, 2023 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -2585,11 +2585,11 @@ public static double addDoubleAndFloatDoubleFloatFromStruct(double arg1, MemoryS
}

public static double addDoubleAndIntDoubleLongFromStruct(double arg1, MemorySegment arg2) {
/* The size of [int, double, long] on AIX/PPC 64-bit is 16 bytes without padding by default
/* The size of [int, double, long] on AIX/PPC 64-bit is 20 bytes without padding by default
* while the same struct is 24 bytes with padding on other platforms.
*/
GroupLayout structLayout = isAixOS ? MemoryLayout.structLayout(C_INT.withName("elem1"),
C_DOUBLE.withName("elem2"), longLayout.withName("elem3"))
C_DOUBLE.withName("elem2"), longLayout.withName("elem3").withBitAlignment(32))
: MemoryLayout.structLayout(C_INT.withName("elem1"), MemoryLayout.paddingLayout(32),
C_DOUBLE.withName("elem2"), longLayout.withName("elem3"));
VarHandle elemHandle1 = structLayout.varHandle(int.class, PathElement.groupElement("elem1"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2022 IBM Corp. and others
* Copyright (c) 2021, 2023 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -821,7 +821,7 @@ public void test_addDoubleAndFloatDoubleFloatFromStructByUpcallMH() throws Throw

@Test
public void test_addDoubleAndIntDoubleLongFromStructByUpcallMH() throws Throwable {
/* The size of [int, double, long] on AIX/PPC 64-bit is 16 bytes without padding by default
/* The size of [int, double, long] on AIX/PPC 64-bit is 20 bytes without padding by default
* while the same struct is 24 bytes with padding on other platforms.
*/
GroupLayout structLayout = isAixOS ? MemoryLayout.structLayout(JAVA_INT.withName("elem1"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2022 IBM Corp. and others
* Copyright (c) 2021, 2023 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -1853,7 +1853,7 @@ public static double addDoubleAndFloatDoubleFloatFromStruct(double arg1, MemoryS

public static double addDoubleAndIntDoubleLongFromStruct(double arg1, MemorySegment arg2) {
int structElem1 = arg2.get(JAVA_INT, 0);
/* The size of [int, double, long] on AIX/PPC 64-bit is 16 bytes without padding by default
/* The size of [int, double, long] on AIX/PPC 64-bit is 20 bytes without padding by default
* while the same struct is 24 bytes with padding on other platforms.
*/
double structElem2 = (isAixOS) ? arg2.get(JAVA_DOUBLE.withBitAlignment(32), 4) : arg2.get(JAVA_DOUBLE, 8);
Expand Down

0 comments on commit ab5679e

Please sign in to comment.