From 5c889be0e5de6863c3b12a206e39d27038a6c592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bl=C3=A4sing?= Date: Fri, 20 Sep 2019 22:41:29 +0200 Subject: [PATCH] [GITHUB-1118] Fix mixed union with double and int members also on arm/aarch64 --- src/com/sun/jna/Structure.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/sun/jna/Structure.java b/src/com/sun/jna/Structure.java index 4cb2c132e3..13433644b8 100644 --- a/src/com/sun/jna/Structure.java +++ b/src/com/sun/jna/Structure.java @@ -2047,7 +2047,10 @@ 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 @@ -2055,6 +2058,9 @@ public FFIType(Structure ref) { // 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) {