blob: 130e09586b7efd2084d1537cd799664f01caf572 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001#ifndef __CKSUM_H
2#define __CKSUM_H
3
4#include <compiler.h>
5
6__BEGIN_CDECLS
7
8 /*
9 * Computes the CRC-CCITT, starting with an initialization value.
10 * buf: the data on which to apply the checksum
11 * length: the number of bytes of data in 'buf' to be calculated.
12 */
13unsigned short crc16(const unsigned char *buf, unsigned int length);
14
15 /*
16 * Computes an updated version of the CRC-CCITT from existing CRC.
17 * crc: the previous values of the CRC
18 * buf: the data on which to apply the checksum
19 * length: the number of bytes of data in 'buf' to be calculated.
20 */
21unsigned short update_crc16(unsigned short crc, const unsigned char *buf, unsigned int len);
22
23unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int len);
24
25unsigned long adler32(unsigned long adler, const unsigned char *buf, unsigned int len);
26
27uint32_t crc32_no_comp(uint32_t crc, const unsigned char *buf, unsigned int len);
28
29__END_CDECLS
30
31#endif
32