2 * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
3 * code or tables extracted from it, as desired without restriction.
6 #ifndef _SYS_GSB_CRC32_H_
7 #define _SYS_GSB_CRC32_H_
13 extern const uint32_t crc32_tab[];
15 static __inline uint32_t
16 crc32_raw(const void *buf, size_t size, uint32_t crc)
18 const uint8_t *p = (const uint8_t *)buf;
21 crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
25 static __inline uint32_t
26 crc32(const void *buf, size_t size)
30 crc = crc32_raw(buf, size, ~0U);
35 uint32_t calculate_crc32c(uint32_t crc32c, const unsigned char *buffer,
38 #if defined(__amd64__) || defined(__i386__)
39 uint32_t sse42_crc32c(uint32_t, const unsigned char *, unsigned);
41 #if defined(__aarch64__)
42 uint32_t armv8_crc32c(uint32_t, const unsigned char *, unsigned int);
46 uint32_t singletable_crc32c(uint32_t, const void *, size_t);
47 uint32_t multitable_crc32c(uint32_t, const void *, size_t);
50 #endif /* !_SYS_GSB_CRC32_H_ */