mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-25 16:11:45 +00:00
crc32: make CRC_*_BITS definition correspond to actual bit counts
crc32.c provides a choice of one of several algorithms for computing the LSB and LSB versions of the CRC32 checksum based on the parameters CRC_LE_BITS and CRC_BE_BITS. In the original version the values 1, 2, 4 and 8 respectively selected versions of the alrogithm that computed the crc 1, 2, 4 and 32 bits as a time. This patch series adds a new version that computes the CRC 64 bits at a time. To make things easier to understand the parameter has been reinterpreted to actually stand for the number of bits processed in each step of the algorithm so that the old value 8 has been replaced with the value 32. This also allows us to add in a widely used crc algorithm that computes the crc 8 bits at a time called the Sarwate algorithm. [djwong@us.ibm.com: Minor changelog tweaks] Signed-off-by: Bob Pearson <rpearson@systemfabricworks.com> Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
ce4320ddda
commit
9a1dbf6a29
3 changed files with 34 additions and 12 deletions
|
@ -4,8 +4,17 @@
|
|||
|
||||
#define ENTRIES_PER_LINE 4
|
||||
|
||||
#if CRC_LE_BITS <= 8
|
||||
#define LE_TABLE_SIZE (1 << CRC_LE_BITS)
|
||||
#else
|
||||
#define LE_TABLE_SIZE 256
|
||||
#endif
|
||||
|
||||
#if CRC_BE_BITS <= 8
|
||||
#define BE_TABLE_SIZE (1 << CRC_BE_BITS)
|
||||
#else
|
||||
#define BE_TABLE_SIZE 256
|
||||
#endif
|
||||
|
||||
static uint32_t crc32table_le[4][256];
|
||||
static uint32_t crc32table_be[4][256];
|
||||
|
@ -24,7 +33,7 @@ static void crc32init_le(void)
|
|||
|
||||
crc32table_le[0][0] = 0;
|
||||
|
||||
for (i = 1 << (CRC_LE_BITS - 1); i; i >>= 1) {
|
||||
for (i = LE_TABLE_SIZE >> 1; i; i >>= 1) {
|
||||
crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
|
||||
for (j = 0; j < LE_TABLE_SIZE; j += 2 * i)
|
||||
crc32table_le[0][i + j] = crc ^ crc32table_le[0][j];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue