Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for LoongArch64 #308

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jffi</artifactId>
<version>1.3.9</version>
<version>1.3.10-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jffi</artifactId>
<version>1.3.9</version>
<version>1.3.10-SNAPSHOT</version>
<scope>runtime</scope>
<classifier>native</classifier>
</dependency>
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/jnr/ffi/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ public enum CPU {
/** 64 bit MIPS */
MIPS64EL,

/** 64 bit LOONGARCH */
LOONGARCH64,

/**
* Unknown CPU architecture. A best effort will be made to infer architecture
* specific values such as address and long size.
Expand Down Expand Up @@ -241,6 +244,8 @@ private static CPU determineCPU() {
return CPU.ARM;
} else if (equalsIgnoreCase("mips64", archString) || equalsIgnoreCase("mips64el", archString)) {
return CPU.MIPS64EL;
} else if (equalsIgnoreCase("loongarch64", archString)) {
return CPU.LOONGARCH64;
}

// Try to find by lookup up in the CPU list
Expand Down Expand Up @@ -302,6 +307,7 @@ private static int calculateAddressSize(CPU cpu) {
case S390X:
case AARCH64:
case MIPS64EL:
case LOONGARCH64:
dataModel = 64;
break;
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2022 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.loongarch64.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<TypeAlias, jnr.ffi.NativeType> ALIASES = buildTypeMap();
private static Map<TypeAlias, jnr.ffi.NativeType> buildTypeMap() {
Map<TypeAlias, jnr.ffi.NativeType> m = new EnumMap<TypeAlias, jnr.ffi.NativeType>(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.SLONGLONG);
m.put(TypeAlias.u_int64_t, NativeType.ULONGLONG);
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;
}
}