From 958aeee20de0c41aa90e54592550445d8f3af850 Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: Tue, 16 May 2023 12:29:01 +0000
Subject: [PATCH] add loongarch64 support for jffi

---
 jni/GNUmakefile                                       | 2 +-
 src/main/java/com/kenai/jffi/Platform.java            | 4 ++++
 src/main/java/com/kenai/jffi/internal/StubLoader.java | 4 ++++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/jni/GNUmakefile b/jni/GNUmakefile
index 65b7655..b3a1f4d 100755
--- a/jni/GNUmakefile
+++ b/jni/GNUmakefile
@@ -245,7 +245,7 @@ ifeq ($(CPU), sparcv9)
   MODEL=64
 endif
 
-ifneq ($(findstring $(CPU), x86_64 amd64 ppc64 ppc64le powerpc64 s390x aarch64),)
+ifneq ($(findstring $(CPU), x86_64 amd64 ppc64 ppc64le powerpc64 s390x aarch64 loongarch64),)
   MODEL = 64
 endif
 
diff --git a/src/main/java/com/kenai/jffi/Platform.java b/src/main/java/com/kenai/jffi/Platform.java
index 8447369..7a7de25 100644
--- a/src/main/java/com/kenai/jffi/Platform.java
+++ b/src/main/java/com/kenai/jffi/Platform.java
@@ -100,6 +100,8 @@ public abstract class Platform {
         ARM(32),
         /** AARCH64 */
         AARCH64(64),
+	/** LOONGARCH64*/
+        LOONGARCH64(64),
         /** Unknown CPU */
         UNKNOWN(64);
 
@@ -230,6 +232,8 @@ public abstract class Platform {
                 
             } else if (Util.equalsIgnoreCase("aarch64", archString, LOCALE)) {
                 return CPU.AARCH64;
+            } else if (Util.equalsIgnoreCase("loongarch64", archString, LOCALE)) {
+                return CPU.LOONGARCH64;
             }
             
 
diff --git a/src/main/java/com/kenai/jffi/internal/StubLoader.java b/src/main/java/com/kenai/jffi/internal/StubLoader.java
index 9b81e83..8d0eaaf 100644
--- a/src/main/java/com/kenai/jffi/internal/StubLoader.java
+++ b/src/main/java/com/kenai/jffi/internal/StubLoader.java
@@ -122,6 +122,8 @@ public class StubLoader {
         ARM,
         /** AArch64 */
         AARCH64,
+        /** LoongArch64 */
+        LOONGARCH64,
         /** Unknown CPU */
         UNKNOWN;
 
@@ -184,6 +186,8 @@ public class StubLoader {
             return CPU.ARM;
         } else if (Util.equalsIgnoreCase("aarch64", archString, LOCALE)) {
             return CPU.AARCH64;
+        } else if (Util.equalsIgnoreCase("loongarch64", archString, LOCALE)) {
+            return CPU.LOONGARCH64;
         }
 
         // Try to find by lookup up in the CPU list
-- 
2.33.0

