diff --git a/CHANGES.md b/CHANGES.md
index b0ecdbe795..7d0b99ef64 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,6 +7,7 @@ Next Release (5.7.0)
Features
--------
+* [#1238](https://github.com/java-native-access/jna/pull/1238): Add macOS `aarch64` architecture to universal `darwin` target. Cherry pick [libffi/libffi#577](https://github.com/libffi/libffi/pull/577). - [@fkistner](https://github.com/fkistner).
* [#1264](https://github.com/java-native-access/jna/pull/1264): Update libffi to v3.3; Add Windows `aarch64` target. - [@tresf](https://github.com/tresf).
* [#1293](https://github.com/java-native-access/jna/issues/1293): Bind part of Windows Application Recovery and Restart API: `RegisterApplicationRestart`, `UnregisterApplicationRestart` and `GetApplicationRestartSettings` in `c.s.j.p.w.Kernel32` - [@matthiasblaesing](https://github.com/matthiasblaesing).
* [#1217](https://github.com/java-native-access/jna/pull/1217): Add mappings for AIX `Perfstat` library to `c.s.j.p.unix.aix` - [@dbwiddis](https://github.com/dbwiddis).
diff --git a/build.xml b/build.xml
index 41bf1be99f..024813e07c 100644
--- a/build.xml
+++ b/build.xml
@@ -296,8 +296,18 @@
+
+
+
+
+
+
+
+
+
+
-
+
@@ -316,7 +326,7 @@
-
+
@@ -521,7 +531,7 @@ com/sun/jna/openbsd-x86-64/libjnidispatch.so;
processor=x86-64;osname=openbsd,
com/sun/jna/darwin/libjnidispatch.jnilib;
-osname=macosx;processor=x86;processor=x86-64;processor=ppc
+osname=macosx;processor=x86;processor=x86-64;processor=ppc;processor=aarch64
"/>
@@ -788,6 +798,8 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
Invalidating native code, new checksum is ${md5}
+
+
@@ -829,7 +841,7 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
-
+
@@ -866,7 +878,7 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
-
+
@@ -874,34 +886,37 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
-
+
-
+
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -919,45 +934,51 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1074,17 +1095,7 @@ cd ..
-
-
-
-
-
-
-
-
+
@@ -1097,6 +1108,47 @@ cd ..
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
@@ -83,7 +93,7 @@
-
+
@@ -157,7 +167,7 @@
-
+
@@ -219,42 +229,45 @@
file="${makefile.path}" byline="true"/>
-
+
-
+
-
+
-
+
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -280,39 +293,45 @@
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/native/libffi/src/aarch64/ffi.c b/native/libffi/src/aarch64/ffi.c
index 99da36cde3..44b1ecdd97 100644
--- a/native/libffi/src/aarch64/ffi.c
+++ b/native/libffi/src/aarch64/ffi.c
@@ -660,12 +660,13 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
state.ngrn = N_X_ARG_REG;
/* Note that the default abi extends each argument
to a full 64-bit slot, while the iOS abi allocates
- only enough space. */
+ only enough space, except for variadic arguments. */
#ifdef __APPLE__
- memcpy(d, a, s);
-#else
- *(ffi_arg *)d = ext;
+ if (!state.allocating_variadic)
+ memcpy(d, a, s);
+ else
#endif
+ *(ffi_arg *)d = ext;
}
}
break;
diff --git a/test/com/sun/jna/LibraryLoadTest.java b/test/com/sun/jna/LibraryLoadTest.java
index d29007f91a..aa07a673a4 100644
--- a/test/com/sun/jna/LibraryLoadTest.java
+++ b/test/com/sun/jna/LibraryLoadTest.java
@@ -203,13 +203,12 @@ public void testLoadLibraryWithLongName() throws Exception {
public void testLoadFrameworkLibrary() {
if (Platform.isMac()) {
final String PATH = "/System/Library/Frameworks/CoreServices.framework";
- assertTrue("CoreServices not present on this setup, expected at " + PATH, new File(PATH).exists());
try {
NativeLibrary lib = NativeLibrary.getInstance("CoreServices");
assertNotNull("CoreServices not found", lib);
}
catch(UnsatisfiedLinkError e) {
- fail("Should search /System/Library/Frameworks");
+ failCoreServices("Should search /System/Library/Frameworks: ", e, PATH);
}
}
}
@@ -218,13 +217,12 @@ public void testLoadFrameworkLibraryAbsolute() {
if (Platform.isMac()) {
final String PATH = "/System/Library/Frameworks/CoreServices";
final String FRAMEWORK = PATH + ".framework";
- assertTrue("CoreServices not present on this setup, expected at " + FRAMEWORK, new File(FRAMEWORK).exists());
try {
NativeLibrary lib = NativeLibrary.getInstance(PATH);
assertNotNull("CoreServices not found", lib);
}
catch(UnsatisfiedLinkError e) {
- fail("Should try FRAMEWORK.framework/FRAMEWORK if the absolute framework (truncated) path given exists: " + e);
+ failCoreServices("Should try FRAMEWORK.framework/FRAMEWORK if the absolute framework (truncated) path given exists: ", e, FRAMEWORK);
}
}
}
@@ -232,17 +230,23 @@ public void testLoadFrameworkLibraryAbsolute() {
public void testLoadFrameworkLibraryAbsoluteFull() {
if (Platform.isMac()) {
final String PATH = "/System/Library/Frameworks/CoreServices.framework/CoreServices";
- assertTrue("CoreServices not present on this setup, expected at " + PATH, new File(PATH).exists());
try {
NativeLibrary lib = NativeLibrary.getInstance(PATH);
assertNotNull("CoreServices not found", lib);
}
catch(UnsatisfiedLinkError e) {
- fail("Should try FRAMEWORK verbatim if the absolute path given exists: " + e);
+ failCoreServices("Should try FRAMEWORK verbatim if the absolute path given exists: ", e, PATH);
}
}
}
+ private void failCoreServices(String message, UnsatisfiedLinkError e, String expectedPath) {
+ if (!new File(expectedPath).exists()) {
+ message = "CoreServices not present on this setup, expected at " + expectedPath + "\n" + message;
+ }
+ fail(message + e);
+ }
+
public void testHandleObjectMethods() {
CLibrary lib = (CLibrary)load();
String method = "toString";
diff --git a/test/com/sun/jna/PlatformTest.java b/test/com/sun/jna/PlatformTest.java
index 21eea41c8d..e12abe3081 100644
--- a/test/com/sun/jna/PlatformTest.java
+++ b/test/com/sun/jna/PlatformTest.java
@@ -47,6 +47,9 @@ public void testOSPrefix() {
assertEquals("Wrong resource path Mac/x86_64", "darwin",
Platform.getNativeLibraryResourcePrefix(Platform.MAC,
"x86_64", "Mac"));
+ assertEquals("Wrong resource path Mac/aarch64", "darwin",
+ Platform.getNativeLibraryResourcePrefix(Platform.MAC,
+ "aarch64", "Mac"));
assertEquals("Wrong resource path Solaris/sparc", "sunos-sparc",
Platform.getNativeLibraryResourcePrefix(Platform.SOLARIS,
"sparc", "Solaris"));
diff --git a/test/com/sun/jna/VarArgsTest.java b/test/com/sun/jna/VarArgsTest.java
index 9710f43795..f93b8030d7 100644
--- a/test/com/sun/jna/VarArgsTest.java
+++ b/test/com/sun/jna/VarArgsTest.java
@@ -42,8 +42,8 @@ protected List getFieldOrder() {
}
public int addVarArgs(String fmt, Number... args);
public String returnStringVarArgs(String fmt, Object... args);
- public void modifyStructureVarArgs(String fmt, Object arg1, Object... args);
- public String returnStringVarArgs2(String... args);
+ public void modifyStructureVarArgs(String fmt, Object... args);
+ public String returnStringVarArgs2(String fmt, String... args);
}
TestLibrary lib;
@Override