Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 firebird3.0 (3.0.11.33637.ds4-2.1) UNRELEASED; urgency=medium
 .
   * loongarch64 support.
Author: sangmeng <sangmeng@loongson.cn>

---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>
Last-Update: 2023-07-26

--- firebird3.0-3.0.11.33637.ds4.orig/src/common/classes/DbImplementation.cpp
+++ firebird3.0-3.0.11.33637.ds4/src/common/classes/DbImplementation.cpp
@@ -50,6 +50,7 @@ static const UCHAR CpuArm64 = 15;
 static const UCHAR CpuPowerPc64el = 16;
 static const UCHAR CpuM68k = 17;
 static const UCHAR CpuRiscV64 = 18;
+static const UCHAR CpuLoongArch64 = 19;
 
 static const UCHAR OsWindows = 0;
 static const UCHAR OsLinux = 1;
@@ -91,7 +92,8 @@ const char* hardware[] = {
 	"ARM64",
 	"PowerPC64el",
 	"M68k",
-	"RiscV64"
+	"RiscV64",
+	"LoongArch64"
 };
 
 const char* operatingSystem[] = {
@@ -118,22 +120,22 @@ const char* compiler[] = {
 // This table lists pre-fb3 implementation codes
 const UCHAR backwardTable[FB_NELEM(hardware) * FB_NELEM(operatingSystem)] =
 {
-//				Intel	AMD		Sparc	PPC		PPC64	MIPSEL	MIPS	ARM		IA64	s390	s390x	SH		SHEB	HPPA	Alpha	ARM64	PPC64el	M68k	RiscV64
-/* Windows */	50,		68,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,
-/* Linux */		60,		66,		65,		69,		86,		71,		72,		75, 	76,		79, 	78,		80,		81,		82,		83,		84,		85,		87,		88,
-/* Darwin */	70,		73,		0,		63,		77,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,
-/* Solaris */	0,		0,		30,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,
-/* HPUX */		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		31,		0,		0,		0,		0,		0,
-/* AIX */		0,		0,		0,		35,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,
-/* MVS */		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,
-/* FreeBSD */	61,		67,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,
-/* NetBSD */	62,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0
+//				Intel	AMD		Sparc	PPC		PPC64	MIPSEL	MIPS	ARM		IA64	s390	s390x	SH		SHEB	HPPA	Alpha	ARM64	PPC64el	M68k	RiscV64     LOONGARCH64
+/* Windows */	50,		68,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,     0,
+/* Linux */	60,		66,		65,		69,		86,		71,		72,		75, 	        76,		79, 	        78,		80,		81,		82,		83,		84,		85,		87,		88,     89,
+/* Darwin */	70,		73,		0,		63,		77,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,      0,
+/* Solaris */	0,		0,		30,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,      0,
+/* HPUX */	0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		31,		0,		0,		0,		0,		0,      0,
+/* AIX */	0,		0,		0,		35,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,      0,
+/* MVS */	0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,      0,
+/* FreeBSD */	61,		67,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,      0,
+/* NetBSD */	62,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,		0,      0
 };
 
 const UCHAR backEndianess[FB_NELEM(hardware)] =
 {
-//	Intel	AMD		Sparc	PPC		PPC64	MIPSEL	MIPS	ARM		IA64	s390	s390x	SH		SHEB	HPPA	Alpha	ARM64	PPC64el	M68k	RiscV64
-	0,		0,		1,		1,		1,		0,		1,		0,		0,		1,		1,		0,		1,		1,		0,		0,		0,		1,		0,
+//	Intel	AMD		Sparc	PPC		PPC64	MIPSEL	MIPS	ARM		IA64	s390	s390x	SH		SHEB	HPPA	Alpha	ARM64	PPC64el	M68k	RiscV64  LoongArch64
+	0,		0,		1,		1,		1,		0,		1,		0,		0,		1,		1,		0,		1,		1,		0,		0,		0,		1,		0,           0,
 };
 
 } // anonymous namespace
--- firebird3.0-3.0.11.33637.ds4.orig/src/common/common.h
+++ firebird3.0-3.0.11.33637.ds4/src/common/common.h
@@ -157,6 +157,11 @@
 #define RISC_ALIGNMENT
 #endif // IA64
 
+#ifdef _LOONGARCH_ARCH
+#define FB_CPU CpuLoongArch64
+#endif /* loongarch64 */
+
+
 #ifndef USE_POSIX_THREADS
 // force pthread detection on Linux for distros that do not provide
 // POSIX thread compatability
--- firebird3.0-3.0.11.33637.ds4.orig/src/jrd/inf_pub.h
+++ firebird3.0-3.0.11.33637.ds4/src/jrd/inf_pub.h
@@ -248,6 +248,7 @@ enum  info_db_implementations
 	isc_info_db_impl_linux_ppc64 = 86,
 	isc_info_db_impl_linux_m68k = 87,
 	isc_info_db_impl_linux_riscv64 = 88,
+	isc_info_db_impl_linux_loongarch64 = 89,
 
 	isc_info_db_impl_last_value   // Leave this LAST!
 };
