diff --git a/CHANGES.md b/CHANGES.md index 470456a22a..80bb519236 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,7 @@ Features -------- * [#1433](https://github.com/java-native-access/jna/pull/1433): Add `CFEqual`, `CFDictionaryRef.ByReference`, `CFStringRef.ByReference` to `c.s.j.p.mac.CoreFoundation` - [@shalupov](https://github.com/shalupov) * [#978](https://github.com/java-native-access/jna/issues/978): Remove use of finalizers in JNA and improve concurrency for `Memory`, `CallbackReference` and `NativeLibrary` - [@matthiasblaesing](https://github.com/matthiasblaesing). +* [#1440](https://github.com/java-native-access/jna/pull/1440): Support for LoongArch64 - [@Panxuefeng-loongson](https://github.com/Panxuefeng-loongson). Bug Fixes --------- diff --git a/build.xml b/build.xml index b81b9d7584..31a053fe5a 100644 --- a/build.xml +++ b/build.xml @@ -529,6 +529,8 @@ com/sun/jna/linux-mips64el/libjnidispatch.so; processor=mips64el;osname=linux, com/sun/jna/linux-s390x/libjnidispatch.so; processor=S390x;osname=linux, +com/sun/jna/linux-loongarch64/libjnidispatch.so; +processor=loongarch64;osname=linux, com/sun/jna/freebsd-x86/libjnidispatch.so; processor=x86;osname=freebsd, @@ -638,6 +640,9 @@ osname=macosx;processor=aarch64 + @@ -851,6 +856,7 @@ osname=macosx;processor=aarch64 + diff --git a/lib/native/linux-loongarch64.jar b/lib/native/linux-loongarch64.jar new file mode 100644 index 0000000000..63862b7a1e Binary files /dev/null and b/lib/native/linux-loongarch64.jar differ diff --git a/src/com/sun/jna/Native.java b/src/com/sun/jna/Native.java index b832d4052f..e3c3d8ebef 100644 --- a/src/com/sun/jna/Native.java +++ b/src/com/sun/jna/Native.java @@ -250,7 +250,7 @@ static boolean isCompatibleVersion(String expectedVersion, String nativeVersion) setProtected(true); } MAX_ALIGNMENT = Platform.isSPARC() || Platform.isWindows() - || (Platform.isLinux() && (Platform.isARM() || Platform.isPPC() || Platform.isMIPS())) + || (Platform.isLinux() && (Platform.isARM() || Platform.isPPC() || Platform.isMIPS() || Platform.isLoongArch())) || Platform.isAIX() || (Platform.isAndroid() && !Platform.isIntel()) ? 8 : LONG_SIZE; diff --git a/src/com/sun/jna/Platform.java b/src/com/sun/jna/Platform.java index 7ee19e4a5b..ac1395e95d 100644 --- a/src/com/sun/jna/Platform.java +++ b/src/com/sun/jna/Platform.java @@ -195,6 +195,7 @@ public static final boolean is64Bit() { || "ppc64".equals(ARCH) || "ppc64le".equals(ARCH) || "sparcv9".equals(ARCH) || "mips64".equals(ARCH) || "mips64el".equals(ARCH) + || "loongarch64".equals(ARCH) || "amd64".equals(ARCH) || "aarch64".equals(ARCH)) { return true; @@ -234,6 +235,10 @@ public static final boolean isMIPS() { return false; } + public static final boolean isLoongArch() { + return ARCH.startsWith("loongarch"); + } + static String getCanonicalArchitecture(String arch, int platform) { arch = arch.toLowerCase().trim(); if ("powerpc".equals(arch)) { diff --git a/src/com/sun/jna/Structure.java b/src/com/sun/jna/Structure.java index b2457f69d7..39d3da0efa 100644 --- a/src/com/sun/jna/Structure.java +++ b/src/com/sun/jna/Structure.java @@ -2081,7 +2081,7 @@ public FFIType(Structure ref) { } } if ((Platform.isIntel() && Platform.is64Bit() && !Platform.isWindows()) - || Platform.isARM()) { + || Platform.isARM() || Platform.isLoongArch()) { // 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 @@ -2091,7 +2091,7 @@ public FFIType(Structure ref) { // passing method would be used. // // It was observed, that the same behaviour is visible on - // arm/aarch64. + // arm/aarch64/loongarch64. if(hasInteger && isFloatType(unionType)) { unionType = new FFIType(unionType); if(unionType.size.intValue() == 4) {