add support for LoongArch
authorDebian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
Sun, 3 Mar 2024 09:03:16 +0000 (09:03 +0000)
committerSteve Langasek <vorlon@debian.org>
Sun, 3 Mar 2024 09:03:16 +0000 (09:03 +0000)
Origin: upstream, commits
 https://code.qt.io/cgit/qt/qtbase.git/commit/?id=bdc16f086f1664b5
 https://code.qt.io/cgit/qt/qtbase.git/commit/?id=0ab51dcc3c0cca0d
Last-Update: 2023-11-05

Gbp-Pq: Name loongarch.diff

src/3rdparty/forkfd/forkfd_linux.c
src/corelib/global/archdetect.cpp
src/corelib/global/qglobal.cpp
src/corelib/global/qprocessordetection.h

index ffe0e9a5e24bc30c5ad9d712ce0107e6f59202d1..b1f5408d111cc568e2bf35776d324bb934079822 100644 (file)
@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
 #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
+    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
+    defined(__loongarch__)
     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
      * but since both values are 0, there's no harm. */
     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
index 1d00b7f5a52c7fbc2c4f710c79602a03febeaeea..281e84df63c244f1a1751e0443b190ea593262ae 100644 (file)
 #  define ARCH_PROCESSOR "x86_64"
 #elif defined(Q_PROCESSOR_IA64)
 #  define ARCH_PROCESSOR "ia64"
+#elif defined(Q_PROCESSOR_LOONGARCH_32)
+#  define ARCH_PROCESSOR "loongarch32"
+#elif defined(Q_PROCESSOR_LOONGARCH_64)
+#  define ARCH_PROCESSOR "loongarch64"
 #elif defined(Q_PROCESSOR_MIPS_64)
 #  define ARCH_PROCESSOR "mips64"
 #elif defined(Q_PROCESSOR_MIPS)
index ac2e85c51e19c0af1357baf52c49406e31fd3bc5..d337c34c63745656f2abf922606b7141862e12b9 100644 (file)
@@ -1815,6 +1815,37 @@ bool qSharedBuild() noexcept
     \sa QSysInfo::buildCpuArchitecture()
 */
 
+/*!
+    \macro Q_PROCESSOR_LOONGARCH
+    \relates <QtGlobal>
+
+    Defined if the application is compiled for LoongArch processors.
+
+    \sa QSysInfo::buildCpuArchitecture()
+*/
+
+/*!
+    \macro Q_PROCESSOR_LOONGARCH_32
+    \relates <QtGlobal>
+
+    Defined if the application is compiled for 32-bit LoongArch processors.
+    The \l Q_PROCESSOR_LOONGARCH macro is also defined when
+    Q_PROCESSOR_LOONGARCH_32 is defined.
+
+    \sa QSysInfo::buildCpuArchitecture()
+*/
+
+/*!
+    \macro Q_PROCESSOR_LOONGARCH_64
+    \relates <QtGlobal>
+
+    Defined if the application is compiled for 64-bit LoongArch processors.
+    The \l Q_PROCESSOR_LOONGARCH macro is also defined when
+    Q_PROCESSOR_LOONGARCH_64 is defined.
+
+    \sa QSysInfo::buildCpuArchitecture()
+*/
+
 /*!
     \macro Q_PROCESSOR_MIPS
     \relates <QtGlobal>
index 8d65720850336ecf562047ad82e871a9cd5d4be4..7b32b919f2a40b5e1e9fcafa5d670c3fa854c2f9 100644 (file)
 #  define Q_PROCESSOR_WORDSIZE   8
 // Q_BYTE_ORDER not defined, use endianness auto-detection
 
+/*
+    LoongArch family, known variants: 32- and 64-bit
+
+    LoongArch is little-endian.
+*/
+#elif defined(__loongarch__)
+#  define Q_PROCESSOR_LOONGARCH
+#  if __loongarch_grlen == 64
+#    define Q_PROCESSOR_LOONGARCH_64
+#  else
+#    define Q_PROCESSOR_LOONGARCH_32
+#  endif
+#  define Q_BYTE_ORDER Q_LITTLE_ENDIAN
+
 /*
     MIPS family, known revisions: I, II, III, IV, 32, 64