diff --git a/crc16.c b/crc16.c index 453e0ab..2549b92 100644 --- a/crc16.c +++ b/crc16.c @@ -20,6 +20,7 @@ #include #include "library.h" +#include "simd.h" #include "crc16.h" /** @@ -64,6 +65,12 @@ AARU_EXPORT int AARU_CALL crc16_update(crc16_ctx *ctx, const uint8_t *data, uint if(!ctx || !data) return -1; +#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \ +defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86) + if(have_avx2()) + return crc16_update_avx2(ctx, data, len); +#endif + uint16_t crc; const uint32_t *current; const uint8_t *current_char = data; diff --git a/crc16_ccitt_clmul.c b/crc16_ccitt_clmul.c index 43e2160..cbfaf29 100644 --- a/crc16_ccitt_clmul.c +++ b/crc16_ccitt_clmul.c @@ -104,6 +104,12 @@ AARU_EXPORT TARGET_WITH_CLMUL int AARU_CALL crc16_ccitt_update_clmul(crc16_ccitt { if(!ctx || !data) return -1; +#if defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64) || defined(__I386__) || \ +defined(__i386__) || defined(__THW_INTEL) || defined(_M_IX86) + if(have_clmul()) + return crc16_ccitt_update_clmul(ctx, data, len); +#endif + uint16_t crc = ctx->crc; // align to 4 bytes, byte-at-a-time.