52#if defined(__GNUC__) && defined(__x86_64__) || defined(_WIN32)
55#define CRC32_x86_64_WIN
57#define CRC32_x86_64_DEFAULT
59#elif defined(__aarch64__) && defined(__GNUC__)
62#define CRC32_ARM64_APPLE
64#define CRC32_ARM64_DEFAULT
121#include <nmmintrin.h>
122#include <wmmintrin.h>
125#ifdef CRC32_x86_64_WIN
134#ifdef CRC32_ARM64_DEFAULT
135#include <asm/hwcap.h>
139#ifdef CRC32_ARM64_APPLE
140#if __has_include(<asm/hwcap.h>) && __has_include(<sys/auxv.h>)
142 "Current implementation is based on assumption that APPLE_ARM always " \
143 "supports crc32 and pmull and that there is no way to check it, yet it "\
144 "seem that this APPLE_ARM has getauxval()."
187MY_ATTRIBUTE((target(
"sse4.2")))
188#elif defined(CRC32_ARM64_DEFAULT)
189MY_ATTRIBUTE((target(
"+crc")))
191static inline uint64_t crc32_update_uint64(uint64_t crc, uint64_t data) {
193 return _mm_crc32_u64(crc, data);
194#elif defined(CRC32_ARM64)
195 return (uint64_t)__crc32cd((uint32_t)crc, data);
202static inline uint64_t crc32_hash_uint64(uint64_t value) {
204 value *= 0x1a2be5a5fa110e23;
205 return (crc32_update_uint64(0, value) ^ value) << 32 |
206 crc32_update_uint64(0, (value >> 32 | value << 32));
Definition: buf0block_hint.cc:29
Version control for database, common definitions, and include files.
uint32_t(* ut_crc32_func_t)(const byte *ptr, size_t len)
Calculates CRC32.
Definition: ut0crc32.h:159
bool ut_crc32_cpu_enabled
Flag that tells whether the CPU supports CRC32 or not.
Definition: crc32.cc:102
uint32_t ut_crc32_legacy_big_endian(const byte *buf, size_t len)
Calculates CRC32 using legacy algorithm, which uses big-endian byte ordering when converting byte seq...
Definition: crc32.cc:286
ut_crc32_func_t ut_crc32
Pointer to standard-compliant CRC32-C (using the GF(2) primitive polynomial 0x11EDC6F41) calculation ...
Definition: crc32.cc:100
void ut_crc32_init()
Initializes the data structures used by ut_crc32*().
Definition: crc32.cc:784
bool ut_poly_mul_cpu_enabled
Flag that tells whether the CPU supports polynomial multiplication or not.
Definition: crc32.cc:103
constexpr uint32_t CRC32C_POLYNOMIAL
The CRC-32C polynomial without the implicit highest 1 at x^32.
Definition: ut0crc32.h:153
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:68