mirror of
https://github.com/aaru-dps/Aaru.Checksums.Native.git
synced 2025-12-16 03:04:28 +00:00
Invoke SIMD accelerated CRC16 if applicable.
This commit is contained in:
7
crc16.c
7
crc16.c
@@ -20,6 +20,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user