From 954043a015db13f42d2cf9dd7720b457f9ac3500 Mon Sep 17 00:00:00 2001 From: maqi Date: Tue, 4 Mar 2025 15:46:10 +0800 Subject: [PATCH] add sw_64 support --- 0001-add-sw_64-support.patch | 125 +++++++++++++++++++++++++++++++++++ jnr-ffi.spec | 7 +- 2 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 0001-add-sw_64-support.patch diff --git a/0001-add-sw_64-support.patch b/0001-add-sw_64-support.patch new file mode 100644 index 0000000..3f3dcab --- /dev/null +++ b/0001-add-sw_64-support.patch @@ -0,0 +1,125 @@ +From 319583a536860ec76ac0d821d27392e5c5c4a1fc Mon Sep 17 00:00:00 2001 +From: mahailiang +Date: Mon, 25 Nov 2024 21:55:38 +0800 +Subject: [PATCH] add sw_64 support + +--- + src/main/java/jnr/ffi/Platform.java | 8 ++- + .../jffi/platform/sw64/linux/TypeAliases.java | 72 +++++++++++++++++++ + 2 files changed, 79 insertions(+), 1 deletion(-) + create mode 100644 src/main/java/jnr/ffi/provider/jffi/platform/sw64/linux/TypeAliases.java + +diff --git a/src/main/java/jnr/ffi/Platform.java b/src/main/java/jnr/ffi/Platform.java +index 54b53b7..5e38672 100644 +--- a/src/main/java/jnr/ffi/Platform.java ++++ b/src/main/java/jnr/ffi/Platform.java +@@ -127,6 +127,9 @@ public abstract class Platform { + /** 64 bit RISC-V */ + RISCV64, + ++ /** 64 bit SW64 */ ++ SW64, ++ + /** + * Unknown CPU architecture. A best effort will be made to infer architecture + * specific values such as address and long size. +@@ -237,6 +240,8 @@ public abstract class Platform { + return CPU.LOONGARCH64; + } else if (equalsIgnoreCase("riscv64", archString)) { + return CPU.RISCV64; ++ } else if (equalsIgnoreCase("sw_64", archString) || equalsIgnoreCase("sw64", archString)) { ++ return CPU.SW64; + } + + // Try to find by lookup up in the CPU list +@@ -296,7 +301,8 @@ public abstract class Platform { + case AARCH64: + case MIPS64EL: + case LOONGARCH64: +- case RISCV64: ++ case RISCV64: ++ case SW64: + dataModel = 64; + break; + default: +diff --git a/src/main/java/jnr/ffi/provider/jffi/platform/sw64/linux/TypeAliases.java b/src/main/java/jnr/ffi/provider/jffi/platform/sw64/linux/TypeAliases.java +new file mode 100644 +index 0000000..c6d6fa3 +--- /dev/null ++++ b/src/main/java/jnr/ffi/provider/jffi/platform/sw64/linux/TypeAliases.java +@@ -0,0 +1,72 @@ ++/* ++ * Copyright (C) 2016 Wayne Meissner ++ * ++ * This file is part of the JNR project. ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++package jnr.ffi.provider.jffi.platform.sw64.linux; ++ ++import jnr.ffi.NativeType; ++import jnr.ffi.TypeAlias; ++ ++import java.util.EnumMap; ++import java.util.Map; ++ ++public final class TypeAliases { ++ public static final Map ALIASES = buildTypeMap(); ++ private static Map buildTypeMap() { ++ Map m = new EnumMap(TypeAlias.class); ++ m.put(TypeAlias.int8_t, NativeType.SCHAR); ++ m.put(TypeAlias.u_int8_t, NativeType.UCHAR); ++ m.put(TypeAlias.int16_t, NativeType.SSHORT); ++ m.put(TypeAlias.u_int16_t, NativeType.USHORT); ++ m.put(TypeAlias.int32_t, NativeType.SINT); ++ m.put(TypeAlias.u_int32_t, NativeType.UINT); ++ m.put(TypeAlias.int64_t, NativeType.SLONG); ++ m.put(TypeAlias.u_int64_t, NativeType.ULONG); ++ m.put(TypeAlias.intptr_t, NativeType.SLONG); ++ m.put(TypeAlias.uintptr_t, NativeType.ULONG); ++ m.put(TypeAlias.caddr_t, NativeType.ADDRESS); ++ m.put(TypeAlias.dev_t, NativeType.ULONG); ++ m.put(TypeAlias.blkcnt_t, NativeType.SLONG); ++ m.put(TypeAlias.blksize_t, NativeType.SINT); ++ m.put(TypeAlias.gid_t, NativeType.UINT); ++ m.put(TypeAlias.in_addr_t, NativeType.UINT); ++ m.put(TypeAlias.in_port_t, NativeType.USHORT); ++ m.put(TypeAlias.ino_t, NativeType.ULONG); ++ m.put(TypeAlias.ino64_t, NativeType.ULONG); ++ m.put(TypeAlias.key_t, NativeType.SINT); ++ m.put(TypeAlias.mode_t, NativeType.UINT); ++ m.put(TypeAlias.nlink_t, NativeType.UINT); ++ m.put(TypeAlias.id_t, NativeType.UINT); ++ m.put(TypeAlias.pid_t, NativeType.SINT); ++ m.put(TypeAlias.off_t, NativeType.SLONG); ++ m.put(TypeAlias.swblk_t, NativeType.SLONG); ++ m.put(TypeAlias.uid_t, NativeType.UINT); ++ m.put(TypeAlias.clock_t, NativeType.SLONG); ++ m.put(TypeAlias.size_t, NativeType.ULONG); ++ m.put(TypeAlias.ssize_t, NativeType.SLONG); ++ m.put(TypeAlias.time_t, NativeType.SLONG); ++ m.put(TypeAlias.fsblkcnt_t, NativeType.ULONG); ++ m.put(TypeAlias.fsfilcnt_t, NativeType.ULONG); ++ m.put(TypeAlias.sa_family_t, NativeType.USHORT); ++ m.put(TypeAlias.socklen_t, NativeType.UINT); ++ m.put(TypeAlias.rlim_t, NativeType.ULONG); ++ m.put(TypeAlias.cc_t, NativeType.UCHAR); ++ m.put(TypeAlias.speed_t, NativeType.UINT); ++ m.put(TypeAlias.tcflag_t, NativeType.UINT); ++ return m; ++ } ++} +-- +2.20.1 + diff --git a/jnr-ffi.spec b/jnr-ffi.spec index 7be6937..8e50ad9 100644 --- a/jnr-ffi.spec +++ b/jnr-ffi.spec @@ -1,12 +1,13 @@ Name: jnr-ffi Version: 2.2.0 -Release: 2 +Release: 3 Summary: Java Abstracted Foreign Function Layer License: Apache-2.0 URL: http://github.com/jnr/%{name}/ Source0: https://github.com/jnr/jnr-ffi/archive/refs/tags/%{name}-%{version}.tar.gz Patch0: 0001-Support-for-LoongArch64.patch Patch1: 0002-Add-riscv64-support.patch +Patch2: 0001-add-sw_64-support.patch BuildRequires: fdupes gcc make maven-local mvn(com.github.jnr:jffi) BuildRequires: mvn(com.github.jnr:jffi::native:) mvn(com.github.jnr:jnr-x86asm) BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) @@ -32,6 +33,7 @@ This package contains the API documentation for %{name}. %setup -q -n %{name}-%{name}-%{version} %patch0 -p1 %patch1 -p1 +%patch2 -p1 find -name '*.jar' -o -name '*.class' -exec rm -f '{}' \; %pom_remove_plugin ":maven-javadoc-plugin" sed -i 's|-Werror||' libtest/GNUmakefile @@ -53,6 +55,9 @@ sed -i '104,105d' .xmvn-reactor %license LICENSE %changelog +* Tue Mar 04 2025 maqi - 2.2.0-3 +- add sw_64 support + * Thu Sep 28 2023 laokz - 2.2.0-2 - Backport riscv64 support patch from 2.2.15