#include <algorithm>
#include <stdexcept>
-#if FOLLY_X64 && (__SSE4_2__ || defined(__clang__) || __GNUC_PREREQ(4, 9))
+#if FOLLY_SSE_PREREQ(4, 2)
#include <nmmintrin.h>
#endif
uint32_t
crc32c_sw(const uint8_t* data, size_t nbytes, uint32_t startingChecksum);
-#if FOLLY_X64 && (__SSE4_2__ || defined(__clang__) || __GNUC_PREREQ(4, 9))
+#if FOLLY_SSE_PREREQ(4, 2)
// Fast SIMD implementation of CRC-32C for x86 with SSE 4.2
FOLLY_TARGET_ATTRIBUTE("sse4.2")
throw std::runtime_error("crc32_hw is not implemented on this platform");
}
+uint32_t crc32_hw(const uint8_t *data, size_t nbytes,
+ uint32_t startingChecksum) {
+ throw std::runtime_error("crc32_hw is not implemented on this platform");
+}
+
bool crc32c_hw_supported() {
return false;
}
namespace folly {
namespace detail {
+#if FOLLY_SSE_PREREQ(4, 2)
+
uint32_t
crc32_hw_aligned(uint32_t remainder, const __m128i* p, size_t vec_count) {
/* Constants precomputed by gen_crc32_multipliers.c. Do not edit! */
x0 = _mm_clmulepi64_si128(_mm_and_si128(x0, mask32), barrett_reduction_constants, 0x10);
return _mm_cvtsi128_si32(_mm_srli_si128(_mm_xor_si128(x0, x1), 4));
}
+
+#endif
}
} // namespace
#pragma once
+#include <folly/Portability.h>
+
+#if FOLLY_SSE_PREREQ(4, 2)
#include <immintrin.h>
+#endif
+
#include <stdint.h>
#include <cstddef>
uint32_t
crc32_hw(const uint8_t* data, size_t nbytes, uint32_t startingChecksum = ~0U);
+#if FOLLY_SSE_PREREQ(4, 2)
uint32_t
crc32_hw_aligned(uint32_t remainder, const __m128i* p, size_t vec_count);
+#endif
/**
* Check whether a hardware-accelerated CRC-32 implementation is