summaryrefslogtreecommitdiffhomepage
path: root/src/crc.c
diff options
context:
space:
mode:
authorYuichiro MASUI <[email protected]>2013-03-02 23:40:34 +0900
committerYuichiro MASUI <[email protected]>2013-03-08 03:14:21 +0900
commit284258367881d74f784485c2e5d282f4f5d490a5 (patch)
treea160d3c745f14e600edaed724f67d3107b362049 /src/crc.c
parent7d47096434994d9eb9712546879e3b52b04d3443 (diff)
downloadmruby-284258367881d74f784485c2e5d282f4f5d490a5.tar.gz
mruby-284258367881d74f784485c2e5d282f4f5d490a5.zip
New mrb format. The detail is in https://github.com/mruby/mruby/issues/944
Diffstat (limited to 'src/crc.c')
-rw-r--r--src/crc.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/crc.c b/src/crc.c
index c150f966b..91013c497 100644
--- a/src/crc.c
+++ b/src/crc.c
@@ -6,6 +6,8 @@
#include <limits.h>
#include <stdint.h>
+#include <sys/types.h>
+
// Calculate CRC (CRC-16-CCITT)
//
// 0000_0000_0000_0000_0000_0000_0000_0000
@@ -16,10 +18,10 @@
#define CRC_CARRY_BIT (1 << 24)
uint16_t
-calc_crc_16_ccitt(unsigned char *src, int nbytes)
+calc_crc_16_ccitt(const unsigned char *src, uint32_t nbytes, uint16_t crc)
{
- uint32_t crcwk = 0ul;
- int ibyte, ibit;
+ uint32_t ibyte, ibit;
+ uint32_t crcwk = crc << 8;
for (ibyte = 0; ibyte < nbytes; ibyte++) {
crcwk |= *src++;
@@ -32,3 +34,4 @@ calc_crc_16_ccitt(unsigned char *src, int nbytes)
}
return (uint16_t)(crcwk >> 8);
}
+