MIDAS
Loading...
Searching...
No Matches
crc32c.h File Reference
#include <stdint.h>
#include <string.h>
Include dependency graph for crc32c.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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)
 

Function Documentation

◆ crc32c()

uint32_t crc32c ( uint32_t  crc,
const void buf,
size_t  len 
)

Definition at line 391 of file crc32c.cxx.

392{
393#ifdef HAVE_HWCRC32C
394 int sse42;
395
396 SSE42(sse42);
397 return sse42 ? crc32c_hw(crc, buf, len) : crc32c_sw(crc, buf, len);
398#elif defined(__ARM_FEATURE_CRC32)
399 return crc32c_arm_hw(crc, buf, len);
400#else
401#warning Hardware accelerated CRC32C is not available.
402 return crc32c_sw(crc, buf, len);
403#endif // HAVE_HWCRC32C
404}
uint32_t crc32c_sw(uint32_t crci, const void *buf, size_t len)
Definition crc32c.cxx:99
uint32_t crc32c_hw(uint32_t crc, const void *buf, size_t len)
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Here is the call graph for this function:
Here is the caller graph for this function:

◆ crc32c_hw()

uint32_t crc32c_hw ( uint32_t  crc,
const void buf,
size_t  len 
)
Here is the caller graph for this function:

◆ crc32c_sw()

uint32_t crc32c_sw ( uint32_t  crc,
const void buf,
size_t  len 
)

Definition at line 99 of file crc32c.cxx.

100{
101 const unsigned char *next = (const unsigned char*)buf;
102 uint64_t crc;
103
105 crc = crci ^ 0xffffffff;
106 while (len && ((uintptr_t)next & 7) != 0) {
107 crc = crc32c_table[0][(crc ^ *next++) & 0xff] ^ (crc >> 8);
108 len--;
109 }
110 while (len >= 8) {
111 crc ^= *(uint64_t *)next;
112 crc = crc32c_table[7][crc & 0xff] ^
113 crc32c_table[6][(crc >> 8) & 0xff] ^
114 crc32c_table[5][(crc >> 16) & 0xff] ^
115 crc32c_table[4][(crc >> 24) & 0xff] ^
116 crc32c_table[3][(crc >> 32) & 0xff] ^
117 crc32c_table[2][(crc >> 40) & 0xff] ^
118 crc32c_table[1][(crc >> 48) & 0xff] ^
119 crc32c_table[0][crc >> 56];
120 next += 8;
121 len -= 8;
122 }
123 while (len) {
124 crc = crc32c_table[0][(crc ^ *next++) & 0xff] ^ (crc >> 8);
125 len--;
126 }
127 return (uint32_t)crc ^ 0xffffffff;
128}
static uint32_t crc32c_table[8][256]
Definition crc32c.cxx:68
static pthread_once_t crc32c_once_sw
Definition crc32c.cxx:67
static void crc32c_init_sw(void)
Definition crc32c.cxx:71
Here is the call graph for this function:
Here is the caller graph for this function: