Skip to content

Commit

Permalink
[GITHUB-1118] Fix mixed union with double and int members also on arm…
Browse files Browse the repository at this point in the history
…/aarch64
  • Loading branch information
matthiasblaesing committed Sep 20, 2019
1 parent 4bc4b88 commit 5c889be
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/com/sun/jna/Structure.java
Original file line number Diff line number Diff line change
Expand Up @@ -2047,14 +2047,20 @@ public FFIType(Structure ref) {
size = sf.size;
}
}
if((! Platform.isWindows()) && Platform.isIntel() && Platform.is64Bit()) {
if( (! Platform.isWindows()) && (
(Platform.isIntel() && Platform.is64Bit())
|| (Platform.isARM())
)) {
// System V x86-64 ABI requires, that in a union aggregate,
// that contains Integer and Double members, the parameters
// must be passed in the integer registers. I.e. in the case
// where the java side declares double and int members, the
// wrong FFI Type would be found, because the doubles size
// is larger than the int member, but the wrong parameter
// passing method would be used.
//
// It was observed, that the same behaviour is visible on
// arm/aarch64.
if(hasInteger && isFloatType(unionType)) {
unionType = new FFIType(unionType);
if(unionType.size.intValue() == 4) {
Expand Down

0 comments on commit 5c889be

Please sign in to comment.