diff --git a/include/aws/checksums/private/crc64_priv.h b/include/aws/checksums/private/crc64_priv.h index 29b8820..39090e0 100644 --- a/include/aws/checksums/private/crc64_priv.h +++ b/include/aws/checksums/private/crc64_priv.h @@ -15,16 +15,18 @@ AWS_EXTERN_C_BEGIN AWS_CHECKSUMS_API uint64_t aws_checksums_crc64xz_sw(const uint8_t *input, int length, uint64_t prev_crc64); -#if defined(AWS_ARCH_INTEL_X64) && defined(AWS_HAVE_CLMUL) && !(defined(_MSC_VER) && _MSC_VER < 1920) +#if defined(AWS_USE_CPU_EXTENSIONS) && defined(AWS_ARCH_INTEL_X64) && defined(AWS_HAVE_CLMUL) && \ + !(defined(_MSC_VER) && _MSC_VER < 1920) uint64_t aws_checksums_crc64xz_intel_clmul(const uint8_t *input, int length, uint64_t previous_crc_64); #endif /* defined(AWS_ARCH_INTEL_X64) && defined(AWS_HAVE_CLMUL) && !(defined(_MSC_VER) && _MSC_VER < 1920) */ -#if defined(AWS_ARCH_INTEL_X64) && defined(AWS_HAVE_AVX2_INTRINSICS) && !(defined(_MSC_VER) && _MSC_VER < 1920) +#if defined(AWS_USE_CPU_EXTENSIONS) && defined(AWS_ARCH_INTEL_X64) && defined(AWS_HAVE_AVX2_INTRINSICS) && \ + !(defined(_MSC_VER) && _MSC_VER < 1920) uint64_t aws_checksums_crc64xz_intel_avx512(const uint8_t *input, int length, uint64_t previous_crc_64); #endif /* defined(AWS_ARCH_INTEL_X64) && defined(AWS_HAVE_AVX2_INTRINSICS) && !(defined(_MSC_VER) && _MSC_VER < 1920) \ */ -#if defined(AWS_ARCH_ARM64) +#if defined(AWS_USE_CPU_EXTENSIONS) && defined(AWS_ARCH_ARM64) uint64_t aws_checksums_crc64xz_arm_pmull(const uint8_t *input, int length, uint64_t previous_crc_64); #endif /* INTPTR_MAX == INT64_MAX && defined(AWS_HAVE_ARMv8_1) */ diff --git a/include/aws/checksums/private/crc_priv.h b/include/aws/checksums/private/crc_priv.h index 93f4d4d..678677d 100644 --- a/include/aws/checksums/private/crc_priv.h +++ b/include/aws/checksums/private/crc_priv.h @@ -20,10 +20,10 @@ AWS_CHECKSUMS_API uint32_t aws_checksums_crc32_sw(const uint8_t *input, int leng /* Computes the Castagnoli CRC32c (iSCSI) using a (slow) reference implementation. */ AWS_CHECKSUMS_API uint32_t aws_checksums_crc32c_sw(const uint8_t *input, int length, uint32_t previousCrc32c); -#if defined(AWS_ARCH_ARM64) +#if defined(AWS_USE_CPU_EXTENSIONS) && defined(AWS_ARCH_ARM64) uint32_t aws_checksums_crc32_armv8(const uint8_t *input, int length, uint32_t previous_crc32); uint32_t aws_checksums_crc32c_armv8(const uint8_t *input, int length, uint32_t previous_crc32c); -#elif defined(AWS_ARCH_INTEL) +#elif defined(AWS_USE_CPU_EXTENSIONS) && defined(AWS_ARCH_INTEL) # if defined(AWS_ARCH_INTEL_X64) typedef uint64_t *slice_ptr_type; typedef uint64_t slice_ptr_int_type; diff --git a/source/crc64.c b/source/crc64.c index 4a41ad9..5976275 100644 --- a/source/crc64.c +++ b/source/crc64.c @@ -21,10 +21,11 @@ checksums_maxks_shifts_type aws_checksums_masks_shifts = { AWS_ALIGNED_TYPEDEF(aws_checksums_crc64_constants_t, cheksums_constants, 16); +/* clang-format off */ + // Pre-computed bit-reflected constants for CRC64XZ // The actual exponents are reduced by 1 to compensate for bit-reflection (e.g. x^1024 is actually x^1023) cheksums_constants aws_checksums_crc64xz_constants = { - /* clang-format off */ .x2048 = {0x8260adf2381ad81c, @@ -84,9 +85,9 @@ cheksums_constants aws_checksums_crc64xz_constants = { {0xb91b6176fc36363f, 0xdda9f27ee08373ad}, // 13 trailing bytes: x^168 mod P(x) / x^104 mod P(x) {0x4dcec64d2edf818c, 0x0dd9b4240837fd99}, // 14 trailing bytes: x^176 mod P(x) / x^112 mod P(x) {0x4550ddde9a383296, 0xf075e4ae5e05bdff} // 15 trailing bytes: x^184 mod P(x) / x^120 mod P(x) - }, - /* clang-format on */ + }, // }; +/* clang-format on */ static uint64_t (*s_crc64xz_fn_ptr)(const uint8_t *input, int length, uint64_t prev_crc64) = 0;