comparison crc32i.h @ 1:90cb48b87dcc

*: don't hardcode the list of impls in multiple places
author Paper <paper@tflc.us>
date Mon, 09 Feb 2026 01:18:06 -0500
parents 422835bc1aca
children 6483683ac857
comparison
equal deleted inserted replaced
0:422835bc1aca 1:90cb48b87dcc
27 typedef uint32_t (*crc32_r_spec)(uint32_t, const unsigned char *, size_t); 27 typedef uint32_t (*crc32_r_spec)(uint32_t, const unsigned char *, size_t);
28 28
29 /* shared by crc32c and crc32qw */ 29 /* shared by crc32c and crc32qw */
30 extern const uint32_t crc32_tab[256]; 30 extern const uint32_t crc32_tab[256];
31 31
32 /* Calculates crc32 by bytes. Has no alignment requirement */ 32 /* declare */
33 uint32_t crc32c_r(uint32_t crc, const unsigned char *message, size_t sz); 33 #define CRC32_IMPL(name) uint32_t crc32##name##_r(uint32_t, const unsigned char *, size_t);
34 /* Calculates crc32 in dwords. Requires 4-byte alignment */ 34 #include "crc32-impls.h"
35 uint32_t crc32qw_r(uint32_t crc, const unsigned char *message, size_t sz);
36 /* Calculates crc32 using intel SIMD. Requires 16-byte alignment */
37 uint32_t crc32x86_vpclmulqdq_r(uint32_t crc, const unsigned char *msg, size_t sz);
38 35
39 /* Maximum alignment value for each impl to work */ 36 /* Maximum alignment value for each impl to work */
40 #define MAX(x, y) ((x)>(y)?(x):(y)) 37 #define MAX(x, y) ((x)>(y)?(x):(y))
41 #define MIN(x, y) ((x)<(y)?(x):(y)) 38 #define MIN(x, y) ((x)<(y)?(x):(y))
42 #define CRC32_MAX_ALIGNMENT MAX(16, ALIGNOF(uint32_t)) 39 #define CRC32_MAX_ALIGNMENT MAX(16, ALIGNOF(uint32_t))