From 176e3ba16a007dce11175c68167f6486a8a817c0 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Wed, 3 Jul 2024 20:41:19 +0200 Subject: [PATCH] LibCrypto: Use ARM C Language Extensions (ACLE) for CRC32 intrinsics The __builtin_arm_* intrinsics don't exist on all ARMv8 systems. Use the standardized ACLE intrinsics, instead. --- Userland/Libraries/LibCrypto/Checksum/CRC32.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibCrypto/Checksum/CRC32.cpp b/Userland/Libraries/LibCrypto/Checksum/CRC32.cpp index 0f86b0d4c3e..6427ae08e45 100644 --- a/Userland/Libraries/LibCrypto/Checksum/CRC32.cpp +++ b/Userland/Libraries/LibCrypto/Checksum/CRC32.cpp @@ -10,10 +10,13 @@ #include #include +#ifdef __ARM_ACLE +# include +#endif + namespace Crypto::Checksum { -#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) - +#if __ARM_ARCH >= 8 && defined(__ARM_FEATURE_CRC32) && defined(__ARM_ACLE) void CRC32::update(ReadonlyBytes span) { // FIXME: Does this require runtime checking on rpi? @@ -23,21 +26,21 @@ void CRC32::update(ReadonlyBytes span) size_t size = span.size(); while (size > 0 && (reinterpret_cast(data) & 7) != 0) { - m_state = __builtin_arm_crc32b(m_state, *data); + m_state = __crc32b(m_state, *data); ++data; --size; } auto* data64 = reinterpret_cast(data); while (size >= 8) { - m_state = __builtin_arm_crc32d(m_state, *data64); + m_state = __crc32d(m_state, *data64); ++data64; size -= 8; } data = reinterpret_cast(data64); while (size > 0) { - m_state = __builtin_arm_crc32b(m_state, *data); + m_state = __crc32b(m_state, *data); ++data; --size; }