[compiler-rt] [scudo] Add support for LoongArch hardware CRC32 checksumming (PR #83113)

WÁNG Xuěruì via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 04:21:28 PST 2024


================
@@ -75,6 +77,15 @@ bool hasHardwareCRC32() {
   return !!(getauxval(AT_HWCAP) & HWCAP_CRC32);
 #endif // SCUDO_FUCHSIA
 }
+#elif defined(__loongarch__)
+// Query HWCAP for platform capability, according to *Software Development and
+// Build Convention for LoongArch Architectures* v0.1, Section 9.1.
+//
+// Link:
+// https://github.com/loongson/la-softdev-convention/blob/v0.1/la-softdev-convention.adoc#kernel-development
+bool hasHardwareCRC32() {
+  return !!(getauxval(AT_HWCAP) & HWCAP_LOONGARCH_CRC32);
----------------
xen0n wrote:

> I got this error:
> 
> ```
> compiler-rt/lib/scudo/standalone/checksum.cpp:87:35: error: use of undeclared identifier 'HWCAP_LOONGARCH_CRC32'
> ```
> 
> Maybe a `.h` file should be included?

Hmm I was wrong in assuming the HWCAP constants are implicitly pulled in by `<sys/auxv.h>`. This is the case only [from glibc 2.38](https://github.com/bminor/glibc/commit/7f079fdc16e88ebb8020e17b2fd900e8924da29a). I'll supply the definition with an `#ifdef` check.

https://github.com/llvm/llvm-project/pull/83113


More information about the llvm-commits mailing list