more type work
This commit is contained in:
parent
2ce38461bb
commit
58f9e4591e
2 changed files with 6 additions and 6 deletions
8
crc32.c
8
crc32.c
|
@ -53,14 +53,14 @@ crc_le_fill_table(uint32_t *table, uint32_t polynomial)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
crc_be_cycle(uint32_t *table, uint32_t *remainder, char c)
|
crc_be_cycle(uint32_t *table, uint32_t *remainder, uint8_t c)
|
||||||
{
|
{
|
||||||
const uint32_t byte = table[(((*remainder) >> 24) ^ c) & 0xFF];
|
const uint32_t byte = table[(((*remainder) >> 24) ^ c)];
|
||||||
*remainder = (((*remainder) << 8) ^ byte) & 0xFFFFFFFF;
|
*remainder = (((*remainder) << 8) ^ byte);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
crc_le_cycle(uint32_t *table, uint32_t *remainder, char c)
|
crc_le_cycle(uint32_t *table, uint32_t *remainder, uint8_t c)
|
||||||
{
|
{
|
||||||
const uint32_t byte = table[((*remainder) ^ c) & 0xFF];
|
const uint32_t byte = table[((*remainder) ^ c) & 0xFF];
|
||||||
*remainder = ((*remainder) >> 8) ^ byte;
|
*remainder = ((*remainder) >> 8) ^ byte;
|
||||||
|
|
4
main.c
4
main.c
|
@ -123,8 +123,8 @@ static uint32_t
|
||||||
cycle_file(FILE *stream)
|
cycle_file(FILE *stream)
|
||||||
{
|
{
|
||||||
uint32_t remainder = starting;
|
uint32_t remainder = starting;
|
||||||
void (*cycle)(uint32_t*, uint32_t*, char) =
|
typeof(&crc_be_cycle) cycle;
|
||||||
(big_endian) ? crc_be_cycle : crc_le_cycle;
|
cycle = (big_endian) ? crc_be_cycle : crc_le_cycle;
|
||||||
uint32_t table[CRC_TABLE_SIZE];
|
uint32_t table[CRC_TABLE_SIZE];
|
||||||
|
|
||||||
if (big_endian)
|
if (big_endian)
|
||||||
|
|
Loading…
Add table
Reference in a new issue