--- cfitsio-4.2.0/fitsio2.h	2023-08-09 10:23:45.508392645 +0800
+++ cfitsio-4.2.0/fitsio2.h	2023-08-09 10:29:44.960511085 +0800
@@ -151,6 +151,18 @@
 #    error "can't handle long size given by __riscv_xlen"
 #  endif
 
+#elif defined(__loongarch__)
+
+#define BYTESWAPPED TRUE
+
+#  if __loongarch_grlen == 32
+#    define LONGSIZE 32
+#  elif __loongarch_grlen == 64
+#    define LONGSIZE 64
+#  else
+#    error "can't handle long size given by __loongarch_grlen"
+#  endif
+
 /* ============================================================== */
 /*  the following are all 32-bit byteswapped platforms            */
 
