#include <stdint.h>
#include <string.h>
Go to the source code of this file.
|
| uint32_t | crc32c_hw (uint32_t crc, const void *buf, size_t len) |
| |
| uint32_t | crc32c_sw (uint32_t crc, const void *buf, size_t len) |
| |
| uint32_t | crc32c (uint32_t crc, const void *buf, size_t len) |
| |
◆ crc32c()
| uint32_t crc32c |
( |
uint32_t |
crc, |
|
|
const void * |
buf, |
|
|
size_t |
len |
|
) |
| |
Definition at line 399 of file crc32c.cxx.
400{
401#if defined(HAVE_AMD64_CRC32C)
402 int sse42;
403 SSE42(sse42);
404 return sse42 ? crc32c_hw_amd64(crc, buf, len) :
crc32c_sw(crc, buf, len);
405#elif defined(HAVE_ARM64_CRC32C)
406 return crc32c_hw_arm64(crc, buf, len);
407#else
408#warning Hardware accelerated CRC32C is not available.
410#endif
411}
uint32_t crc32c_sw(uint32_t crci, const void *buf, size_t len)
◆ crc32c_hw()
| uint32_t crc32c_hw |
( |
uint32_t |
crc, |
|
|
const void * |
buf, |
|
|
size_t |
len |
|
) |
| |
Definition at line 413 of file crc32c.cxx.
414{
415#if defined(HAVE_AMD64_CRC32C)
416 return crc32c_hw_amd64(crc, buf, len);
417#elif defined(HAVE_ARM64_CRC32C)
418 return crc32c_hw_arm64(crc, buf, len);
419#else
420#warning Hardware accelerated CRC32C is not available.
421 abort();
422#endif
423}
◆ crc32c_sw()
| uint32_t crc32c_sw |
( |
uint32_t |
crc, |
|
|
const void * |
buf, |
|
|
size_t |
len |
|
) |
| |
Definition at line 101 of file crc32c.cxx.
102{
103 const unsigned char *next = (const unsigned char*)buf;
104 uint64_t crc;
105
106
107
109 crc = crci ^ 0xffffffff;
110 while (len && ((uintptr_t)next & 7) != 0) {
111 crc =
crc32c_table[0][(crc ^ *next++) & 0xff] ^ (crc >> 8);
112 len--;
113 }
114 while (len >= 8) {
115 crc ^= *(uint64_t *)next;
124 next += 8;
125 len -= 8;
126 }
127 while (len) {
128 crc =
crc32c_table[0][(crc ^ *next++) & 0xff] ^ (crc >> 8);
129 len--;
130 }
131 return (uint32_t)crc ^ 0xffffffff;
132}
static uint32_t crc32c_table[8][256]
static pthread_once_t crc32c_once_sw
static void crc32c_init_sw(void)