-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for ARM requires non-accelerated CRC.
- Loading branch information
Showing
13 changed files
with
85 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,3 +105,4 @@ cmake-*/** | |
# Visual Studio | ||
CMakeSettings.json | ||
.vs/** | ||
.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#define MAX_ITER 8 | ||
|
||
extern "C" { | ||
// crc16_t10dif reference function, slow crc16 from the definition. | ||
static inline uint16_t crc16_t10dif(uint16_t seed, const unsigned char* buf, uint64_t len) { | ||
size_t rem = seed; | ||
unsigned int i, j; | ||
|
||
uint16_t poly = 0x8bb7; // t10dif standard | ||
|
||
for (i = 0; i < len; i++) { | ||
rem = rem ^ (buf[i] << 8); | ||
for (j = 0; j < MAX_ITER; j++) { | ||
rem = rem << 1; | ||
rem = (rem & 0x10000) ? rem ^ poly : rem; | ||
} | ||
} | ||
return rem; | ||
} | ||
|
||
// crc32_ieee reference function, slow crc32 from the definition. | ||
static inline uint32_t crc32_ieee(uint32_t seed, const unsigned char* buf, uint64_t len) { | ||
uint64_t rem = ~seed; | ||
unsigned int i, j; | ||
|
||
uint32_t poly = 0x04C11DB7; // IEEE standard | ||
|
||
for (i = 0; i < len; i++) { | ||
rem = rem ^ ((uint64_t)buf[i] << 24); | ||
for (j = 0; j < MAX_ITER; j++) { | ||
rem = rem << 1; | ||
rem = (rem & 0x100000000ULL) ? rem ^ poly : rem; | ||
} | ||
} | ||
return ~rem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters