diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-01-20 23:12:43 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-01-20 23:12:43 +0900 |
| commit | 47a68e89ffcfcacb4a0c6c64c3b2ab69ee4da35f (patch) | |
| tree | ef21aeddd840459cef963c2f360c27673117a1e4 /src/crc.c | |
| parent | e91dfd07be6e07179814cfc17be182fd114c3d28 (diff) | |
| download | mruby-47a68e89ffcfcacb4a0c6c64c3b2ab69ee4da35f.tar.gz mruby-47a68e89ffcfcacb4a0c6c64c3b2ab69ee4da35f.zip | |
Remove CRC16 from dumped mruby binary.
`calc_crc_16_ccitt()` consumes a lot of clock cycles in programs like
`mrbtest` which loads a lot of dumped binary. Error detection for flaky
channels should be done in the higher level.
Note: `mruby/c` should be updated to support this change.
Diffstat (limited to 'src/crc.c')
| -rw-r--r-- | src/crc.c | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/src/crc.c b/src/crc.c deleted file mode 100644 index 290b2ca0e..000000000 --- a/src/crc.c +++ /dev/null @@ -1,39 +0,0 @@ -/* -** crc.c - calculate CRC -** -** See Copyright Notice in mruby.h -*/ - -#include <limits.h> -#include <stdint.h> -#include <stddef.h> - -/* Calculate CRC (CRC-16-CCITT) -** -** 0000_0000_0000_0000_0000_0000_0000_0000 -** ^|------- CRC -------|- work --| -** carry -*/ -#define CRC_16_CCITT 0x11021ul /* x^16+x^12+x^5+1 */ -#define CRC_XOR_PATTERN (CRC_16_CCITT << 8) -#define CRC_CARRY_BIT (0x01000000) - -uint16_t -calc_crc_16_ccitt(const uint8_t *src, size_t nbytes, uint16_t crc) -{ - size_t ibyte; - uint32_t ibit; - uint32_t crcwk = crc << 8; - - for (ibyte = 0; ibyte < nbytes; ibyte++) { - crcwk |= *src++; - for (ibit = 0; ibit < CHAR_BIT; ibit++) { - crcwk <<= 1; - if (crcwk & CRC_CARRY_BIT) { - crcwk ^= CRC_XOR_PATTERN; - } - } - } - return (uint16_t)(crcwk >> 8); -} - |
