otrx: make crc32 table global for further optimizations
So far we got only one generic function accessing this table, but implementing optimizations will require calculating crc32 in other code parts as well. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> SVN-Revision: 46077
This commit is contained in:
@@ -48,8 +48,7 @@ char *partition[TRX_MAX_PARTS] = {};
|
||||
* CRC32
|
||||
**************************************************/
|
||||
|
||||
uint32_t otrx_crc32(uint8_t *buf, size_t len) {
|
||||
static const uint32_t t[] = {
|
||||
static const uint32_t crc32_tbl[] = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
|
||||
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
||||
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
||||
@@ -115,10 +114,12 @@ uint32_t otrx_crc32(uint8_t *buf, size_t len) {
|
||||
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
||||
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
|
||||
};
|
||||
|
||||
uint32_t otrx_crc32(uint8_t *buf, size_t len) {
|
||||
uint32_t crc = 0xffffffff;
|
||||
|
||||
while (len) {
|
||||
crc = t[(crc ^ *buf) & 0xff] ^ (crc >> 8);
|
||||
crc = crc32_tbl[(crc ^ *buf) & 0xff] ^ (crc >> 8);
|
||||
buf++;
|
||||
len--;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user